So, this is what I did so far.
As I said before, I’m using the code given by JetsonHacksNano.
I set the pipeline in the following way:
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 = 5000000,
exposuretime_high = 5000000,
):
return (
"nvarguscamerasrc sensor-id=%d, "
"video/x-raw(memory:NVMM), "
"width=(int)%d, height=(int)%d, "
"wbmode=0, awblock=true, gainrange="8 8", ispdigitalgainrange="4 4", "
"exposuretimerange="(int)%d (int)%d", aeLock=true, "
"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,
capture_width,
capture_height,
exposuretime_low,
exposuretime_high,
framerate,
flip_method,
display_width,
display_height,
)
)
Then I start the two cameras. For example, this is how I initialize the first one:
def start_cameras():
left_camera = CSI_Camera()
left_camera.open(
gstreamer_pipeline(
sensor_id=0,
exposuretime_low=1000000,
exposuretime_high=1000000,
framerate=30,
flip_method=0,
display_height=540,
display_width=960,
)
)
left_camera.start()
These are the only changes I did to the original code.
Unfortunately, I get this error when I run the code:
(python:7330): GStreamer-CRITICAL **: 13:06:07.953: gst_element_make_from_uri: assertion ‘gst_uri_is_valid (uri)’ failed
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (711) open OpenCV | GStreamer warning: Error opening bin: could not set property “sensor-id” in element “nvarguscamerasrc0” to “0,”
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
(python:7330): GStreamer-CRITICAL **: 13:06:07.965: gst_element_make_from_uri: assertion ‘gst_uri_is_valid (uri)’ failed
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (711) open OpenCV | GStreamer warning: Error opening bin: could not set property “sensor-id” in element “nvarguscamerasrc1” to “1,”
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
Unable to open any cameras
Traceback (most recent call last):
File “dual_exp.py”, line 202, in
start_cameras()
File “dual_exp.py”, line 184, in start_cameras
_ , right_image=right_camera.read()
File “dual_exp.py”, line 88, in read
frame = self.frame.copy()
AttributeError: ‘NoneType’ object has no attribute ‘copy’
Can’t really figure out where the problem is, being the code exactly the same as before.
Maybe there is an error in the new pipeline?