Ask Your Question
0

surface_matching: how to create custom point cloud

asked 2016-03-15 14:54:04 -0600

stephanschulz gravatar image

i am working of the surface_matching example here: http://docs.opencv.org/trunk/d9/d25/g...

it loads two ply files in to a mat.

but i would like to read my own data in to the mat. what format would the data have to be so that it works just like the ply file?

i have a whole bunch of x,y,z points that i get back from a kinect. but i do not use the kinect through opencv but rather through openframeworks.cc

somewhere i read it needs to have the right col and row numbers?

thank you very much for any help.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-03-16 02:16:10 -0600

berak gravatar image

if you look at the ply loader code , it should be quite simple to supply your own data in the same format:

  • the point cloud is a single channel, 32f Mat
  • each 3d point goes on its own row, so there are 3 cols without normals, or 6 cols with normals
  • if there are normals, they have to get normalized to [0..1]

(pseudo) code:

// without normals:
Mat cloud(num3dPoints, 3, CV_32F);
for (int row=0; row<num3dPoints; row++)
{
     x,y,z = points3d[row];
     cloud.at<float>(row, 0) = x;
     cloud.at<float>(row, 1) = y;
     cloud.at<float>(row, 2) = z;
}

// or, with normals:
Mat cloud(num3dPoints, 6, CV_32F);
for (int row=0; row<num3dPoints; row++)
{
     x,y,z = points3d[row];
     cloud.at<float>(row, 0) = x;
     cloud.at<float>(row, 1) = y;
     cloud.at<float>(row, 2) = z;

     nx,ny,nz = normals[row];
     float length = sqrt(nx*nx + ny*ny + nz*nz);
     cloud.at<float>(row, 3) = nx/length;
     cloud.at<float>(row, 4) = ny/length;
     cloud.at<float>(row, 5) = nz/length;
}
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-03-15 14:54:04 -0600

Seen: 770 times

Last updated: Mar 16 '16