Depth and Color frame data read
I am trying to extract depth and color frame data using Python from recorded *.bag file. I am able to extract depth and color frames when I use config.enable_allstreams() but doesn't work when I use:
config.enable_stream(rs.stream.color, rs.format.bgr8, 30)
config.enable_stream(rs.stream.depth, rs.format.z16, 30)
Error statement:
Traceback (most recent call last):
File "read_bag.py", line 40, in <module>
pipeline.start(config)
RuntimeError: Couldn't resolve requests
Please help me with this issue. I want to read both the frames using config.enable_stream.
-
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 -
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 -
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
-
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 -
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
Please sign in to leave a comment.
Comments
8 comments