How do you find multiple planes in a 3D pointcloud? - point-cloud-library

I am looking to find all the planes in a 3D pointcloud using PCL. The example snippet has a video showing two different planes detected:
http://pointclouds.org/documentation/tutorials/planar_segmentation.php
But if I look at the source code snippet I think it assumes that there is only one plane in the point cloud.
Is it possible to use PCL to detect all the planar sections in a point cloud using RANSAC?

Have a look at this cluster extraction tutorial. From line 44 to line 69 you can see how "all" planes are removed from the cloud. The trick is to set the filter to negative .setNegative(true) to extract the cloud without the planar surface.

Related

Polygonal surface reconstruction

I want to reconstruct a surface from a point cloud of xyz points only, but the example provided requires a normal for each point. I have 2 questions: 1) what does the normal represent. 2) what do I do if I don't have the normal.
If you have a point cloud that represent a surface, the associated normal is the normal direction on the surface at the point. If you don't have such normals, CGAL provides some methods to estimate and orient those normals:
pca_estimate_normals() or jet_estimate_normals() for the estimation and mst_orient_normals() for the orientation.
Note that the links I'm giving are for the upcoming 5.1 release but the functions exist in previous releases. You can also read the new reconstruction tutorial here.

Simple 2D Point Cloud visualisation with Point Cloud Library

What class/functions should I use to visualize a 2d point cloud? All the documentation online seem to only point to 3d point cloud visualization.
You're right, the visualization module of PCL is done for 3D point clouds. But, you can perfectly visualize a 2D pointcloud in 3D. You will just have one of the coordinate set to 0 (or any other constant).
Your point cloud will appear planar and, as the viewer is 3D, you will be able to move and rotate around it.
If you really need to constraint the camera, I think you will need to write your own visualizer using VTK. This will require more effort, especially if you are not familiar with the way VTK is working. (vtkInteractorStyleRubberBand2D is the type of 2D camera interactor that could be used.)

I'm trying to detect a square using Point cloud library. I have pcl data from a 3D lidar in which I need to find squares

I'm trying to detect squares using Point cloud library. I have pcl data from a 3D lidar in which I need to find squares. Ransac doesn't have a model for square. I wish to know what can be the most efficient method for square detection.
If you are looking for a filled square, the SACMODEL_PLANE should be able to find it. You may need to cluster the inliers of the plane model, and filter the clusters to find the location of the square.
If you are looking for the outline of a square, the SACMODEL_LINE should be able to find the 4 sides separately. You will then need some logic to filter out lines that do not belong, as well as to combine the inliners of the correct lines.

Point cloud:project city square to ground plane

I have a city square with people, cars, trees and buildings in pcl format. I need to automatically determine the ground plane and project this objects on that ground plane to get a 2D map with occupied places.
Any idea?
I think the best thing to do here would be to familiarise yourself with the following two PCL tutorials:
http://pointclouds.org/documentation/tutorials/planar_segmentation.php
http://pointclouds.org/documentation/tutorials/project_inliers.php
The first tutorial makes use of the RANSAC algorithm to find a dominant plane in a scene. I use it to find tables and floors in robotics scenarios. You would use it to find your dominant ground plane.
The second tutorial shows how to project points directly onto a plane. This is what you would use to make your 3D point cloud into a 2D one. Note that, despite the "inlier" keyword, you can pass your whole point cloud to be projected onto the plane.
Actually, if you are after "occupied" places, you might want to project all of the points that aren't in the ground plane (i.e. the outliers), and that are above it (you can use a PCL filter, such as PlaneClipper3D, for example, or just the complement of the outliers from the plane-segmentation operation.
If the plane that you end up with (containing all your projected points) is not in the coordinate frame you want, you may wish to rotate the whole lot, for example, to align with the coordinate axes so that all z-coordinates are zero. See pcl::transformPointCloud for this (the transform will be obtainable from the plane coefficients returned from the plane segmentation).
I hope this is helpful and not at too basic a level, though the question was rather general so I suppose it should be okay.

How to construct a mesh from given edge points?

I have some points on the edge(left image), and I want to construct a mesh(right), Is there any good algorithm to achieve it? many thanks!
image can see here http://ww3.sinaimg.cn/large/6a2c8e2bjw1dk8jr3t7eaj.jpg
To begin with, see Delauney triangulation. Look at this project: http://people.sc.fsu.edu/~jburkardt/c_src/triangulate/triangulate.html.
Edited because my original had too few details on edge-flipping, and when I tried to provided those details I found the TRIANGULATE project.
If the region is flat or quasi-flat look for Ear Clipping approach (http://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf). In the case of curved surface you need point inside the region and therefore you may need Constrained Delaunay Triangulation (otherwise some edges may not be included in the triangulation).
There is delaunayn function in geometry package for R language (see doc)
It takes an array of boundary points (as in your case) to create a Delaunay mesh on it.
You could also save your geometry into some well-known format, and use one of mesh generators.

Resources