Windows 7 上的 WIA 2 无法检测到我的相机,而 Windows XP 上的 WIA 1 可以检测到。
我尝试以管理员身份运行我的程序。
我的相机是:
华硕 USB2 网络摄像头。
Delphi返回消息:
(like this) not available any wia devices from specified type
或
Access Violation at address ...... in module ......
我使用这个代码:
procedure TForm1.Button9Click(Sender: TObject);
Const
wiaFormatBMP ='{B96B3CAB-0728-11D3-9D7B-0000F81EF32E}';
var
CommonDlg: ICommonDialog;
AImage: IImageFile;
ImagePath: String;
DeviceManager1 :iDeviceManager;
begin
CommonDlg := createOleObject('WIA.CommonDialog') as ICommonDialog;
DeviceManager1 := createOleObject('WIA.DeviceManager') as iDeviceManager;
edit1.Text:= inttostr( DeviceManager1.DeviceInfos.Count);
AImage := CommonDlg.ShowAcquireImage(UnspecifiedDeviceType,UnspecifiedIntent,
MaximizeQuality,wiaFormatBMP,true,False,True);
ImagePath := 'C:\temp\test.bmp';
AImage.SaveFile(ImagePath);
end;
最佳答案
我最近在 WIA 和 Win7 上也有过类似的经历。
我最终使用的是 DirectX 解决方案。
Delphi Basics - DirectX webcam capture
我不记得我最初是如何找到这个项目的,但在 Win7 下,它甚至可以与我在办公室周围发现的旧网络摄像头一起使用。
我建议您查看下载文件中的 Demo3,因为它提供了我所需要的最好、简单的示例。 YMMV。
(编辑)我的 WIA 问题源于网络摄像头制造商在 Win7 下不支持 WIA 或 Twain。
关于delphi - Windows 7 上的 WIA 2 -- Delphi,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10472647/