Errors when using TX2 on-board camera with OpenCV (Unable to query number of channels)

Hi!

I have a TX2 dev kit and I try to use the on-Board camera using OpenCV.

It works fine but I’ve the following error:

VIDEOIO ERROR: V4L: device nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720,format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink: Unable to query number of channels

Available Sensor modes : 
2592 x 1944 FR=30.000000 CF=0x1109208a10 SensorModeType=4 CSIPixelBitDepth=10 DynPixelBitDepth=10
2592 x 1458 FR=30.000000 CF=0x1109208a10 SensorModeType=4 CSIPixelBitDepth=10 DynPixelBitDepth=10
1280 x 720 FR=120.000000 CF=0x1109208a10 SensorModeType=4 CSIPixelBitDepth=10 DynPixelBitDepth=10

NvCameraSrc: Trying To Set Default Camera Resolution. Selected sensorModeIndex = 1 WxH = 2592x1458 FrameRate = 30.000000 ...

That makes me unable to change the Camera Resolution. How can I fixe it?

Here is my code:

import cv2 as cv

cap = cv.VideoCapture("nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720,format=(string)I420, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink")

while(cv.waitKey(1) < 0 ):
    OK, frame = cap.read()

    cv.imshow("Live", frame)

cap.release()

Thank you and best regards!
Quentin

Not sure, but I think this VIDEOIO ERROR may be related to your opencv build to use v4l2 lib. You may try to rebuild with v4l2 support, but not v4l2lib.
Anyway, further than this message it should work. You may change the resolution by launching another capture with another gstreamer pipeline specifying another supported resolution, and if further required using gstreamer plugins for scaling or changing framerate.

I’m sorry for the late reply. Thank you for your response! I didn’t take the time to build openCV with v4l2 but, as you said, I don’t need it. Thanks!