librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

How do I save all the aligned color and depth frames in a.bag file?

Open nevynwong opened this issue 7 years ago • 13 comments

| Camera Model |D415| | Operating System & Version | Win 10 | | Platform | PC | | Language |MATLAB |

I've recorded a.bag file and aligned the depth and color, but how do I save all the aligned frames?Because I need to align the color image sequence and the depth sequence or point cloud. My alignment code looks like this.

pipe = realsense.pipeline; config = realsense.config; config.enable_device_from_file('11.bag'); profile = pipe.start(config); align = realsense.align(realsense.stream.color);

frameset = pipe.wait_for_frames(); color_frame = frameset.get_color_frame(); frameset = align.process(frameset); aligned_depth_frame = frameset.get_depth_frame();

I don't know if this is the right thing to do. Can you help me?I'm in a hurry.Thanks.

nevynwong avatar Jun 27 '19 03:06 nevynwong

If you save the frames normally, you can then align them when you play them back later.

jb455 avatar Jun 27 '19 08:06 jb455

I don't quite understand this. Could you tell me how to do it specifically?Thanks.

nevynwong avatar Jun 27 '19 09:06 nevynwong

I don't know specifically how you do it using the matlab wrapper, but the basic process would be: save the colour and depth frames in the bag file (no need to do alignment at this stage unless you need it for something else while recording), then when playing back align the frames as required. The code you've posted looks reasonable for this purpose (the second part), unless matlab needs anything special. If you're getting any errors etc with this code, post them to help others understand what's going wrong.

jb455 avatar Jun 27 '19 09:06 jb455

The above code aligns depth to color from .bag file, but I don't know how to extract the aligned color and depth sequence. Coulc the aligned color and depth frames be saved in a.bag and then extract them?But that doesn't seem right.

nevynwong avatar Jun 27 '19 09:06 nevynwong

Bag file records raw data from the camera. Using this data, you can perform alignment when you need aligned frames back.

dorodnic avatar Jun 27 '19 16:06 dorodnic

Yes, I now need to align the data recorded in the.bag file, but how to extract the aligned color and depth sequences is difficult for me.

nevynwong avatar Jun 28 '19 01:06 nevynwong

Your code seems correct. To save aligned_depth_frame, you need to extract the data. From depth_example.m:

depth= aligned_depth_frame.get_data();

menandro avatar Jun 28 '19 05:06 menandro

It's just one frame. What I want to save is the whole video sequence images.

nevynwong avatar Jun 28 '19 15:06 nevynwong

@dorodnic, I now need to align the depth and color in the collected. Bag and then do something else.But it looks like I can't extract all the aligned frame sequences with the above processing, so what should I do?

nevynwong avatar Jul 01 '19 02:07 nevynwong


@nevynwong Sorry for late response. Which SDK and FW version did you use when get the issue? Did you still have the issue with the latest SDK and FW version? Looking forward to your update. Thanks!


@nevynwong Could you please update if you still have the issue with the latest SDK and FW? @kjacks21 Please feel free to create another new issue for your case. Thanks!


@nevynwong Could you please update? Thanks!


@nevynwong We didn't get response from you for weeks. Will close this at this point. Please feel free to create another one if you still have issues or questions. Thanks!