32#include "rtabmap/core/rtabmap_core_export.h"
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>
64 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
95 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
96 bool bgrOrder =
true);
113 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
114 bool depth16U =
true);
132 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
135 bool bgrOrder =
true,
136 bool depth16U =
true);
157 const cv::Mat & depthImage,
162 float depthErrorRatio = 0.02f);
181 const cv::Size & imageSize,
208RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT
cloudFromDepth(
209 const cv::Mat & imageDepth,
213 float maxDepth = 0.0f,
214 float minDepth = 0.0f,
215 std::vector<int> * validIndices = 0);
232 const cv::Mat & imageDepth,
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,
243 float maxDepth = 0.0f,
244 float minDepth = 0.0f,
245 unsigned char confidenceThr = 0,
246 std::vector<int> * validIndices = 0);
274 const cv::Mat & imageRgb,
275 const cv::Mat & imageDepth,
279 float maxDepth = 0.0f,
280 float minDepth = 0.0f,
281 std::vector<int> * validIndices = 0);
305 const cv::Mat & imageRgb,
306 const cv::Mat & imageDepth,
309 float maxDepth = 0.0f,
310 float minDepth = 0.0f,
311 std::vector<int> * validIndices = 0);
313 const cv::Mat & imageRgb,
314 const cv::Mat & imageDepth,
315 const cv::Mat & imageDepthConfidence,
318 float maxDepth = 0.0f,
319 float minDepth = 0.0f,
320 unsigned char confidenceThr = 0,
321 std::vector<int> * validIndices = 0);
353 const cv::Mat & imageDisparity,
356 float maxDepth = 0.0f,
357 float minDepth = 0.0f,
358 std::vector<int> * validIndices = 0);
394 const cv::Mat & imageRgb,
395 const cv::Mat & imageDisparity,
398 float maxDepth = 0.0f,
399 float minDepth = 0.0f,
400 std::vector<int> * validIndices = 0);
439 const cv::Mat & imageLeft,
440 const cv::Mat & imageRight,
443 float maxDepth = 0.0f,
444 float minDepth = 0.0f,
445 std::vector<int> * validIndices = 0,
489 float maxDepth = 0.0f,
490 float minDepth = 0.0f,
491 std::vector<pcl::IndicesPtr> * validIndices = 0,
493 const std::vector<float> & roiRatios = std::vector<float>(),
494 unsigned char confidenceThr = 0);
527 float maxDepth = 0.0f,
528 float minDepth = 0.0f,
529 std::vector<int> * validIndices = 0,
531 const std::vector<float> & roiRatios = std::vector<float>(),
532 unsigned char confidenceThr = 0);
569 float maxDepth = 0.0f,
570 float minDepth = 0.0f,
571 std::vector<pcl::IndicesPtr > * validIndices = 0,
573 const std::vector<float> & roiRatios = std::vector<float>(),
574 unsigned char confidenceThr = 0);
605 float maxDepth = 0.0f,
606 float minDepth = 0.0f,
607 std::vector<int> * validIndices = 0,
609 const std::vector<float> & roiRatios = std::vector<float>(),
610 unsigned char confidenceThr = 0);
635 const cv::Mat & depthImage,
663 const cv::Mat & depthImages,
664 const std::vector<CameraModel> & cameraModels,
731template<
typename Po
intCloud2T>
806pcl::PointXYZRGB RTABMAP_CORE_EXPORT
laserScanToPointRGB(
const LaserScan & laserScan,
int index,
unsigned char r = 100,
unsigned char g = 100,
unsigned char b = 100);
835void RTABMAP_CORE_EXPORT
getMinMax3D(
const cv::Mat & laserScan, cv::Point3f & min, cv::Point3f & max);
850void RTABMAP_CORE_EXPORT
getMinMax3D(
const cv::Mat & laserScan, pcl::PointXYZ & min, pcl::PointXYZ & max);
875 const cv::Point2f & pt,
898 const cv::Point2f & pt,
899 const cv::Mat & disparity,
923 const cv::Size & imageSize,
924 const cv::Mat & cameraMatrixK,
925 const cv::Mat & laserScan,
949 const cv::Size & imageSize,
950 const cv::Mat & cameraMatrixK,
951 const pcl::PointCloud<pcl::PointXYZ>::Ptr laserScan,
975 const cv::Size & imageSize,
976 const cv::Mat & cameraMatrixK,
977 const pcl::PCLPointCloud2::Ptr laserScan,
1000 cv::Mat & depthRegistered,
1001 bool verticalDirection,
1033 const cv::Mat & depth,
1034 const std::vector<CameraModel> & cameraModels,
1036 cv::Mat * depthBelow = 0);
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,
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,
1110bool RTABMAP_CORE_EXPORT
isFinite(
const cv::Point3f & pt);
1122 const std::list<pcl::PointCloud<pcl::PointXYZ>::Ptr> & clouds);
1133 const std::list<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds);
1150 const std::vector<pcl::IndicesPtr> & indices);
1167 const pcl::IndicesPtr & indicesA,
1168 const pcl::IndicesPtr & indicesB);
1182 const std::string & fileName,
1183 const std::multimap<int, pcl::PointXYZ> & words,
1198 const std::string & fileName,
1199 const std::multimap<int, cv::Point3f> & words,
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);
1257RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT
loadCloud(
1258 const std::string & path,
1260 int downsampleStep = 1,
1261 float voxelSize = 0.0f);
1318 bool slerp =
false);
1327 (
float, intensity, intensity)
1328 (std::uint16_t, ring, ring)
1332#include "rtabmap/core/impl/util3d.hpp"
Represents a pinhole camera model containing intrinsic and extrinsic parameters, used for projection,...
Represents 2D or 3D laser scan data with support for multiple point data formats.
Container class for all sensor data captured at a specific time.
A class representing a calibrated stereo camera system.
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::...
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 ¶meters=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).
This namespace contains 3D point cloud processing utilities.