Tx1 onboard camera

i’m trying to run my code using onboard camera, but there’s error.

my code is

import cv2

print(cv2.version)
gst_str = ("nvarguscamerasrc ! video/x-raw(memory:NVMM), format=NV12, width=640, height=480, framerate=30/1 ! "
"nvvidconv ! video/x-raw, format=(string)BGRx ! "
"videoconvert ! video/x-raw, format=(string)BGR ! "

              "appsink")

vidcap = cv2.VideoCapture(gst_str, cv2.CAP_GSTREAMER)
success,image = vidcap.read()
count = 0
success = True
while success:
cv2.imwrite(“frame%d.jpg” % count, image) # save frame as JPEG file
success,image = vidcap.read()
print ('Read a new frame: ', success)
count += 1

but when i run this code,

GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected…
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 2592 x 1944 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 34000, max 550385000;

GST_ARGUS: 2592 x 1458 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 34000, max 550385000;

GST_ARGUS: 1280 x 720 FR = 120.000005 fps Duration = 8333333 ; Analog Gain range min 1.000000, max 16.000000; Exposure Range min 22000, max 358733000;

GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 2
Output Stream W = 1280 H = 720
seconds to Run = 0
Frame Rate = 120.000005
GST_ARGUS: PowerService: requested_clock_Hz=2016000
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
Segmentation fault (core dumped)

what should i do?

Hi,
You may try this code:

This code shows preview. You may refer to it and debug further.

when i run
$ gst-launch-1.0 nvarguscamerasrc ! ‘video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1’ ! nvoverlaysink

Setting pipeline to PAUSED …
Pipeline is live and does not need PREROLL …
Setting pipeline to PLAYING …
New clock: GstSystemClock
Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:543 Failed to create CaptureSession
Got EOS from element “pipeline0”.
Execution ended after 0:00:00.001995013
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

this error comes out
what’s wrong with it…?

Hi,
It looks like the camera cannot be launched. You may try a simplified pipeline:

$ gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink

when i try
gst-launch-1.0 nvarguscamerasrc ! nvoverlaysink

it works well.
but after that, if i run

import sys
import cv2

def read_cam():
cap = cv2.VideoCapture(“nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! appsink”)
if cap.isOpened():
cv2.namedWindow(“demo”, cv2.WINDOW_AUTOSIZE)
while True:
ret_val, img = cap.read();
cv2.imshow(‘demo’,img)
cv2.waitKey(10)
else:
print (“camera open failed”)

cv2.destroyAllWindows()

if name == ‘main’:
read_cam()

this code on your link,

Segmentation fault (core dumped)

same error comes out…

Hi,
You may try other resolutions such as 1280x720 or 640x480. The onboard camera(ov5693) can run in 1920x1080 but somehow it fails on your TX1.

For information, please share your release version( $ head -1 /etc/nv_tegra_release )

here is my version
R32 (release), REVISION: 3.1, GCID: 18186506, BOARD: t210ref, EABI: aarch64, DATE: Tue Dec 10 06:58:34 UTC 2019

my camera works well now!
thanks!!

1 Like