So, I wrote this little script to test the two cameras:
import cv2
import numpy as np
def gstreamer_pipeline(
sensor_id=0,
capture_width=1280,
capture_height=720,
display_width=1280,
display_height=720,
framerate=30,
flip_method=0,
exposuretime_low=16000000,
exposuretime_high=16000000,
):
return (
'nvarguscamerasrc sensor-id=%d wbmode=0 awblock=true gainrange="4 4" ispdigitalgainrange="2 2" exposuretimerange="%d %d" aelock=true ! '
"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"
% (
sensor_id,
exposuretime_low,
exposuretime_high,
capture_width,
capture_height,
framerate,
flip_method,
display_width,
display_height,
)
)
cam1 = cv2.VideoCapture(gstreamer_pipeline(sensor_id=0, exposuretime_low=16000000, exposuretime_high=16000000), cv2.CAP_GSTREAMER)
cam2 = cv2.VideoCapture(gstreamer_pipeline(sensor_id=1, exposuretime_low=20000000, exposuretime_high=20000000), cv2.CAP_GSTREAMER)
print("CAM1: ", cam1.isOpened())
print("CAM2: ", cam2.isOpened())
and the result was the following output:
$ python camera_test.py
('CAM1: ', False)
('CAM2: ', False)
Moreover, I tried to import cv2 through from cv2 import cv2, but nothing changed, getting the error
$ python camera_test.py
Traceback (most recent call last):
File "prova_camere.py", line 1, in <module>
from cv2 import cv2
ImportError: cannot import name cv2
I also got the error Module 'cv2' has no 'VideoCapture' member
while coding.
At the very end, I tried to run the following two command lines from terminal, getting an error both times:
Code 1:
$ gst-launch-1.0 nvarguscamerasrc sensor_id=0 ! 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:568 Failed to create CaptureSession
Got EOS from element "pipeline0".
Execution ended after 0:00:00.004857453
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
Code 2:
$ gst-launch-1.0 nvarguscamerasrmode=0 awblock=true gainrange="8 8" ispdigitalgainrange="4 4" exposuretimerange="10000000 10000000" aelock=true sensor-id=1 sensor-mode=3 ! nvvidconv ! ximagesink
WARNING: erroneous pipeline: syntax error