Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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;
}