C#网民WM_CAP_CONNECT:要强制捕获源时,多个采集源存在 [英] C# web cam WM_CAP_CONNECT: Want to force a capture source when multiple capture sources present

查看:377
本文介绍了C#网民WM_CAP_CONNECT:要强制捕获源时,多个采集源存在的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用WebCam_Capture代码我在网上找到通过C#来访问网络摄像头。与上一个视频源在计算机它就像一个魅力! (程序在启动时启动,发现摄像头和它的作品)。



虽然有许多视频源在计算机(说一个网络摄像头,然后manycam跑在最前面的那个),程序开始,并查询要使用的源的用户。我很想我的程序在机器启动自动启动,所以这种等待用户输入抛出一个扳手,反正我可以强制其只选择说第一个找到的来源以及与该走?



让我有些网络摄像头的代码,我的确是在网上找到的位置:



http://channel9.msdn.com/forums/TechOff/93476-Programatically-使用-A-网络摄像头 - 在-C /?CommentID = 94149



和现在准备这个帖子我做更多的研究和发现,我的问题位于这条线从上面的代码:

 的SendMessage(mCapHwnd,WM_CAP_CONNECT,0,0); 

这是连接摄像头了,唯一的问题是,上面带来了这恼人的视频源对话框,如果我有一个以上的来源。我希望它只是使用第一个源,以便对话框不上来。我尝试过在0的是不同的价值观,果然对话框不上来,但它也不起作用。任何人都知道,如果有一个价值,我可以传递给SendMessage函数暂停对话,但有它选择它找到?


解决方案

我发现的唯一的暗示是,第一个0是相机索引:

 的SendMessage(_windowHandle,WM_CAP_CONNECT,_videoSourceIndex ,0)

尽量给0,1,2直到所需的相机连接。注意:只有一个摄像头的响应,可能需要5秒。其中有些是相当缓慢。



但是,最好的建议是尝试的 DirectShow.NET 库,因为它是比你当前使用的API功能更加实用。


I am using WebCam_Capture code I found online to access through C# a web cam. On a computer with one video source it works like a charm! (Program starts up at start up, finds the webcam and it works).

Though on a computer with many video sources (Say a web cam and then manycam running on top of that), the program starts and queries the user which source to use. I would love my program to start up autonomously at the restart of a machine so this waiting for user input throws a wrench in that, anyway I can force it to just select say the first found source and go with that?

So i have some webcam code I yes indeed found online here:

http://channel9.msdn.com/forums/TechOff/93476-Programatically-Using-A-Webcam-In-C/?CommentID=94149

and now in preparing this post I did do more research and found out that my issue lies in this line from the above code:

SendMessage(mCapHwnd, WM_CAP_CONNECT, 0, 0);

That is what connects the webcam up, the only issue is that the above brings up this annoying video source dialog if I have more than one source. I want it to just use the first source so that dialog doesn't come up. I tried passing in different values where the 0's are, sure enough the dialog doesn't come up but it doesn't work either. Anyone know if there is a value I can pass to the SendMessage to suspend the dialog and yet have it select the first video source it finds?

解决方案

The only hint I found is that the first 0 is the camera index:

SendMessage(_windowHandle, WM_CAP_CONNECT, _videoSourceIndex, 0)

Try to give 0,1,2 until the desired camera is connected. Note it may take up to 5 sec until a webcam responds. Some of them are pretty slow.

But the best suggestion would be to try out DirectShow.NET library as it is much more capable than the API you're currently using.

这篇关于C#网民WM_CAP_CONNECT:要强制捕获源时,多个采集源存在的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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