koide3 / small_gicp

Efficient and parallel algorithms for point cloud registration [C++, Python]
MIT License
364 stars 46 forks source link

Manually adding normals #21

Closed mcmingchang closed 4 months ago

mcmingchang commented 5 months ago

If I have normals, how can I manually add them to the point cloud to avoid duplicate calculations and improve calculation speed?

koide3 commented 5 months ago

If you are using small_gicp::PointCloud, you can fill normal values as follows:

auto points = std::make_shared<small_gicp::PointCloud>();
points->resize(1024);

for (int i = 0; i < 1024; i++) {
  Eigen::Vector4d& point = points->points[i];
  point << 1.0, 0.0, 0.0, 1.0;

  Eigen::Vector4d& normal = points->normals[i]
  normal << 1.0, 0.0, 0.0, 0.0;
}

In case with pcl::PointCloud<pcl::PointNormal>:

auto points = pcl::make_shared<pcl::PointCloud<pcl::PointNormal>>();
points->resize(1024);

for(int i=0; i<1024; i++) {
  points->at(i).getNormalVector4fMap() << 1.0, 0.0, 0.0, 0.0;
}
mcmingchang commented 4 months ago

thanks