I'm trying to have a simple JS app to open the camera and to display it on localhost a webpage.
Opening the camera and setting the resolution works fine with a simple :
navigator.mediaDevices.getUserMedia({ video: { frameRate: { ideal: 30, max: 30 } , width: 4608, height: 2592 } }) .then(stream => { video.srcObject = stream; }) .catch(err => { console.error("Error accessing webcam:", err); }); My issue is that using this code the camera doesn't use autofocus...
So I've been exploring the libcamera options. Code: Select all
libcamera-hello Nicely displays the camera with focus-mode set to continuous.
Opted solution :
Setting up a v4l2 loopback device with :
sudo modprobe v4l2loopback video_nr=123 card_label="VirtualCam" exclusive_caps=1 Then using a GStreamer pipeline using libcamerasrc:
gst-launch-1.0 libcamerasrc af-mode=continuous ! "video/x-raw,format=BGRx,width=4608,height=2592" ! queue ! videoconvert ! v4l2sink device=/dev/video123 With the af-mode=continuous I finally get what I want on my /dev/video123 opened with VLC.
But now I'm unable to see the v4l2loopback interface in Chromium nor Firefox...
So my questions are :
- How to default the /dev/video0 to a certain resolution and focus mode ?
- How to have Chromium or Firefox detect the V4l2loopback device?
I'm using :
- Pi 5
- Latest Bookworm
- Camera Module 3