Converting Mat of point cloud mesh to vector<cv::Point3d>
My task is to project a point cloud of a scene to a plane image. I have 3D point cloud of scene represented as PLY mesh. Here is header an d few data lines in this PLY file:
ply
format ascii 1.0
comment PCL generated
element vertex 180768
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
property float nx
property float ny
property float nz
property float curvature
element camera 1
property float view_px
property float view_py
property float view_pz
property float x_axisx
property float x_axisy
property float x_axisz
property float y_axisx
property float y_axisy
property float y_axisz
property float z_axisx
property float z_axisy
property float z_axisz
property float focal
property float scalex
property float scaley
property float centerx
property float centery
property int viewportx
property int viewporty
property float k1
property float k2
end_header
0.021613657 0.60601699 -1.5027865 120 89 71 -0.92790836 -0.26353598 0.26369458 0.00016434079
-1.1746287 -1.7522405 -1.4859273 193 128 72 0.093781963 -0.043701902 0.99463314 0.048953384
I have found a way to project point cloud to image here. So far I load PLY model to cv::Mat using function loadPLYSimple from ppf_match_3d.
Mat scene_mat = loadPLYSimple("a_cloud.ply", 1);
I need to convert Mat representing the scene clout to vector<cv::point3d>. My Mat scene_mat has size: [6 x 180768]. How I can do it?
please add the ply header to your question (and maybe the first few data lines), so we can estimate, what's in it
(the point data is probably float, not double, and there are either normals or colors present, but please show !)
also, the size() of your corresponding 2d image ?
I have updated the question with listing header an d few data lines in this PLY file. The size() is the size of the scene_mat Mat object.
can you also print out the 1st 2 lines of your scene_mat ? like:
i'm afraid, the loadPLYSimple() method is a bit too simple for this task (it won't read colors properly, and assumes data is x,y,z,nx,ny,nz)
printing out the 1st 2 lines of my scene_mat gives this:
So is there another way to load PLY mesh in OpenCV?
Btw pcl_mesh2pcd gives me Segmentation fault (vtkPLYReader (0xe0f6e0): Cannot read geometry)