How to write on a virtual webcam in Linux?

18,942

Solution 1

Well, actually this is possible. A quick and dirty way to do this is to use WebcamStudio. That will create a new video device (e.g., /device/video2) that other programs see as a normal video device and can take its input from desktop, so you just set it up to capture a part of the screen that OpenCV's output is shown there.

A better but more technical way is to use the V4L2 loop back module. This way you can simply pipe the output of OpenCV to the module which is seen as a regular video device by the other programs. See the readme at the bottom of this page: https://github.com/umlaeute/v4l2loopback and the wiki page: https://github.com/umlaeute/v4l2loopback/wiki for more information.

Hope that helps.

Solution 2

You can also use a combination of v4l2loopback, OBS Studio and obs-v4l2sink.

Use OBS Studio to capture video from your device, then obs-v4l2sink is a small plugin that writes output into /dev/video* of your choice.

v4l2sink

https://github.com/umlaeute/v4l2loopback/wiki/OBS-Studio

https://github.com/CatxFish/obs-v4l2sink

Share:
18,942
user1275896
Author by

user1275896

Updated on July 10, 2022

Comments

  • user1275896
    user1275896 almost 2 years

    I want to capture a video from a real webcam, apply filters with openCv and write the filtered video on a virtual webcam, to stream it on web.

    I don't have problem with the first 2 points, but I don't know how I can write on a virtual webcam.

    It's possible?

    How can I do it?

    I use openCv with C++ on Debian. Thanks