44 #include <pcl/surface/reconstruction.h>
45 #include <pcl/common/transforms.h>
46 #include <pcl/TextureMesh.h>
47 #include <pcl/octree/octree_search.h>
52 namespace texture_mapping
90 using CameraVector = std::vector<Camera, Eigen::aligned_allocator<Camera> >;
98 template<
typename Po
intInT>
103 using Ptr = shared_ptr<TextureMapping<PointInT> >;
104 using ConstPtr = shared_ptr<const TextureMapping<PointInT> >;
198 double sizeX = cam.
width;
199 double sizeY = cam.
height;
210 double focal_x, focal_y;
221 UV_coordinates[0] =
static_cast<float> ((focal_x * (pt.x / pt.z) + cx) / sizeX);
222 UV_coordinates[1] = 1.0f -
static_cast<float> (((focal_y * (pt.y / pt.z) + cy) / sizeY));
225 if (UV_coordinates[0] >= 0.0 && UV_coordinates[0] <= 1.0 && UV_coordinates[1] >= 0.0 && UV_coordinates[1]
231 UV_coordinates[0] = -1.0;
232 UV_coordinates[1] = -1.0;
253 PointCloudPtr &filtered_cloud,
const double octree_voxel_size,
286 const double octree_voxel_size,
PointCloud &visible_pts);
301 const double octree_voxel_size,
302 const bool show_nb_occlusions =
true,
303 const int max_occlusions = 4);
318 double octree_voxel_size,
319 bool show_nb_occlusions =
true,
320 int max_occlusions = 4);
350 std::vector<Eigen::Vector2f, Eigen::aligned_allocator<Eigen::Vector2f> >
351 mapTexture2Face (
const Eigen::Vector3f &p1,
const Eigen::Vector3f &p2,
const Eigen::Vector3f &p3);
397 const PointInT &p1,
const PointInT &p2,
const PointInT &p3,
414 return (
"TextureMapping");
shared_ptr< PointCloud< PointInT > > Ptr
shared_ptr< const PointCloud< PointInT > > ConstPtr
The texture mapping algorithm.
void setF(float f)
Set mesh scale control.
bool getPointUVCoordinates(const PointInT &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.
TexMaterial tex_material_
list of texture materials
void mapTexture2Mesh(pcl::TextureMesh &tex_mesh)
Map texture to a mesh synthesis algorithm.
shared_ptr< const TextureMapping< PointInT > > ConstPtr
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.
TextureMapping()=default
Constructor.
~TextureMapping()=default
Destructor.
typename PointCloud::Ptr PointCloudPtr
std::string getClassName() const
Class get name method.
typename Octree::Ptr OctreePtr
void setTextureFiles(std::vector< std::string > tex_files)
Set texture files.
float f_
mesh scale control.
bool isPointOccluded(const PointInT &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.
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.
bool isFaceProjected(const Camera &camera, const PointInT &p1, const PointInT &p2, const PointInT &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.
void removeOccludedPoints(const PointCloudPtr &input_cloud, PointCloudPtr &filtered_cloud, const double octree_voxel_size, pcl::Indices &visible_indices, pcl::Indices &occluded_indices)
Remove occluded points from a point cloud.
std::vector< std::string > tex_files_
list of texture files
typename Octree::ConstPtr OctreeConstPtr
std::vector< Eigen::Vector2f, Eigen::aligned_allocator< Eigen::Vector2f > > mapTexture2Face(const Eigen::Vector3f &p1, const Eigen::Vector3f &p2, const Eigen::Vector3f &p3)
Map texture to a face.
Eigen::Vector3f vector_field_
vector field
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.
void getTriangleCircumcenterAndSize(const pcl::PointXY &p1, const pcl::PointXY &p2, const pcl::PointXY &p3, pcl::PointXY &circumcenter, double &radius)
Returns the circumcenter of a triangle and the circle's radius.
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.
typename PointCloud::ConstPtr PointCloudConstPtr
void mapMultipleTexturesToMeshUV(pcl::TextureMesh &tex_mesh, pcl::texture_mapping::CameraVector &cams)
Map textures acquired from a set of cameras onto a mesh.
shared_ptr< TextureMapping< PointInT > > Ptr
void setTextureMaterials(TexMaterial tex_material)
Set texture materials.
void textureMeshwithMultipleCameras(pcl::TextureMesh &mesh, const pcl::texture_mapping::CameraVector &cameras)
Segment and texture faces by camera visibility.
Octree pointcloud search class
shared_ptr< const OctreePointCloudSearch< PointT, LeafContainerT, BranchContainerT > > ConstPtr
shared_ptr< OctreePointCloudSearch< PointT, LeafContainerT, BranchContainerT > > Ptr
#define PCL_MAKE_ALIGNED_OPERATOR_NEW
Macro to signal a class requires a custom allocator.
Defines functions, macros and traits for allocating and using memory.
std::vector< Camera, Eigen::aligned_allocator< Camera > > CameraVector
IndicesAllocator<> Indices
Type used for indices in PCL.
Defines all the PCL and non-PCL macros used.
A 2D point structure representing Euclidean xy coordinates.
Structure to store camera pose and focal length.
Structure that links a uv coordinate to its 3D point and face.