-
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
3D Point Cloud Depth Estimation using Python #13221
Comments
Hi @Jaswanth987 The Python pointcloud script at #4612 (comment) may meet your requirements. It generates a pointcloud, stores its values in a numpy array and then uses the points.get_vertices instruction to retrieve the 3D X, Y and Z (depth) coordinates and print them. |
Using the code mentioned, we will be able to retrieve all points of the point cloud. However, what I need instead is to visualize the 3D point cloud, and by hovering over or clicking on any point in the 3D point cloud, I need to get the depth at that point in python. |
That kind of graphical user interface (GUI) is not straightforward to implement in Python. It would likely require an interface such as Pyglet or Tkinter (see #10337 (comment) for Tkinter resources). The pyglet_pointcloud_viewer example would seem to be the best foundation to use for your project, as it already uses the same pointcloud generation and vertices retrieval method as the script that I linked to earlier. It just currently lacks the code line that displays the depth value with a print instruction. The other mechanism that would need to be added is to print the value of a particular pointcloud coordinate when clicked or hovered on. I do not have RealSense Pyglet code for that kind of mouse interface though, unfortunately. It could possibly be triggered with a Pyglet On Mouse Press Event, as described at the link below. https://www.geeksforgeeks.org/pyglet-on-mouse-press-event/ The position of the mouse cursor on the screen can also be tracked with On Mouse Motion. https://pyglet.readthedocs.io/en/latest/programming_guide/mouse.html |
Thank you for providing these approaches. I will review and try them out. |
Is the following procedure correct?
Thanks in Advance. |
You could implement it that way, yes. |
Yes, it's working, thank you for that. I have one more question. I am noticing occlusions in the stereo depth stream and the 3D point cloud. I have observed that there is an option in the RealSense Viewer called "Perform Occlusion Invalidation". Even after enabling this option, I am still experiencing occlusions. What might be the possible reasons for this? Thank you in advance. In 1st image and 3rd image you can see occlusions or reflections are present and 2nd image is rgb image of that. |
It is not clear that the black areas of the image are all due to occlusion. It is a general physics principle (not specific to RealSense) that dark grey or black absorbs light and so makes it more difficult for depth cameras to read depth information from such surfaces. The darker the color shade, the more light that is absorbed and so the less depth detail that the camera can obtain. So the blackness on the rear of the screen and the diagonal surface on the other side of the image could be because their color is too dark for the camera to read depth information from (the screen's slight reflectivity would help light to bounce back to the camera instead of the surface absorbing all the light, hence its blue depth color). The black area to the side of the bottle could be due to the depth sensing being confused by its high reflectivity. And the black area of the foreground nearest to the camera could be because the minimum depth sensing distance of the camera will be around 0.5 meters / 50 cms, so that front area could be too close to the camera to register. |
Hi @Jaswanth987 Do you require further assistance with this case, please? Thanks! |
Case closed due to no further comments received. |
Issue Description
Hii,
I am able to estimate depth using RealSenseViewer, and I want to estimate depth using Python instead. Using opencv_pointcloud_viewer.py and pyglet_pointcloud_viewer.py, I can visualize a 3D point cloud, but I cannot find the depth. Is there any example or source that can help me find depth using a 3D point cloud in Python? I am able to find depth in 2D using Python, but not in 3D.
Thanks in Advance.
The text was updated successfully, but these errors were encountered: