A simple application of the OpenGL shader to the Linux video device (webcamera)
-
Install v4l2loopback - the Linux kernel module for creation virtual webcamera devices
-
Create virtual device:
sudo modprobe v4l2loopback
- Build and run the applicatoin:
cargo build --release && ./target/release/v4l2_gl_filter /dev/video0 /dev/video2
In your case the device ids (video0
, video2
) may differ. Select the appropriate ones (the first device is your main camera, the second one is your virtual camera, created by v4l2loopback module)
- Now you can select the virtual camera in any streaming application (e.g Zoom)
You can implement your custom fragment shader which will be applied to each video frame. filter.frag provides the default implementation. Modify it as you need and rebuild the apllication.