用dspack2.1(要安装directX8.0以上版本)
//选择视频采集卡
SysDev:= TSysDevEnum.Create(CLSID_VideoInputDeviceCategory);
FilterGraph.ClearGraph;
if (SysDev.CountFilters = 0) then
begin
Messagebox(0,'没安装视频采集卡或没开启视频输入设备!','视频初始化错误',id_ok);
SysDev.Destroy;
Application.Terminate;
exit;
end;
Filter.BaseFilter.Moniker := SysDev.GetMoniker(0);
FilterGraph.Active := true;
//连接视频流并采集
with FilterGraph as ICaptureGraphBuilder2do
begin
//Connect Video preview (VideoWindow)
RenderStream(@PIN_CATEGORY_PREVIEW, nil, Filter as IBaseFilter, SampleGrabber as IBaseFilter, VideoWindow as IbaseFilter);
end;
FilterGraph.Play;
//截图
SampleGrabber.GetBitmap(Image.Picture.Bitmap);