Hey, I’m was using a Waveshare IMX219-200 on a Jetson Nano and by calling nvgstcapture-1.0
I was able to see the feed.
But now I want to use it in Python with OpenCV and I cannot manage to get the camera stream. Therefore I was browsing for hours, trying every combination for the VideoCapture and came to the previous topic named “OpenCV Video Capture with GStreamer doesn’t work on ROS-melodic”
Here the lik
I plugged in the code to confirm my source is valid and always get the answer “camera open failed”…
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()
Error:
[ERROR:0@0.056] global cap.cpp:164 open VIDEOIO(CV_IMAGES): raised OpenCV exception:
OpenCV(4.7.0) /io/opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): 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 in function 'icvExtractPattern'
camera open failed
How can I fix that? What is the problem? The camera works fine but not like that…