0

大家好,我正在创建一个消息应用程序,但是一旦应用程序从我的网络摄像头中抓取图片,它就会开始显示一个窗口来选择一个摄像头,知道它只安装了一个摄像头

[DllImport("user32", EntryPoint = "SendMessage")]
static extern int SendMessage(int hWnd, uint Msg, int wParam, int lParam);
[DllImport("avicap32.dll", EntryPoint = "capCreateCaptureWindowA")]
static extern int capCreateCaptureWindowA(string lpszWindowName, int dwStyle,
    int X, int Y, int nWidth, int nHeight, int hwndParent, int nID);
const int WM_CAP_CONNECT = 1034;
const int WM_CAP_DISCONNECT = 1035;
const int WM_CAP_COPY = 1054;
const int WM_CAP_GET_FRAME = 1084;

这个api适用于带有服务应用程序的windows xp,所以我创建了服务应用程序,它通过管道与应用程序通信并以字节为单位传输图片,但请注意它只适用于windows xp

我如何在没有此窗口的情况下捕捉网络摄像头图片我在 windows vista,7,8 中使用了一些 api

谢谢 B。

4

1 回答 1

0

The API you are referring to (Video for Windows) is not supposed to operate without a window. The window however does not need to be visible, and you can move it out of work area too. It does not have to paint actually captured video as well, the window purpose is to communicate with the API. So it is usable in Window 7 too, provided of course that you have a well operating driver for these operating systems as well.

Other APIs you might want to look at are DirectShow and Media Foundation. DirectShow is the richest and best compatible throughout versions of Windows API, and you can do the task mentioned in the subject (capture without showing). From C# you typically work with it via DirectShow.NET library/binding and it has decent samples to look at on the website.

于 2012-10-08T18:47:55.333 回答