40 #ifndef PCL_SURFACE_TEXTURE_MAPPING_H_
41 #define PCL_SURFACE_TEXTURE_MAPPING_H_
43 #include <pcl/surface/reconstruction.h>
44 #include <pcl/common/transforms.h>
45 #include <pcl/TextureMesh.h>
50 namespace texture_mapping
63 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
75 typedef std::vector<Camera, Eigen::aligned_allocator<Camera> >
CameraVector;
83 template<
typename Po
intInT>
88 typedef boost::shared_ptr< PointInT >
Ptr;
89 typedef boost::shared_ptr< const PointInT >
ConstPtr;
188 double sizeX = cam.
width;
189 double sizeY = cam.
height;
190 double cx = (sizeX) / 2.0;
191 double cy = (sizeY) / 2.0;
197 UV_coordinates[0] =
static_cast<float> ((focal_x * (pt.x / pt.z) + cx) / sizeX);
198 UV_coordinates[1] = 1.0f -
static_cast<float> (((focal_y * (pt.y / pt.z) + cy) / sizeY));
201 if (UV_coordinates[0] >= 0.0 && UV_coordinates[0] <= 1.0 && UV_coordinates[1] >= 0.0 && UV_coordinates[1]
207 UV_coordinates[0] = -1.0;
208 UV_coordinates[1] = -1.0;
229 PointCloudPtr &filtered_cloud,
const double octree_voxel_size,
230 std::vector<int> &visible_indices, std::vector<int> &occluded_indices);
262 const double octree_voxel_size,
PointCloud &visible_pts);
277 const double octree_voxel_size,
278 const bool show_nb_occlusions =
true,
279 const int max_occlusions = 4);
294 double octree_voxel_size,
295 bool show_nb_occlusions =
true,
296 int max_occlusions = 4);
326 std::vector<Eigen::Vector2f>
327 mapTexture2Face (
const Eigen::Vector3f &p1,
const Eigen::Vector3f &p2,
const Eigen::Vector3f &p3);
390 return (
"TextureMapping");
394 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
void getTriangleCircumcenterAndSize(const pcl::PointXY &p1, const pcl::PointXY &p2, const pcl::PointXY &p3, pcl::PointXY &circomcenter, double &radius)
Returns the circumcenter of a triangle and the circle's radius.
~TextureMapping()
Destructor.
A 2D point structure representing Euclidean xy coordinates.
bool isFaceProjected(const Camera &camera, const pcl::PointXYZ &p1, const pcl::PointXYZ &p2, const pcl::PointXYZ &p3, pcl::PointXY &proj1, pcl::PointXY &proj2, pcl::PointXY &proj3)
Returns true if all the vertices of one face are projected on the camera's image plane.
Structure to store camera pose and focal length.
boost::shared_ptr< const PointCloud< PointT > > ConstPtr
boost::shared_ptr< const PointInT > ConstPtr
boost::shared_ptr< PointCloud< PointT > > Ptr
void setTextureMaterials(TexMaterial tex_material)
Set texture materials.
bool checkPointInsideTriangle(const pcl::PointXY &p1, const pcl::PointXY &p2, const pcl::PointXY &p3, const pcl::PointXY &pt)
Returns True if a point lays within a triangle.
boost::shared_ptr< const OctreePointCloudSearch< PointT, LeafContainerT, BranchContainerT > > ConstPtr
void showOcclusions(const PointCloudPtr &input_cloud, pcl::PointCloud< pcl::PointXYZI >::Ptr &colored_cloud, const double octree_voxel_size, const bool show_nb_occlusions=true, const int max_occlusions=4)
Colors a point cloud, depending on its occlusions.
std::string getClassName() const
Class get name method.
pcl::octree::OctreePointCloudSearch< PointInT > Octree
pcl::PointCloud< PointInT > PointCloud
boost::shared_ptr< PointInT > Ptr
PointCloud::ConstPtr PointCloudConstPtr
bool isPointOccluded(const pcl::PointXYZ &pt, const OctreePtr octree)
Check if a point is occluded using raycasting on octree.
void setVectorField(float x, float y, float z)
Set vector field.
std::vector< Camera, Eigen::aligned_allocator< Camera > > CameraVector
PointCloud::Ptr PointCloudPtr
std::vector< std::string > tex_files_
list of texture files
Eigen::Vector3f vector_field_
vector field
void setTextureFiles(std::vector< std::string > tex_files)
Set texture files.
TexMaterial tex_material_
list of texture materials
float f_
mesh scale control.
pcl::texture_mapping::UvIndex UvIndex
Octree::ConstPtr OctreeConstPtr
Octree pointcloud search class
int sortFacesByCamera(pcl::TextureMesh &tex_mesh, pcl::TextureMesh &sorted_mesh, const pcl::texture_mapping::CameraVector &cameras, const double octree_voxel_size, PointCloud &visible_pts)
Segment faces by camera visibility.
Structure that links a uv coordinate to its 3D point and face.
void mapMultipleTexturesToMeshUV(pcl::TextureMesh &tex_mesh, pcl::texture_mapping::CameraVector &cams)
Map textures acquired from a set of cameras onto a mesh.
boost::shared_ptr< OctreePointCloudSearch< PointT, LeafContainerT, BranchContainerT > > Ptr
void mapTexture2Mesh(pcl::TextureMesh &tex_mesh)
Map texture to a mesh synthesis algorithm.
void getTriangleCircumcscribedCircleCentroid(const pcl::PointXY &p1, const pcl::PointXY &p2, const pcl::PointXY &p3, pcl::PointXY &circumcenter, double &radius)
Returns the centroid of a triangle and the corresponding circumscribed circle's radius.
std::vector< Eigen::Vector2f > mapTexture2Face(const Eigen::Vector3f &p1, const Eigen::Vector3f &p2, const Eigen::Vector3f &p3)
Map texture to a face.
void setF(float f)
Set mesh scale control.
A point structure representing Euclidean xyz coordinates.
The texture mapping algorithm.
pcl::texture_mapping::Camera Camera
bool getPointUVCoordinates(const pcl::PointXYZ &pt, const Camera &cam, Eigen::Vector2f &UV_coordinates)
computes UV coordinates of point, observed by one particular camera
void mapTexture2MeshUV(pcl::TextureMesh &tex_mesh)
Map texture to a mesh UV mapping.
TextureMapping()
Constructor.
void textureMeshwithMultipleCameras(pcl::TextureMesh &mesh, const pcl::texture_mapping::CameraVector &cameras)
Segment and texture faces by camera visibility.
void removeOccludedPoints(const PointCloudPtr &input_cloud, PointCloudPtr &filtered_cloud, const double octree_voxel_size, std::vector< int > &visible_indices, std::vector< int > &occluded_indices)
Remove occluded points from a point cloud.