I want to use an ArduCam Camarray Hat with four imx219 Cameras with a Jetson Nano. Because I want to “analyze” the video-stream and run some code for object detection and stuff like that, I tried to get the video-stream with OpenCV (I installed it via “sudo apt install python3-opencv”).
First, I tested the cameras with “nvgstcapture-1.0” and it ran without problems.
“gst-launch-1.0 nvarguscamerasrc ! ‘video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1’ ! nvoverlaysink” runs without problems too, but the code: OpenCV Video Capture with GStreamer doesn't work on ROS-melodic - #3 by DaneLLL says, “camera open failed”. Then I found this Python-code for OpenCV:
import cv2 cap = cv2.VideoCapture(0) if (cap.isOpened()== False): print("Error opening video stream or file") while(cap.isOpened()): ret, frame = cap.read() if ret == True: cv2.imshow('Frame',frame) if cv2.waitKey(25) & 0xFF == ord('q'): break else: break cap.release() cv2.destroyAllWindows()
But I get this Error:
select timeout select timeout OpenCV Error: Assertion failed (total() == 0 || data != NULL) in Mat, file /build/opencv-XDqSFW/opencv-3.2.0+dfsg/modules/core/include/opencv2/core/mat.inl.hpp, line 431 Traceback (most recent call last): File "/home/konrad/Documents/Folder/Cameratest2.py", line 15, in <module> ret, frame = cap.read() cv2.error: /build/opencv-XDqSFW/opencv-3.2.0+dfsg/modules/core/include/opencv2/core/mat.inl.hpp:431: error: (-215) total() == 0 || data != NULL in function Mat
Because I thought the Camarray Hat may cause the issue, I tried the same code with a Raspberry Pi v2.1 imx219 camera. With it, I don’t get the error, but the output is just green (what is maybe the standard output of gstreamer).
Do you know how I can solve my problem?
Thanks in advance, Konrad