Hello, I tried to capture and display video using opencv and jetson tx2 onboard camera.
I downloaded jetpack 4.3 for opencv and version of opencv is 4.1.1.
I saw cat /etc/nv_tegra_release
# R32 (release), REVISION: 3.1, GCID: 18186506, BOARD: t186ref, EABI: aarch64, DATE: Tue Dec 10 07:03:07 UTC 2019
And I executed some test code below:
import sys
import cv2
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
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 ! video/x-raw, format=(string)BGR ! appsink")
if cap.isOpened():
cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
while True:
ret_val, img = cap.read()
cv2.imshow('demo',img)
if cv2.waitKey(1) == ord('q'):
break
else:
print ("camera open failed")
if __name__=="__main__":
read_cam()
then I had the error
Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:532 No cameras available
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
Gtk-Message: 16:44:29.638: Failed to load module "canberra-gtk-module"
Traceback (most recent call last):
File "thank.py", line 19, in <module>
read_cam()
File "thank.py", line 12, in read_cam
cv2.imshow('demo',img)
cv2.error: OpenCV(4.1.1) /home/nvidia/host/build_opencv/nv_opencv/modules/highgui/src/window.cpp:352: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'imshow'
I tried to execute another example code for activating the camera but I got always ‘No cameras available’ :(
How can I solve this problem?
p.s Would you mind if I ask you a gentle document for activating camera step by step? :D
I’m sorry poor English. I’m in Non-English country.