0
votes

I'm new to PCL (Point Cloud Library) and just want to apply to ICP to two sets of points. The online code sample for ICP, however, throws a fatal error when I try to run it with Visual Studio 2010 64 bit. I've tried different ways of creating a point cloud but no luck. Fatal error occurs inside icp.setInputTarget, at the line target_ = target.makeShared ();

This is how I create both of my cloud points

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);
        }
    }

And this is where error occurs

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

Any help will be appreciated

1
How do you declare/create cloud_out? If you run the example at pointclouds.org/documentation/tutorials/… does it work?Sassa
Not really, that's the code I tried to use :/ I suspect it might be a 64bit problemEge Akpinar

1 Answers

1
votes

I have a few questions what is not right in my eyes: -The depht map is not correct, the values of x,y are not real world coordinates

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);
        }
    }

- Also for speeding up thing use PTR (smart pointers)

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