-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpcMesher.h
146 lines (100 loc) · 5.14 KB
/
pcMesher.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#ifndef PCMESHER_H
#define PCMESHER_H
#include <iostream>
#include <string>
#include <stdio.h>
#include <pcl/surface/poisson.h>
#include <pcl/geometry/polygon_mesh.h>
#include "pointXYZRGBNormalCam.h"
#include "camera.h"
typedef pcl::geometry::PolygonMesh <pcl::geometry::DefaultMeshTraits <PointXYZRGBNormalCam> > Mesh;
class PcMesher{
public:
PcMesher();
~PcMesher();
// Get number of clouds
unsigned int getNClouds() const;
// Get the vector of point-camera correspondance
std::vector<std::vector<int> > getCamPerVtx() const;
// Get a Ptr to a cloud
PointCloud<PointXYZRGBNormalCam>::Ptr getPointCloudPtr(unsigned int _index);
// Remove pointclouds
void clearPointClouds();
// Get dimensions of Point Cloud or Mesh
Eigen::Vector3f getDimensions(const PointCloud<PointXYZRGBNormalCam>::Ptr& _cloud);
Eigen::Vector3f getDimensions(const unsigned int _index);
Eigen::Vector3f getDimensions(const PolygonMesh& _mesh);
// Compute point cloud resolution
double computeResolution(const PointCloud<PointXYZRGBNormalCam>::Ptr& _cloud) const;
// Outlier filtering
void removeOutliers(PointCloud<PointXYZRGBNormalCam>::Ptr& _cloud);
void removeOutliers(unsigned int _index);
void removeAllOutliers();
// Downsample a pointcloud
void downSample(const PointCloud<PointXYZRGBNormalCam>::Ptr& _cloud, PointCloud<PointXYZRGBNormalCam>::Ptr _outCloud);
// Estimates the plane defined by the cameras
void getPlaneDefinedByCameras(PointXYZRGBNormalCam& _normal) const;
// Fit a plane in a point cloud given and return its normal
void fitPlane(const std::vector<Eigen::Vector3f> _cloud, Eigen::Vector3f& _normal) const;
// Estimate the normals of a cloud and store them
void estimateNormals(const unsigned int _index);
void estimateNormals(const unsigned int _index, const float _radius);
void estimateAllNormals();
void estimateAllNormals(const float _radius);
// Fix the normal orientation using the camera position
void fixNormal(const unsigned int _index);
void fixAllNormals();
// Plane segmentation
void segmentPlanes(float _threshold);
// Cilinder segmentation
void segmentCylinders();
// Surface reconstruction
void surfaceReconstruction(const unsigned int _index);
PolygonMesh surfaceReconstruction(PointCloud<PointXYZRGBNormalCam>::Ptr _cloud);
void allSurfaceReconstruction();
// Mesh operations
void detectLargestComponent(Mesh& _inputMesh) const;
bool isMeshOpen(const Mesh& _inputMesh) const;
void openHole(Mesh& _inputMesh, const PointXYZRGBNormalCam& _normal) const;
// Mesh refining
void cleanOpenMesh(const PointCloud<PointXYZRGBNormalCam>::Ptr& _cloud, Mesh& _inputMesh) const;
PolygonMesh deleteWrongVertices(PointCloud<PointXYZRGBNormalCam>::Ptr _cloud, PolygonMesh& _inputMesh);
PolygonMesh decimateMesh(const PolygonMesh& _mesh, float _reduction);
PolygonMesh smoothMeshLaplacian(const PolygonMesh& _mesh);
// Adding every camera to the cloud to see if their position is correct
void drawCameras();
// Export a txt file with the camera setup information for the multi-texturing process
void writeCameraSetupFile(std::string _fileName, const int _width, const int _height);
void writeCameraSetupFile(std::string _fileName);
void getImageDimensions(std::string _imageName, unsigned int& _height, unsigned int& _width);
// Combine point clouds
PointCloud<PointXYZRGBNormalCam> combinePointClouds();
PointCloud<PointXYZRGBNormalCam> combinePointClouds(std::vector<PointCloud<PointXYZRGBNormalCam>::Ptr > _pointclouds);
// Asign cameras to mesh and export a file with it
void assignCam2Mesh(const PolygonMesh& _mesh, const PointCloud<PointXYZRGBNormalCam>::Ptr _cloud, const std::string _fileName);
// I/O functions
bool bundlerPointReader(PointXYZRGBNormalCam& _point, std::ifstream& _stream);
void readPLYCloud(const std::string& _fileName);
void writeOneCloud(const unsigned int _index, const std::string& _fileName);
void writeCloud(const std::string& _fileName);
void bundlerReader(const std::string& _fileName);
void bundlerReadOnlyCameraInfo(const std::string& _fileName);
void readImageList(const std::string& _fileName);
void readPLYMesh(const std::string& _fileName, PolygonMesh& _mesh);
void readOBJMesh(const std::string& _fileName, PolygonMesh& _mesh);
void writeOBJMesh(const std::string& _fileName, PolygonMesh& _mesh);
void exportIndices (PointIndices& _indices, const std::string& _fileName);
void exportCamPerVtx (const std::string& _fileName);
// Other...
void deleteWrongCameras(const std::string& _fileName);
private:
bool isPointCloseToPointCloud(const PointXYZRGBNormalCam& _point, const PointCloud<PointXYZRGBNormalCam>::Ptr _cloud, float _radius) const;
void removeOutliersFromCamPerVtx(PointIndices& _indices);
std::vector<PointCloud<PointXYZRGBNormalCam>::Ptr > pointClouds_;
unsigned int nClouds_;
std::vector<Camera> cameras_;
unsigned int nCameras_;
std::vector<std::string> imageList_;
std::vector<std::vector<int> > camPerVtx_;
};
#endif