Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 7503

Camera board • Camera Module 3 - Pi5 - getUserMedia - AutoFocus

$
0
0
Hello all !

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 :

Code:

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:

libcamera-hello
Nicely displays the camera with focus-mode set to continuous.

Opted solution :

Setting up a v4l2 loopback device with :

Code:

sudo modprobe v4l2loopback video_nr=123 card_label="VirtualCam" exclusive_caps=1
Then using a GStreamer pipeline using libcamerasrc:

Code:

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 :

Is there a way to default the /dev/video0 to a certain resolution and focus mode ?

Is there a way to have Chromium or Firefox detecting the V4l2loopback device ?

I'm struggling on this since quite a while and it kinda blew my mind ^^"

Many thanks !

Statistics: Posted by TooT — Mon May 05, 2025 9:53 am — Replies 0 — Views 44



Viewing all articles
Browse latest Browse all 7503

Trending Articles