I’ve been developping a program using the raspberry pi v2 camera on a jetson nano with v4l2.
As part of the program, I cange the resolution of the camera to 1280*720 (which is one of the possibilities listed by v4l2-ctl --list-formats-ext) through the C API of v4l2.
This worked during the last two weeks but doesn’t anymore, now the resolution change is ingored and the resolution stays to the default 3264*2464. I don’t quite understand why as I’m still using the same executable, perhaps something got updated in the meantime. On the other hand, I still capture the video as expected, only the resolution is wrong.
Using v4l2-ctl --set-fmt-video=width=1280,height=720 doesn’t do anything either. Running v4l2-ctl --get-fmt-video afterwards returns width/height: 3264/2464.
this works and the camera is set to 1280*720 afterwards.
Unfortunately, I need to set the video resolution through my program using the V4L2 API (or equivalently, v4l2-ctl --set-fmt-video=width=1280,height=720). In addition, using this command seems to have consequences over the state of the camera.
When I run my program without, I cannot set the image resolution but I manage to receive images.
When I run my program after this command, the resolution stays to 1280*720 but I fail to receive an image. More precisely, I get a “select timeout” in v4l2 capture example · GitHub on line 206.
My program is not only targeting jetson platforms but anything that is compatible with V4L2.
In addition, using nvarguscamerasrc makes the V4L2 API I’m using fail when trying to capture an image.
I did not know there was a verbose argument to v4l2-ctl, thanks.
Unfortunately, it doesn’t print anything of value, it says everything is OK (include VIDIOC_S_FMT) and then shows that the video format is still 3264/2464
nvidia@nvidia-desktop:~$ v4l2-ctl --set-fmt-video=width=1920,height=1080 --verbose
VIDIOC_QUERYCAP: ok
VIDIOC_G_FMT: ok
VIDIOC_S_FMT: ok
Format Video Capture:
Width/Height : 2592/1944
Pixel Format : 'BG10'
Field : None
Bytes per Line : 5184
Size Image : 10077696
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :
nvidia@nvidia-desktop:~$ v4l2-ctl --set-fmt-video=width=2592,height=1458 --verbose
VIDIOC_QUERYCAP: ok
VIDIOC_G_FMT: ok
VIDIOC_S_FMT: ok
Format Video Capture:
Width/Height : 2592/1458
Pixel Format : 'BG10'
Field : None
Bytes per Line : 5184
Size Image : 7558272
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :
v4l2-ctl --set-fmt-video=width=1280,height=720 --verbose
VIDIOC_QUERYCAP: ok
VIDIOC_G_FMT: ok
VIDIOC_S_FMT: ok
Format Video Capture:
Width/Height : 3264/2464
Pixel Format : 'RG10'
Field : None
Bytes per Line : 6528
Size Image : 16084992
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :
nvidia@ubuntu:~$ v4l2-ctl --set-fmt-video=width=1280,height=720,pixelformat=RG10 --verbose --set-ctrl=sensor_mode=4
VIDIOC_QUERYCAP: ok
VIDIOC_S_EXT_CTRLS: ok
VIDIOC_G_FMT: ok
VIDIOC_S_FMT: ok
Format Video Capture:
Width/Height : 1280/720
Pixel Format : 'RG10'
Field : None
Bytes per Line : 2560
Size Image : 1843200
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :
nvidia@ubuntu:~$ v4l2-ctl --set-fmt-video=width=1640,height=1232,pixelformat=RG10 --verbose --set-ctrl=sensor_mode=3
VIDIOC_QUERYCAP: ok
VIDIOC_S_EXT_CTRLS: ok
VIDIOC_G_FMT: ok
VIDIOC_S_FMT: ok
Format Video Capture:
Width/Height : 1640/1232
Pixel Format : 'RG10'
Field : None
Bytes per Line : 3280
Size Image : 4040960
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Full Range)
Flags :