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
697LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
702LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
707LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointNormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
712LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointNormal> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
717LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
722LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGB> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
727LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGB> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
732LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
737LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
742LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<rtabmap::PointXYZIRT> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
747LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<rtabmap::PointXYZIRT> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
752LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGB> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
757LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
762LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
767LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
772LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZINormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
777LaserScan RTABMAP_CORE_EXPORT laserScanFromPointCloud(const pcl::PointCloud<pcl::PointXYZINormal> & cloud, const pcl::IndicesPtr & indices, const Transform & transform = Transform(), bool filterNaNs = true);
778
783template<typename PointCloud2T>
784LaserScan laserScanFromPointCloud(const PointCloud2T & cloud, bool filterNaNs = true, bool is2D = false, const Transform & transform = Transform());
785
810LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
815LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
820LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointNormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
825LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZ> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
830LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZINormal> & cloud, const Transform & transform = Transform(), bool filterNaNs = true);
835LaserScan RTABMAP_CORE_EXPORT laserScan2dFromPointCloud(const pcl::PointCloud<pcl::PointXYZI> & cloud, const pcl::PointCloud<pcl::Normal> & normals, const Transform & transform = Transform(), bool filterNaNs = true);
836
853pcl::PCLPointCloud2::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloud2(const LaserScan & laserScan, const Transform & transform = Transform());
854pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloud(const LaserScan & laserScan, const Transform & transform = Transform());
855pcl::PointCloud<pcl::PointNormal>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudNormal(const LaserScan & laserScan, const Transform & transform = Transform());
856pcl::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);
857pcl::PointCloud<pcl::PointXYZI>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudI(const LaserScan & laserScan, const Transform & transform = Transform(), float intensity = 0.0f);
858pcl::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);
859pcl::PointCloud<pcl::PointXYZINormal>::Ptr RTABMAP_CORE_EXPORT laserScanToPointCloudINormal(const LaserScan & laserScan, const Transform & transform = Transform(), float intensity = 0.0f);
860
861
862pcl::PointXYZ RTABMAP_CORE_EXPORT laserScanToPoint(const LaserScan & laserScan, int index);
863pcl::PointNormal RTABMAP_CORE_EXPORT laserScanToPointNormal(const LaserScan & laserScan, int index);
864pcl::PointXYZRGB RTABMAP_CORE_EXPORT laserScanToPointRGB(const LaserScan & laserScan, int index, unsigned char r = 100, unsigned char g = 100, unsigned char b = 100);
865pcl::PointXYZI RTABMAP_CORE_EXPORT laserScanToPointI(const LaserScan & laserScan, int index, float intensity);
866pcl::PointXYZRGBNormal RTABMAP_CORE_EXPORT laserScanToPointRGBNormal(const LaserScan & laserScan, int index, unsigned char r, unsigned char g, unsigned char b);
867pcl::PointXYZINormal RTABMAP_CORE_EXPORT laserScanToPointINormal(const LaserScan & laserScan, int index, float intensity);
868
890void RTABMAP_CORE_EXPORT getMinMax3D(const cv::Mat & laserScan, cv::Point3f & min, cv::Point3f & max);
891
905void RTABMAP_CORE_EXPORT getMinMax3D(const cv::Mat & laserScan, pcl::PointXYZ & min, pcl::PointXYZ & max);
906
929cv::Point3f RTABMAP_CORE_EXPORT projectDisparityTo3D(
930 const cv::Point2f & pt,
931 float disparity,
932 const StereoCameraModel & model);
933
952cv::Point3f RTABMAP_CORE_EXPORT projectDisparityTo3D(
953 const cv::Point2f & pt,
954 const cv::Mat & disparity,
955 const StereoCameraModel & model);
956
977cv::Mat RTABMAP_CORE_EXPORT projectCloudToCamera(
978 const cv::Size & imageSize,
979 const cv::Mat & cameraMatrixK,
980 const cv::Mat & laserScan,
981 const rtabmap::Transform & cameraTransform);
982
1003cv::Mat RTABMAP_CORE_EXPORT projectCloudToCamera(
1004 const cv::Size & imageSize,
1005 const cv::Mat & cameraMatrixK,
1006 const pcl::PointCloud<pcl::PointXYZ>::Ptr laserScan,
1007 const rtabmap::Transform & cameraTransform);
1008
1029cv::Mat RTABMAP_CORE_EXPORT projectCloudToCamera(
1030 const cv::Size & imageSize,
1031 const cv::Mat & cameraMatrixK,
1032 const pcl::PCLPointCloud2::Ptr laserScan,
1033 const rtabmap::Transform & cameraTransform);
1034
1054void RTABMAP_CORE_EXPORT fillProjectedCloudHoles(
1055 cv::Mat & depthRegistered,
1056 bool verticalDirection,
1057 bool fillToBorder);
1058
1087cv::Mat RTABMAP_CORE_EXPORT filterFloor(
1088 const cv::Mat & depth,
1089 const std::vector<CameraModel> & cameraModels,
1090 float threshold,
1091 cv::Mat * depthBelow = 0);
1092
1113std::vector<std::pair< std::pair<int, int>, pcl::PointXY> > RTABMAP_CORE_EXPORT projectCloudToCameras (
1114 const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud,
1115 const std::map<int, Transform> & cameraPoses,
1116 const std::map<int, std::vector<CameraModel> > & cameraModels,
1117 float maxDistance = 0.0f,
1118 float maxAngle = 0.0f,
1119 float maxDepthError = 0.0f,
1120 const std::vector<float> & roiRatios = std::vector<float>(),
1121 const cv::Mat & projMask = cv::Mat(),
1122 bool distanceToCamPolicy = false,
1123 const ProgressState * state = 0);
1144std::vector<std::pair< std::pair<int, int>, pcl::PointXY> > RTABMAP_CORE_EXPORT projectCloudToCameras (
1145 const pcl::PointCloud<pcl::PointXYZINormal> & cloud,
1146 const std::map<int, Transform> & cameraPoses,
1147 const std::map<int, std::vector<CameraModel> > & cameraModels,
1148 float maxDistance = 0.0f,
1149 float maxAngle = 0.0f,
1150 float maxDepthError = 0.0f,
1151 const std::vector<float> & roiRatios = std::vector<float>(),
1152 const cv::Mat & projMask = cv::Mat(),
1153 bool distanceToCamPolicy = false,
1154 const ProgressState * state = 0);
1155
1165bool RTABMAP_CORE_EXPORT isFinite(const cv::Point3f & pt);
1166
1176pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT concatenateClouds(
1177 const std::list<pcl::PointCloud<pcl::PointXYZ>::Ptr> & clouds);
1187pcl::PointCloud<pcl::PointXYZRGB>::Ptr RTABMAP_CORE_EXPORT concatenateClouds(
1188 const std::list<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds);
1189
1204pcl::IndicesPtr RTABMAP_CORE_EXPORT concatenate(
1205 const std::vector<pcl::IndicesPtr> & indices);
1206
1221pcl::IndicesPtr RTABMAP_CORE_EXPORT concatenate(
1222 const pcl::IndicesPtr & indicesA,
1223 const pcl::IndicesPtr & indicesB);
1224
1236void RTABMAP_CORE_EXPORT savePCDWords(
1237 const std::string & fileName,
1238 const std::multimap<int, pcl::PointXYZ> & words,
1239 const Transform & transform = Transform::getIdentity());
1240
1252void RTABMAP_CORE_EXPORT savePCDWords(
1253 const std::string & fileName,
1254 const std::multimap<int, cv::Point3f> & words,
1255 const Transform & transform = Transform::getIdentity());
1256
1267cv::Mat RTABMAP_CORE_EXPORT loadBINScan(const std::string & fileName);
1276pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT loadBINCloud(const std::string & fileName);
1285RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT loadBINCloud(const std::string & fileName, int dim);
1286
1297LaserScan RTABMAP_CORE_EXPORT loadScan(const std::string & path);
1298
1312RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT loadCloud(
1313 const std::string & path,
1314 const Transform & transform = Transform::getIdentity(),
1315 int downsampleStep = 1,
1316 float voxelSize = 0.0f);
1317
1349LaserScan RTABMAP_CORE_EXPORT deskew(
1350 const LaserScan & input,
1351 double inputStamp,
1352 const rtabmap::Transform & velocity);
1353
1354} // namespace util3d
1355} // namespace rtabmap
1356
1357POINT_CLOUD_REGISTER_POINT_STRUCT(rtabmap::PointXYZIRT,
1358 (float, x, x)
1359 (float, y, y)
1360 (float, z, z)
1361 (float, intensity, intensity)
1362 (std::uint16_t, ring, ring)
1363 (float, time, time)
1364)
1365
1366#include "rtabmap/core/impl/util3d.hpp"
1367
1368#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::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::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