Difference between grid visualization and its point cloud

I work with PCL and the Mesh editor (MeshLab). I am interested in importing my grids in PCL for 3D processing.

I have a grid model in Ply format. When I load the model with code:

PointCloud<PointXYZRGBA>::Ptr cloud (new PointCloud<PointXYZRGBA> ()); pcl::io::loadPLYFile<pcl::PointXYZRGBA>(argv[1], *cloud); 

and I present it as a point cloud:

 visualization::PCLVisualizer viewer ("Model"); viewer.addPointCloud (cloud,"model"); 

geometry differs from loading and rendering the mesh directly:

 viewer.addModelFromPLYFile(argv[1], "model"); 

In the second case, I visualize the model in the same way as in the Mesh editor, but in the first case I visualize its deformed version, i.e. sphere and ellipsoid are similar. What's going on here? Maybe I should manually sample the mesh?

If I add two models to the viewer, the difference will become very obvious, the point cloud will be smaller than the grid, and it will get some strange deformation (see the attached image)

Thank you very much

ply
(source: pcl-users.org )

+4
source share
2 answers

If anyone is interested, here is the answer:

 PointCloud<PointXYZRGBA>::Ptr cloud (new PointCloud<PointXYZRGBA> ()); pcl::PolygonMesh triangles; pcl::io::loadPolygonFilePLY(argv[1], triangles); pcl::fromROSMsg(triangles.cloud, *cloud); 

This code opens the PLY file and converts it into a point cloud with the correct shape.

+5
source

I am pretty sure that this is a PCL bug before 1.7.2, which was not mentioned in the release notes and was proved by my own experience:

Fixed bug in PLYReader, which led to deformation of point clouds when displayed in CloudViewer or PCLVisualizer # 879

If you are not updating, add one line to fix the error as follows:

  if (pcl::io::loadPLYFile <pcl::PointXYZRGBNormal> (file, *cloud) == -1) { std::cout << "Cloud reading failed." << std::endl; return (-1); } cloud->sensor_orientation_.setIdentity(); 
+1
source

Source: https://habr.com/ru/post/1489922/


All Articles