TX2 - Onboard camera command reference for opencv


Where is the reference documentation for invoking onboard camera in Jetson TX2? I used the following command from canndetection.py (example code); however,it produces the following error statement although the program is working. Any reference documentation will really help. Thanks!

Error Message:

VIDEOIO ERROR: V4L: device nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv ! 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 …


One easy way is to access through gstreamer plugin nvcamerasrc (up to R28) or nvarguscamerasrc (above).

# Up to LT4 R28
gst-launch-1.0 nvcamerasrc ! nvvidconv ! xvimagesink

#or (above R28)
gst-launch-1.0 nvarguscamerasrc ! nvvidconv ! xvimagesink

This should work when logged in locally, or remotely if X-forwarding is enabled (for example, you may ssh -Y into a headless Jetson).
You would add caps and more elements in your pipeline for your usecase.

When it works, you would change the end of the pipeline into (assuming post R28):

nvarguscamerasrc ! nvvidconv ! video/x-raw, format=BGRx ! videoconvert ! video/x-raw, format=BGR ! appsink

for opencv capture.

Note that videoconvert is CPU only, and may be slow for high resolutions. Depending on your opencv processing, you may also try to remove videoconvert and read I420 or NV12 format from opencv:

nvarguscamerasrc ! nvvidconv ! video/x-raw, format=NV12 ! appsink

[EDIT: looking at your logs, it may be working…The ‘Unable to query number of channels’ message may not be harmful. You may explain further what doesn’t work.
Not sure, but you may try to rebuild opencv with V4L2 support, but not v4l2lib.]