on board cam

On Xavier this open_cam:onboard doesn’t work.

def open_cam_onboard(width, height):
    # On versions of L4T prior to 28.1, add 'flip-method=2' into gst_str
    gst_str = ('nvcamerasrc ! '
               'video/x-raw(memory:NVMM), '
               'width=(int)2592, height=(int)1458, '
               'format=(string)I420, framerate=(fraction)30/1 ! '
               'nvvidconv ! '
               'video/x-raw, width=(int){}, height=(int){}, '
               'format=(string)BGRx ! '
               'videoconvert ! appsink').format(width, height)
    return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)

This works only with cv2.CaptureVideo(dev)

def open_cam_usb(dev, width, height):
    # We want to set width and height here, otherwise we could just do:
    #     return cv2.VideoCapture(dev)
    gst_str = ('v4l2src device=/dev/video{} ! '
               'video/x-raw, width=(int){}, height=(int){}, '
               'format=(string)RGB ! '
               'videoconvert ! appsink').format(dev, width, height)
#    return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
    return cv2.VideoCapture(1)

Anybody could help making working python onboard cam ? thanks

The camera element isn’t called nvcamerasrc anymore, it is now called nvarguscamerasrc

Please see the CAMERA CAPTURE section of the L4T Accelerated GStreamer User Guide for the updated pipeline.

def open_cam_onboard(width, height):
    # On versions of L4T prior to 28.1, add 'flip-method=2' into gst_str
    # Use Jetson onboard camera
#    gst_str = ("nvcamerasrc ! "
    gst_str = ("nvarguscamerasrc ! "
               "video/x-raw(memory:NVMM), width=(int)2592, height=(int)1458, format=(string)I420, framerate=(fraction)30/1 ! "
               "nvvidconv ! video/x-raw, width=(int){}, height=(int){}, format=(string)BGRx ! "
               "videoconvert ! appsink").format(width, height)
    return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)

Thank you, I’ll read carefully the doc.

At present, first attempt, something start working but at the end Failed to open camera !

First, try running this standalone sample program to see if you can get video:

$ nvgstcapture-1.0

You can also try running this GStreamer pipeline from the command line:

$ gst-launch-1.0 nvarguscamerasrc ! ‘video/x-raw(memory:NVMM), \
 width=1920, height=1080, format=(string)NV12, \
 framerate=(fraction)30/1' ! nvoverlaysink -e

If those don’t work, it may be an issue with your camera setup. Which camera are you using?

Thanks a lot!!

both of the two “commands” are well working.

I’m using the onboardcam from Jetson TX2 Development kit.

The onboard cam is well working with jetson-inference, too.

No way to make it working with tegra-cam.py and tegra-cam-caffe.py that’s interesting me.

Thanks for help

hm, in my case the first command executes, though doesn’t provide any video output that can be seen, but the second sequence complains:

<s>syntax error near unexpected token `(</s>'

Update: deleting and adding helped get it running
However, I am using the below sequence :

gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),width=1024, height=768, framerate=120/1, format=NV12' ! nvvidconv flip-method=0 ! nvegltransform ! nveglglessink -e

I can capture with the sequence below [first press 1 and then either 2 or 0 to stop capturing]:

nvgstcapture-1.0 -m 2 -k 2

Thank you so much for your suggestions, Andrey1984.

Me too, I can use the onboard cam from terminal as well as from original NVIDIA jetson-inference tutorial.

My problem and my thread is becasuse I cannot use on-board-camera like I used with Jetson TX" from Python tutorial tegra-cam.py, tegra-cam-caffe.py :

def open_cam_onboard(width, height):
        # On versions of L4T prior to 28.1, add 'flip-method=2' into gst_str
        # Use Jetson onboard camera
    #    gst_str = ("nvcamerasrc ! "
        gst_str = ("nvarguscamerasrc ! "
                   "video/x-raw(memory:NVMM), width=(int)2592, height=(int)1458, format=(string)I420, framerate=(fraction)30/1 ! "
                   "nvvidconv ! video/x-raw, width=(int){}, height=(int){}, format=(string)BGRx ! "
                   "videoconvert ! appsink").format(width, height)
        return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)

and at poresent I cannot understand why, even if I replaced nvcamerasrc with nvarguscamerasrc.

Thank you to all, my best

I solved:

def open_cam_onboard(width, height):
    gst_str = ('nvarguscamerasrc ! '
               'video/x-raw(memory:NVMM), '
               'width=(int)2592, height=(int)1458, '
               'format=(string)NV12, framerate=(fraction)30/1 ! '
               'nvvidconv flip-method=2 ! '
               'video/x-raw, width=(int){}, height=(int){}, '
               'format=(string)BGRx ! '
               'videoconvert ! appsink').format(width, height)
    return cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)

I’m using Python OpenCV GStreamer Caffe as per tegra-cam-caffe.py.

The on_board_cam is the same from Jetson TX2.

Thanks to all, hope it’s useful for everybody.

This is interesting. You have mainly two things different in working case as compared to previous non working case.
First one is nvvidconv option flip-method=2 that was used in old L4T versions for having the onboard camera upside up. This should be unrelated.
Second one is that you are using NV12 instead of I420 as nvarguscamerasrc output format. While with nvcamerasrc on TX1/TX2 the default (and most failsafe) format was I420, it may have changed with nvarguscamerasrc/Xavier.
You may try to figure out which one make the difference.

This is pure speculation, but you may also check what gives specifying BGR format between videoconvert and appsink:

gst_str = ('nvarguscamerasrc ! '
               'video/x-raw(memory:NVMM), '
               'width=(int)2592, height=(int)1458, '
               'format=(string)I420, framerate=(fraction)30/1 ! '
               'nvvidconv ! '
               'video/x-raw, width=(int){}, height=(int){}, '
               'format=(string)BGRx ! '
               'videoconvert ! format=(string)BGR ! '
               'appsink').format(width, height)

my reference for the solution was:

Jetson_Xavier_Accelerated_GStreamer_User_Guide.pdf, page 22, SAMPLE CSI CAMERA PIPELINE


Can I use the TX2’s on board cam module to mount on Xavier’s Camera Connector directly?

Yes, you can use the TX2’s on board cam module to mount on Xavier’s Camera Connector directly.

any ideas on the below?

gst-launch-1.0 nvarguscamerasrc ! 'video/x-raw(memory:NVMM),   width=1920, height=1080, format=(string)NV12, framerate=(fraction)30/1' ! v4l2sink device=/dev/video2
WARNING: erroneous pipeline: could not link nvarguscamerasrc0 to v4l2sink0, v4l2sink0 can't handle caps video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)NV12, framerate=(fraction)30/1
gst-launch-1.0 nvarguscamerasrc !  v4l2sink device=/dev/video2
WARNING: erroneous pipeline: could not link nvarguscamerasrc0 to v4l2sink0