title: pcl::PCLPointCloud2 usage
body: <p>I'm confused with when to use <code>pcl::PointCloud2</code> vs <code>pcl::PointCloudPointCloud</code></p>
  
  <p>For example, using these definitions for <code>pcl1_ptrA</code>, <code>pcl1_ptrB</code> and <code>pcl1_ptrC</code>:</p>
  
  <pre><code>pcl::PointCloud&lt;pcl::PointXYZRGB&gt;::Ptr pcl1_ptrA(new pcl::PointCloud&lt;pcl::PointXYZRGB&gt;); //pointer for color version of pointcloud
  pcl::PointCloud&lt;pcl::PointXYZRGB&gt;::Ptr pcl1_ptrB(new pcl::PointCloud&lt;pcl::PointXYZRGB&gt;); //ptr to hold filtered Kinect image
  pcl::PointCloud&lt;pcl::PointXYZRGB&gt;::Ptr pcl1_ptrC(new pcl::PointCloud&lt;pcl::PointXYZRGB&gt;); //ptr to hold filtered Kinect image
  </code></pre>
  
  <p>I can invoke the following PCL functions:</p>
  
  <pre><code>pcl::VoxelGrid&lt;pcl::PointXYZRGB&gt; vox;
  
  vox.setInputCloud(pcl1_ptrA); 
  
  vox.setLeafSize(0.02f, 0.02f, 0.02f);
  
  vox.filter(*pcl1_ptrB); 
  
  cout&lt;&lt;"done voxel filtering"&lt;&lt;endl;
  
  cout&lt;&lt;"num bytes in original cloud data = "&lt;&lt;pcl1_ptrA-&gt;points.size()&lt;&lt;endl;
  
  cout&lt;&lt;"num bytes in filtered cloud data = "&lt;&lt;pcl1_ptrB-&gt;points.size()&lt;&lt;endl; // -&gt;data.size()&lt;&lt;endl; 
  
  Eigen::Vector4f xyz_centroid; 
  
  pcl::compute3DCentroid (*pcl1_ptrB, xyz_centroid);
  
  float curvature;
  
  Eigen::Vector4f plane_parameters;  
  
  pcl::computePointNormal(*pcl1_ptrB, plane_parameters, curvature); //pcl fnc to compute plane fit to point cloud
  
  Eigen::Affine3f A(Eigen::Affine3f::Identity());
  
  pcl::transformPointCloud(*pcl1_ptrB, *pcl1_ptrC, A);    
  </code></pre>
  
  <p>However, if I instead use <code>pcl::PCLPointCloud2</code> objects, e.g.:</p>
  
  <pre><code>pcl::PCLPointCloud2::Ptr pcl2_ptrA (new pcl::PCLPointCloud2 ());
  
  pcl::PCLPointCloud2::Ptr pcl2_ptrB (new pcl::PCLPointCloud2 ());
  
  pcl::PCLPointCloud2::Ptr pcl2_ptrC (new pcl::PCLPointCloud2 ());
  </code></pre>
  
  <p>This function  works:</p>
  
  <pre><code>pcl::VoxelGrid&lt;pcl::PCLPointCloud2&gt; vox;
  
  vox.setInputCloud(pcl2_ptrA); 
  
  vox.setLeafSize(0.02f, 0.02f, 0.02f);
  
  vox.filter(*pcl2_ptrB);
  </code></pre>
  
  <p>But these do not even compile:</p>
  
  <pre><code>//the next 3 functions do NOT compile:
  
  Eigen::Vector4f xyz_centroid; 
  
  pcl::compute3DCentroid (*pcl2_ptrB, xyz_centroid);
  
  float curvature;
  
  Eigen::Vector4f plane_parameters;   
  
  pcl::computePointNormal(*pcl2_ptrB, plane_parameters, curvature); 
  
  Eigen::Affine3f A(Eigen::Affine3f::Identity());
  
  pcl::transformPointCloud(*pcl2_ptrB, *pcl2_ptrC, A);  
  </code></pre>
  
  <p>I am having trouble discovering which functions accept which objects.  Ideally, wouldn't all PCL functions accept <code>pcl::PCLPointCloud2</code> arguments?</p>