-
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
Getting distance and 3D coordinate from specific pixel #9945
Comments
Hi @IvanNataP The case #1904 (comment) has a Python script in which depth and color was also being saved as jpg image files with cv2.imwrite, and then the mid-point distance was obtained by placing the instruction depth_frame.get_distance(int(x+w/2), int(y+h/2))) immediately after the imwrite instructions. If you are aiming to obtain XYZ 3D coordinates for a single pixel then you could potentially use the instruction rs2_project_color_pixel_to_depth_pixel to convert a color pixel to a depth pixel. An example of scripting for using this instruction with Python can be found at #5603 (comment) |
Hi @MartyG-RealSense , thanks for the links provided. So, in my understanding, From #1904 (comment), distance was obtained from the From #5603 (comment), I need to have all the parameters from the
which then I can implement the I'll try to implement these idea to my code and see the results. Once again, thank you. |
Yes, get_distance() is an attribute of the depth_frame class of the librealsense library. The official documentation relating to the pyrealsense2 form of this instruction is at the link below. In regard to the required parameters for rs2_project_color_pixel_to_depth_pixel, the parameters listed in the quoted code are consistent with the description in the C++ version of the instruction in the official documentation (the pyrealsense2 documentation's entry for the instruction does not have an equivalent description). |
Thank you for clarifying that |
Thanks very much for the update. Good luck with your testing! |
Hi, after some testing, I've managed to get the depth points of the desired specific pixel on the color frame. Even though there's a deviation from my initial issue, which was about getting depth points using saved the jpg files of both color and depth frame, I decided to implement the code by getting both frame using the camera in real time, which is my end-goal. Below are snippet of the result I got (ignore the radius part): and part of the code:
Thanks so much for all the help. Have a nice day. |
You are very welcome, @IvanNataP - thanks so much for sharing your solution with the RealSense community :) |
Hi, first time asking here. I'm quite new to programming and currently making a program written in Python on Windows 10 using D415 camera.
My current goal is to get the 3D coordinate (x, y, z) and the distance of an object's mid-point. My limitation right now is that I only have both color_frame and depth_frame saved as .jpg file.
I already know which pixel from the color_frame, let's say (x_col, y_col), that I want to know the 3D coordinate and the distance.
I need some help on 2 things (an example code would be better):
Please let me know if there are things that are unclear or some info that I should have included above. Thank you in advance.
Edit:
Code for snapping:
The text was updated successfully, but these errors were encountered: