TX2 Onboard Camera

I’ve browed through a bunch of topics on this (a search capability or pinned topic would help!) and I’m still getting errors trying to read from the TX2 devkit onboard camera. The error I see is:

VIDEOIO ERROR: V4L: device nvcamerasrc fpsRange='30 30'! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)30/1 ! nvvidconv !  video/x-raw, format=(string)BGRx ! nvvidconv ! video/x-raw, format=(string)BGR ! nvvidconv ! video/x-raw, format=(string)BGR ! videoconvert ! 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 ...

OpenCV(3.4.1-dev) Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp, line 890
VIDEOIO(cvCreateCapture_GStreamer (CV_CAP_GSTREAMER_FILE, filename)): raised OpenCV exception:

OpenCV(3.4.1-dev) /home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp:890: error: (-2) GStreamer: unable to start pipeline
 in function cvCaptureFromCAM_GStreamer


VIDEOIO ERROR: libv4l unable convert to requested pixfmt
VIDEOIO ERROR: libv4l unable to ioctl VIDIOCSPICT

OpenCV(3.4.1-dev) Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp, line 890
VIDEOIO(cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, reinterpret_cast<char *>(index))): raised OpenCV exception:

OpenCV(3.4.1-dev) /home/nvidia/opencv/modules/videoio/src/cap_gstreamer.cpp:890: error: (-2) GStreamer: unable to start pipeline
 in function cvCaptureFromCAM_GStreamer

As you can see I’m running my own build of OpenCV with GStreamer enabled (following jetsonhacks/buildOpenCVTX2), but no matter what I try I can’t get the pipeline to start.

Any suggestions?

You may try to give this pipeline to VideoCapture:

const char* gst =  "nvcamerasrc ! video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, format=(string)I420, framerate=(fraction)120/1 ! \
                    nvvidconv   ! video/x-raw, format=(string)BGRx ! \
                    videoconvert ! video/x-raw, format=(string)BGR ! \
                    appsink";

That string works … once I realized I was calling VideoCapture.open() instead of VideoCapture.isOpen(). :facepalm:

Now I need to figure out why once my object tracker finds something it (a) cuts framerate WAY down; (b) stalls out after a few minutes, or © segfaults. But that’s not a problem with the string yet.

Thanks!

Sam issue here, not working even with the pipeline

@toolelucidator You may provide more details of what you are doing (what commands, code…) and what errors you see, this may lead to better advice. You may also give details about your setup (dev kit, camera, opencv version, …).

Just guessing, does your opencv build support gstreamer ? Opencv provides a function named getBuildInformation() that returns a long string with build options, so you would print this. Python example:

import cv2
print(cv2.getBuildInformation())

and check for this part in output:

GStreamer:                   
      base:                      YES (ver 1.8.3)
      video:                     YES (ver 1.8.3)
      app:                       YES (ver 1.8.3)
      riff:                      YES (ver 1.8.3)
      pbutils:                   YES (ver 1.8.3)

Same issue.

how can i use onboard cam.
I’m using python3, opencv 3.4.0

Error message :
VIDEOIO ERROR: libv4l unable convert to requested pixfmt
VIDEOIO ERROR: libv4l unable to ioctl VIDIOCSPICT

OpenCV Error: Unspecified error (GStreamer: unable to start pipeline
) in cvCaptureFromCAM_GStreamer, file /home/nvidia/opencv-3.4.0/modules/videoio/src/cap_gstreamer.cpp
, line 890
VIDEOIO(cvCreateCapture_GStreamer(CV_CAP_GSTREAMER_V4L2, reinterpret_cast<char *>(index))): raised Op
enCV exception:

/home/nvidia/opencv-3.4.0/modules/videoio/src/cap_gstreamer.cpp:890: error: (-2) GStreamer: unable to
start pipeline
in function cvCaptureFromCAM_GStreamer

getBuildInformation() is following :
Video I/O:
DC1394: NO
FFMPEG: YES
avcodec: YES (ver 56.60.100)
avformat: YES (ver 56.40.101)
avutil: YES (ver 54.31.100)
swscale: YES (ver 3.1.101)
avresample: NO
GStreamer:
base: YES (ver 1.8.3)
video: YES (ver 1.8.3)
app: YES (ver 1.8.3)
riff: YES (ver 1.8.3)
pbutils: YES (ver 1.8.3)
libv4l/libv4l2: 1.10.0 / 1.10.0
v4l/v4l2: linux/videodev2.h
gPhoto2: NO

any advice would be appreciated.
thx in advance.

It is hard to advise without knowing the gstreamer pipeline you are using, but you may try this simple example.