Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detecting set of planes from point cloud

I have a set of point cloud, and I would like to test if there is a corner in a 3D room. So I would like to discuss my approach and if there is a better approach or not in terms of speed, because I want to test it on mobile phones.

I will try to use hough tranform to detect lines, then I will try to see if there are three lines that are intersecting and they make a two plane that are intersecting too.

like image 505
Ahmed Saleh Avatar asked Feb 25 '15 23:02

Ahmed Saleh


Video Answer


2 Answers

If the point cloud data comes from a depth sensor, then you have a relatively dense sampling of your walls. One thing I found that works well with depth sensors (e.g. Kinect or DepthSense) is a robust version of the RANSAC procedure that @MartinBeckett suggested. Instead of picking 3 points at random, pick one point at random, and get the neighboring points in the cloud. There are two ways to do that:

  1. The proper way: use a 3D nearest neighbor query data structure, like a KD-tree, to get all the points within some small distance from your query point.
  2. The sloppy but faster way: use the pixel grid neighborhood of your randomly selected pixel. This may include points that are far from it in 3D, because they are on a different plane/object, but that's OK, since this pixel will not get much support from the data.

The next step is to generate a plane equation from that group of 3D points. You can use PCA on their 3D coordinates to get the two most significant eigenvectors, which define the plane surface (the last eigenvector should be the normal).

From there, the RANSAC algorithm proceeds as usual: check how many other points in the data are close to that plane, and find the plane(s) with maximal support. I found it better to find the largest support plane, remove the supporting 3D points, and run the algorithm again to find other 'smaller' planes. This way you may be able to get all the walls in your room.

EDIT:

To clarify the above: the support of a hypothesized plane is the set of all 3D points whose distance from that plane is at most some threshold (e.g. 10 cm, should depend on the depth sensor's measurement error model). After each run of the RANSAC algorithm, the plane that had the largest support is chosen. All the points supporting that plane may be used to refine the plane equation (this is more robust than just using the neighboring points) by performing PCA/linear regression on the support set.

In order to proceed and find other planes, the support of the previous iteration should be removed from the 3D point set, so that remaining points lie on other planes. This may be repeated as long as there are enough points and best plane fit error is not too large. In your case (looking for a corner), you need at least 3 perpendicular planes. If you find two planes with large support which are roughly parallel, then they may be the floor and some counter, or two parallel walls. Either the room has no visible corner, or you need to keep looking for a perpendicular plane with smaller support.

like image 97
killogre Avatar answered Oct 07 '22 22:10

killogre


Normal approach would be ransac

  1. Pick 3 points at random.
  2. Make a plane.
  3. Check if each other point lies on the plane.
  4. If enough are on the plane - recalculate a best plane from all these points and remove them from the set
  5. If not try another 3 points
  6. Stop when you have enough planes, or too few points left.

Another approach if you know that the planes are near vertical or near horizontal.

  1. pick a small vertical range
  2. Get all the points in this range
  3. Try and fit 2d lines
  4. Repeat for other Z ranges
  5. If you get a parallel set of lines in each Z slice then they are probably have a plane - recalculate the best fit plane for the points.
like image 4
Martin Beckett Avatar answered Oct 07 '22 23:10

Martin Beckett