I have a rectangle in the 3D scene, which I know its width and height. It is placed in the 3D scene like the image below. I can manually select all points on the rectangle by mouse click.

Given the manually selected points, I want to find the location of the four corners of this rectangle. I have some ideas. However, to avoid reinventing the wheel, I decided to ask. Do you have any suggestions?

enter image description here

To explain it more, look at the point cloud in the below image, I selected all points of the rectangle by mouse click, and all of them are in yellow. Given the yellow points and width and height of the rectangle in the 3d world, I want to write a code that gives me the location of 4 corners. I draw those four green lines for a better explanation. enter image description here

  • $\begingroup$ "I can manually select all points on the rectangle by mouse click." This suggests that you are doing this in some visualization tool -- are you asking how to write some computer vision code that does this, or how to get the tool to do it, or what? Please edit your question to clarify this point, and if you want to do it in some existing tool, tell us what that tool is. $\endgroup$
    – TimWescott
    Commented Jul 29, 2022 at 22:45
  • $\begingroup$ @TimWescott I updated the question. $\endgroup$
    – CVDE
    Commented Jul 30, 2022 at 1:24

1 Answer 1


Once you have your list of points that fall in your rectangular object, I would propose doing something like the following.

  1. Find the best fit plane. This could be done with principal component analysis or RANSAC or other methods.
  2. Project the points onto the plane.
  3. Find a rectangle around the 2D plane points. This could be done, for example, by finding the minimum area bounding box.
  4. Find the corner of the bounding box, then move back from the plane coordinate system to the 3d coordinate system.

This certainly is not the only way to approach the problem, but it is where I would start.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.