title: Integral Image normal estimation from kinect depth image
body: <p>I am doing the following to try and estimate surface normals from a point cloud generated from a Kinect depth image:</p>
  
  <pre><code>pcl::PointCloud&lt;pcl::PointXYZRGB&gt;::Ptr create_point_cloud_ptr(Mat&amp; depthImage, Mat&amp; rgbImage){
  
      pcl::PointCloud&lt;pcl::PointXYZRGB&gt;::Ptr cloud(new pcl::PointCloud&lt;pcl::PointXYZRGB&gt;());
      cloud-&gt;width = depthImage.rows; //Dimensions must be initialized to use 2-D indexing
      cloud-&gt;height = depthImage.cols;
      cloud-&gt;resize(cloud-&gt;width*cloud-&gt;height);
  
      int min_depth = INT_MAX;
      int num_of_points_added = 0;
      for(int v=0; v&lt; depthImage.rows; v++){ //2-D indexing
          for(int u=0; u&lt; depthImage.cols; u++) {
                Vec3b bgrPixel = rgbImage.at&lt;Vec3b&gt;(v, u);
                pcl::PointXYZRGB p = pcl::PointXYZRGB();
                p.b = bgrPixel[0];
                p.g = bgrPixel[1];
                p.r = bgrPixel[2];
                p.x = u;
                p.y = v;
                p.z = depthImage.at&lt;int16_t&gt;(v,u);
                cloud-&gt;at(u,v) = p;
                num_of_points_added++;
          }
      }
      return cloud;
  } 
  
  
  int main(int argc, char* argv[]) {
  Mat cap_depth = imread("cap_depth.png",CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH);
  Mat cap_rgb = imread("cap.png",CV_LOAD_IMAGE_ANYCOLOR);
  
  pcl::PointCloud&lt;pcl::PointXYZRGB&gt;::Ptr cloud = create_point_cloud_ptr(cap_depth, cap_rgb);
  
  pcl::PointCloud&lt;pcl::Normal&gt;::Ptr normals (new pcl::PointCloud&lt;pcl::Normal&gt;);
  
  pcl::IntegralImageNormalEstimation&lt;pcl::PointXYZRGB, pcl::Normal&gt; ne;
  ne.setNormalEstimationMethod (ne.AVERAGE_3D_GRADIENT);
  ne.setMaxDepthChangeFactor(0.02f);
  ne.setNormalSmoothingSize(10.0f);
  ne.setInputCloud(cloud);
  ne.compute(*normals);
  
  pcl::visualization::PCLVisualizer viewer("PCL Viewer");
  viewer.setBackgroundColor (0.0, 0.0, 0.5);
  viewer.addPointCloudNormals&lt;pcl::PointXYZRGB,pcl::Normal&gt;(cloud, normals);
  </code></pre>
  
  <p>And am getting the following error:</p>
  
  <blockquote>
    <p>[1;31m[pcl::OrganizedNeighbor::radiusSearch] Input dataset is not from a projective device!
        Residual (MSE) 0.053184, using 1406 valid points
        [0;m</p>
  </blockquote>
  
  <p>I'm not sure how to proceed, or what is the correct way to (efficiently) compute normals from a raw kinect depth image?</p>