-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Manually align the depth image with the color image. #12928
Comments
Hi @shiyt0313 A RealSense user at #11758 with a similar development board called Orange Pi also experienced almost 3 FPS when aligning with Python code. The approach that the user ended up applying - described at #11758 (comment) - was to use the instruction rs2_project_color_pixel_to_depth_pixel to convert a single coordinate from a color pixel to a depth pixel. This is more processing-efficient than aligning the entire image if the reason that you are aligning is to obtain a 3D real-world coordinate. If you require an aligned image and do not mind generating a depth-color aligned 3D pointcloud image then pc.calculate() is an alternative to align_to. A Python example of this instruction is at #4612 (comment) It is worth bearing in mind that when RealSense cameras are used with Raspberry Pi, you can obtain individual depth and color streams but more processing intensive operations such as depth-color alignment or pointclouds may have problems. |
@MartyG-RealSense Thanks for your advice! However, neither of these two methods apply to my situation.
Is there any other possible solution? |
If you use pc.calculate with map_to() to map depth and color together then you could obtain depth for all the pixels by storing the data as vertices in a numpy array and then retrieve the vertices as x, y and z (depth) values. An example of a script for doing this in Python is at #4612 (comment) |
As I mentioned above, my frame rate drops to 3fps when using map_to() and storing the point cloud, which is same as align_to(). Are there any other efficient alignment methods, or manual alignment solutions? |
map_to() and align_to() are the two main methods of alignment. Other than rs2_project_color_pixel_to_depth_pixel, there are no alternatives unfortunately. Below I modified a depth to color Python align_to script to align to the monochrome infrared image instead of the RGB color image. As depth and infrared originate from the same sensor, if FPS improves when this script is run then this would indicate that it is the RGB color that is likely causing the slowdown.
|
I'm really appreciate for your suggestions. I tried the method you proposed and found that it is impossible to ensure a frame rate of 10 fps while aligning RGB and depth in real time. Therefore, I am planning to try two other approaches.
|
Something else you could try is to disable an RGB option called auto-exposure priority. When depth and RGB are both enabled, if auto-exposure is enabled and auto-exposure priority is disabled then the SDK will try to force both streams to maintain a constant FPS rate instead of permitting FPS to vary. A line of Python code that can be placed after the pipe start line to disable auto-exposure priority is below.
|
@MartyG-RealSense We tried to set auto-exposure priority, but it didn't work on Raspi. So we finally used different frame rates. Thank you very much for your suggestions and methods. If you have no other recommendations, I will close this issue in the next comment. To make it easier for someone else who encounters the same problem with me in the future, I have put all possible solutions here:
|
Thanks so much for sharing your solutions. I do not have further recommendations. |
I tried to use RealSense to obtain depth and RGB images on a Raspberry Pi 4B. When I use
align()
in librealsense, the frame rate drops to 3 fps, but I need at least 10 fps of data. Therefore, I want to manually save the unaligned depth and RGB images.How can I manually align them (If there is any interface I can use in librealsense)?
Alternatively, is there any other effective way to obtain aligned data with at least 10 fps besides manual alignment?
The text was updated successfully, but these errors were encountered: