简体   繁体   English

如何在avicap32.dll中获取已连接网络摄像头的列表?

[英]How to get list of connected WebCams in avicap32.dll?

I'm coding an application to handle WebCams. 我正在编写一个处理WebCams的应用程序。 I have to use (this is an external constraint) the avicap32.dll library. 我必须使用avicap32.dll库(这是一个外部约束)。 So here I am, using some extern functions (for which I have to marshal types) from this library, as well as user32 (sending WindowsMessages). 因此,在这里,我使用了该库中的一些extern函数(必须为它们编组类型)以及user32(发送WindowsMessages)。 And I digged up half the Internet, but failed to find how to get list of all the connected WebCam devices? 我挖了一半的Internet,但是找不到如何获取所有已连接的WebCam设备的列表?

Of course I'm fully aware of function: 当然我完全了​​解功能:

[DllImport(avicap32dll)]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool capGetDriverDescription(
    short driverIndex,
    StringBuilder name, int nameSize,
    StringBuilder version, int versionSize);

, but it gives me list of drivers , not cams ! ,但它提供了驱动程序列表,而不是摄像头列表! When I connect two cameras to my PC, I still can find only one capture driver by this function (checking driverIndex from 0 to 9). 当我将两台摄像机连接到PC时,通过此功能,我仍然只能找到一个捕获驱动程序(检查driverIndex从0到9)。 Both of them must be using the same capture driver. 他们两个都必须使用相同的捕获驱动程序。 So, not having a list of WebCams I cannot really decide, to which one I want to connect. 因此,没有我无法真正决定要连接的WebCam的列表。 There is a WindowsMessage WM_CAP_DLG_VIDEOSOURCE, but it doesn't show video source dialog before I connect with a WebCam. 有WindowsMessage WM_CAP_DLG_VIDEOSOURCE,但在连接WebCam之前它不显示视频源对话框。

This is legacy API (Video for Windows, avicap32.dll) and it is not that flexible as you could expect. 这是旧版API(适用于Windows的视频,avicap32.dll),不像您期望的那样灵活。 Still being supported though. 仍然受到支持。

Newer API with the best coverage is DirectShow, it is native, but with DirectShow.NET you have a bridge into .NET. 覆盖范围最广的较新API是DirectShow,它是本机的,但有了DirectShow.NET,您就可以连接到.NET。 Take a look at code sample and article inroducing this approach: Finding Your Web Cam with C# & DirectShow.NET 看一下代码示例和介绍这种方法的文章: 使用C#和DirectShow.NET查找网络摄像头

Edit: Original article no longer exists, however found a copy in the Internet Archive https://archive.org/web/ 编辑:原始文章不再存在,但是在Internet存档https://archive.org/web/中找到了一个副本

Its easier and better to use the AForge.NET library. 使用AForge.NET库更容易,更好。 It contains all the tools to do these kind of jobs http://aforgenet.com/ 它包含完成这些工作的所有工具http://aforgenet.com/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM