Hello,
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.
nvarguscamerasrc seems to work fine.
Thanks for your help
Try launch by gst-launch-1.0 then check by v4l2
gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1280,height=720,framerate=60/1,format=NV12' ! nvvidconv ! fpsdisplaysink video-sink=xvimagesink sync=false
Hi,
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.
Thank you for your help
Why not set mode by nvarguscamerasrc?
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.
Maybe need trace the code flow to figure the problem.
Independtly of any bug in my code, I don’t see why v4l2-ctl --set-fmt-video=width=1280,height=720 doesn’t work.
Are you aware of any place where error logging might occur, I couldn’t find anything in /var/log/syslog
I also tried one of nvidia samples
https://docs.nvidia.com/jetson/l4t-multimedia/l4t_mm_12_camera_v4l2_cuda.html
Setting the width/height in this sample does not work either (it stays to 3264*2464) no matter what I specify as argument
Try add --verbose like below.
v4l2-ctl --set-fmt-video=width=1280,height=720 --verbose
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
It should change the result like below.
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 :
I get
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 :
Add --set-ctrl=sensor_mode=[0|1|2|…] to verify.
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 :
Setting the sensor_mode to 4 does the job, I was also able to patch it in my application.
Thank you very much for your help and
Thank you for the answer your provided there 2 years ago, it helped me to patch it in my app.
Have a nice day