You are not logged in.

#1 2023-09-30 04:30:40

scot
Member
Registered: 2017-04-22
Posts: 36

How to view a v4l2 image snapshot taken with qv4l2?

I have a logitech 920C webcam attached to an up-to-date archlinux box.
To complicate matters a bit, I use this webcam by first running the following command at startup:

# sudo modprobe v4l2loopback devices=2 video_nr="3,4" 'card_label=c920.1,c920.2'  exclusive_caps=1

and then use the Logitech webcam as a "virtual camera" using obs.

If i start up qv4l2 and choose to open /dev/video7, everything works as expected. The image format is YUYV 4:2:2 and the resolution is 960x720. When I press the green "play" button, I see the camera image just fine. I then choose "Snapshot" and it seems to save the file just fine. if I run the "file" command on the resulting file (which is 1382400 bytes long), "file" tells me that the file contains "data".

What utility do i install  // what command do i run to  view the file's data as an image (i.e. as the snapshot i think i took when i chose "Snapshot")?

After several tries. I thought that perhaps the image format is "YUV". so I installed the YUView.appimage from the AUR. When i try to view the file with YUView.appimage, i get an immediate seg fault.

Thank you for your help

-scott

Last edited by scot (2023-09-30 04:34:16)

Offline

#2 2023-09-30 06:48:27

seth
Member
From: Won't reply 2 private help req
Registered: 2012-09-03
Posts: 76,013

Re: How to view a v4l2 image snapshot taken with qv4l2?

Try imagemagick/identify,display

Online

#3 2024-03-28 14:24:41

jebinici
Member
Registered: 2024-03-28
Posts: 1

Re: How to view a v4l2 image snapshot taken with qv4l2?

Hey scot,

I ran into the same problem. The problem is that the snapshot files contain no header at all, so file and identify remain clueless. Since qv4l2 styles itself a test bench, we likely cannot suppose it to produce anything nicer. Still, it is possible to guess the format. Here is my result of that trial and error process:

When configuring qv4l2’s Capture Image Format to MJPG (Motion-JPEG), the result has three times as many bytes as pixels, and indeed it is just a raw rgb image. Easy guess. You can view or convert it with ImageMagick. Since it is a plain pixel map, you have to specify the image’s resolution (960×720 in your case) and the image depth of 8 bit per pixel and color. Given the stored snapshot-file, displaying respectively converting it is done by

display -size 960x720 -depth 8 rgb:snapshot-file
convert -size 960x720 -depth 8 rgb:snapshot-file snapshot.jpg

Configuring YUYV 4:2:2 as you did, results in 2 bytes per pixel. Indeed, YUYV 4:2:2 is some exotic format used in television which forgets about some data, so if available use the variant above. Anyway, here is information on YUYV 4:2:2, the underlying concept and a program to convert it. All you really need is the netpbm package and a call to

yuy2topam -width=960 -height=720 snapshot-file | pamtopng > snapshot.png

Now, that you have some ordinary format, you can use ImageMagick as usual:

convert snapshot.png snapshot.jpg

Hope that helps.
– Jebinici

Offline

Board footer

Powered by FluxBB