Select() timeout with v4l2cuda

Hi,

I was trying to run the Nvidia-provided multimedia example Jetson Linux API Reference: v4l2cuda (CUDA format conversion) | NVIDIA Docs and saw that the call to “select()” was timing out.
I’m using Xavier NX and IMX477 (Arducam 12.3Mpx cameras).
This is similar to post: How to use v4l2cuda sample on Jetson?
but discussion is closed already, so I’m posting what worked for me here.

It turns out that v4l2cuda has some hardcoded/static parameters at the top of the file: width, height, pixel format and field and these were not supported by my camera.

Fix for me was to retrieve the format information using xioctl(fd, VIDIOC_G_FMT, …) and retrieve these values in init_device().

if (0 == xioctl (fd, VIDIOC_CROPCAP, &cropcap)) {
    ... 
}

// ----- begin added code
CLEAR(fmt);
fmt.type                = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if(-1 == xioctl(fd, VIDIOC_G_FMT, &fmt)) {
    errno_exit ("VIDIOC_G_FMT");
}
    // retrieve sensor information and save in global variables
width        = fmt.fmt.pix.width;
height       = fmt.fmt.pix.height;
pixel_format = fmt.fmt.pix.pixelformat;
field        = fmt.fmt.pix.field;
 // code below will use the just saved values
 // ----- end added code

CLEAR (fmt);
fmt.type                = V4L2_BUF_TYPE_VIDEO_CAPTURE;
fmt.fmt.pix.width       = width;
fmt.fmt.pix.height      = height;
fmt.fmt.pix.pixelformat = pixel_format;
fmt.fmt.pix.field       = field;

if (-1 == xioctl (fd, VIDIOC_S_FMT, &fmt)) {
    errno_exit ("VIDIOC_S_FMT");
}

Dumping the camera information can help you figure out if you’re having the same issue:

$ v4l2-ctl --device /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: ‘RG10’ <= not YUYV
Name : 10-bit Bayer RGRG/GBGB
Size: Discrete 4032x3040
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 3840x2160
Interval: Discrete 0.033s (30.000 fps)
Size: Discrete 1920x1080
Interval: Discrete 0.017s (60.000 fps)

So in my case, YUYV format was not supported, the added code switched format to RG10.

Hope this helps,
Alain

Have a check timeout at VIDIOC_G_FMT or VIDIOC_S_FMT

Before run the v4l2 APP please issue below command first.

v4l2-ctl -c bypass_mode=0

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.