windows 充当虚拟网络摄像头的设备驱动程序
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5079165/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Device driver to act as a virtual web camera
提问by mitesh keswani
I'm looking for writing virtual camera drivers. Does anybody has idea?
Any book that would be helpful or any link.
我正在寻找编写虚拟相机驱动程序。有人有想法吗?
任何有用的书或任何链接。
Adding more details: I have developed a device driver which saves the image to disk and the display uses the device driver to display the image. The performance does not seem good. The fns. that I have used are: //to capture GetDesktopWindow() CreateCompatibleBitmap() Save() //to display WM_MOUSEMOVE giving a call to capture and display every time but the display is not continuous and appears only after window goes out of focus and comes in focus again
添加更多细节:我开发了一个将图像保存到磁盘的设备驱动程序,显示器使用设备驱动程序来显示图像。表现似乎不太好。fns。我使用的是: //捕获 GetDesktopWindow() CreateCompatibleBitmap() Save() // 显示 WM_MOUSEMOVE 每次都调用捕获和显示但显示不是连续的,只有在窗口失去焦点后才会出现再次聚焦
Should I use some other technique to record or display images, what will give fruitful results, please help.
我应该使用其他一些技术来记录或显示图像,什么会产生丰硕的结果,请帮助。
Thanks, -mitesh
谢谢,-mitesh
回答by Ralf
What do you mean by virtual camera driver?
虚拟相机驱动程序是什么意思?
It is possible to write a virtual capture device using DirectShow. Such a virtual capture device can then be used by applications such as skype, etc. If that suffices for your needs, you can download vcam from http://tmhare.mvps.org/downloads.htmunder the "Capture Source Filter" link.
可以使用 DirectShow 编写虚拟捕获设备。这样的虚拟捕获设备可以被Skype等应用程序使用。如果这足以满足您的需求,您可以从http://tmhare.mvps.org/downloads.htm的“Capture Source Filter”链接下下载vcam .
Edit: In order to use that capture device in the link I posted you need to download the Windows SDK. The Windows SDK has a tool called "GraphEdit" If you search online, I'm sure you can find a quick GraphEdit tutorial. Basically GraphEdit allows you to construct a multimedia pipeline by connecting a bunch of filters. (This is what happens in the background for instance when you play a movie on your computer. ) This could be something like
编辑:为了在我发布的链接中使用该捕获设备,您需要下载 Windows SDK。Windows SDK 有一个名为“GraphEdit”的工具,如果您在网上搜索,我相信您可以找到一个快速的 GraphEdit 教程。基本上,GraphEdit 允许您通过连接一堆过滤器来构建多媒体管道。(例如,当您在计算机上播放电影时,后台会发生这种情况。)这可能类似于
web cam -> renderer
网络摄像头 -> 渲染器
or
或者
file source -> some decoder -> renderer
文件源 -> 一些解码器 -> 渲染器
and would result in you seeing the video captured by the web cam or the content of the file. The example download shows how you can construct a virtual capture device i.e. it looks like media is coming from a 'real' capture device, but actually you can generate any video you want if you adapt the code to your specific means i.e. take a screengrab and output that. Applications like skype can pick up you virtual capture device if it is registered correctly.
并且会导致您看到网络摄像头捕获的视频或文件内容。示例下载显示了如何构建虚拟捕获设备,即看起来媒体来自“真实”捕获设备,但实际上,如果您将代码调整为您的特定方式,即获取屏幕截图和输出那个。如果注册正确,Skype 等应用程序可以获取您的虚拟捕获设备。
The easiest way to find out if this is sufficient for your needs is to download the capture source filter, register it with the regsvr32 command, and then to use GraphEdit to insert the capture source into a graph, connect the source to a video renderer and hit the play button. A lot of the above mentioned concepts/keywords might seem new to you, but you can do some reading on each topic, and perhaps this will give you a point to get started.
确定这是否足以满足您的需求的最简单方法是下载捕获源过滤器,使用 regsvr32 命令注册它,然后使用 GraphEdit 将捕获源插入到图形中,将源连接到视频渲染器并点击播放按钮。上面提到的许多概念/关键字对您来说可能看起来很陌生,但是您可以对每个主题进行一些阅读,也许这会给您一个入门点。
Edit 2: Is the capture source filter approach not sufficient for your requirements? 1) AFAIR you stated in your (now deleted) answer that you would like to take a screen grab, and use that as a virtual camera device for use in applications such as skype.
编辑 2:捕获源过滤器方法是否不足以满足您的要求?1) AFAIR 您在(现已删除)回答中表示您想进行屏幕抓取,并将其用作虚拟相机设备以用于 Skype 等应用程序。
If that is all you require, you do NOT have to write a device driver. DirectShow can do that perfectly well by means of the capture source filter. You would then need to
如果这就是您所需要的,您就不必编写设备驱动程序。DirectShow 可以通过捕获源过滤器完美地做到这一点。然后你需要
- learn some basic DirectShow
- modify the source code of the capture filter to take screen grabs etc.
- 学习一些基本的 DirectShow
- 修改捕获过滤器的源代码以获取屏幕抓取等。
As far as books are concerned to write device driver to accomplish the same, I have no idea. The point I'm trying to make, is that you need to determine whether you actually need to write a device driver or whether simply modifying the open source capture filter is sufficient.
就书籍而言,编写设备驱动程序来完成相同的工作,我不知道。我想说明的一点是,您需要确定是否确实需要编写设备驱动程序,或者仅修改开源捕获过滤器是否就足够了。