Virtual video camera

Previous tutorial: Video writing - from single file to video archive


Starting from version 1.2.0 the Computer Vision Sandbox setup package allows to install a virtual web camera into a system, which will become available to applications supporting DirectShow interface. Checking Skype's camera settings, for example, would show an extra camera named CVSandbox Virtual Camera available in the system. Obviously it is a virtual camera - you don't have any physical device with such name connection to your system, do you? Running it as is will not produce too much - just a random black and white noise. But that can be changed.

Together with the virtual camera itself there is a video processing plug-in for the Computer Vision Sandbox application gets installed. The Virtual Camera Push plug-in allows pushing video frames from any video source available in a sandbox to the CVSandbox Virtual Camera. This can be used for multiple purposes. For example, it is possible to turn any video source into a DirectShow compatible one. Most USB web cameras (or laptops' integrated cameras) do support DirectShow interface and so are accessible from applications using this interface as well. But what if you may want to use your IP camera, for example, as DirectShow camera. IP cameras provide RTSP and MJPEG streams usually (also JPEG snapshots for simple picture grabbing) and so are not accessible from DirectShow applications naturally. Of course this can be solved with some special DirectShow filters, but those are custom made for specific cameras usually. However in Computer Vision Sandbox there is very little limitation on what can be pushed into the CVSandbox Virtual Camera. As long as you have a plug-in to access your particular camera model and it can be played in the application, you may push its frames into the virtual camera.

Since Computer Vision Sandbox is a modular system, the virtual camera can be used for more than just adding DirectShow interface to something which does not have it. The key point is that the Virtual Camera Push plug-in is just one of many the application provides. And it can be put anywhere in a video processing graph to achieve unique results. This plug-in can be a single step in a video graph, if we just wish to copy frames from some video source into the virtual one. However it gets more interesting if other image/video processing plug-ins are put into the graph, which would do some image processing before it gets pushed into the virtual camera.

As it is mentioned above, the CVSandbox Virtual Camera displays only random noise. In order for it to show something different it is required to run a video processing graph in Computer Vision Sandbox, which contains the Virtual Camera Push plug-in. Once a sandbox with such graph is running, it is time to switch to the application where the virtual camera is about to be used. In Skype, for example, it may look something like shown on the picture below.

The virtual camera can be played in Computer Vision Sandbox as well. For example, someone might want to create a sandbox with two video sources - the virtual camera and some web camera, for example. Then put some image processing on the web camera and push it to the virtual one - it will result in two cameras showing the same. However it can be changed - some image processing plug-ins can be put on top of the virtual camera as well or on the web camera right after the push to virtual is done. Indeed, pushing to virtual does not have to be the last step in a video processing graph - it is just one of the steps in the processing chain.

Few things to mention. The 1.0.0 version of CVSandbox Virtual Camera (included into 1.2.(0-4) versions of Computer Vision Sandbox) supports only one resolution - 640x480 at 15 frames per seconds rate. However, starting from version 1.1.0 (included into Computer Vision Sandbox version 1.2.5+) it provides support for a range of resolutions and frame rates, which can be set by the application using the virtual camera. In any case, if original video source is faster and so images are pushed at higher rate than virtual camera is configured for, then some images will be skipped - the virtual camera will still operate at the configured frame rate. One the other hand, if the source video has lower frame rate, then the virtual camera will simply duplicate some of the frames.


Next tutorial: Introduction to Scripting