Are color images and depth images aligned frame by frame?Whether the depth to point cloud can be directly calculated by internal and external parameters?
I want to use the align.m function to align the color and depth in the collected .bag file. Is it frame-by-frame?So how exactly do you convert to a point cloud?I'm using matlab. I've asked this question before, but it still doesn't feel like there's a clear answer.
-
Hello 1106569356,
Thank you for your patience in receiving a reply.
Could you please try the following code example to align the depth and RGB frames?
function align_cust_example()
% Make Pipeline object to manage streaming
pipe = realsense.pipeline();
% Start streaming on an arbitrary camera with default settings
profile = pipe.start();
align_to = realsense.stream.color;
alignedFs = realsense.align(align_to);
% Get streaming device's name
dev = profile.get_device();
name = dev.get_info(realsense.camera_info.name);
% Get frames. We discard the first couple to allow
% the camera time to settle
%while(true)
for i = 1:5
fs = pipe.wait_for_frames();
end
pipe.stop();
% Select depth frame
aligned_frames = alignedFs.process(fs);
depth = aligned_frames.get_depth_frame();
%depth = fs.get_depth_frame();
% get depth image parameters
depthSensor = dev.first('depth_sensor');
depthScale = depthSensor.get_depth_scale();
depthWidth = depth.get_width();
depthHeight = depth.get_height();
% retrieve UINT16 depth vector
depthVector = depth.get_data();
% reshape vector, and scale to depth in meters
depthMap = double(transpose(reshape(depthVector, [depthWidth,depthHeight]))) .* depthScale;
%align the depth frames to the color stream
%Select rgb frame
color = fs.get_color_frame();
colordata=color.get_data();
img = permute(reshape(colordata',[3,color.get_width(),color.get_height()]),[3 2 1]);
subplot(2,1,1);
imshow(depthMap)
impixelinfo;
title('Depth Map (m)');
subplot(2,1,2);
imshow(img)
impixelinfo;
title('Color Map');
%end
% Stop streaming
end
Please be aware that this is an example code. Please feel free to test and modify the code to your specifications.
Best regards,
Alexandru
-
Hello 1106569356,
The same as for the other thread, let's continue the conversation on: https://support.intelrealsense.com/hc/en-us/community/posts/360033198613
Thank you and best regards,
Eliza
-
Hi Eliza,
I am sorry that I have raised the same question many times since I urgently need to solve this problem.
Since I have already recorded a.bag file, now I need to align the color and depth of the record in video and save the aligned sequence image, but it is a little difficult for me.
Let's discuss it in the other one.https://support.intelrealsense.com/hc/en-us/community/posts/360033198613
Thank you.
Please sign in to leave a comment.
Comments
4 comments