31#include "rtabmap/core/rtabmap_core_export.h"
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>
63 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
94 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
95 bool bgrOrder =
true);
112 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
113 bool depth16U =
true);
131 const pcl::PointCloud<pcl::PointXYZRGBA> & cloud,
134 bool bgrOrder =
true,
135 bool depth16U =
true);
156 const cv::Mat & depthImage,
161 float depthErrorRatio = 0.02f);
180 const cv::Size & imageSize,
207RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT
cloudFromDepth(
208 const cv::Mat & imageDepth,
212 float maxDepth = 0.0f,
213 float minDepth = 0.0f,
214 std::vector<int> * validIndices = 0);
231 const cv::Mat & imageDepth,
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,
242 float maxDepth = 0.0f,
243 float minDepth = 0.0f,
244 unsigned char confidenceThr = 0,
245 std::vector<int> * validIndices = 0);
273 const cv::Mat & imageRgb,
274 const cv::Mat & imageDepth,
278 float maxDepth = 0.0f,
279 float minDepth = 0.0f,
280 std::vector<int> * validIndices = 0);
304 const cv::Mat & imageRgb,
305 const cv::Mat & imageDepth,
308 float maxDepth = 0.0f,
309 float minDepth = 0.0f,
310 std::vector<int> * validIndices = 0);
312 const cv::Mat & imageRgb,
313 const cv::Mat & imageDepth,
314 const cv::Mat & imageDepthConfidence,
317 float maxDepth = 0.0f,
318 float minDepth = 0.0f,
319 unsigned char confidenceThr = 0,
320 std::vector<int> * validIndices = 0);
352 const cv::Mat & imageDisparity,
355 float maxDepth = 0.0f,
356 float minDepth = 0.0f,
357 std::vector<int> * validIndices = 0);
393 const cv::Mat & imageRgb,
394 const cv::Mat & imageDisparity,
397 float maxDepth = 0.0f,
398 float minDepth = 0.0f,
399 std::vector<int> * validIndices = 0);
438 const cv::Mat & imageLeft,
439 const cv::Mat & imageRight,
442 float maxDepth = 0.0f,
443 float minDepth = 0.0f,
444 std::vector<int> * validIndices = 0,
488 float maxDepth = 0.0f,
489 float minDepth = 0.0f,
490 std::vector<pcl::IndicesPtr> * validIndices = 0,
492 const std::vector<float> & roiRatios = std::vector<float>(),
493 unsigned char confidenceThr = 0);
526 float maxDepth = 0.0f,
527 float minDepth = 0.0f,
528 std::vector<int> * validIndices = 0,
530 const std::vector<float> & roiRatios = std::vector<float>(),
531 unsigned char confidenceThr = 0);
568 float maxDepth = 0.0f,
569 float minDepth = 0.0f,
570 std::vector<pcl::IndicesPtr > * validIndices = 0,
572 const std::vector<float> & roiRatios = std::vector<float>(),
573 unsigned char confidenceThr = 0);
604 float maxDepth = 0.0f,
605 float minDepth = 0.0f,
606 std::vector<int> * validIndices = 0,
608 const std::vector<float> & roiRatios = std::vector<float>(),
609 unsigned char confidenceThr = 0);
634 const cv::Mat & depthImage,
662 const cv::Mat & depthImages,
663 const std::vector<CameraModel> & cameraModels,
730template<
typename Po
intCloud2T>
805pcl::PointXYZRGB RTABMAP_CORE_EXPORT
laserScanToPointRGB(
const LaserScan & laserScan,
int index,
unsigned char r = 100,
unsigned char g = 100,
unsigned char b = 100);
834void RTABMAP_CORE_EXPORT
getMinMax3D(
const cv::Mat & laserScan, cv::Point3f & min, cv::Point3f & max);
849void RTABMAP_CORE_EXPORT
getMinMax3D(
const cv::Mat & laserScan, pcl::PointXYZ & min, pcl::PointXYZ & max);
874 const cv::Point2f & pt,
897 const cv::Point2f & pt,
898 const cv::Mat & disparity,
922 const cv::Size & imageSize,
923 const cv::Mat & cameraMatrixK,
924 const cv::Mat & laserScan,
948 const cv::Size & imageSize,
949 const cv::Mat & cameraMatrixK,
950 const pcl::PointCloud<pcl::PointXYZ>::Ptr laserScan,
974 const cv::Size & imageSize,
975 const cv::Mat & cameraMatrixK,
976 const pcl::PCLPointCloud2::Ptr laserScan,
999 cv::Mat & depthRegistered,
1000 bool verticalDirection,
1032 const cv::Mat & depth,
1033 const std::vector<CameraModel> & cameraModels,
1035 cv::Mat * depthBelow = 0);
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,
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,
1109bool RTABMAP_CORE_EXPORT
isFinite(
const cv::Point3f & pt);
1121 const std::list<pcl::PointCloud<pcl::PointXYZ>::Ptr> & clouds);
1132 const std::list<pcl::PointCloud<pcl::PointXYZRGB>::Ptr> & clouds);
1149 const std::vector<pcl::IndicesPtr> & indices);
1166 const pcl::IndicesPtr & indicesA,
1167 const pcl::IndicesPtr & indicesB);
1181 const std::string & fileName,
1182 const std::multimap<int, pcl::PointXYZ> & words,
1197 const std::string & fileName,
1198 const std::multimap<int, cv::Point3f> & words,
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);
1256RTABMAP_DEPRECATED pcl::PointCloud<pcl::PointXYZ>::Ptr RTABMAP_CORE_EXPORT
loadCloud(
1257 const std::string & path,
1259 int downsampleStep = 1,
1260 float voxelSize = 0.0f);
1305 (
float, intensity, intensity)
1306 (std::uint16_t, ring, ring)
1310#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.