Duplicating UVC camera
-
We are using a USB webcam plugged in to the USB port on the modem. Currently we can access the webcam from within a docker image as a USB device. But now we want to use this same camera feed for two separate docker images/ processes. so,
How to duplicate video feed / USB device on Voxl?
Existing methods use
v4l2loopback
to generate duplicate video streams, however the default yocto distribution does not contain the kernel modules necessary to run v4l2
How would I duplicate video stream without using a custom kernelAsked this question before in a different channel but wanted to see if anyone has experience with this
-
@maxwelllwang You can build a custom kernel with this project: https://gitlab.com/voxl-public/system-image-build/voxl-build
-
@maxwelllwang Another idea is to use the dev branch of the new voxl-uvc-project here: https://gitlab.com/voxl-public/modal-pipe-architecture/voxl-uvc-server/-/tree/dev. This will stream the video out with MPA. You can then have MPA clients in multiple docker containers consuming the video frames.
-
Hey,
I will try my best to explain the idea I had.
You can use gstreamer to stream your camera to a shared memory sink (shmsink). To implement this I would use cv2 (python) with the video writer class to write the video to a FIFO file location. The location can be set to /temp/[name] which will utilize shared memory. This location can be mapped to both docker containers with the -v / --volume parameter so you can access the stream from the other docker container as well. This is obviously not the easiest nor best solution but probably better than a custom kernel.
All the best -
This is essentially the point of MPA (Modal Pipe Architecture, our interprocess communications standard). We publish FIFOs to /run/mpa with the data (standard FIFOs use the filesystem as a handle, not for actually transferring the data, the kernel will pass the data directly from process to process). voxl-uvc-server will pull the data from the camera and write it out to a pipe in /run/mpa, which can easily be mounted in a docker image and read there. You can use the libmodal_pipe(or manually request a pipe and open the FIFO, though this will be less reliable than our extensively tested library) to read it in a docker image (or images as MPA allows numerous clients).