mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
Added util3d::laserScan2dFromPointCloud()
This commit is contained in:
@@ -127,7 +127,10 @@ pcl::PointCloud<pcl::PointXYZ> RTABMAP_EXP laserScanFromDepthImage(
|
|||||||
float maxDepth = 0,
|
float maxDepth = 0,
|
||||||
const Transform & localTransform = Transform::getIdentity());
|
const Transform & localTransform = Transform::getIdentity());
|
||||||
|
|
||||||
|
// return CV_32FC3
|
||||||
cv::Mat RTABMAP_EXP laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const Transform & transform = Transform());
|
cv::Mat RTABMAP_EXP laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const Transform & transform = Transform());
|
||||||
|
// return CV_32FC2
|
||||||
|
cv::Mat RTABMAP_EXP laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const Transform & transform = Transform());
|
||||||
pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_EXP laserScanToPointCloud(const cv::Mat & laserScan, const Transform & transform = Transform());
|
pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_EXP laserScanToPointCloud(const cv::Mat & laserScan, const Transform & transform = Transform());
|
||||||
|
|
||||||
pcl::PointXYZ RTABMAP_EXP projectDisparityTo3D(
|
pcl::PointXYZ RTABMAP_EXP projectDisparityTo3D(
|
||||||
|
|||||||
@@ -815,6 +815,29 @@ cv::Mat laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, co
|
|||||||
return laserScan;
|
return laserScan;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cv::Mat laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & 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<cloud.size(); ++i)
|
||||||
|
{
|
||||||
|
if(!nullTransform)
|
||||||
|
{
|
||||||
|
pcl::PointXYZ pt = pcl::transformPoint(cloud.at(i), transform3f);
|
||||||
|
laserScan.at<cv::Vec2f>(i)[0] = pt.x;
|
||||||
|
laserScan.at<cv::Vec2f>(i)[1] = pt.y;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
laserScan.at<cv::Vec2f>(i)[0] = cloud.at(i).x;
|
||||||
|
laserScan.at<cv::Vec2f>(i)[1] = cloud.at(i).y;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return laserScan;
|
||||||
|
}
|
||||||
|
|
||||||
pcl::PointCloud<pcl::PointXYZ>::Ptr laserScanToPointCloud(const cv::Mat & laserScan, const Transform & transform)
|
pcl::PointCloud<pcl::PointXYZ>::Ptr laserScanToPointCloud(const cv::Mat & laserScan, const Transform & transform)
|
||||||
{
|
{
|
||||||
UASSERT(laserScan.empty() || laserScan.type() == CV_32FC2 || laserScan.type() == CV_32FC3);
|
UASSERT(laserScan.empty() || laserScan.type() == CV_32FC2 || laserScan.type() == CV_32FC3);
|
||||||
|
|||||||
Reference in New Issue
Block a user