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
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);
445float RTABMAP_CORE_EXPORT computeNormalsComplexity(
446 const pcl::PointCloud<pcl::Normal> & normals,
447 const Transform & t = Transform::getIdentity(),
448 bool is2d = false,
449 cv::Mat * pcaEigenVectors = 0,
450 cv::Mat * pcaEigenValues = 0,
451 bool centered = true);
456float RTABMAP_CORE_EXPORT computeNormalsComplexity(
457 const pcl::PointCloud<pcl::PointNormal> & 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);
467float RTABMAP_CORE_EXPORT computeNormalsComplexity(
468 const pcl::PointCloud<pcl::PointXYZINormal> & cloud,
469 const Transform & t = Transform::getIdentity(),
470 bool is2d = false,
471 cv::Mat * pcaEigenVectors = 0,
472 cv::Mat * pcaEigenValues = 0,
473 bool centered = true);
478float RTABMAP_CORE_EXPORT computeNormalsComplexity(
479 const pcl::PointCloud<pcl::PointXYZRGBNormal> & cloud,
480 const Transform & t = Transform::getIdentity(),
481 bool is2d = false,
482 cv::Mat * pcaEigenVectors = 0,
483 cv::Mat * pcaEigenValues = 0,
484 bool centered = true);
485
486pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr RTABMAP_CORE_EXPORT mls(
487 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
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
496pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr RTABMAP_CORE_EXPORT mls(
497 const pcl::PointCloud<pcl::PointXYZRGB>::Ptr & cloud,
498 const pcl::IndicesPtr & indices,
499 float searchRadius = 0.0f,
500 int polygonialOrder = 2,
501 int upsamplingMethod = 0, // NONE, DISTINCT_CLOUD, SAMPLE_LOCAL_PLANE, RANDOM_UNIFORM_DENSITY, VOXEL_GRID_DILATION
502 float upsamplingRadius = 0.0f, // SAMPLE_LOCAL_PLANE
503 float upsamplingStep = 0.0f, // SAMPLE_LOCAL_PLANE
504 int pointDensity = 0, // RANDOM_UNIFORM_DENSITY
505 float dilationVoxelSize = 1.0f, // VOXEL_GRID_DILATION
506 int dilationIterations = 0); // VOXEL_GRID_DILATION
507
508// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
509RTABMAP_DEPRECATED LaserScan RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
510 const LaserScan & scan,
511 const Eigen::Vector3f & viewpoint,
512 bool forceGroundNormalsUp);
513LaserScan RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
514 const LaserScan & scan,
515 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
516 float groundNormalsUp = 0.0f);
517// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
518RTABMAP_DEPRECATED void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
519 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
520 const Eigen::Vector3f & viewpoint,
521 bool forceGroundNormalsUp);
522void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
523 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
524 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
525 float groundNormalsUp = 0.0f);
526// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
527RTABMAP_DEPRECATED void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
528 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
529 const Eigen::Vector3f & viewpoint,
530 bool forceGroundNormalsUp);
531void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
532 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
533 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
534 float groundNormalsUp = 0.0f);
535// Use version with groundNormalsUp as float. For forceGroundNormalsUp=true, set groundNormalsUp to 0.8f, otherwise set groundNormalsUp to 0.0f.
536RTABMAP_DEPRECATED void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
537 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
538 const Eigen::Vector3f & viewpoint,
539 bool forceGroundNormalsUp);
540void RTABMAP_CORE_EXPORT adjustNormalsToViewPoint(
541 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
542 const Eigen::Vector3f & viewpoint = Eigen::Vector3f(0,0,0),
543 float groundNormalsUp = 0.0f);
544
545void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
546 const std::map<int, Transform> & poses,
547 const std::vector<int> & cameraIndices,
548 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
549 float groundNormalsUp = 0.0f);
550void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
551 const std::map<int, Transform> & poses,
552 const std::vector<int> & cameraIndices,
553 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
554 float groundNormalsUp = 0.0f);
555void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
556 const std::map<int, Transform> & poses,
557 const std::vector<int> & cameraIndices,
558 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
559 float groundNormalsUp = 0.0f);
560
561void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
562 const std::map<int, Transform> & poses,
563 const pcl::PointCloud<pcl::PointXYZ>::Ptr & rawCloud,
564 const std::vector<int> & rawCameraIndices,
565 pcl::PointCloud<pcl::PointNormal>::Ptr & cloud,
566 float groundNormalsUp = 0.0f);
567void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
568 const std::map<int, Transform> & poses,
569 const pcl::PointCloud<pcl::PointXYZ>::Ptr & rawCloud,
570 const std::vector<int> & rawCameraIndices,
571 pcl::PointCloud<pcl::PointXYZRGBNormal>::Ptr & cloud,
572 float groundNormalsUp = 0.0f);
573void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
574 const std::map<int, Transform> & poses,
575 const pcl::PointCloud<pcl::PointXYZ>::Ptr & rawCloud,
576 const std::vector<int> & rawCameraIndices,
577 pcl::PointCloud<pcl::PointXYZINormal>::Ptr & cloud,
578 float groundNormalsUp = 0.0f);
579
580void RTABMAP_CORE_EXPORT adjustNormalsToViewPoints(
581 const std::map<int, Transform> & viewpoints,
582 const LaserScan & rawScan,
583 const std::vector<int> & viewpointIds,
584 LaserScan & scan,
585 float groundNormalsUp = 0.0f);
586
587pcl::PolygonMesh::Ptr RTABMAP_CORE_EXPORT meshDecimation(const pcl::PolygonMesh::Ptr & mesh, float factor);
588
589template<typename pointT>
590std::vector<pcl::Vertices> normalizePolygonsSide(
591 const pcl::PointCloud<pointT> & cloud,
592 const std::vector<pcl::Vertices> & polygons,
593 const pcl::PointXYZ & viewPoint = pcl::PointXYZ(0,0,0));
594
595template<typename pointRGBT>
596void denseMeshPostProcessing(
597 pcl::PolygonMeshPtr & mesh,
598 float meshDecimationFactor = 0.0f, // value between 0 and 1, 0=disabled
599 int maximumPolygons = 0, // 0=disabled
600 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)
601 float transferColorRadius = 0.05f, // <0=disabled, 0=nearest color
602 bool coloredOutput = true, // Not used anymore, output is colored if transferColorRadius>=0
603 bool cleanMesh = true, // Remove polygons not colored (if coloredOutput is disabled, transferColorRadius is still used to clean the mesh)
604 int minClusterSize = 50, // Remove small polygon clusters after the mesh has been cleaned (0=disabled)
605 ProgressState * progressState = 0);
606
629bool RTABMAP_CORE_EXPORT intersectRayTriangle(
630 const Eigen::Vector3f & p,
631 const Eigen::Vector3f & dir,
632 const Eigen::Vector3f & v0,
633 const Eigen::Vector3f & v1,
634 const Eigen::Vector3f & v2,
635 float & distance,
636 Eigen::Vector3f & normal);
637
638template<typename PointT>
639bool intersectRayMesh(
640 const Eigen::Vector3f & origin,
641 const Eigen::Vector3f & dir,
642 const typename pcl::PointCloud<PointT> & cloud,
643 const std::vector<pcl::Vertices> & polygons,
644 bool ignoreBackFaces,
645 float & distance,
646 Eigen::Vector3f & normal,
647 int & index);
648
649int RTABMAP_CORE_EXPORT saveOBJFile(
650 const std::string &file_name,
651 const pcl::TextureMesh &tex_mesh,
652 unsigned precision = 5);
653
654int RTABMAP_CORE_EXPORT saveOBJFile(
655 const std::string &file_name,
656 const pcl::PolygonMesh &mesh,
657 unsigned precision = 5);
658
659} // namespace util3d
660} // namespace rtabmap
661
662#include "rtabmap/core/impl/util3d_surface.hpp"
663
664#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)