Repository-Metriken
- Stars
- (9.023 Stars)
- PR-Merge-Metriken
- (Durchschn. Merge 8T 7h) (3 gemergte PRs in 30 T)
Beschreibung
I first generate 1000 random points to form the source point cloud: for (size_t i = 0; i < cloud_in->points.size (); ++i) { cloud_in->points[i].x = 1024 * rand () / (RAND_MAX + 1.0f); cloud_in->points[i].y = 1024 * rand () / (RAND_MAX + 1.0f); cloud_in->points[i].z = 1024 * rand () / (RAND_MAX + 1.0f); } and then form the target point cloud from the front 100 points of source point cloud , and add 0.7 to x for (size_t i = 0; i < cloud_out->points.size (); ++i) { cloud_out->points[i].x = cloud_in->points[i].x + 0.7f; cloud_out->points[i].y = cloud_in->points[i].y; cloud_out->points[i].z = cloud_in->points[i].z; } I try two times for the indices: boost::shared_ptr< std::vector > pr(new std::vector); // first try // for(int i=0; i<100; i+=1) // pr->push_back(i); // second try for(int i=100; i<200; i+=1) pr->push_back(i); but the result transformation is the same, if the setIndices works, the result shouldn't be the same, because the points in source point cloud we use to registration is different.
Your Environment
- Operating System and version: ubuntu16.04
- Compiler:cmake
- PCL Version:1.7
Context
Expected Behavior
Current Behavior
Code to Reproduce
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_in (new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_out (new pcl::PointCloud<pcl::PointXYZ>);
// Fill in the CloudIn data
cloud_in->width = 1000;
cloud_in->height = 1;
cloud_in->is_dense = false;
cloud_in->points.resize (cloud_in->width * cloud_in->height);
for (size_t i = 0; i < cloud_in->points.size (); ++i)
{
cloud_in->points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
cloud_in->points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
cloud_in->points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
}
cloud_out->width = 100;
cloud_out->height = 1;
cloud_out->is_dense = false;
cloud_out->points.resize (cloud_out->width * cloud_out->height);
for (size_t i = 0; i < cloud_out->points.size (); ++i)
{
cloud_out->points[i].x = cloud_in->points[i].x + 0.7f;
cloud_out->points[i].y = cloud_in->points[i].y;
cloud_out->points[i].z = cloud_in->points[i].z;
}
std::cout << cloud_out->points.size() << std::endl;
boost::shared_ptr< std::vector<int> > pr(new std::vector<int>);
// first try
// for(int i=0; i<100; i+=1)
// pr->push_back(i);
// second try
for(int i=100; i<200; i+=1)
pr->push_back(i);
pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
icp.setMaxCorrespondenceDistance(0.5);
icp.setTransformationEpsilon(1e-12);
icp.setEuclideanFitnessEpsilon(0.0001);
icp.setMaximumIterations (1000000);
icp.setInputSource(cloud_in);
icp.setInputTarget(cloud_out);
//icp.setIndices(pr);
pcl::PointCloud<pcl::PointXYZ> Final;
icp.align(Final);
std::cout << "has converged:" << icp.hasConverged() << " score: " <<
icp.getFitnessScore() << std::endl;
std::cout << icp.getFinalTransformation() << std::endl;
pcl::transformPointCloud(*cloud_out,*cloud_out,icp.getFinalTransformation().inverse());