title: Point cloud registration using PCL Iterative closest point
body: <p>I try to perform ICP with PCL,</p>
  
  <p>but   <code>pcl::transformPointCloud</code> doesn't work. This my code:</p>
  
  <pre><code>int
   main ()
  {
     pcl::PointCloud&lt;pcl::PointXYZI&gt;::Ptr cloudIn (new pcl::PointCloud&lt;pcl::PointXYZI&gt;);
     pcl::PointCloud&lt;pcl::PointXYZI&gt;::Ptr cloudOut (new pcl::PointCloud&lt;pcl::PointXYZI&gt;);
     pcl::PointCloud&lt;pcl::PointXYZI&gt; finalCloud ;
     pcl::PointCloud&lt;pcl::PointXYZI&gt; finalCloud1 ;
     pcl::PointCloud&lt;pcl::PointXYZI&gt;::Ptr cloudOut_new (new pcl::PointCloud&lt;pcl::PointXYZI&gt;) ;
  
     if(pcl::io::loadPCDFile ("/ICP_PCL/000.pcd", *cloudIn)==-1)
     {
       PCL_ERROR ("Couldn't read first file! \n");
       return (-1);
     }
  
     if(pcl::io::loadPCDFile ("/ICP_PCL/001.pcd", *cloudOut)==-1)
     {
       PCL_ERROR ("Couldn't read second input file! \n");
       return (-1);
     }
  
    pcl::IterativeClosestPoint&lt;pcl::PointXYZI, pcl::PointXYZI&gt; icp;
    icp.setInputCloud(cloudOut);
    icp.setInputTarget(cloudIn);
    icp.setMaximumIterations (500);
    icp.setTransformationEpsilon (1e-9);
    icp.setMaxCorrespondenceDistance (0.05);
    icp.setEuclideanFitnessEpsilon (1);
    icp.setRANSACOutlierRejectionThreshold (1.5);
  
    icp.align(finalCloud);
  
    if (icp.hasConverged())
    {
        std::cout &lt;&lt; "ICP converged." &lt;&lt; std::endl
                  &lt;&lt; "The score is " &lt;&lt; icp.getFitnessScore() &lt;&lt; std::endl;
        std::cout &lt;&lt; "Transformation matrix:" &lt;&lt; std::endl;
        std::cout &lt;&lt; icp.getFinalTransformation() &lt;&lt; std::endl;
    }
    else std::cout &lt;&lt; "ICP did not converge." &lt;&lt; std::endl;
  
    Eigen::Matrix4f transformationMatrix = icp.getFinalTransformation ();
    std::cout&lt;&lt;"trans %n"&lt;&lt;transformationMatrix&lt;&lt;std::endl;
  
    pcl::transformPointCloud( *cloudOut, *cloudOut_new, transformationMatrix);
  
    pcl::io::savePCDFileASCII ("/ICP_PCL/IcpResult3.pcd", finalCloud);
  
    finalCloud1=*cloudIn;
    finalCloud1+=*cloudOut_new;
  
     boost::shared_ptr&lt;pcl::visualization::PCLVisualizer&gt; viewer (new pcl::visualization::PCLVisualizer("3D Viewer"));
     viewer-&gt;setBackgroundColor(0,0,0);
     pcl::visualization::PointCloudColorHandlerCustom&lt;pcl::PointXYZI&gt; single_color1 (cloudIn, 0, 0, 200);
     pcl::visualization::PointCloudColorHandlerCustom&lt;pcl::PointXYZI&gt; single_color2 (cloudOut_new, 200, 0, 0);
  
     viewer-&gt;addPointCloud&lt;pcl::PointXYZI&gt; (cloudIn,single_color1, "sample_cloud_1");
     viewer-&gt;addPointCloud&lt;pcl::PointXYZI&gt; (cloudOut_new, single_color2, "sample_cloud_2");
  
      viewer-&gt;addCoordinateSystem(1.0);
        while(!viewer-&gt;wasStopped())
        {
            viewer-&gt;spinOnce();
            boost::this_thread::sleep (boost::posix_time::microseconds(100000));
        }
   return (0);
  }
  </code></pre>
  
  <p>and this is what I get as result: 
  <a href="https://i.stack.imgur.com/aSjr6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/aSjr6.png" alt="enter image description here"></a></p>
  
  <p>The <code>transformpointcloud</code> is not working, but the saved PCD file having two clouds looks fine. Can someone please suggest me what is happening?</p>