-
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
Get the top view of the object from the 3d point cloud xy coordinates #12705
Comments
Hi @EthanUNC Are you trying to remove height from the pointcloud so that only the top of the gear is shown as though it is a flat 2D drawing, please? If you are, and if the camera is in a fixed position, then you could use a post-processing Threshold filter to set a maximum distance from the camera that corresponds to the top of the gear. Depth values greater than the defined maximum distance should then be excluded from the image. #8170 (comment) has an example of Python code for defining and applying the threshold filter. An alternative approach, if your pointcloud uses the rs2_deproject_pixel_to_point instruction to obtain the 3D coordinates, would be to then use rs2_project_point_to_pixel to convert the 3D XYZ values back to 2D XY values. |
@MartyG-RealSense Thanks for your quick reply, but I noticed that rs2_project_point_to_pixel is undefined. How do I use this function? Any examples? In response to my question, is it unnecessary to generate a 3D point cloud model? Do I just need to get the 3D coordinates of the pixels and align the rgb with the depth image? |
Once However, instead of using deproject / project, the other main alternative way to generate a pointcloud - pc.calculate - might work better for you. A Python script for this pointcloud method is at #4612 (comment) |
Hi,@MartyG-RealSense, I just run the code you mentioned, but the coordinates I got are all 0, so here's the code and the output.Is it a wrong configuration of the camera? Sorry, I'm just starting to learn how to use this camera.
<pyrealsense2.frame Z16 #0 1709546607096.326416> |
#3631 (comment) advices that when retrieving vertices, the values may be zero due to how numpy summarizes when printing large arrays. Further advice in this discussion suggests converting the large array into a list and then printing it to get more information from the vertices. Guides can be found online for numpy to list conversion by googling for the term convert numpy array into list, which returns search results such as the link below. https://www.digitalocean.com/community/tutorials/python-convert-numpy-array-to-list |
@MartyG-RealSense hi,I've got the coordinates I want for x and z, but if I wanted to display these coordinates directly, I wouldn't be able to identify the image I want. So I figured I should get the rgb information for each pixel, and I've seen many examples of texture coordinates being used. I want to know if I want to get the texture coordinates if I just want to get the rgb information of the pixel. |
My understanding is that each texture coordinate has a (u, v) value which ranges from [0-1] that can be mapped to the color frame. |
@MartyG-RealSense I think I need to take the rgb information of each 3D coordinate point and turn this rgb information into an array so that I can distinguish my target when displaying the image. So, are there examples of getting rgb information for coordinate points? thanks!. |
As you mention distinguishing your target, are you thinking of an array in terms of a grid overlay on the RGB image like the project in the link below? Or do you have something else in mind? For example, performing depth-color alignment and then creating 3D pointcloud coordinates with the instruction rs2_deproject_pixel_to_point and converting 3D points back into 2D pixel coordinates with rs2_project_point_to_pixel. Thanks! |
@MartyG-RealSense I'm sorry, my expression may be wrong. My goal is to get a top view of the object and shoot the object from the side. So I want to get the three-dimensional coordinates of this scene. And then remove the z-axis coordinates from the three-dimensional coordinates. And then use the dots to show these three-dimensional coordinates. But there is a problem, if there is no rgb information for every coordinate point and only a few points are displayed on the image, I can't tell which points are my objects. So I want to get the rgb information for each pixel, which should be a numpy array. |
It sounds as though your camera will be pointing at the side of the object but you want to be able to view the top of the object as well. Is that correct, please? If the camera is in a fixed position and pointing towards the side of the object then the camera will not be able to see the top. There will therefore be no data representing a top view as it is not in the camera's field of view. This means that a 3D image viewing an object in side-on perspective cannot simply be 'collapsed' in height into a paper-thin 2D blueprint view to show what is on top of the object. In this situation, you can either add a second camera placed above the object pointing down and then combine the side-on and top-down views of the cameras together into a single combined image. Or you can move a single camera, take individual pointcloud captures of the side and top views and save them to a file, and then 'stitch' the pointcloud files together to create the combined view. |
@MartyG-RealSense |
3D reconstruction does not necessarily need commercial software such as RecFusion, but the complexities of stitching separate images together does make use of commercial tools preferable if there is the option to do so. If it is possible to use C++ instead of Python then the RealSense SDK's rs-kinfu tool allows a pointcloud to be constructed by moving a single camera around an object. https://github.com/IntelRealSense/librealsense/tree/master/wrappers/opencv/kinfu If you can capture the top on a pointcloud then it is possible to rotate the pointcloud to a different viewing perspective, like in the SDK's opencv_pointcloud_viewer.py Python example program at the link below. |
@MartyG-RealSense
so that i get the x z coordinates.i wonder if this is possible? |
Retrieving vertices individually as x, y and z instead of printing all of the coordinates is rare. If retrieving x and y individually from the vertices is your goal then the Python script at the link below looks as though it may be helpful. https://support.intelrealsense.com/hc/en-us/community/posts/21674251140883/comments/21885537480851 |
Hi @EthanUNC Do you require further assistance with this case, please? Thanks! |
Case closed due to no further comments received. |
Issue Description
My problem was that I had a scene where I was going to shoot a gear with my camera tilted, and after I had obtained his 3D point cloud model, I wanted to capture a top view of the gear, which should have been drawn from the xy coordinates of the 3D point cloud. There's some way I can get this picture.
![gear](https://private-user-images.githubusercontent.com/161324546/307810062-6f1b5bc5-236b-4feb-841f-752692a5a681.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTg2ODI5NjQsIm5iZiI6MTcxODY4MjY2NCwicGF0aCI6Ii8xNjEzMjQ1NDYvMzA3ODEwMDYyLTZmMWI1YmM1LTIzNmItNGZlYi04NDFmLTc1MjY5MmE1YTY4MS5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjE4JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYxOFQwMzUxMDRaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1kNmEyOGZjNDE4MWVmZTM1ZDZiNWJlOWYwMzM0ZWY2YjEyNmY0YWY3MDI5NDYzZTEzMDVhNzcyOTljOGY0ZDlhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.y4eF6qbPhYeXTk9SutT0qGaRq3ypxiFJzmzX6tJvO6o)
The text was updated successfully, but these errors were encountered: