RTAB-Map 0.23.10
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);
154pcl::TextureMesh::Ptr RTABMAP_CORE_EXPORT createTextureMesh(
155 const pcl::PolygonMesh::Ptr & mesh,
156 const std::map<int, Transform> & poses,
157 const std::map<int, std::vector<CameraModel> > & cameraModels,
158 const std::map<int, cv::Mat> & cameraDepths,
159 float maxDistance = 0.0f, // max camera distance to polygon to apply texture
160 float maxDepthError = 0.0f, // maximum depth error between reprojected mesh and depth image to texture a face (-1=disabled, 0=edge length is used)
161 float maxAngle = 0.0f, // maximum angle between camera and face (0=disabled)
162 int minClusterSize = 50, // minimum size of polygons clusters textured
163 const std::vector<float> & roiRatios = std::vector<float>(), // [left, right, top, bottom] region of interest (in ratios) of the image projected.
164 const ProgressState * state = 0,
165 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.
166 bool distanceToCamPolicy = false);
167
171void RTABMAP_CORE_EXPORT cleanTextureMesh(
172 pcl::TextureMesh & textureMesh,
173 int minClusterSize);
174
175pcl::TextureMesh::Ptr RTABMAP_CORE_EXPORT concatenateTextureMeshes(
176 const std::list<pcl::TextureMesh::Ptr> & meshes);
177
178void RTABMAP_CORE_EXPORT concatenateTextureMaterials(
179 pcl::TextureMesh & mesh, const cv::Size & imageSize, int textureSize, int maxTextures, float & scale, std::vector<bool> * materialsKept=0);
180
181std::vector<std::vector<RTABMAP_PCL_INDEX> > RTABMAP_CORE_EXPORT convertPolygonsFromPCL(
182 const std::vector<pcl::Vertices> & polygons);
183std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > RTABMAP_CORE_EXPORT convertPolygonsFromPCL(
184 const std::vector<std::vector<pcl::Vertices> > & polygons);
185std::vector<pcl::Vertices> RTABMAP_CORE_EXPORT convertPolygonsToPCL(
186 const std::vector<std::vector<RTABMAP_PCL_INDEX> > & polygons);
187std::vector<std::vector<pcl::Vertices> > RTABMAP_CORE_EXPORT convertPolygonsToPCL(
188 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & tex_polygons);
189
190pcl::TextureMesh::Ptr RTABMAP_CORE_EXPORT assembleTextureMesh(
191 const cv::Mat & cloudMat,
192 const std::vector<std::vector<std::vector<RTABMAP_PCL_INDEX> > > & polygons,
193#if PCL_VERSION_COMPARE(>=, 1, 8, 0)
194 const std::vector<std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> > > & texCoords,
195#else
196 const std::vector<std::vector<Eigen::Vector2f> > & texCoords,
197#endif
198 cv::Mat & textures,
199 bool mergeTextures = false);
200
201pcl::PolygonMesh::Ptr RTABMAP_CORE_EXPORT assemblePolygonMesh(
202 const cv::Mat & cloudMat,
203 const std::vector<std::vector<RTABMAP_PCL_INDEX> > & polygons);
204
209cv::Mat RTABMAP_CORE_EXPORT mergeTextures(
210 pcl::TextureMesh & mesh,
211 const std::map<int, cv::Mat> & images, // raw or compressed, can be empty if memory or dbDriver should be used
212 const std::map<int, CameraModel> & calibrations, // Should match images
213 const Memory * memory = 0, // Should be set if images are not set
214 const DBDriver * dbDriver = 0, // Should be set if images and memory are not set
215 int textureSize = 4096,
216 int textureCount = 1,
217 const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels = std::vector<std::map<int, pcl::PointXY> >(), // needed for parameters below
218 bool gainCompensation = true,
219 float gainBeta = 10.0f,
220 bool gainRGB = true, //Do gain compensation on each channel
221 bool blending = true,
222 int blendingDecimation = 0, //0=auto depending on projected polygon size and texture size
223 int brightnessContrastRatioLow = 0, //0=disabled, values between 0 and 100
224 int brightnessContrastRatioHigh = 0, //0=disabled, values between 0 and 100
225 bool exposureFusion = false, //Exposure fusion can be used only with OpenCV3
226 const ProgressState * state = 0,
227 unsigned char blankValue = 255, //Gray value for blank polygons (without texture)
228 bool clearVertexColorUnderTexture = true,
229 std::map<int, std::map<int, cv::Vec4d> > * gains = 0, // <Camera ID, Camera Sub Index (multi-cameras), gains Gray-R-G-B>
230 std::map<int, std::map<int, cv::Mat> > * blendingGains = 0, // <Camera ID, Camera Sub Index (multi-cameras), gains>
231 std::pair<float, float> * contrastValues = 0); // Alpha/beta contrast values
232cv::Mat RTABMAP_CORE_EXPORT mergeTextures(
233 pcl::TextureMesh & mesh,
234 const std::map<int, cv::Mat> & images, // raw or compressed, can be empty if memory or dbDriver should be used
235 const std::map<int, std::vector<CameraModel> > & calibrations, // Should match images
236 const Memory * memory = 0, // Should be set if images are not set
237 const DBDriver * dbDriver = 0, // Should be set if images and memory are not set
238 int textureSize = 4096,
239 int textureCount = 1,
240 const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels = std::vector<std::map<int, pcl::PointXY> >(), // needed for parameters below
241 bool gainCompensation = true,
242 float gainBeta = 10.0f,
243 bool gainRGB = true, //Do gain compensation on each channel
244 bool blending = true,
245 int blendingDecimation = 0, //0=auto depending on projected polygon size and texture size
246 int brightnessContrastRatioLow = 0, //0=disabled, values between 0 and 100
247 int brightnessContrastRatioHigh = 0, //0=disabled, values between 0 and 100
248 bool exposureFusion = false, //Exposure fusion can be used only with OpenCV3
249 const ProgressState * state = 0,
250 unsigned char blankValue = 255, //Gray value for blank polygons (without texture)
251 bool clearVertexColorUnderTexture = true,
252 std::map<int, std::map<int, cv::Vec4d> > * gains = 0, // <Camera ID, Camera Sub Index (multi-cameras), gains Gray-R-G-B>
253 std::map<int, std::map<int, cv::Mat> > * blendingGains = 0, // <Camera ID, Camera Sub Index (multi-cameras), gains>
254 std::pair<float, float> * contrastValues = 0); // Alpha/beta contrast values
255
256void RTABMAP_CORE_EXPORT fixTextureMeshForVisualization(pcl::TextureMesh & textureMesh);
257
258// Use the same method with 22 parameters instead.
259RTABMAP_DEPRECATED bool RTABMAP_CORE_EXPORT multiBandTexturing(
260 const std::string & outputOBJPath,
261 const pcl::PCLPointCloud2 & cloud,
262 const std::vector<pcl::Vertices> & polygons,
263 const std::map<int, Transform> & cameraPoses,
264 const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels, // required output of util3d::createTextureMesh()
265 const std::map<int, cv::Mat> & images, // raw or compressed, can be empty if memory or dbDriver should be used
266 const std::map<int, std::vector<CameraModel> > & cameraModels, // Should match images
267 const Memory * memory = 0, // Should be set if images are not set
268 const DBDriver * dbDriver = 0, // Should be set if images and memory are not set
269 int textureSize = 8192,
270 const std::string & textureFormat = "jpg", // png, jpg
271 const std::map<int, std::map<int, cv::Vec4d> > & gains = std::map<int, std::map<int, cv::Vec4d> >(), // optional output of util3d::mergeTextures()
272 const std::map<int, std::map<int, cv::Mat> > & blendingGains = std::map<int, std::map<int, cv::Mat> >(), // optional output of util3d::mergeTextures()
273 const std::pair<float, float> & contrastValues = std::pair<float, float>(0,0), // optional output of util3d::mergeTextures()
274 bool gainRGB = true);
275
302bool RTABMAP_CORE_EXPORT multiBandTexturing(
303 const std::string & outputOBJPath,
304 const pcl::PCLPointCloud2 & cloud,
305 const std::vector<pcl::Vertices> & polygons,
306 const std::map<int, Transform> & cameraPoses,
307 const std::vector<std::map<int, pcl::PointXY> > & vertexToPixels,
308 const std::map<int, cv::Mat> & images,
309 const std::map<int, std::vector<CameraModel> > & cameraModels,
310 const Memory * memory = 0,
311 const DBDriver * dbDriver = 0,
312 unsigned int textureSize = 8192,
313 unsigned int textureDownscale = 2,
314 const std::string & nbContrib = "1 5 10 0",
315 const std::string & textureFormat = "jpg",
316 const std::map<int, std::map<int, cv::Vec4d> > & gains = std::map<int, std::map<int, cv::Vec4d> >(),
317 const std::map<int, std::map<int, cv::Mat> > & blendingGains = std::map<int, std::map<int, cv::Mat> >(),
318 const std::pair<float, float> & contrastValues = std::pair<float, float>(0,0),
319 bool gainRGB = true,
320 unsigned int unwrapMethod = 0,
321 bool fillHoles = false,
322 unsigned int padding = 5,
323 double bestScoreThreshold = 0.1,
324 double angleHardThreshold = 90.0,
325 bool forceVisibleByAllVertices = false);
326
327cv::Mat RTABMAP_CORE_EXPORT computeNormals(
328 const cv::Mat & laserScan,
329 int searchK,
330 float searchRadius);
331pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
332 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
333 int searchK = 20,
334 float searchRadius = 0.0f,
335 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
336pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
337 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
338 int searchK = 20,
339 float searchRadius = 0.0f,
340 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
341pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
342 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
343 int searchK = 20,
344 float searchRadius = 0.0f,
345 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
346pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
347 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
348 const pcl::IndicesPtr & indices,
349 int searchK = 20,
350 float searchRadius = 0.0f,
351 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
352pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
353 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
354 const pcl::IndicesPtr & indices,
355 int searchK = 20,
356 float searchRadius = 0.0f,
357 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
358pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals(
359 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
360 const pcl::IndicesPtr & indices,
361 int searchK = 20,
362 float searchRadius = 0.0f,
363 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
364
365pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals2D(
366 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
367 int searchK = 5,
368 float searchRadius = 0.0f,
369 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
370pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeNormals2D(
371 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
372 int searchK = 5,
373 float searchRadius = 0.0f,
374 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
375pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeFastOrganizedNormals2D(
376 const pcl::PointCloud<pcl::PointXYZ>::Ptr & cloud,
377 int searchK = 5,
378 float searchRadius = 0.0f,
379 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
380pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeFastOrganizedNormals2D(
381 const pcl::PointCloud<pcl::PointXYZI>::Ptr & cloud,
382 int searchK = 5,
383 float searchRadius = 0.0f,
384 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
385
386pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeFastOrganizedNormals(
387 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
388 float maxDepthChangeFactor = 0.02f,
389 float normalSmoothingSize = 10.0f,
390 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
391pcl::PointCloud<pcl::Normal>::Ptr RTABMAP_CORE_EXPORT computeFastOrganizedNormals(
392 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
393 const pcl::IndicesPtr & indices,
394 float maxDepthChangeFactor = 0.02f,
395 float normalSmoothingSize = 10.0f,
396 const Eigen::Vector3f & viewPoint = Eigen::Vector3f(0,0,0));
397
433float RTABMAP_CORE_EXPORT computeNormalsComplexity(
434 const LaserScan & scan,
435 const Transform & t = Transform::getIdentity(),
436 cv::Mat * pcaEigenVectors = 0,
437 cv::Mat * pcaEigenValues = 0,
438 bool centered = true);
440float RTABMAP_CORE_EXPORT computeNormalsComplexity(
441 const pcl::PointCloud<pcl::Normal> & normals,
442 const Transform & t = Transform::getIdentity(),
443 bool is2d = false,
444 cv::Mat * pcaEigenVectors = 0,
445 cv::Mat * pcaEigenValues = 0,
446 bool centered = true);
448float RTABMAP_CORE_EXPORT computeNormalsComplexity(
449 const pcl::PointCloud<pcl::PointNormal> & cloud,
450 const Transform & t = Transform::getIdentity(),
451 bool is2d = false,
452 cv::Mat * pcaEigenVectors = 0,
453 cv::Mat * pcaEigenValues = 0,
454 bool centered = true);
456float RTABMAP_CORE_EXPORT computeNormalsComplexity(
457 const pcl::PointCloud<pcl::PointXYZINormal> & cloud,
458 const Transform & t = Transform::getIdentity(),
459 bool is2d = false,
460 cv::Mat * pcaEigenVectors = 0,
461 cv::Mat * pcaEigenValues = 0,
462 bool centered = true);
464float RTABMAP_CORE_EXPORT computeNormalsComplexity(
465 const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud,
466 const Transform & t = Transform::getIdentity(),
467 bool is2d = false,
468 cv::Mat * pcaEigenVectors = 0,
469 cv::Mat * pcaEigenValues = 0,
470 bool centered = true);
473pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr RTABMAP_CORE_EXPORT mls(
474 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
475 float searchRadius = 0.0f,
476 int polygonialOrder = 2,
477 int upsamplingMethod = 0, // NONE, DISTINCT_CLOUD, SAMPLE_LOCAL_PLANE, RANDOM_UNIFORM_DENSITY, VOXEL_GRID_DILATION
478 float upsamplingRadius = 0.0f, // SAMPLE_LOCAL_PLANE
479 float upsamplingStep = 0.0f, // SAMPLE_LOCAL_PLANE
480 int pointDensity = 0, // RANDOM_UNIFORM_DENSITY
481 float dilationVoxelSize = 1.0f, // VOXEL_GRID_DILATION
482 int dilationIterations = 0); // VOXEL_GRID_DILATION
483pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr RTABMAP_CORE_EXPORT mls(
484 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
485 const pcl::IndicesPtr & indices,
486 float searchRadius = 0.0f,
487 int polygonialOrder = 2,
488 int upsamplingMethod = 0, // NONE, DISTINCT_CLOUD, SAMPLE_LOCAL_PLANE, RANDOM_UNIFORM_DENSITY, VOXEL_GRID_DILATION
489 float upsamplingRadius = 0.0f, // SAMPLE_LOCAL_PLANE
490 float upsamplingStep = 0.0f, // SAMPLE_LOCAL_PLANE
491 int pointDensity = 0, // RANDOM_UNIFORM_DENSITY
492 float dilationVoxelSize = 1.0f, // VOXEL_GRID_DILATION
493 int dilationIterations = 0); // VOXEL_GRID_DILATION
494
495// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
496RTABMAP_DEPRECATED LaserScan RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
497 const LaserScan & scan,
498 const Eigen::Vector3f & viewpoint,
499 bool forceGroundNormalsUp);
500LaserScan RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
501 const LaserScan & scan,
502 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
503 float groundNormalsUp = 0.0f);
504// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
505RTABMAP_DEPRECATED void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
506 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
507 const Eigen::Vector3f & viewpoint,
508 bool forceGroundNormalsUp);
509void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
510 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
511 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
512 float groundNormalsUp = 0.0f);
513// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
514RTABMAP_DEPRECATED void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
515 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
516 const Eigen::Vector3f & viewpoint,
517 bool forceGroundNormalsUp);
518void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
519 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
520 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
521 float groundNormalsUp = 0.0f);
522// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
523RTABMAP_DEPRECATED void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
524 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
525 const Eigen::Vector3f & viewpoint,
526 bool forceGroundNormalsUp);
527void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
528 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
529 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
530 float groundNormalsUp = 0.0f);
531
532void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
533 const std::map<int, Transform> & poses,
534 const std::vector<int> & cameraIndices,
535 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
536 float groundNormalsUp = 0.0f);
537void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
538 const std::map<int, Transform> & poses,
539 const std::vector<int> & cameraIndices,
540 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
541 float groundNormalsUp = 0.0f);
542void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
543 const std::map<int, Transform> & poses,
544 const std::vector<int> & cameraIndices,
545 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
546 float groundNormalsUp = 0.0f);
547
548void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
549 const std::map<int, Transform> & poses,
550 const pcl::PointCloud<pcl::PointXYZ>::Ptr & rawCloud,
551 const std::vector<int> & rawCameraIndices,
552 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
553 float groundNormalsUp = 0.0f);
554void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
555 const std::map<int, Transform> & poses,
556 const pcl::PointCloud<pcl::PointXYZ>::Ptr & rawCloud,
557 const std::vector<int> & rawCameraIndices,
558 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
559 float groundNormalsUp = 0.0f);
560void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
561 const std::map<int, Transform> & poses,
562 const pcl::PointCloud<pcl::PointXYZ>::Ptr & rawCloud,
563 const std::vector<int> & rawCameraIndices,
564 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
565 float groundNormalsUp = 0.0f);
566
567void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
568 const std::map<int, Transform> & viewpoints,
569 const LaserScan & rawScan,
570 const std::vector<int> & viewpointIds,
571 LaserScan & scan,
572 float groundNormalsUp = 0.0f);
573
574pcl::PolygonMesh::Ptr RTABMAP_CORE_EXPORT meshDecimation(const pcl::PolygonMesh::Ptr & mesh, float factor);
575
576template<typename pointT>
577std::vector<pcl::Vertices> normalizePolygonsSide(
578 const pcl::PointCloud<pointT> & cloud,
579 const std::vector<pcl::Vertices> & polygons,
580 const pcl::PointXYZ & viewPoint = pcl::PointXYZ(0,0,0));
581
582template<typename pointRGBT>
583void denseMeshPostProcessing(
584 pcl::PolygonMeshPtr & mesh,
585 float meshDecimationFactor = 0.0f, // value between 0 and 1, 0=disabled
586 int maximumPolygons = 0, // 0=disabled
587 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)
588 float transferColorRadius = 0.05f, // <0=disabled, 0=nearest color
589 bool coloredOutput = true, // Not used anymore, output is colored if transferColorRadius>=0
590 bool cleanMesh = true, // Remove polygons not colored (if coloredOutput is disabled, transferColorRadius is still used to clean the mesh)
591 int minClusterSize = 50, // Remove small polygon clusters after the mesh has been cleaned (0=disabled)
592 ProgressState * progressState = 0);
593
616bool RTABMAP_CORE_EXPORT intersectRayTriangle(
617 const Eigen::Vector3f & p,
618 const Eigen::Vector3f & dir,
619 const Eigen::Vector3f & v0,
620 const Eigen::Vector3f & v1,
621 const Eigen::Vector3f & v2,
622 float & distance,
623 Eigen::Vector3f & normal);
624
625template<typename PointT>
626bool intersectRayMesh(
627 const Eigen::Vector3f & origin,
628 const Eigen::Vector3f & dir,
629 const typename pcl::PointCloud<PointT> & cloud,
630 const std::vector<pcl::Vertices> & polygons,
631 bool ignoreBackFaces,
632 float & distance,
633 Eigen::Vector3f & normal,
634 int & index);
635
636int RTABMAP_CORE_EXPORT saveOBJFile(
637 const std::string &file_name,
638 const pcl::TextureMesh &tex_mesh,
639 unsigned precision = 5);
640
641int RTABMAP_CORE_EXPORT saveOBJFile(
642 const std::string &file_name,
643 const pcl::PolygonMesh &mesh,
644 unsigned precision = 5);
645
646} // namespace util3d
647} // namespace rtabmap
648
649#include "rtabmap/core/impl/util3d_surface.hpp"
650
651#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)