【问题标题】:Integral Image normal estimation from kinect depth image从 kinect 深度图像进行积分图像法线估计
【发布时间】:2013-02-14 14:46:12
【问题描述】:

我正在执行以下操作以尝试从 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;31m[pcl::OrganizedNeighbor::radiusSearch] 输入数据集不是来自投影设备! 残差 (MSE) 0.053184,使用 1406 个有效点 [0;m

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

【问题讨论】:

  • 此错误意味着 PCL 无法估计投影矩阵;也就是说,从数据中隐含的 2D-3D 对应关系中,它试图确定一个好的映射。在你的情况下它失败了。可能的原因:从 x,y,z 到 u,v 的映射有点糟糕;没有足够的(非 NaN)数据。如果这是来自 kinect,那么我希望会有数万或数十万个有效点,但你最终只会得到 1406。我建议可视化你的点云,看看例如深度值是正确的(你用 min_depth 做什么?)。
  • 其他人也有类似的问题:answers.ros.org/question/54838/…

标签: c++ computer-vision normals point-cloud-library


【解决方案1】:

对于这种情况,答案是这样做:

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

如果像素的深度无效(在这种情况下为 0),我们必须将其设置为 NAN 以便 pcl 识别它

【讨论】:

    猜你喜欢
    • 2014-11-17
    • 1970-01-01
    • 2013-03-03
    • 2013-11-24
    • 1970-01-01
    • 2016-04-11
    • 2016-06-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多