1
我做以下,以从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] Input dataset is not from a projective device! Residual (MSE) 0.053184, using 1406 valid points [0;m
我不知道如何继续,或者什么是从一个原始kinect深度图像(有效)计算法线的正确方法?
此错误意味着PCL无法估计投影矩阵;也就是说,从数据中隐含的2D-3D对应关系中,它试图确定一个好的映射。在你的情况下,它失败了。可能的原因:从x,y,z到u,v的映射有点不好;没有足够的(非NaN)数据。如果这是来自一个kinect,那么我预计会有数十或数十万有效点的数量,但最终只能使用1406.我建议将点云可视化,以查看例如深度值是正确的(你使用min_depth来做什么?)。 – 2013-02-15 07:15:51
其他人也有类似的问题:http://answers.ros.org/question/54838/pcl-outlier-removal-error-with-swissranger/ – 2013-02-22 07:23:26