从kinect的深度图像积分图像正常估计(Integral Image normal estimat

2019-08-16 23:47发布

我做以下操作,从Kinect的深度图像生成点云试图估计表面法线:

pcl::PointCloud<pcl::PointXYZRGB>::Ptr create_point_cloud_ptr(Mat& depthImage, Mat& rgbImage){

    pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>());
    cloud->width = depthImage.rows; //Dimensions must be initialized to use 2-D indexing
    cloud->height = depthImage.cols;
    cloud->resize(cloud->width*cloud->height);

    int min_depth = INT_MAX;
    int num_of_points_added = 0;
    for(int v=0; v< depthImage.rows; v++){ //2-D indexing
        for(int u=0; u< depthImage.cols; u++) {
              Vec3b bgrPixel = rgbImage.at<Vec3b>(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<int16_t>(v,u);
              cloud->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<pcl::PointXYZRGB>::Ptr cloud = create_point_cloud_ptr(cap_depth, cap_rgb);

pcl::PointCloud<pcl::Normal>::Ptr normals (new pcl::PointCloud<pcl::Normal>);

pcl::IntegralImageNormalEstimation<pcl::PointXYZRGB, pcl::Normal> 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<pcl::PointXYZRGB,pcl::Normal>(cloud, normals);

而且正在以下错误:

[1;31米[PCL :: OrganizedNeighbor :: radiusSearch]输入数据集不是从投影设备! 残留(MSE)0.053184,使用1406个的有效点[0;米

我不知道如何着手,或什么是正确的方式(有效)从原始的Kinect深度图像计算法线?

Answer 1:

对于这种情况,得到的答复是要做到这一点:

    if (depthImage.at<int16_t>(v, u) == 0) {
        p.z = NAN;
    }

如果像素具有无效的深度(0在这种情况下)我们必须把它设置为NAN用于PCL认识到这一点



文章来源: Integral Image normal estimation from kinect depth image