View my account

Depth and Color frame data read

Comments

8 comments

  • Aznie Syaarriehaah

    Hi Charmipatel17071995,
    From your snippet code, you are missing the resolution for the FPS of the stream. Have a look at this opencv_viewer_example.py line 22 for the code or else you also can pass and export the argument as done in this export_ply_example.py script.

    Regards,
    Aznie
    Intel RealSense Customer Support

    0
    Comment actions Permalink
  • Charmipatel17071995

    Hello, 

    Thanks for your quick help. I tried using the resolution, but getting the same error.

    config.enable_stream(rs.stream.color, 960, 540, rs.format.bgr8, 30)
    config.enable_stream(rs.stream.depth, 640, 480, rs.format.z16, 30)
    0
    Comment actions Permalink
  • Aznie Syaarriehaah

    Hi Charmipatel17071995,
    Did you get the recorded .bag file from RealSense Viewer? Please provide us more detail on the python programs you are running from the examples directory? Also, can you try to connect your camera with RealSense Viewer and check the USB detected at the top of the viewer? Please shares the screenshot with us.

    Regards,
    Aznie
    Intel RealSense Customer Support

    0
    Comment actions Permalink
  • Charmipatel17071995

    Hello,

    Yes I have recorded *.bag file from the viewer. I am trying to write a python code which extracts depth and color frame from recorded *.bag file and display it using opencv window. The camera is connected perfectly and I view the parameters in the rs-rosbag-inspector properly.

    pipeline = rs.pipeline()

    # Create a config object
    config = rs.config()

    rs.config.enable_device_from_file(config, '*.bag', False)
    config.enable_stream(rs.stream.color)
    config.enable_stream(rs.stream.depth)

    pipeline.start(config)

    while True:
           # Get frameset of depth
           frames = pipeline.wait_for_frames()

           # Get depth frame
           depth_frame = frames.get_depth_frame()

           # Get color frame
           color_frame = frames.get_color_frame()

     

    I tried simply doing this as per your suggestion and it works fine.

    config.enable_stream(rs.stream.color)
    config.enable_stream(rs.stream.depth)

     

    I also want to extract the confidence value of each pixel in a frame. Is it possible to get that with L515?

    Regards,

    Charmi

    0
    Comment actions Permalink
  • Aznie Syaarriehaah

    Hi Charmipatel17071995,
    Yes, you can access the confidence value within L515, Here is the example of how to enable the stream confidence for each sensor:
    config.enable_stream(rs2_stream::RS2_STREAM_CONFIDENCE, 640, 480, RS2_FORMAT_RAW8, 30);

    Regards,
    Aznie
    Intel RealSense Customer Support

    0
    Comment actions Permalink
  • Charmipatel17071995

    Hello,

    I have recorded the stream after enabling the stream confidence. But I do not know how to access the stream after enabling it. Can you please help me with that?

    Regards,

    Charmi 

    0
    Comment actions Permalink
  • Aznie Syaarriehaah

    Hi Charmipatel,
    You can access the stream by doing this:

    confidence_frame = frame_data.first_or_default(RS2_STREAM_CONFIDENCE);

    Regards,
    Aznie
    Intel RealSense Customer Support

    0
    Comment actions Permalink
  • Charmipatel17071995

    Hi,

    Thank you very much. I am able to access the confidence stream after converting the stream to numpy array. I found that the confidence maps are stored in the following format. I want to extract the data in the following format for each pixel.

     

    confidence_output = confidence_frame.get_data()
    confidence = np.asanyarray(confidence_output)

     

    Regards,

    Charmi

    0
    Comment actions Permalink

Please sign in to leave a comment.