View my account

Set ROI for RGB Kamera in Python D455

Comments

6 comments

  • MartyG

    Hi Arne Luken  The best available reference for defining a ROI, including one for the RGB sensor, using Python code is at the link below.

    https://github.com/IntelRealSense/librealsense/issues/3427

    0
    Comment actions Permalink
  • Arne Luken

    Hi, thanks again. I have found that as well but it is not working for the rgb sensor on the D455. I have the same issue as migel in your link. Any other Idea?

    0
    Comment actions Permalink
  • MartyG

    Does it make a difference if you change is_depth_sensor() to is_color_sensor()

     

    dev = profile.get_device()
    for sensor in dev.sensors:
    if sensor.is_color_sensor():
    roi_sensor = sensor.as_roi_sensor()
    0
    Comment actions Permalink
  • Arne Luken

    Hey, i tried that:

    Traceback (most recent call last):
      File "/media/tec/SSDOrin/yolov8/roi_tst copy.py", line 17, in <module>
        roi_sensor.set_region_of_interest(sensor_roi)
    RuntimeError: hwmon command 0x75( b4 21c 140 3c0 ) failed (response -6= Invalid parameter)

    import pyrealsense2 as rs

    config = rs.config()
    config.enable_stream(rs.stream.color, 1280, 720, rs.format.rgb8, 30)
    config.enable_stream(rs.stream.depth, 848, 480, rs.format.z16, 30)

    pipeline = rs.pipeline()
    profile = pipeline.start(config)
    dev = profile.get_device()
    for sensor in dev.sensors:
    if sensor.is_color_sensor():
    roi_sensor = sensor.as_roi_sensor()

    sensor_roi = roi_sensor.get_region_of_interest()
    sensor_roi.min_x, sensor_roi.max_x = 320, 960
    sensor_roi.min_y, sensor_roi.max_y = 180, 540
    roi_sensor.set_region_of_interest(sensor_roi)
    0
    Comment actions Permalink
  • MartyG

    If that code did not work then there are not any other references available for setting an RGB ROI unfortunately as it is very rare to do so with code.  I do apologize.

    0
    Comment actions Permalink
  • Arne Luken

    i got it working if i put this before setting the new roi of the color sensor. It's not needed for the depth sensor. Do you know why?

    frames = pipeline.wait_for_frames()
    1
    Comment actions Permalink

Please sign in to leave a comment.