Delphi网络摄像头快照 [英] Delphi Webcam Snapshot

查看:107
本文介绍了Delphi网络摄像头快照的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要找到一种使用Delphi XE的万无一失的方法,以使用网络摄像头拍摄快照并将其另存为图片文件.有很多关于此的帖子,但没有一个对我有用.代码无法编译或未创建图像.迄今为止最好的一种是使用VFrames的.它完美显示了网络摄像头视频,但是当我尝试使用下面的代码将快照保存到bmp时,图像为空白白色.我尝试将其分配给具有相同结果的TImage.有谁知道为什么会这样或有更好的方法来做到这一点?

I need to find a foolproof way with Delphi XE to take a snapshot using a webcam and save it as a picture file. There are many posts about this but none of them work for me. Either the code won't compile or the image is not created. The best one so far is this one using VFrames. It shows the web cam video perfectly but when I try to save a snapshot to a bmp using the code below the image is blank white. I tried assigning it to a TImage with the same result. Does anyone know why this happens or have a better way to do this?

procedure TForm1.Button2Click(Sender: TObject);
var
  cam:TVideoImage;
  strlst:TStringList;
  BMP:TBitmap;
begin
  strlst := TStringList.Create ;
  cam :=TVideoImage.Create;
  cam.GetListOfDevices(strlst);
  cam.VideoStart(strlst.Strings[0]); //specify a cam by number
  //get snapshot
  BMP := TBitmap.Create;
  cam.GetBitmap(BMP);
  BMP.SaveToFile('C:\test.bmp');
  cam.VideoStop;
  BMP.Free;
end;

推荐答案

我认为您应该看一下DirectX,我想您应该看一下这个站点:

I Think you should have a look a DirectX and I think you should have a look at this site :

http://www.delphibasics.info/home/delphibasicsprojects/directxdelphiwebcamcaptureexample

此页面提供了一种在Windows下使用网络摄像头的好方法,它非常可靠,并允许您设置任何cam属性.它全部开源,易于使用,并且基于本机Windows DirectX库.

This page offers a great way to use webcams under windows, its very reliable and allows you to set any cam property. Its all opensource, easy to use and based on native windows DirectX libraries.

使用此示例:

http://www.delphibasics.info/home/delphibasicsprojects/directxdelphiwebcamcaptureexample/DirectXDelphiWebcamCapture.rar

这是由michael@grizzlymotion.com进行的Pascal的DirectX转换

This is a directX conversion to pascal made by michael@grizzlymotion.com

将VSample.pas和VFrames.pas添加到您的项目中

add VSample.pas and VFrames.pas to your project

uses  VFrames;

procedure TForm6.Button1Click(Sender: TObject);

var
  cam:TVideoImage;
  strlst:TStringList;
begin    
   strlst := TStringList.Create ;

   cam := TVideoImage.Create;
   cam.GetListOfDevices(strlst);

   cam.SetDisplayCanvas(PaintBox1.Canvas);
   cam.VideoStart(strlst.Strings[0])    ;//specify your cam by number
end;


或者您可以看一下: http://sourceforge.net/projects/webcam-cap/它使用对AVICAP32.DLL的纯API调用


Or you can have a look at this : http://sourceforge.net/projects/webcam-cap/ it uses pure API calls to AVICAP32.DLL

这篇关于Delphi网络摄像头快照的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆