Software device depth image aligning to rgb
Hello everyone!
I need to align my own depth map created by using pair of infrared cameras to color image. So, I've tried to align it by using software device, but there was no effect. Is it possible to do? I shortly describe what I have done:
1. Initialize grabbing images from camera and create software device ().
2. Get rgb and two infrared images from camera.
3. Generate depth map using opencv.
4. Use software device for syncronize depth and color images. Then try to align images.
rs2::frameset fset = mSyncer.wait_for_frames();
fset = mAlignToColor->process(fset);
5. Then gets images from frameset. But depth image have old resolution.
I would be grateful for advice or a solution to this problem. Thanks.
-
Unless you are taking frames from non-RealSense cameras, using software device may be an over-complicated solution to align depth with color. An expert RealSense user called UnaNancyOwen has written an align program that makes use of OpenCV. Hopefully that may be of use to you.
https://github.com/UnaNancyOwen/RealSense2Sample/tree/master/sample/Align
Alternatively, if using OpenCV is not compulsory, the RealSense SDK has its own depth-color align sample program.
https://github.com/IntelRealSense/librealsense/tree/master/examples/align-advanced
-
Thanks. I use realsense sdk for getting color and infrared frames (very similar to UnaNancyOwen solution). But I want to generate depth map without realsense support, using only opencv. So I have realsense color image (1920*1080) and my own depth map (640*480). I tried to use software device for aligning images, like it described in https://github.com/IntelRealSense/librealsense/tree/master/examples/software-device and https://github.com/IntelRealSense/librealsense/tree/master/examples/align-advanced. But it doesn't work. I know that opencv have functionality for such aligning (rgbd::registerDepth), but it works only with point cloud, not with depth map image. It would be great if there are will be function for aligning external depth map in realsense sdk.
-
The usual way to translate 3D point cloud data into a 2D depth map is an SDK instruction called rs2_project_point_to_pixel. Maybe you could adapt the software device point cloud example to do this operation after the 3D point cloud data is calculated. Example code for a 3D to 2D conversion is in the link below.
https://github.com/IntelRealSense/librealsense/issues/2204#issuecomment-411066051
You could perhaps leave out the line of code at the end of the example that draws the point cloud and draw the 2D depth map instead.
The Realsense GitHub forum can give expert advice on using software device.
Please sign in to leave a comment.
Comments
3 comments