RTAB-Map 0.23.10
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 "rtabmap/core/rtabmap_core_export.h"
32
33#include <pcl/point_cloud.h>
34#include <pcl/point_types.h>
35#include <pcl/pcl_base.h>
36#include <pcl/TextureMesh.h>
37#include <rtabmap/core/Transform.h>
38#include <rtabmap/core/SensorData.h>
39#include <rtabmap/core/Parameters.h>
40#include <opencv2/core/core.hpp>
41#include <rtabmap/core/ProgressState.h>
42#include <cstdint>
43#include <map>
44#include <list>
45
46namespace rtabmap
47{
48
53// Point type carrying xyz + intensity + ring (laser line index) + time
54// (per-point acquisition offset, seconds from the scan start). Matches the
55// layout expected by LIO-SAM's Velodyne feature extractor so it can be fed
56// directly via util3d::laserScanFromPointCloud().
57struct EIGEN_ALIGN16 PointXYZIRT
58{
59 PCL_ADD_POINT4D;
60 float intensity;
61 std::uint16_t ring;
62 float time;
63 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
64};
65
74namespace util3d
75{
76
93cv::Mat RTABMAP_CORE_EXPORT rgbFromCloud(
94 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
95 bool bgrOrder = true);
96
111cv::Mat RTABMAP_CORE_EXPORT depthFromCloud(
112 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
113 bool depth16U = true);
114
130void RTABMAP_CORE_EXPORT rgbdFromCloud(
131 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
132 cv::Mat & rgb,
133 cv::Mat & depth,
134 bool bgrOrder = true,
135 bool depth16U = true);
136
155pcl::PointXYZ RTABMAP_CORE_EXPORT projectDepthTo3D(
156 const cv::Mat & depthImage,
157 float x, float y,
158 float cx, float cy,
159 float fx, float fy,
160 bool smoothing,
161 float depthErrorRatio = 0.02f);
162
179Eigen::Vector3f RTABMAP_CORE_EXPORT projectDepthTo3DRay(
180 const cv::Size & imageSize,
181 float x, float y,
182 float cx, float cy,
183 float fx, float fy);
184
207RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT cloudFromDepth(
208 const cv::Mat & imageDepth,
209 float cx, float cy,
210 float fx, float fy,
211 int decimation = 1,
212 float maxDepth = 0.0f,
213 float minDepth = 0.0f,
214 std::vector<int> * validIndices = 0);
230pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT cloudFromDepth(
231 const cv::Mat & imageDepth,
232 const CameraModel & model,
233 int decimation = 1,
234 float maxDepth = 0.0f,
235 float minDepth = 0.0f,
236 std::vector<int> * validIndices = 0);
237pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT cloudFromDepth(
238 const cv::Mat & imageDepth,
239 const cv::Mat & imageDepthConfidence,
240 const CameraModel & model,
241 int decimation = 1,
242 float maxDepth = 0.0f,
243 float minDepth = 0.0f,
244 unsigned char confidenceThr = 0,
245 std::vector<int> * validIndices = 0);
246
272RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudFromDepthRGB(
273 const cv::Mat & imageRgb,
274 const cv::Mat & imageDepth,
275 float cx, float cy,
276 float fx, float fy,
277 int decimation = 1,
278 float maxDepth = 0.0f,
279 float minDepth = 0.0f,
280 std::vector<int> * validIndices = 0);
281
303pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudFromDepthRGB(
304 const cv::Mat & imageRgb,
305 const cv::Mat & imageDepth,
306 const CameraModel & model,
307 int decimation = 1,
308 float maxDepth = 0.0f,
309 float minDepth = 0.0f,
310 std::vector<int> * validIndices = 0);
311pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudFromDepthRGB(
312 const cv::Mat & imageRgb,
313 const cv::Mat & imageDepth,
314 const cv::Mat & imageDepthConfidence,
315 const CameraModel & model,
316 int decimation = 1,
317 float maxDepth = 0.0f,
318 float minDepth = 0.0f,
319 unsigned char confidenceThr = 0, // 0=low, 100=high
320 std::vector<int> * validIndices = 0);
321
351pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT cloudFromDisparity(
352 const cv::Mat & imageDisparity,
353 const StereoCameraModel & model,
354 int decimation = 1,
355 float maxDepth = 0.0f,
356 float minDepth = 0.0f,
357 std::vector<int> * validIndices = 0);
358
392pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudFromDisparityRGB(
393 const cv::Mat & imageRgb,
394 const cv::Mat & imageDisparity,
395 const StereoCameraModel & model,
396 int decimation = 1,
397 float maxDepth = 0.0f,
398 float minDepth = 0.0f,
399 std::vector<int> * validIndices = 0);
400
437pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudFromStereoImages(
438 const cv::Mat & imageLeft,
439 const cv::Mat & imageRight,
440 const StereoCameraModel & model,
441 int decimation = 1,
442 float maxDepth = 0.0f,
443 float minDepth = 0.0f,
444 std::vector<int> * validIndices = 0,
445 const ParametersMap & parameters = ParametersMap());
446
485std::vector<pcl::PointCloud<pcl::PointXYZ>::Ptr> RTABMAP_CORE_EXPORT cloudsFromSensorData(
486 const SensorData & sensorData,
487 int decimation = 1,
488 float maxDepth = 0.0f,
489 float minDepth = 0.0f,
490 std::vector<pcl::IndicesPtr> * validIndices = 0,
491 const ParametersMap & stereoParameters = ParametersMap(),
492 const std::vector<float> & roiRatios = std::vector<float>(), // ignored for stereo
493 unsigned char confidenceThr = 0); // ignored for stereo
494
523pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT cloudFromSensorData(
524 const SensorData & sensorData,
525 int decimation = 1,
526 float maxDepth = 0.0f,
527 float minDepth = 0.0f,
528 std::vector<int> * validIndices = 0,
529 const ParametersMap & stereoParameters = ParametersMap(),
530 const std::vector<float> & roiRatios = std::vector<float>(), // ignored for stereo
531 unsigned char confidenceThr = 0); // ignored for stereo
532
565std::vector<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> RTABMAP_CORE_EXPORT cloudsRGBFromSensorData(
566 const SensorData & sensorData,
567 int decimation = 1,
568 float maxDepth = 0.0f,
569 float minDepth = 0.0f,
570 std::vector<pcl::IndicesPtr > * validIndices = 0,
571 const ParametersMap & stereoParameters = ParametersMap(),
572 const std::vector<float> & roiRatios = std::vector<float>(), // ignored for stereo
573 unsigned char confidenceThr = 0); // ignored for stereo
574
601pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT cloudRGBFromSensorData(
602 const SensorData & sensorData,
603 int decimation = 1,
604 float maxDepth = 0.0f,
605 float minDepth = 0.0f,
606 std::vector<int> * validIndices = 0,
607 const ParametersMap & stereoParameters = ParametersMap(),
608 const std::vector<float> & roiRatios = std::vector<float>(), // ignored for stereo
609 unsigned char confidenceThr = 0); // ignored for stereo
610
633pcl::PointCloud<pcl::PointXYZ> RTABMAP_CORE_EXPORT laserScanFromDepthImage(
634 const cv::Mat & depthImage,
635 float fx,
636 float fy,
637 float cx,
638 float cy,
639 float maxDepth = 0,
640 float minDepth = 0,
641 const Transform & localTransform = Transform::getIdentity());
661pcl::PointCloud<pcl::PointXYZ> RTABMAP_CORE_EXPORT laserScanFromDepthImages(
662 const cv::Mat & depthImages,
663 const std::vector<CameraModel> & cameraModels,
664 float maxDepth,
665 float minDepth);
666
695LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
697LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
699LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointNormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
701LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointNormal> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
703LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
705LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGB> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
707LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGB> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
709LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
711LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
713LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<rtabmap::PointXYZIRT> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
715LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<rtabmap::PointXYZIRT> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
717LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGB> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
719LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
721LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
723LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
725LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZINormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
727LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZINormal> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
728
730template<typename PointCloud2T>
731LaserScan laserScanFromPointCloud(const PointCloud2T & cloud, bool filterNaNs = true, bool is2D = false, const Transform & transform = Transform());
756LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
758LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
760LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointNormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
762LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
764LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZINormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
766LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
785pcl::PCLPointCloud2::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloud2(const LaserScan & laserScan, const Transform & transform = Transform());
787pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloud(const LaserScan & laserScan, const Transform & transform = Transform());
789pcl::PointCloud<pcl::PointNormal>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudNormal(const LaserScan & laserScan, const Transform & transform = Transform());
791pcl::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);
793pcl::PointCloud<pcl::PointXYZI>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudI(const LaserScan & laserScan, const Transform & transform = Transform(), float intensity = 0.0f);
795pcl::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);
797pcl::PointCloud<pcl::PointXYZINormal>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudINormal(const LaserScan & laserScan, const Transform & transform = Transform(), float intensity = 0.0f);
798
799
801pcl::PointXYZ RTABMAP_CORE_EXPORT laserScanToPoint(const LaserScan & laserScan, int index);
803pcl::PointNormal RTABMAP_CORE_EXPORT laserScanToPointNormal(const LaserScan & laserScan, int index);
805pcl::PointXYZRGB RTABMAP_CORE_EXPORT laserScanToPointRGB(const LaserScan & laserScan, int index, unsigned char r = 100, unsigned char g = 100, unsigned char b = 100);
807pcl::PointXYZI RTABMAP_CORE_EXPORT laserScanToPointI(const LaserScan & laserScan, int index, float intensity);
809pcl::PointXYZRGBNormal RTABMAP_CORE_EXPORT laserScanToPointRGBNormal(const LaserScan & laserScan, int index, unsigned char r, unsigned char g, unsigned char b);
811pcl::PointXYZINormal RTABMAP_CORE_EXPORT laserScanToPointINormal(const LaserScan & laserScan, int index, float intensity);
812
834void RTABMAP_CORE_EXPORT getMinMax3D(const cv::Mat & laserScan, cv::Point3f & min, cv::Point3f & max);
835
849void RTABMAP_CORE_EXPORT getMinMax3D(const cv::Mat & laserScan, pcl::PointXYZ & min, pcl::PointXYZ & max);
850
873cv::Point3f RTABMAP_CORE_EXPORT projectDisparityTo3D(
874 const cv::Point2f & pt,
875 float disparity,
876 const StereoCameraModel & model);
877
896cv::Point3f RTABMAP_CORE_EXPORT projectDisparityTo3D(
897 const cv::Point2f & pt,
898 const cv::Mat & disparity,
899 const StereoCameraModel & model);
900
921cv::Mat RTABMAP_CORE_EXPORT projectCloudToCamera(
922 const cv::Size & imageSize,
923 const cv::Mat & cameraMatrixK,
924 const cv::Mat & laserScan,
925 const rtabmap::Transform & cameraTransform);
926
947cv::Mat RTABMAP_CORE_EXPORT projectCloudToCamera(
948 const cv::Size & imageSize,
949 const cv::Mat & cameraMatrixK,
950 const pcl::PointCloud<pcl::PointXYZ>::Ptr laserScan,
951 const rtabmap::Transform & cameraTransform);
952
973cv::Mat RTABMAP_CORE_EXPORT projectCloudToCamera(
974 const cv::Size & imageSize,
975 const cv::Mat & cameraMatrixK,
976 const pcl::PCLPointCloud2::Ptr laserScan,
977 const rtabmap::Transform & cameraTransform);
978
998void RTABMAP_CORE_EXPORT fillProjectedCloudHoles(
999 cv::Mat & depthRegistered,
1000 bool verticalDirection,
1001 bool fillToBorder);
1002
1031cv::Mat RTABMAP_CORE_EXPORT filterFloor(
1032 const cv::Mat & depth,
1033 const std::vector<CameraModel> & cameraModels,
1034 float threshold,
1035 cv::Mat * depthBelow = 0);
1036
1057std::vector<std::pair< std::pair<int, int>, pcl::PointXY> > RTABMAP_CORE_EXPORT projectCloudToCameras (
1058 const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud,
1059 const std::map<int, Transform> & cameraPoses,
1060 const std::map<int, std::vector<CameraModel> > & cameraModels,
1061 float maxDistance = 0.0f,
1062 float maxAngle = 0.0f,
1063 float maxDepthError = 0.0f,
1064 const std::vector<float> & roiRatios = std::vector<float>(),
1065 const cv::Mat & projMask = cv::Mat(),
1066 bool distanceToCamPolicy = false,
1067 const ProgressState * state = 0);
1088std::vector<std::pair< std::pair<int, int>, pcl::PointXY> > RTABMAP_CORE_EXPORT projectCloudToCameras (
1089 const pcl::PointCloud<pcl::PointXYZINormal> & cloud,
1090 const std::map<int, Transform> & cameraPoses,
1091 const std::map<int, std::vector<CameraModel> > & cameraModels,
1092 float maxDistance = 0.0f,
1093 float maxAngle = 0.0f,
1094 float maxDepthError = 0.0f,
1095 const std::vector<float> & roiRatios = std::vector<float>(),
1096 const cv::Mat & projMask = cv::Mat(),
1097 bool distanceToCamPolicy = false,
1098 const ProgressState * state = 0);
1099
1109bool RTABMAP_CORE_EXPORT isFinite(const cv::Point3f & pt);
1110
1120pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT concatenateClouds(
1121 const std::list<pcl::PointCloud<pcl::PointXYZ>::Ptr> & clouds);
1131pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT concatenateClouds(
1132 const std::list<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds);
1133
1148pcl::IndicesPtr RTABMAP_CORE_EXPORT concatenate(
1149 const std::vector<pcl::IndicesPtr> & indices);
1150
1165pcl::IndicesPtr RTABMAP_CORE_EXPORT concatenate(
1166 const pcl::IndicesPtr & indicesA,
1167 const pcl::IndicesPtr & indicesB);
1168
1180void RTABMAP_CORE_EXPORT savePCDWords(
1181 const std::string & fileName,
1182 const std::multimap<int, pcl::PointXYZ> & words,
1183 const Transform & transform = Transform::getIdentity());
1184
1196void RTABMAP_CORE_EXPORT savePCDWords(
1197 const std::string & fileName,
1198 const std::multimap<int, cv::Point3f> & words,
1199 const Transform & transform = Transform::getIdentity());
1200
1211cv::Mat RTABMAP_CORE_EXPORT loadBINScan(const std::string & fileName);
1220pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT loadBINCloud(const std::string & fileName);
1229RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT loadBINCloud(const std::string & fileName, int dim);
1230
1241LaserScan RTABMAP_CORE_EXPORT loadScan(const std::string & path);
1242
1256RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT loadCloud(
1257 const std::string & path,
1258 const Transform & transform = Transform::getIdentity(),
1259 int downsampleStep = 1,
1260 float voxelSize = 0.0f);
1261
1293LaserScan RTABMAP_CORE_EXPORT deskew(
1294 const LaserScan & input,
1295 double inputStamp,
1296 const rtabmap::Transform & velocity);
1297
1298} // namespace util3d
1299} // namespace rtabmap
1300
1301POINT_CLOUD_REGISTER_POINT_STRUCT(rtabmap::PointXYZIRT,
1302 (float, x, x)
1303 (float, y, y)
1304 (float, z, z)
1305 (float, intensity, intensity)
1306 (std::uint16_t, ring, ring)
1307 (float, time, time)
1308)
1309
1310#include "rtabmap/core/impl/util3d.hpp"
1311
1312#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:58