从kinect深度图像的积分图像正常估计 [英] Integral Image normal estimation from kinect depth image

查看:1025
本文介绍了从kinect深度图像的积分图像正常估计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am doing the following to try and estimate surface normals from a point cloud generated from a Kinect depth image:

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; 31m [pcl :: OrganizedNeighbor :: radiusSearch]输入数据集不是来自投影设备!
剩余(MSE)0.053184,使用1406个有效点
[0; m

[1;31m[pcl::OrganizedNeighbor::radiusSearch] Input dataset is not from a projective device! Residual (MSE) 0.053184, using 1406 valid points [0;m

如何继续,或者什么是从原始kinect深度图像(有效地)计算法线的正确方法?

I'm not sure how to proceed, or what is the correct way to (efficiently) compute normals from a raw kinect depth image?

推荐答案

case,答案是这样做的:

For this case, the answer was to do this:

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

如果像素具有无效的深度到 NAN ,以便pcl识别此

If the pixel has invalid depth (0 in this case) we must set it to NAN for pcl to recognize this

这篇关于从kinect深度图像的积分图像正常估计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆