PCL ICP导致致命错误

时间:2012-08-21 00:27:26

标签: point-cloud-library

我是PCL(Point Cloud Library)的新手,只想将ICP应用于两组。但是,当我尝试使用Visual Studio 2010 64位运行它时,ICP的在线代码示例会引发致命错误。我尝试了不同的创建点云的方法,但没有运气。 icp.setInputTargettarget_ = target.makeShared ();

行内发生致命错误

这就是我创建两个云点的方法

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_in (new pcl::PointCloud<pcl::PointXYZ>);
cloud_in->width    = _head_width+1;
cloud_in->height   = _head_height+1;
cloud_in->is_dense = true;
for(int x=0; x<=width; x++) {
        for(int y=0; y<=height; y++)    {
            float z = depths[x][y];
            pcl::PointXYZ curr_point;
            curr_point.x = x;
            curr_point.y = y;
            curr_point.z = z;
            cloud_in->points.push_back(curr_point);
        }
    }

这就是发生错误的地方

pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp;
icp_dummy.setInputCloud(cloud_in);
icp_dummy.setInputTarget(cloud_out); /* This throws a fatal error */

任何帮助将不胜感激

1 个答案:

答案 0 :(得分:1)

我有几个问题在我眼中是不对的: - depht贴图不正确,x,y的值不是真实世界坐标

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud (new pcl::PointCloud<pcl::PointXYZ>);
cloud->points.reserve(depthmap.rows*depthmap.cols);//for speeding up code, whitout it cost more time

cloud->is_dense = true;
//Don't know how it'd defined but try something like this by the depthmap
for(int x=0; x<depthmap.rows; x++) {
        for(int y=0; y<depthmap.cols; y++)    {
            float z = depths[x][y];
            pcl::PointXYZ curr_point;
            curr_point.x = (x - cx) * z / fx; //for speedup calculate inverse of fx and multiply this 
            curr_point.y = (y - cy) * z / fy;//for speedup calculate inverse of fy and multiply this 
            curr_point.z = z;
            cloud->points.push_back(curr_point);
        }
    }

- 也用于加速事物使用PTR(智能指针)

pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_out;

pcl::IterativeClosestPoint<pcl::PointXYZ, pcl::PointXYZ> icp; //hereyou have to define icp

icp.setInputCloud(cloud_in);//so here icp_dummy needs to be icp

icp.setInputTarget(cloud_out); //so here icp_dummy needs to be icp

// The fatal error must be gone, otherwise change cloud_in to same type
// as cloud_out