Wait_for_frames () does not fully extract all the depth frames in the. Bag file.
I'm going to extract all the depth frames in the.bag file for post-processing, but it's not completely extracted, so here's my code. I don't know what went wrong.Can you help me?
pipe = realsense.pipeline;
config = realsense.config;
config.enable_device_from_file('F:\test_bag\848.bag',0);
profile = pipe.start(config);
%%
dec_filter = realsense.decimation_filter();
dec_filter.set_option(realsense.option.filter_magnitude,1);
temp_filter = realsense.temporal_filter();
spa_filter = realsense.spatial_filter();
spa_filter.set_option(realsense.option.filter_magnitude, 5);
spa_filter.set_option(realsense.option.filter_smooth_alpha, 1);
spa_filter.set_option(realsense.option.filter_smooth_delta, 32);
spa_filter.set_option(realsense.option.holes_fill, 3);
fill_filter = realsense.hole_filling_filter();
depth_to_disparity = realsense.disparity_transform(1);
disparity_to_depth = realsense.disparity_transform(0);
depth_sensor = profile.get_device().first('depth_sensor');
scale = depth_sensor.get_depth_scale();%%scale
pointcloud = realsense.pointcloud();
align = realsense.align(realsense.stream.color);
%%playback
playback = profile.get_device().as('playback');
playback.get_duration();
playback.set_real_time(0);
num = 0
while playback.current_status() == realsense.playback_status.playing
% %create a point cloud player
% % Main loop
num = num + 1;
frameset = pipe.wait_for_frames();
colorizer = realsense.colorizer()
depth_frame = frameset.get_depth_frame();
colorized_depth = colorizer.colorize(depth_frame).get_data();
color_frame = frameset.get_color_frame();
color = color_frame.get_data();
img = permute(reshape(color',[3,color_frame.get_width(),color_frame.get_height()]),[3 2 1]);
% Display image
figure
imshow(img);
%%
% player1 = pcplayer([-1 1],[-1 1],[-1 1]);
pointcloud.map_to(color_frame);
points = pointcloud.calculate(depth_frame);
%%
frameset = align.process(frameset);
%%
aligned_depth_frame = frameset.get_depth_frame();
frame = aligned_depth_frame;
%%
frame = dec_filter.process(frame);
frame = depth_to_disparity.process(frame);
frame = spa_filter.process(frame);
frame = temp_filter.process(frame);
frame = disparity_to_depth.process(frame);
frame = fill_filter.process(frame);
% Display image
data = colorizer.colorize(frame).get_data();
col_depth = colorizer.colorize(frame);
img = permute(reshape(data',[3,col_depth.get_width(),col_depth.get_height()]),[3 2 1]);
% figure
% imshow(img);
color_frame = frameset.get_color_frame();
colorized_depth = colorizer.colorize(frame).get_data();
col_depth = colorizer.colorize(frame);
% Get actual data and convert into a format imshow can use
% (Color data arrives as [R, G, B, R, G, B, ...] vector)
data = colorized_depth;
img = permute(reshape(data',[3,col_depth.get_width(),col_depth.get_height()]),[3 2 1]);
% Display image
% figure
% imshow(img);
% player2 = pcplayer([-1 1],[-1 1],[-1 1]);
pointcloud.map_to(color_frame);
points = pointcloud.calculate(frame);
end
% Stop streaming
pipe.stop();
-
There are a number of reasons why your recording may have "dropped" frames instead of recording all of the frames that should be present in theory. The SDK's documentation page on frame buffering management is a good read.
https://github.com/IntelRealSense/librealsense/wiki/Frame-Buffering-Management-in-RealSense-SDK-2.0
Aside from latency caused by software drivers, a slowdown 'bottleneck' may also be caused during recording if the computing hardware that you are using has a slow hard drive that is not an SSD (since a slower drive will struggle to keep up with the incoming data). The processor on a computing device may also sometimes have some incompatibility with the SDK's recording compression algorithm, a situation that can be corrected by turning recording compression off using the SDK's compression API.
https://github.com/IntelRealSense/librealsense/pull/2687
Also, a recording may sometimes have frames with duplicate time stamps and frame numbers. When a 'hiccup' in the recording occurs, the system may try to return to the most recent good frame.
Another approach to recording is to use a function called Keep() to store the frames in memory during recording and then at the end of the recording, do post-processing and file save in a single action. This method is only suitable for short recording durations such as 10 seconds though, due to the amount of memory that the data consumes.
https://github.com/IntelRealSense/librealsense/issues/3121#issuecomment-466263469
-
Hi MartyG,
I didn't find the keep() function, and I've got a lot of . bag files are more than 10s, so I need a better way to extract these depth frames for processing.
Or I can record the video through the Matlab program, post-processing and aligning in the recording process, and finally save the depth and color of the acquisition. But one problem is that I don't know how to use 'syncer' in the recording process.
-
I do not have any further ideas about this since the last time it was discussed in June, unfortunately. I will put the link to that past discussion here so that the Intel support team members can continue the discussion with you.
Please sign in to leave a comment.
Comments
6 comments