Hi, I'm trying to convert a point cloud to a range image following this tutorial: http://pointclouds.org/documentation/tutorials/range_image_creation.php
I have a pcl::PointCloud<pcl::PointXYZI> that I transform to pcl::PointCloud<pcl::PointXYZ> by using pcl::copyPointCloud. This makes the function createFromPointCloud() return a segfault: //cloud_1 is type pcl::PointCloud<pcl::PointXYZI> and has the data pcl::PointCloud<pcl::PointXYZ> pointCloud; pcl::copyPointCloud(*cloud_1, pointCloud); pointCloud.width = (uint32_t) pointCloud.points.size(); pointCloud.height = 1; pointCloud.points.resize (pointCloud.width * pointCloud.height); float angularResolution = (float) ( 0.125f * (M_PI/180.0f)); // 1.0 degree in radians float maxAngleWidth = (float) (360.0f * (M_PI/180.0f)); // 360.0 degree in radians float maxAngleHeight = (float) (180.0f * (M_PI/180.0f)); // 180.0 degree in radians Eigen::Affine3f sensorPose = (Eigen::Affine3f)Eigen::Translation3f(0.0f, 0.0f, 0.0f); pcl::RangeImage::CoordinateFrame coordinate_frame = pcl::RangeImage::CAMERA_FRAME; float noiseLevel=0.00; float minRange = 0.0f; int borderSize = 1; pcl::RangeImage rangeImage; rangeImage.createFromPointCloud(pointCloud, angularResolution, maxAngleWidth, maxAngleHeight, sensorPose, coordinate_frame, noiseLevel, minRange, borderSize); -------------------------------------------------------------------------------------------------------------- This produces a segFault, however, if I copy it element by element turns out OK. I think it might have something to do with the resize of the pointcloud but I can't put my finger on it. pcl::PointCloud<pcl::PointXYZ> pointCloud; for(int i; i<cloud_1->size(); i++) { pcl::PointXYZ point; point.x = cloud_1->points[i].x; point.y =cloud_1->points[i].y; point.z = cloud_1->points[i].z; pointCloud.points.push_back(point); } pointCloud.width = (uint32_t) pointCloud.points.size(); pointCloud.height = 1; pointCloud.points.resize (pointCloud.width * pointCloud.height); float angularResolution = (float) ( 0.125f * (M_PI/180.0f)); // 1.0 degree in radians float maxAngleWidth = (float) (360.0f * (M_PI/180.0f)); // 360.0 degree in radians float maxAngleHeight = (float) (180.0f * (M_PI/180.0f)); // 180.0 degree in radians Eigen::Affine3f sensorPose = (Eigen::Affine3f)Eigen::Translation3f(0.0f, 0.0f, 0.0f); pcl::RangeImage::CoordinateFrame coordinate_frame = pcl::RangeImage::CAMERA_FRAME; float noiseLevel=0.00; float minRange = 0.0f; int borderSize = 1; pcl::RangeImage rangeImage; rangeImage.createFromPointCloud(pointCloud, angularResolution, maxAngleWidth, maxAngleHeight, sensorPose, coordinate_frame, noiseLevel, minRange, borderSize); std::cout << rangeImage << "\n"; Thanks! -- Atentamente, David Serret Mayer_______________________________________________ [hidden email] / http://pointclouds.org http://pointclouds.org/mailman/listinfo/pcl-users |
Compile PCL with debug symbols, run your program on your debugger, let it segfault and examine the backtrace. Check if there’s a pointer which is null and shouldn’t or if something is trying to access some out-of-range index, these are the most common situations. Check what are the differences in the point cloud resultant from copyPointCloud and the one in which you copy the coordinates manually. That’s where the answer lies. Also, why are you invoking resize on pointCloud.points ? Cheers From: [hidden email] Hi, I'm trying to convert a point cloud to a range image following this tutorial: http://pointclouds.org/documentation/tutorials/range_image_creation.php Atentamente, David Serret Mayer _______________________________________________ [hidden email] / http://pointclouds.org http://pointclouds.org/mailman/listinfo/pcl-users |
Free forum by Nabble - Resume Templates | Edit this page |