Jetson Nano B01 - setting exposure times for two raspberry pi cameras

Your python code defines a function gstreamer_pipeline() that return the pipeline string. Printing it would allow you to copy it from terminal and post it here so that someone would be able to check.

I think I got it…You added these options to the output caps of nvarguscamerasrc, while these are nvarguscamerasrc options. Try:

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, wbmode=0, awblock=true, gainrange=\"8 8\", ispdigitalgainrange=\"4 4\", 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,
    )
)

Okay I understood, infact I was posting the pipeline output, which is:

nvarguscamerasrc sensor-id=0 video/x-raw(memory:NVMM), width=(int)1280, height=(int)720, wbmode=0, awblock=true, gainrange="8 8", ispdigitalgainrange="4 4", exposuretimerange="5000000 5000000", aeLock=true, format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv flip-method=0 ! video/x-raw, width=(int)1280, height=(int)720, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink

This time I got this error:

(python:7955): GStreamer-CRITICAL **: 16:32:41.347: 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: no element "video"**
[ 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:7955): GStreamer-CRITICAL **: 16:32:41.359: 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: no element "video"**
[ 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

I also understood your point, the order of the parameter is really important then. I used your part of code, but I’m still getting different errors, I could punch my monitor sooner or later :DDD
This time I’m getting these errors:

  1. Something similar to:
GStreamer warning: Error opening bin: could not set property "sensor-id" in element "nvarguscamerasrc0" to "0"
  1. This one is pretty awkward
Traceback (most recent call last):
  File "dual_exp.py", line 197, in <module>
    start_cameras()
  File "dual_exp.py", line 145, in start_cameras
    display_width=960,
  File "dual_exp.py", line 130, in gstreamer_pipeline
    display_height,
TypeError: not enough arguments for format string

This is the part of code I use to initialize the first camera (same code for the second one):

 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()

I see some errors I did when modifying your code (I have not tested).
Plugin options are only separated by spaces, while caps properties are comma-separated.
You would modify the nvarguscamera options and remove the commas:

def gstreamer_pipeline(
sensor_id=0,
exposuretime_low = 5000000,
exposuretime_high = 5000000,
capture_width=1280,
capture_height=720,
display_width=1280,
display_height=720,
framerate=30,
flip_method=0,
):
return (
"nvarguscamerasrc sensor-id=%d wbmode=0 awblock=true gainrange=\"8 8\" ispdigitalgainrange=\"4 4\" 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,
    )
)
1 Like

hello tooricco,

please note that, the exposure time range settings were based-on nanoseconds,
your setting, exposuretimerange="5000000 5000000" seems a quite small exposure values.
please also check your sensor capability for the supported exposure-time values.
you may look into device tree for the min_exp_time and max_exp_time properties.
while you enable camera steam, there’ll also report the available ranges for each sensor modes.
for example,

GST_ARGUS: Available Sensor modes :
GST_ARGUS: 1280 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 8.000000; Exposure Range min 17000, max 28220000;
1 Like

I know they’re small exposure values, but they worked pretty well.
I choose those values just to test the cameras, but I also got solid results!

Thank you Honey, that solved my problem.
Just had a bit of difficulty setting the pipeline.
There is a documentation about it?

You may find some doc from NVIDIA here.

As general rule, for gstreamer some description is supposed to be embedded into plugins. Use:

# This would list all available plugins and more
gst-inspect-1.0

# This would show details about a given plugin. 
# Tells which library provides it
# SINK caps are for input, SRC caps for output
# Will list available options, default values...and more
gst-inspect-1.0 given_plugin