RTAB-Map 0.23.11
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
util3d_surface.h
1/*
2Copyright (c) 2010-2016, 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_SURFACE_H_
29#define UTIL3D_SURFACE_H_
30
31#include <rtabmap/core/rtabmap_core_export.h>
32
33#include <pcl/PolygonMesh.h>
34#include <pcl/point_cloud.h>
35#include <pcl/point_types.h>
36#include <pcl/TextureMesh.h>
37#include <pcl/pcl_base.h>
38#include <rtabmap/core/Transform.h>
39#include <rtabmap/core/CameraModel.h>
40#include <rtabmap/core/ProgressState.h>
41#include <rtabmap/core/LaserScan.h>
42#include <rtabmap/core/Version.h>
43#include <set>
44#include <list>
45
46namespace rtabmap
47{
48
49class Memory;
50class DBDriver;
51
52namespace util3d
53{
54
64void RTABMAP_CORE_EXPORT createPolygonIndexes(
65 const std::vector<pcl::Vertices> & polygons,
66 int cloudSize,
67 std::vector<std::set<int> > & neighborPolygons,
68 std::vector<std::set<int> > & vertexPolygons);
69
70std::list<std::list<int> > RTABMAP_CORE_EXPORT clusterPolygons(
71 const std::vector<std::set<int> > & neighborPolygons,
72 int minClusterSize = 0);
73
74std::vector<pcl::Vertices> RTABMAP_CORE_EXPORT organizedFastMesh(
75 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
76 double angleTolerance,
77 bool quad,
78 int trianglePixelSize,
79 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0));
80std::vector<pcl::Vertices> RTABMAP_CORE_EXPORT organizedFastMesh(
81 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
82 double angleTolerance = M_PI/16,
83 bool quad=true,
84 int trianglePixelSize = 2,
85 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0));
86std::vector<pcl::Vertices> RTABMAP_CORE_EXPORT organizedFastMesh(
87 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
88 double angleTolerance = M_PI/16,
89 bool quad=true,
90 int trianglePixelSize = 2,
91 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0));
92
93void RTABMAP_CORE_EXPORT appendMesh(
94 pcl::PointCloud<pcl::PointXYZRGBNormal> & cloudA,
95 std::vector<pcl::Vertices> & polygonsA,
96 const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloudB,
97 const std::vector<pcl::Vertices> & polygonsB);
98void RTABMAP_CORE_EXPORT appendMesh(
99 pcl::PointCloud<pcl::PointXYZRGB> & cloudA,
100 std::vector<pcl::Vertices> & polygonsA,
101 const pcl::PointCloud<pcl::PointXYZRGB> & cloudB,
102 const std::vector<pcl::Vertices> & polygonsB);
103
104// return map from new to old polygon indices
105std::vector<int> RTABMAP_CORE_EXPORT filterNotUsedVerticesFromMesh(
106 const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud,
107 const std::vector<pcl::Vertices> & polygons,
108 pcl::PointCloud<pcl::PointXYZRGBNormal> & outputCloud,
109 std::vector<pcl::Vertices> & outputPolygons);
110std::vector<int> RTABMAP_CORE_EXPORT filterNotUsedVerticesFromMesh(
111 const pcl::PointCloud<pcl::PointXYZRGB> & cloud,
112 const std::vector<pcl::Vertices> & polygons,
113 pcl::PointCloud<pcl::PointXYZRGB> & outputCloud,
114 std::vector<pcl::Vertices> & outputPolygons);
115std::vector<int> RTABMAP_CORE_EXPORT filterNaNPointsFromMesh(
116 const pcl::PointCloud<pcl::PointXYZRGB> & cloud,
117 const std::vector<pcl::Vertices> & polygons,
118 pcl::PointCloud<pcl::PointXYZRGB> & outputCloud,
119 std::vector<pcl::Vertices> & outputPolygons);
120
121std::vector<pcl::Vertices> RTABMAP_CORE_EXPORT filterCloseVerticesFromMesh(
122 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr cloud,
123 const std::vector<pcl::Vertices> & polygons,
124 float radius,
125 float angle,
126 bool keepLatestInRadius);
127
128std::vector<pcl::Vertices> RTABMAP_CORE_EXPORT filterInvalidPolygons(
129 const std::vector<pcl::Vertices> & polygons);
130
131pcl::PolygonMesh::Ptr RTABMAP_CORE_EXPORT createMesh(
132 const pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloudWithNormals,
133 float gp3SearchRadius = 0.025,
134 float gp3Mu = 2.5,
135 int gp3MaximumNearestNeighbors = 100,
136 float gp3MaximumSurfaceAngle = M_PI/4,
137 float gp3MinimumAngle = M_PI/18,
138 float gp3MaximumAngle = 2*M_PI/3,
139 bool gp3NormalConsistency = true);
140
141pcl::TextureMesh::Ptr RTABMAP_CORE_EXPORT createTextureMesh(
142 const pcl::PolygonMesh::Ptr & mesh,
143 const std::map<int, Transform> & poses,
144 const std::map<int, CameraModel> & cameraModels,
145 const std::map<int, cv::Mat> & cameraDepths,
146 float maxDistance = 0.0f, // max camera distance to polygon to apply texture
147 float maxDepthError = 0.0f, // maximum depth error between reprojected mesh and depth image to texture a face (-1=disabled, 0=edge length is used)
148 float maxAngle = 0.0f, // maximum angle between camera and face (0=disabled)
149 int minClusterSize = 50, // minimum size of polygons clusters textured
150 const std::vector<float> & roiRatios = std::vector<float>(), // [left, right, top, bottom] region of interest (in ratios) of the image projected.
151 const ProgressState * state = 0,
152 std::vector<std::map<int, pcl::PointXY> > * vertexToPixels = 0, // For each point, we have a list of cameras with corresponding pixel in it. Beware that the camera ids don't correspond to pose ids, they are indexes from 0 to total camera models and texture's materials.
153 bool distanceToCamPolicy = false,
154 int numThreads = 1); // number of threads used to compute the visible faces of the cameras (1=sequential)
155pcl::TextureMesh::Ptr RTABMAP_CORE_EXPORT createTextureMesh(
156 const pcl::PolygonMesh::Ptr & mesh,
157 const std::map<int, Transform> & poses,
158 const std::map<int, std::vector<CameraModel> > & cameraModels,
159 const std::map<int, cv::Mat> & cameraDepths,
160 float maxDistance = 0.0f, // max camera distance to polygon to apply texture
161 float maxDepthError = 0.0f, // maximum depth error between reprojected mesh and depth image to texture a face (-1=disabled, 0=edge length is used)
162 float maxAngle = 0.0f, // maximum angle between camera and face (0=disabled)
163 int minClusterSize = 50, // minimum size of polygons clusters textured
164 const std::vector<float> & roiRatios = std::vector<float>(), // [left, right, top, bottom] region of interest (in ratios) of the image projected.
165 const ProgressState * state = 0,
166 std::vector<std::map<int, pcl::PointXY> > * vertexToPixels = 0, // For each point, we have a list of cameras with corresponding pixel in it. Beware that the camera ids don't correspond to pose ids, they are indexes from 0 to total camera models and texture's materials.
167 bool distanceToCamPolicy = false,
168 int numThreads = 1); // number of threads used to compute the visible faces of the cameras (1=sequential)
169
173void RTABMAP_CORE_EXPORT cleanTextureMesh(
174 pcl::TextureMesh & textureMesh,
175 int minClusterSize);
176
177pcl::TextureMesh::Ptr RTABMAP_CORE_EXPORT concatenateTextureMeshes(
178 const std::list<pcl::TextureMesh::Ptr> & meshes);
179
180void RTABMAP_CORE_EXPORT concatenateTextureMaterials(
181 pcl::TextureMesh & mesh, const cv::Size & imageSize, int textureSize, int maxTextures, float & scale, std::vector<bool> * materialsKept=0);
182
183std::vector<std::vector<RTABMAP_PCL_INDEX> > RTABMAP_CORE_EXPORT convertPolygonsFromPCL(
184 const std::vector<pcl::Vertices> & polygons);
185std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > RTABMAP_CORE_EXPORT convertPolygonsFromPCL(
186 const std::vector<std::vector<pcl::Vertices> > & polygons);
187std::vector<pcl::Vertices> RTABMAP_CORE_EXPORT convertPolygonsToPCL(
188 const std::vector<std::vector<RTABMAP_PCL_INDEX> > & polygons);
189std::vector<std::vector<pcl::Vertices> > RTABMAP_CORE_EXPORT convertPolygonsToPCL(
190 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & tex_polygons);
191
192pcl::TextureMesh::Ptr RTABMAP_CORE_EXPORT assembleTextureMesh(
193 const cv::Mat & cloudMat,
194 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons,
195#if PCL_VERSION_COMPARE(>=, 1, 8, 0)
196 const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords,
197#else
198 const std::vector<std::vector<Eigen::Vector2f> > & texCoords,
199#endif
200 cv::Mat & textures,
201 bool mergeTextures = false);
202
203pcl::PolygonMesh::Ptr RTABMAP_CORE_EXPORT assemblePolygonMesh(
204 const cv::Mat & cloudMat,
205 const std::vector<std::vector<RTABMAP_PCL_INDEX> > & polygons);
206
211cv::Mat RTABMAP_CORE_EXPORT mergeTextures(
212 pcl::TextureMesh & mesh,
213 const std::map<int, cv::Mat> & images, // raw or compressed, can be empty if memory or dbDriver should be used
214 const std::map<int, CameraModel> & calibrations, // Should match images
215 const Memory * memory = 0, // Should be set if images are not set
216 const DBDriver * dbDriver = 0, // Should be set if images and memory are not set
217 int textureSize = 4096,
218 int textureCount = 1,
219 const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels = std::vector<std::map<int, pcl::PointXY> >(), // needed for parameters below
220 bool gainCompensation = true,
221 float gainBeta = 10.0f,
222 bool gainRGB = true, //Do gain compensation on each channel
223 bool blending = true,
224 int blendingDecimation = 0, //0=auto depending on projected polygon size and texture size
225 int brightnessContrastRatioLow = 0, //0=disabled, values between 0 and 100
226 int brightnessContrastRatioHigh = 0, //0=disabled, values between 0 and 100
227 bool exposureFusion = false, //Exposure fusion can be used only with OpenCV3
228 const ProgressState * state = 0,
229 unsigned char blankValue = 255, //Gray value for blank polygons (without texture)
230 bool clearVertexColorUnderTexture = true,
231 std::map<int, std::map<int, cv::Vec4d> > * gains = 0, // <Camera ID, Camera Sub Index (multi-cameras), gains Gray-R-G-B>
232 std::map<int, std::map<int, cv::Mat> > * blendingGains = 0, // <Camera ID, Camera Sub Index (multi-cameras), gains>
233 std::pair<float, float> * contrastValues = 0); // Alpha/beta contrast values
234cv::Mat RTABMAP_CORE_EXPORT mergeTextures(
235 pcl::TextureMesh & mesh,
236 const std::map<int, cv::Mat> & images, // raw or compressed, can be empty if memory or dbDriver should be used
237 const std::map<int, std::vector<CameraModel> > & calibrations, // Should match images
238 const Memory * memory = 0, // Should be set if images are not set
239 const DBDriver * dbDriver = 0, // Should be set if images and memory are not set
240 int textureSize = 4096,
241 int textureCount = 1,
242 const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels = std::vector<std::map<int, pcl::PointXY> >(), // needed for parameters below
243 bool gainCompensation = true,
244 float gainBeta = 10.0f,
245 bool gainRGB = true, //Do gain compensation on each channel
246 bool blending = true,
247 int blendingDecimation = 0, //0=auto depending on projected polygon size and texture size
248 int brightnessContrastRatioLow = 0, //0=disabled, values between 0 and 100
249 int brightnessContrastRatioHigh = 0, //0=disabled, values between 0 and 100
250 bool exposureFusion = false, //Exposure fusion can be used only with OpenCV3
251 const ProgressState * state = 0,
252 unsigned char blankValue = 255, //Gray value for blank polygons (without texture)
253 bool clearVertexColorUnderTexture = true,
254 std::map<int, std::map<int, cv::Vec4d> > * gains = 0, // <Camera ID, Camera Sub Index (multi-cameras), gains Gray-R-G-B>
255 std::map<int, std::map<int, cv::Mat> > * blendingGains = 0, // <Camera ID, Camera Sub Index (multi-cameras), gains>
256 std::pair<float, float> * contrastValues = 0); // Alpha/beta contrast values
257
258void RTABMAP_CORE_EXPORT fixTextureMeshForVisualization(pcl::TextureMesh & textureMesh);
259
260// Use the same method with 22 parameters instead.
261RTABMAP_DEPRECATED bool RTABMAP_CORE_EXPORT multiBandTexturing(
262 const std::string & outputOBJPath,
263 const pcl::PCLPointCloud2 & cloud,
264 const std::vector<pcl::Vertices> & polygons,
265 const std::map<int, Transform> & cameraPoses,
266 const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels, // required output of util3d::createTextureMesh()
267 const std::map<int, cv::Mat> & images, // raw or compressed, can be empty if memory or dbDriver should be used
268 const std::map<int, std::vector<CameraModel> > & cameraModels, // Should match images
269 const Memory * memory = 0, // Should be set if images are not set
270 const DBDriver * dbDriver = 0, // Should be set if images and memory are not set
271 int textureSize = 8192,
272 const std::string & textureFormat = "jpg", // png, jpg
273 const std::map<int, std::map<int, cv::Vec4d> > & gains = std::map<int, std::map<int, cv::Vec4d> >(), // optional output of util3d::mergeTextures()
274 const std::map<int, std::map<int, cv::Mat> > & blendingGains = std::map<int, std::map<int, cv::Mat> >(), // optional output of util3d::mergeTextures()
275 const std::pair<float, float> & contrastValues = std::pair<float, float>(0,0), // optional output of util3d::mergeTextures()
276 bool gainRGB = true);
277
304bool RTABMAP_CORE_EXPORT multiBandTexturing(
305 const std::string & outputOBJPath,
306 const pcl::PCLPointCloud2 & cloud,
307 const std::vector<pcl::Vertices> & polygons,
308 const std::map<int, Transform> & cameraPoses,
309 const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels,
310 const std::map<int, cv::Mat> & images,
311 const std::map<int, std::vector<CameraModel> > & cameraModels,
312 const Memory * memory = 0,
313 const DBDriver * dbDriver = 0,
314 unsigned int textureSize = 8192,
315 unsigned int textureDownscale = 2,
316 const std::string & nbContrib = "1 5 10 0",
317 const std::string & textureFormat = "jpg",
318 const std::map<int, std::map<int, cv::Vec4d> > & gains = std::map<int, std::map<int, cv::Vec4d> >(),
319 const std::map<int, std::map<int, cv::Mat> > & blendingGains = std::map<int, std::map<int, cv::Mat> >(),
320 const std::pair<float, float> & contrastValues = std::pair<float, float>(0,0),
321 bool gainRGB = true,
322 unsigned int unwrapMethod = 0,
323 bool fillHoles = false,
324 unsigned int padding = 5,
325 double bestScoreThreshold = 0.1,
326 double angleHardThreshold = 90.0,
327 bool forceVisibleByAllVertices = false);
328
329cv::Mat RTABMAP_CORE_EXPORT computeNormals(
330 const cv::Mat & laserScan,
331 int searchK,
332 float searchRadius);
333pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
334 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
335 int searchK = 20,
336 float searchRadius = 0.0f,
337 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
338pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
339 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
340 int searchK = 20,
341 float searchRadius = 0.0f,
342 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
343pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
344 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
345 int searchK = 20,
346 float searchRadius = 0.0f,
347 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
348pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
349 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
350 const pcl::IndicesPtr & indices,
351 int searchK = 20,
352 float searchRadius = 0.0f,
353 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
354pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
355 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
356 const pcl::IndicesPtr & indices,
357 int searchK = 20,
358 float searchRadius = 0.0f,
359 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
360pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
361 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
362 const pcl::IndicesPtr & indices,
363 int searchK = 20,
364 float searchRadius = 0.0f,
365 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
366
367pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals2D(
368 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
369 int searchK = 5,
370 float searchRadius = 0.0f,
371 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
372pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals2D(
373 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
374 int searchK = 5,
375 float searchRadius = 0.0f,
376 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
377pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeFastOrganizedNormals2D(
378 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
379 int searchK = 5,
380 float searchRadius = 0.0f,
381 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
382pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeFastOrganizedNormals2D(
383 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
384 int searchK = 5,
385 float searchRadius = 0.0f,
386 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
387
388pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeFastOrganizedNormals(
389 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
390 float maxDepthChangeFactor = 0.02f,
391 float normalSmoothingSize = 10.0f,
392 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
393pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeFastOrganizedNormals(
394 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
395 const pcl::IndicesPtr & indices,
396 float maxDepthChangeFactor = 0.02f,
397 float normalSmoothingSize = 10.0f,
398 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
399
435float RTABMAP_CORE_EXPORT computeNormalsComplexity(
436 const LaserScan & scan,
437 const Transform & t = Transform::getIdentity(),
438 cv::Mat * pcaEigenVectors = 0,
439 cv::Mat * pcaEigenValues = 0,
440 bool centered = true);
442float RTABMAP_CORE_EXPORT computeNormalsComplexity(
443 const pcl::PointCloud<pcl::Normal> & normals,
444 const Transform & t = Transform::getIdentity(),
445 bool is2d = false,
446 cv::Mat * pcaEigenVectors = 0,
447 cv::Mat * pcaEigenValues = 0,
448 bool centered = true);
450float RTABMAP_CORE_EXPORT computeNormalsComplexity(
451 const pcl::PointCloud<pcl::PointNormal> & cloud,
452 const Transform & t = Transform::getIdentity(),
453 bool is2d = false,
454 cv::Mat * pcaEigenVectors = 0,
455 cv::Mat * pcaEigenValues = 0,
456 bool centered = true);
458float RTABMAP_CORE_EXPORT computeNormalsComplexity(
459 const pcl::PointCloud<pcl::PointXYZINormal> & cloud,
460 const Transform & t = Transform::getIdentity(),
461 bool is2d = false,
462 cv::Mat * pcaEigenVectors = 0,
463 cv::Mat * pcaEigenValues = 0,
464 bool centered = true);
466float RTABMAP_CORE_EXPORT computeNormalsComplexity(
467 const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud,
468 const Transform & t = Transform::getIdentity(),
469 bool is2d = false,
470 cv::Mat * pcaEigenVectors = 0,
471 cv::Mat * pcaEigenValues = 0,
472 bool centered = true);
475pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr RTABMAP_CORE_EXPORT mls(
476 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
477 float searchRadius = 0.0f,
478 int polygonialOrder = 2,
479 int upsamplingMethod = 0, // NONE, DISTINCT_CLOUD, SAMPLE_LOCAL_PLANE, RANDOM_UNIFORM_DENSITY, VOXEL_GRID_DILATION
480 float upsamplingRadius = 0.0f, // SAMPLE_LOCAL_PLANE
481 float upsamplingStep = 0.0f, // SAMPLE_LOCAL_PLANE
482 int pointDensity = 0, // RANDOM_UNIFORM_DENSITY
483 float dilationVoxelSize = 1.0f, // VOXEL_GRID_DILATION
484 int dilationIterations = 0); // VOXEL_GRID_DILATION
485pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr RTABMAP_CORE_EXPORT mls(
486 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
487 const pcl::IndicesPtr & indices,
488 float searchRadius = 0.0f,
489 int polygonialOrder = 2,
490 int upsamplingMethod = 0, // NONE, DISTINCT_CLOUD, SAMPLE_LOCAL_PLANE, RANDOM_UNIFORM_DENSITY, VOXEL_GRID_DILATION
491 float upsamplingRadius = 0.0f, // SAMPLE_LOCAL_PLANE
492 float upsamplingStep = 0.0f, // SAMPLE_LOCAL_PLANE
493 int pointDensity = 0, // RANDOM_UNIFORM_DENSITY
494 float dilationVoxelSize = 1.0f, // VOXEL_GRID_DILATION
495 int dilationIterations = 0); // VOXEL_GRID_DILATION
496
497// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
498RTABMAP_DEPRECATED LaserScan RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
499 const LaserScan & scan,
500 const Eigen::Vector3f & viewpoint,
501 bool forceGroundNormalsUp);
502LaserScan RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
503 const LaserScan & scan,
504 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
505 float groundNormalsUp = 0.0f);
506// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
507RTABMAP_DEPRECATED void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
508 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
509 const Eigen::Vector3f & viewpoint,
510 bool forceGroundNormalsUp);
511void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
512 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
513 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
514 float groundNormalsUp = 0.0f);
515// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
516RTABMAP_DEPRECATED void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
517 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
518 const Eigen::Vector3f & viewpoint,
519 bool forceGroundNormalsUp);
520void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
521 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
522 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
523 float groundNormalsUp = 0.0f);
524// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
525RTABMAP_DEPRECATED void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
526 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
527 const Eigen::Vector3f & viewpoint,
528 bool forceGroundNormalsUp);
529void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
530 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
531 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
532 float groundNormalsUp = 0.0f);
533
534void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
535 const std::map<int, Transform> & poses,
536 const std::vector<int> & cameraIndices,
537 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
538 float groundNormalsUp = 0.0f);
539void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
540 const std::map<int, Transform> & poses,
541 const std::vector<int> & cameraIndices,
542 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
543 float groundNormalsUp = 0.0f);
544void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
545 const std::map<int, Transform> & poses,
546 const std::vector<int> & cameraIndices,
547 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
548 float groundNormalsUp = 0.0f);
549
550void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
551 const std::map<int, Transform> & poses,
552 const pcl::PointCloud<pcl::PointXYZ>::Ptr & rawCloud,
553 const std::vector<int> & rawCameraIndices,
554 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
555 float groundNormalsUp = 0.0f);
556void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
557 const std::map<int, Transform> & poses,
558 const pcl::PointCloud<pcl::PointXYZ>::Ptr & rawCloud,
559 const std::vector<int> & rawCameraIndices,
560 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
561 float groundNormalsUp = 0.0f);
562void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
563 const std::map<int, Transform> & poses,
564 const pcl::PointCloud<pcl::PointXYZ>::Ptr & rawCloud,
565 const std::vector<int> & rawCameraIndices,
566 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
567 float groundNormalsUp = 0.0f);
568
569void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
570 const std::map<int, Transform> & viewpoints,
571 const LaserScan & rawScan,
572 const std::vector<int> & viewpointIds,
573 LaserScan & scan,
574 float groundNormalsUp = 0.0f);
575
576pcl::PolygonMesh::Ptr RTABMAP_CORE_EXPORT meshDecimation(const pcl::PolygonMesh::Ptr & mesh, float factor);
577
578template<typename pointT>
579std::vector<pcl::Vertices> normalizePolygonsSide(
580 const pcl::PointCloud<pointT> & cloud,
581 const std::vector<pcl::Vertices> & polygons,
582 const pcl::PointXYZ & viewPoint = pcl::PointXYZ(0,0,0));
583
584template<typename pointRGBT>
585void denseMeshPostProcessing(
586 pcl::PolygonMeshPtr & mesh,
587 float meshDecimationFactor = 0.0f, // value between 0 and 1, 0=disabled
588 int maximumPolygons = 0, // 0=disabled
589 const typename pcl::PointCloud<pointRGBT>::Ptr & cloud = pcl::PointCloud<pointRGBT>::Ptr(), // A RGB point cloud used to transfer colors back to mesh (needed for parameters below)
590 float transferColorRadius = 0.05f, // <0=disabled, 0=nearest color
591 bool coloredOutput = true, // Not used anymore, output is colored if transferColorRadius>=0
592 bool cleanMesh = true, // Remove polygons not colored (if coloredOutput is disabled, transferColorRadius is still used to clean the mesh)
593 int minClusterSize = 50, // Remove small polygon clusters after the mesh has been cleaned (0=disabled)
594 ProgressState * progressState = 0);
595
618bool RTABMAP_CORE_EXPORT intersectRayTriangle(
619 const Eigen::Vector3f & p,
620 const Eigen::Vector3f & dir,
621 const Eigen::Vector3f & v0,
622 const Eigen::Vector3f & v1,
623 const Eigen::Vector3f & v2,
624 float & distance,
625 Eigen::Vector3f & normal);
626
627template<typename PointT>
628bool intersectRayMesh(
629 const Eigen::Vector3f & origin,
630 const Eigen::Vector3f & dir,
631 const typename pcl::PointCloud<PointT> & cloud,
632 const std::vector<pcl::Vertices> & polygons,
633 bool ignoreBackFaces,
634 float & distance,
635 Eigen::Vector3f & normal,
636 int & index);
637
638int RTABMAP_CORE_EXPORT saveOBJFile(
639 const std::string &file_name,
640 const pcl::TextureMesh &tex_mesh,
641 unsigned precision = 5);
642
643int RTABMAP_CORE_EXPORT saveOBJFile(
644 const std::string &file_name,
645 const pcl::PolygonMesh &mesh,
646 unsigned precision = 5);
647
648} // namespace util3d
649} // namespace rtabmap
650
651#include "rtabmap/core/impl/util3d_surface.hpp"
652
653#endif /* UTIL3D_SURFACE_H_ */
Abstract database driver for RTAB-Map maps (signatures, links, words, statistics).
Definition DBDriver.h:72
Represents 2D or 3D laser scan data with support for multiple point data formats.
Definition LaserScan.h:46
Three-tiered memory management (STM, WM, LTM) for RTAB-Map.
Definition Memory.h:102
Represents a 3D rigid body transformation (rotation + translation).
Definition Transform.h:53
static Transform getIdentity()
Returns identity transform.
float RTABMAP_CORE_EXPORT computeNormalsComplexity(const LaserScan &scan, const Transform &t=Transform::getIdentity(), cv::Mat *pcaEigenVectors=0, cv::Mat *pcaEigenValues=0, bool centered=true)
Computes the complexity of surface normals in a point cloud of type LaserScan.
void RTABMAP_CORE_EXPORT cleanTextureMesh(pcl::TextureMesh &textureMesh, int minClusterSize)
void RTABMAP_CORE_EXPORT createPolygonIndexes(const std::vector< pcl::Vertices > &polygons, int cloudSize, std::vector< std::set< int > > &neighborPolygons, std::vector< std::set< int > > &vertexPolygons)
Given a set of polygons, create two indexes: polygons to neighbor polygons and vertices to polygons.
bool RTABMAP_CORE_EXPORT intersectRayTriangle(const Eigen::Vector3f &p, const Eigen::Vector3f &dir, const Eigen::Vector3f &v0, const Eigen::Vector3f &v1, const Eigen::Vector3f &v2, float &distance, Eigen::Vector3f &normal)
cv::Mat RTABMAP_CORE_EXPORT mergeTextures(pcl::TextureMesh &mesh, const std::map< int, cv::Mat > &images, const std::map< int, CameraModel > &calibrations, const Memory *memory=0, const DBDriver *dbDriver=0, int textureSize=4096, int textureCount=1, const std::vector< std::map< int, pcl::PointXY > > &vertexToPixels=std::vector< std::map< int, pcl::PointXY > >(), bool gainCompensation=true, float gainBeta=10.0f, bool gainRGB=true, bool blending=true, int blendingDecimation=0, int brightnessContrastRatioLow=0, int brightnessContrastRatioHigh=0, bool exposureFusion=false, const ProgressState *state=0, unsigned char blankValue=255, bool clearVertexColorUnderTexture=true, std::map< int, std::map< int, cv::Vec4d > > *gains=0, std::map< int, std::map< int, cv::Mat > > *blendingGains=0, std::pair< float, float > *contrastValues=0)