I have a Raspberry Pi CSI camera connected to my Nano. When I run the gst-launch command, found in https://github.com/JetsonHacksNano/CSI-Camera, in the terminal it works fine, no problem.
But when I’m trying to run the GStreamer with OpenCV in Python the camera is not open.
import cv2
def gstreamer_pipeline (capture_width=1280, capture_height=720, display_width=1280, display_height=720, framerate=60, flip_method=0) :
return ('nvarguscamerasrc ! '
'video/x-raw(memory:NVMM), '
'width=(int)%d, height=(int)%d, '
'format=(string)NV12, framerate=(fraction)%d/1 ! '
'nvvidconv flip-method=%d ! '
'video/x-raw, width=(int)%d, height=(int)%d, format=(string)BGRx ! '
'videoconvert ! '
'video/x-raw, format=(string)BGR ! appsink' % (capture_width,capture_height,framerate,flip_method,display_width,display_height))
cap = cv2.VideoCapture(gstreamer_pipeline(flip_method=0), cv2.CAP_GSTREAMER)
cap.isOpened()
>>> False
I found out that the pre-installed opencv-3.2.0 was built without gstreamer support:
Python 3.6.7 (default, Oct 22 2018, 11:32:17)
[GCC 8.2.0] on linux
Type “help”, “copyright”, “credits” or “license” for more information.
>>> import cv2
>>> print(cv2.getBuildInformation())
…
GStreamer: NO
How do I proceed?
I used a newly flashed SD card with latest Jetpack.