diff --git a/corelib/include/rtabmap/core/util3d.h b/corelib/include/rtabmap/core/util3d.h index 491707a7..a0b9857a 100644 --- a/corelib/include/rtabmap/core/util3d.h +++ b/corelib/include/rtabmap/core/util3d.h @@ -127,7 +127,10 @@ pcl::PointCloud RTABMAP_EXP laserScanFromDepthImage( float maxDepth = 0, const Transform & localTransform = Transform::getIdentity()); +// return CV_32FC3 cv::Mat RTABMAP_EXP laserScanFromPointCloud(const pcl::PointCloud & cloud, const Transform & transform = Transform()); +// return CV_32FC2 +cv::Mat RTABMAP_EXP laserScan2dFromPointCloud(const pcl::PointCloud & cloud, const Transform & transform = Transform()); pcl::PointCloud::Ptr RTABMAP_EXP laserScanToPointCloud(const cv::Mat & laserScan, const Transform & transform = Transform()); pcl::PointXYZ RTABMAP_EXP projectDisparityTo3D( diff --git a/corelib/src/util3d.cpp b/corelib/src/util3d.cpp index 2f01cdf8..5afe8b08 100644 --- a/corelib/src/util3d.cpp +++ b/corelib/src/util3d.cpp @@ -815,6 +815,29 @@ cv::Mat laserScanFromPointCloud(const pcl::PointCloud & cloud, co return laserScan; } +cv::Mat laserScan2dFromPointCloud(const pcl::PointCloud & cloud, const Transform & transform) +{ + cv::Mat laserScan(1, (int)cloud.size(), CV_32FC2); + bool nullTransform = transform.isNull(); + Eigen::Affine3f transform3f = transform.toEigen3f(); + for(unsigned int i=0; i(i)[0] = pt.x; + laserScan.at(i)[1] = pt.y; + } + else + { + laserScan.at(i)[0] = cloud.at(i).x; + laserScan.at(i)[1] = cloud.at(i).y; + } + + } + return laserScan; +} + pcl::PointCloud::Ptr laserScanToPointCloud(const cv::Mat & laserScan, const Transform & transform) { UASSERT(laserScan.empty() || laserScan.type() == CV_32FC2 || laserScan.type() == CV_32FC3);