RTAB-Map 0.24.1
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
util3d.h
1/*
2Copyright (c) 2010-2025, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the Universite de Sherbrooke nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#ifndef UTIL3D_H_
29#define UTIL3D_H_
30
31#include <functional>
32#include "rtabmap/core/rtabmap_core_export.h"
33
34#include <pcl/point_cloud.h>
35#include <pcl/point_types.h>
36#include <pcl/pcl_base.h>
37#include <pcl/TextureMesh.h>
38#include <rtabmap/core/Transform.h>
39#include <rtabmap/core/SensorData.h>
40#include <rtabmap/core/Parameters.h>
41#include <opencv2/core/core.hpp>
42#include <rtabmap/core/ProgressState.h>
43#include <cstdint>
44#include <map>
45#include <list>
46
47namespace rtabmap
48{
49
54// Point type carrying xyz + intensity + ring (laser line index) + time
55// (per-point acquisition offset, seconds from the scan start). Matches the
56// layout expected by LIO-SAM's Velodyne feature extractor so it can be fed
57// directly via util3d::laserScanFromPointCloud().
58struct EIGEN_ALIGN16 PointXYZIRT
59{
60 PCL_ADD_POINT4D;
61 float intensity;
62 std::uint16_t ring;
63 float time;
64 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
65};
66
75namespace util3d
76{
77
94cv::Mat RTABMAP_CORE_EXPORT rgbFromCloud(
95 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
96 bool bgrOrder = true);
97
112cv::Mat RTABMAP_CORE_EXPORT depthFromCloud(
113 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
114 bool depth16U = true);
115
131void RTABMAP_CORE_EXPORT rgbdFromCloud(
132 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
133 cv::Mat & rgb,
134 cv::Mat & depth,
135 bool bgrOrder = true,
136 bool depth16U = true);
137
156pcl::PointXYZ RTABMAP_CORE_EXPORT projectDepthTo3D(
157 const cv::Mat & depthImage,
158 float x, float y,
159 float cx, float cy,
160 float fx, float fy,
161 bool smoothing,
162 float depthErrorRatio = 0.02f);
163
180Eigen::Vector3f RTABMAP_CORE_EXPORT projectDepthTo3DRay(
181 const cv::Size & imageSize,
182 float x, float y,
183 float cx, float cy,
184 float fx, float fy);
185
208RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT cloudFromDepth(
209 const cv::Mat & imageDepth,
210 float cx, float cy,
211 float fx, float fy,
212 int decimation = 1,
213 float maxDepth = 0.0f,
214 float minDepth = 0.0f,
215 std::vector<int> * validIndices = 0);
231pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT cloudFromDepth(
232 const cv::Mat & imageDepth,
233 const CameraModel & model,
234 int decimation = 1,
235 float maxDepth = 0.0f,
236 float minDepth = 0.0f,
237 std::vector<int> * validIndices = 0);
238pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT cloudFromDepth(
239 const cv::Mat & imageDepth,
240 const cv::Mat & imageDepthConfidence,
241 const CameraModel & model,
242 int decimation = 1,
243 float maxDepth = 0.0f,
244 float minDepth = 0.0f,
245 unsigned char confidenceThr = 0,
246 std::vector<int> * validIndices = 0);
247
273RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudFromDepthRGB(
274 const cv::Mat & imageRgb,
275 const cv::Mat & imageDepth,
276 float cx, float cy,
277 float fx, float fy,
278 int decimation = 1,
279 float maxDepth = 0.0f,
280 float minDepth = 0.0f,
281 std::vector<int> * validIndices = 0);
282
304pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudFromDepthRGB(
305 const cv::Mat & imageRgb,
306 const cv::Mat & imageDepth,
307 const CameraModel & model,
308 int decimation = 1,
309 float maxDepth = 0.0f,
310 float minDepth = 0.0f,
311 std::vector<int> * validIndices = 0);
312pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudFromDepthRGB(
313 const cv::Mat & imageRgb,
314 const cv::Mat & imageDepth,
315 const cv::Mat & imageDepthConfidence,
316 const CameraModel & model,
317 int decimation = 1,
318 float maxDepth = 0.0f,
319 float minDepth = 0.0f,
320 unsigned char confidenceThr = 0, // 0=low, 100=high
321 std::vector<int> * validIndices = 0);
322
352pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT cloudFromDisparity(
353 const cv::Mat & imageDisparity,
354 const StereoCameraModel & model,
355 int decimation = 1,
356 float maxDepth = 0.0f,
357 float minDepth = 0.0f,
358 std::vector<int> * validIndices = 0);
359
393pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudFromDisparityRGB(
394 const cv::Mat & imageRgb,
395 const cv::Mat & imageDisparity,
396 const StereoCameraModel & model,
397 int decimation = 1,
398 float maxDepth = 0.0f,
399 float minDepth = 0.0f,
400 std::vector<int> * validIndices = 0);
401
438pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudFromStereoImages(
439 const cv::Mat & imageLeft,
440 const cv::Mat & imageRight,
441 const StereoCameraModel & model,
442 int decimation = 1,
443 float maxDepth = 0.0f,
444 float minDepth = 0.0f,
445 std::vector<int> * validIndices = 0,
446 const ParametersMap & parameters = ParametersMap());
447
486std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> RTABMAP_CORE_EXPORT cloudsFromSensorData(
487 const SensorData & sensorData,
488 int decimation = 1,
489 float maxDepth = 0.0f,
490 float minDepth = 0.0f,
491 std::vector<pcl::IndicesPtr> * validIndices = 0,
492 const ParametersMap & stereoParameters = ParametersMap(),
493 const std::vector<float> & roiRatios = std::vector<float>(), // ignored for stereo
494 unsigned char confidenceThr = 0); // ignored for stereo
495
524pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT cloudFromSensorData(
525 const SensorData & sensorData,
526 int decimation = 1,
527 float maxDepth = 0.0f,
528 float minDepth = 0.0f,
529 std::vector<int> * validIndices = 0,
530 const ParametersMap & stereoParameters = ParametersMap(),
531 const std::vector<float> & roiRatios = std::vector<float>(), // ignored for stereo
532 unsigned char confidenceThr = 0); // ignored for stereo
533
566std::vector<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> RTABMAP_CORE_EXPORT cloudsRGBFromSensorData(
567 const SensorData & sensorData,
568 int decimation = 1,
569 float maxDepth = 0.0f,
570 float minDepth = 0.0f,
571 std::vector<pcl::IndicesPtr > * validIndices = 0,
572 const ParametersMap & stereoParameters = ParametersMap(),
573 const std::vector<float> & roiRatios = std::vector<float>(), // ignored for stereo
574 unsigned char confidenceThr = 0); // ignored for stereo
575
602pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudRGBFromSensorData(
603 const SensorData & sensorData,
604 int decimation = 1,
605 float maxDepth = 0.0f,
606 float minDepth = 0.0f,
607 std::vector<int> * validIndices = 0,
608 const ParametersMap & stereoParameters = ParametersMap(),
609 const std::vector<float> & roiRatios = std::vector<float>(), // ignored for stereo
610 unsigned char confidenceThr = 0); // ignored for stereo
611
634pcl::PointCloud<pcl::PointXYZ> RTABMAP_CORE_EXPORT laserScanFromDepthImage(
635 const cv::Mat & depthImage,
636 float fx,
637 float fy,
638 float cx,
639 float cy,
640 float maxDepth = 0,
641 float minDepth = 0,
642 const Transform & localTransform = Transform::getIdentity());
662pcl::PointCloud<pcl::PointXYZ> RTABMAP_CORE_EXPORT laserScanFromDepthImages(
663 const cv::Mat & depthImages,
664 const std::vector<CameraModel> & cameraModels,
665 float maxDepth,
666 float minDepth);
667
696LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
698LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
700LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointNormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
702LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointNormal> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
704LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
706LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGB> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
708LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGB> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
710LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
712LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
714LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<rtabmap::PointXYZIRT> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
716LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<rtabmap::PointXYZIRT> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
718LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGB> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
720LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
722LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
724LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
726LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZINormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
728LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZINormal> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
729
731template<typename PointCloud2T>
732LaserScan laserScanFromPointCloud(const PointCloud2T & cloud, bool filterNaNs = true, bool is2D = false, const Transform & transform = Transform());
757LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
759LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
761LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointNormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
763LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
765LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZINormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
767LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
786pcl::PCLPointCloud2::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloud2(const LaserScan & laserScan, const Transform & transform = Transform());
788pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloud(const LaserScan & laserScan, const Transform & transform = Transform());
790pcl::PointCloud<pcl::PointNormal>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudNormal(const LaserScan & laserScan, const Transform & transform = Transform());
792pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudRGB(const LaserScan & laserScan, const Transform & transform = Transform(), unsigned char r = 100, unsigned char g = 100, unsigned char b = 100);
794pcl::PointCloud<pcl::PointXYZI>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudI(const LaserScan & laserScan, const Transform & transform = Transform(), float intensity = 0.0f);
796pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudRGBNormal(const LaserScan & laserScan, const Transform & transform = Transform(), unsigned char r = 100, unsigned char g = 100, unsigned char b = 100);
798pcl::PointCloud<pcl::PointXYZINormal>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudINormal(const LaserScan & laserScan, const Transform & transform = Transform(), float intensity = 0.0f);
799
800
802pcl::PointXYZ RTABMAP_CORE_EXPORT laserScanToPoint(const LaserScan & laserScan, int index);
804pcl::PointNormal RTABMAP_CORE_EXPORT laserScanToPointNormal(const LaserScan & laserScan, int index);
806pcl::PointXYZRGB RTABMAP_CORE_EXPORT laserScanToPointRGB(const LaserScan & laserScan, int index, unsigned char r = 100, unsigned char g = 100, unsigned char b = 100);
808pcl::PointXYZI RTABMAP_CORE_EXPORT laserScanToPointI(const LaserScan & laserScan, int index, float intensity);
810pcl::PointXYZRGBNormal RTABMAP_CORE_EXPORT laserScanToPointRGBNormal(const LaserScan & laserScan, int index, unsigned char r, unsigned char g, unsigned char b);
812pcl::PointXYZINormal RTABMAP_CORE_EXPORT laserScanToPointINormal(const LaserScan & laserScan, int index, float intensity);
813
835void RTABMAP_CORE_EXPORT getMinMax3D(const cv::Mat & laserScan, cv::Point3f & min, cv::Point3f & max);
836
850void RTABMAP_CORE_EXPORT getMinMax3D(const cv::Mat & laserScan, pcl::PointXYZ & min, pcl::PointXYZ & max);
851
874cv::Point3f RTABMAP_CORE_EXPORT projectDisparityTo3D(
875 const cv::Point2f & pt,
876 float disparity,
877 const StereoCameraModel & model);
878
897cv::Point3f RTABMAP_CORE_EXPORT projectDisparityTo3D(
898 const cv::Point2f & pt,
899 const cv::Mat & disparity,
900 const StereoCameraModel & model);
901
922cv::Mat RTABMAP_CORE_EXPORT projectCloudToCamera(
923 const cv::Size & imageSize,
924 const cv::Mat & cameraMatrixK,
925 const cv::Mat & laserScan,
926 const rtabmap::Transform & cameraTransform);
927
948cv::Mat RTABMAP_CORE_EXPORT projectCloudToCamera(
949 const cv::Size & imageSize,
950 const cv::Mat & cameraMatrixK,
951 const pcl::PointCloud<pcl::PointXYZ>::Ptr laserScan,
952 const rtabmap::Transform & cameraTransform);
953
974cv::Mat RTABMAP_CORE_EXPORT projectCloudToCamera(
975 const cv::Size & imageSize,
976 const cv::Mat & cameraMatrixK,
977 const pcl::PCLPointCloud2::Ptr laserScan,
978 const rtabmap::Transform & cameraTransform);
979
999void RTABMAP_CORE_EXPORT fillProjectedCloudHoles(
1000 cv::Mat & depthRegistered,
1001 bool verticalDirection,
1002 bool fillToBorder);
1003
1032cv::Mat RTABMAP_CORE_EXPORT filterFloor(
1033 const cv::Mat & depth,
1034 const std::vector<CameraModel> & cameraModels,
1035 float threshold,
1036 cv::Mat * depthBelow = 0);
1037
1058std::vector<std::pair< std::pair<int, int>, pcl::PointXY> > RTABMAP_CORE_EXPORT projectCloudToCameras (
1059 const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud,
1060 const std::map<int, Transform> & cameraPoses,
1061 const std::map<int, std::vector<CameraModel> > & cameraModels,
1062 float maxDistance = 0.0f,
1063 float maxAngle = 0.0f,
1064 float maxDepthError = 0.0f,
1065 const std::vector<float> & roiRatios = std::vector<float>(),
1066 const cv::Mat & projMask = cv::Mat(),
1067 bool distanceToCamPolicy = false,
1068 const ProgressState * state = 0);
1089std::vector<std::pair< std::pair<int, int>, pcl::PointXY> > RTABMAP_CORE_EXPORT projectCloudToCameras (
1090 const pcl::PointCloud<pcl::PointXYZINormal> & cloud,
1091 const std::map<int, Transform> & cameraPoses,
1092 const std::map<int, std::vector<CameraModel> > & cameraModels,
1093 float maxDistance = 0.0f,
1094 float maxAngle = 0.0f,
1095 float maxDepthError = 0.0f,
1096 const std::vector<float> & roiRatios = std::vector<float>(),
1097 const cv::Mat & projMask = cv::Mat(),
1098 bool distanceToCamPolicy = false,
1099 const ProgressState * state = 0);
1100
1110bool RTABMAP_CORE_EXPORT isFinite(const cv::Point3f & pt);
1111
1121pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT concatenateClouds(
1122 const std::list<pcl::PointCloud<pcl::PointXYZ>::Ptr> & clouds);
1132pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT concatenateClouds(
1133 const std::list<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds);
1134
1149pcl::IndicesPtr RTABMAP_CORE_EXPORT concatenate(
1150 const std::vector<pcl::IndicesPtr> & indices);
1151
1166pcl::IndicesPtr RTABMAP_CORE_EXPORT concatenate(
1167 const pcl::IndicesPtr & indicesA,
1168 const pcl::IndicesPtr & indicesB);
1169
1181void RTABMAP_CORE_EXPORT savePCDWords(
1182 const std::string & fileName,
1183 const std::multimap<int, pcl::PointXYZ> & words,
1184 const Transform & transform = Transform::getIdentity());
1185
1197void RTABMAP_CORE_EXPORT savePCDWords(
1198 const std::string & fileName,
1199 const std::multimap<int, cv::Point3f> & words,
1200 const Transform & transform = Transform::getIdentity());
1201
1212cv::Mat RTABMAP_CORE_EXPORT loadBINScan(const std::string & fileName);
1221pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT loadBINCloud(const std::string & fileName);
1230RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT loadBINCloud(const std::string & fileName, int dim);
1231
1242LaserScan RTABMAP_CORE_EXPORT loadScan(const std::string & path);
1243
1257RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT loadCloud(
1258 const std::string & path,
1259 const Transform & transform = Transform::getIdentity(),
1260 int downsampleStep = 1,
1261 float voxelSize = 0.0f);
1262
1294LaserScan RTABMAP_CORE_EXPORT deskew(
1295 const LaserScan & input,
1296 double inputStamp,
1297 const rtabmap::Transform & velocity);
1298
1314LaserScan RTABMAP_CORE_EXPORT deskew(
1315 const LaserScan & input,
1316 double inputStamp,
1317 const std::function<rtabmap::Transform(double stamp)> & motion,
1318 bool slerp = false);
1319
1320} // namespace util3d
1321} // namespace rtabmap
1322
1323POINT_CLOUD_REGISTER_POINT_STRUCT(rtabmap::PointXYZIRT,
1324 (float, x, x)
1325 (float, y, y)
1326 (float, z, z)
1327 (float, intensity, intensity)
1328 (std::uint16_t, ring, ring)
1329 (float, time, time)
1330)
1331
1332#include "rtabmap/core/impl/util3d.hpp"
1333
1334#endif /* UTIL3D_H_ */
Represents a pinhole camera model containing intrinsic and extrinsic parameters, used for projection,...
Definition CameraModel.h:53
Represents 2D or 3D laser scan data with support for multiple point data formats.
Definition LaserScan.h:46
Container class for all sensor data captured at a specific time.
Definition SensorData.h:97
A class representing a calibrated stereo camera system.
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53
static Transform getIdentity()
Returns identity transform.
LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud< pcl::PointXYZ > &cloud, const Transform &transform=Transform(), bool filterNaNs=true)
PointXYZ → LaserScan::kXY
LaserScan laserScanFromPointCloud(const PointCloud2T &cloud, bool filterNaNs, bool is2D, const Transform &transform)
Convert pcl::PCLPointCloud2 to rtabmap::LaserScan with all supported fields (see rtabmap::LaserScan::...
Definition util3d.hpp:37
pcl::PointXYZI RTABMAP_CORE_EXPORT laserScanToPointI(const LaserScan &laserScan, int index, float intensity)
The point at index of the scan, as PointXYZI.
pcl::PCLPointCloud2::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloud2(const LaserScan &laserScan, const Transform &transform=Transform())
Convert rtabmap::LaserScan to pcl::PCLPointCloud2 with all supported fields (see rtabmap::LaserScan::...
pcl::PointNormal RTABMAP_CORE_EXPORT laserScanToPointNormal(const LaserScan &laserScan, int index)
The point at index of the scan, as PointNormal.
pcl::PointXYZRGBNormal RTABMAP_CORE_EXPORT laserScanToPointRGBNormal(const LaserScan &laserScan, int index, unsigned char r, unsigned char g, unsigned char b)
The point at index of the scan, as PointXYZRGBNormal.
pcl::PointCloud< pcl::PointXYZI >::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudI(const LaserScan &laserScan, const Transform &transform=Transform(), float intensity=0.0f)
LaserScan → PointXYZI (x, y, z, intensity); intensity is used if the scan has none.
pcl::PointCloud< pcl::PointXYZRGBNormal >::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudRGBNormal(const LaserScan &laserScan, const Transform &transform=Transform(), unsigned char r=100, unsigned char g=100, unsigned char b=100)
LaserScan → PointXYZRGBNormal (x, y, z, rgb, nx, ny, nz); missing color and normals are filled as abo...
pcl::PointCloud< pcl::PointXYZINormal >::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudINormal(const LaserScan &laserScan, const Transform &transform=Transform(), float intensity=0.0f)
LaserScan → PointXYZINormal (x, y, z, intensity, nx, ny, nz); missing intensity and normals are fille...
pcl::PointXYZINormal RTABMAP_CORE_EXPORT laserScanToPointINormal(const LaserScan &laserScan, int index, float intensity)
The point at index of the scan, as PointXYZINormal.
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloud(const LaserScan &laserScan, const Transform &transform=Transform())
LaserScan → PointXYZ (x, y, z); any other field of the scan is dropped.
pcl::PointXYZRGB RTABMAP_CORE_EXPORT laserScanToPointRGB(const LaserScan &laserScan, int index, unsigned char r=100, unsigned char g=100, unsigned char b=100)
The point at index of the scan, as PointXYZRGB.
pcl::PointXYZ RTABMAP_CORE_EXPORT laserScanToPoint(const LaserScan &laserScan, int index)
The point at index of the scan, as PointXYZ.
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudRGB(const LaserScan &laserScan, const Transform &transform=Transform(), unsigned char r=100, unsigned char g=100, unsigned char b=100)
LaserScan → PointXYZRGB (x, y, z, rgb); r, g and b are used if the scan has no color.
pcl::PointCloud< pcl::PointNormal >::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudNormal(const LaserScan &laserScan, const Transform &transform=Transform())
LaserScan → PointNormal (x, y, z, nx, ny, nz); normals are zeroed if the scan has none.
pcl::PointCloud< pcl::PointXYZ > RTABMAP_CORE_EXPORT laserScanFromDepthImages(const cv::Mat &depthImages, const std::vector< CameraModel > &cameraModels, float maxDepth, float minDepth)
Converts multiple depth images (e.g., from a stereo or multi-camera setup) into a single laser scan (...
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_CORE_EXPORT cloudFromDisparityRGB(const cv::Mat &imageRgb, const cv::Mat &imageDisparity, const StereoCameraModel &model, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0)
Converts a disparity image and an RGB image to a 3D point cloud with color.
std::vector< pcl::PointCloud< pcl::PointXYZRGB >::Ptr > RTABMAP_CORE_EXPORT cloudsRGBFromSensorData(const SensorData &sensorData, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< pcl::IndicesPtr > *validIndices=0, const ParametersMap &stereoParameters=ParametersMap(), const std::vector< float > &roiRatios=std::vector< float >(), unsigned char confidenceThr=0)
Generates a point cloud with RGB color data from sensor data.
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_CORE_EXPORT cloudRGBFromSensorData(const SensorData &sensorData, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0, const ParametersMap &stereoParameters=ParametersMap(), const std::vector< float > &roiRatios=std::vector< float >(), unsigned char confidenceThr=0)
Generates a point cloud of type pcl::PointXYZRGB from sensor data.
cv::Mat RTABMAP_CORE_EXPORT rgbFromCloud(const pcl::PointCloud< pcl::PointXYZRGBA > &cloud, bool bgrOrder=true)
Converts a PCL point cloud with RGBA information to an OpenCV RGB or BGR image.
pcl::PointCloud< pcl::PointXYZ > RTABMAP_CORE_EXPORT laserScanFromDepthImage(const cv::Mat &depthImage, float fx, float fy, float cx, float cy, float maxDepth=0, float minDepth=0, const Transform &localTransform=Transform::getIdentity())
Converts the middle row of a depth image into a laser scan (point cloud) using camera intrinsics and ...
pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_CORE_EXPORT cloudFromStereoImages(const cv::Mat &imageLeft, const cv::Mat &imageRight, const StereoCameraModel &model, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0, const ParametersMap &parameters=ParametersMap())
Converts a pair of stereo images (left and right) into a 3D point cloud with RGB color information.
cv::Point3f RTABMAP_CORE_EXPORT projectDisparityTo3D(const cv::Point2f &pt, float disparity, const StereoCameraModel &model)
Projects a 2D point from the left image and its disparity into 3D space.
RTABMAP_DEPRECATED pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_CORE_EXPORT cloudFromDepth(const cv::Mat &imageDepth, float cx, float cy, float fx, float fy, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0)
Converts a depth image to a 3D point cloud.
pcl::PointXYZ RTABMAP_CORE_EXPORT projectDepthTo3D(const cv::Mat &depthImage, float x, float y, float cx, float cy, float fx, float fy, bool smoothing, float depthErrorRatio=0.02f)
Projects a single depth pixel into 3D space.
void RTABMAP_CORE_EXPORT savePCDWords(const std::string &fileName, const std::multimap< int, pcl::PointXYZ > &words, const Transform &transform=Transform::getIdentity())
Saves 3D word points to a PCD file, applying a transform to each point.
void RTABMAP_CORE_EXPORT rgbdFromCloud(const pcl::PointCloud< pcl::PointXYZRGBA > &cloud, cv::Mat &rgb, cv::Mat &depth, bool bgrOrder=true, bool depth16U=true)
Converts a PCL point cloud (with RGBA colors) into aligned RGB and depth OpenCV images.
cv::Mat RTABMAP_CORE_EXPORT loadBINScan(const std::string &fileName)
Loads a KITTI-style Velodyne binary scan file into an OpenCV matrix.
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_CORE_EXPORT loadBINCloud(const std::string &fileName)
Loads a KITTI-style Velodyne binary scan and converts it to a PCL point cloud.
Eigen::Vector3f RTABMAP_CORE_EXPORT projectDepthTo3DRay(const cv::Size &imageSize, float x, float y, float cx, float cy, float fx, float fy)
Projects pixel coordinates to a normalized 3D ray in camera coordinates.
cv::Mat RTABMAP_CORE_EXPORT projectCloudToCamera(const cv::Size &imageSize, const cv::Mat &cameraMatrixK, const cv::Mat &laserScan, const rtabmap::Transform &cameraTransform)
Register a point cloud (laser scan) to the camera's frame of reference and return a registered depth ...
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_CORE_EXPORT concatenateClouds(const std::list< pcl::PointCloud< pcl::PointXYZ >::Ptr > &clouds)
Concatenates a list of PointXYZ point clouds into a single point cloud.
RTABMAP_DEPRECATED pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_CORE_EXPORT loadCloud(const std::string &path, const Transform &transform=Transform::getIdentity(), int downsampleStep=1, float voxelSize=0.0f)
Loads and optionally transforms/downsamples/voxelizes a point cloud.
RTABMAP_DEPRECATED pcl::PointCloud< pcl::PointXYZRGB >::Ptr RTABMAP_CORE_EXPORT cloudFromDepthRGB(const cv::Mat &imageRgb, const cv::Mat &imageDepth, float cx, float cy, float fx, float fy, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0)
Creates a point cloud from an RGB image and a depth image.
void RTABMAP_CORE_EXPORT fillProjectedCloudHoles(cv::Mat &depthRegistered, bool verticalDirection, bool fillToBorder)
Fills holes (missing depth values) in a depth image by interpolating between non-zero values.
std::vector< std::pair< std::pair< int, int >, pcl::PointXY > > RTABMAP_CORE_EXPORT projectCloudToCameras(const pcl::PointCloud< pcl::PointXYZRGBNormal > &cloud, const std::map< int, Transform > &cameraPoses, const std::map< int, std::vector< CameraModel > > &cameraModels, float maxDistance=0.0f, float maxAngle=0.0f, float maxDepthError=0.0f, const std::vector< float > &roiRatios=std::vector< float >(), const cv::Mat &projMask=cv::Mat(), bool distanceToCamPolicy=false, const ProgressState *state=0)
Projects a 3D point cloud to the best camera (NodeID -> CameraIndex) for each point based on a policy...
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_CORE_EXPORT cloudFromSensorData(const SensorData &sensorData, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0, const ParametersMap &stereoParameters=ParametersMap(), const std::vector< float > &roiRatios=std::vector< float >(), unsigned char confidenceThr=0)
Generates a point cloud from sensor data.
cv::Mat RTABMAP_CORE_EXPORT depthFromCloud(const pcl::PointCloud< pcl::PointXYZRGBA > &cloud, bool depth16U=true)
Generates a depth image from a PCL organized point cloud.
bool RTABMAP_CORE_EXPORT isFinite(const cv::Point3f &pt)
Checks if all coordinates of a 3D point are finite.
void RTABMAP_CORE_EXPORT getMinMax3D(const cv::Mat &laserScan, cv::Point3f &min, cv::Point3f &max)
Computes the minimum and maximum 3D points from a laser scan matrix.
std::vector< pcl::PointCloud< pcl::PointXYZ >::Ptr > RTABMAP_CORE_EXPORT cloudsFromSensorData(const SensorData &sensorData, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< pcl::IndicesPtr > *validIndices=0, const ParametersMap &stereoParameters=ParametersMap(), const std::vector< float > &roiRatios=std::vector< float >(), unsigned char confidenceThr=0)
Generates a set of point clouds from sensor data.
cv::Mat RTABMAP_CORE_EXPORT filterFloor(const cv::Mat &depth, const std::vector< CameraModel > &cameraModels, float threshold, cv::Mat *depthBelow=0)
Filters out points below a certain threshold in a depth image based on camera models.
LaserScan RTABMAP_CORE_EXPORT deskew(const LaserScan &input, double inputStamp, const rtabmap::Transform &velocity)
Lidar deskewing.
pcl::PointCloud< pcl::PointXYZ >::Ptr RTABMAP_CORE_EXPORT cloudFromDisparity(const cv::Mat &imageDisparity, const StereoCameraModel &model, int decimation=1, float maxDepth=0.0f, float minDepth=0.0f, std::vector< int > *validIndices=0)
Converts a disparity image to a 3D point cloud.
LaserScan RTABMAP_CORE_EXPORT loadScan(const std::string &path)
Loads a 3D scan from a file (.pcd, .ply, or .bin format).
pcl::IndicesPtr RTABMAP_CORE_EXPORT concatenate(const std::vector< pcl::IndicesPtr > &indices)
Concatenates multiple sets of indices into a single index vector.
std::map< std::string, std::string > ParametersMap
Parameter keys mapped to their values, as used by every configurable class (see Parameters).
Definition Parameters.h:44
This namespace contains 3D point cloud processing utilities.
Definition util3d.h:59