PointCloudLibrary/pcl

icp setIndices doesn't work

Open

#3,109 建立於 2019年5月30日

在 GitHub 查看
 (7 留言) (0 反應) (0 負責人)C++ (4,506 fork)batch import
help wantedkind: bugkind: todomodule: registration

倉庫指標

Star
 (9,023 star)
PR 合併指標
 (平均合併 8天 7小時) (30 天內合併 3 個 PR)

描述

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());

Possible Solution

貢獻者指南