mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-03 01:50:24 +08:00
Added util3d::fixTextureMeshForVisualization()
This commit is contained in:
@@ -231,6 +231,8 @@ cv::Mat RTABMAP_EXP mergeTextures(
|
|||||||
bool exposureFusion = false, //Exposure fusion can be used only with OpenCV3
|
bool exposureFusion = false, //Exposure fusion can be used only with OpenCV3
|
||||||
const ProgressState * state = 0);
|
const ProgressState * state = 0);
|
||||||
|
|
||||||
|
void RTABMAP_EXP fixTextureMeshForVisualization(pcl::TextureMesh & textureMesh);
|
||||||
|
|
||||||
cv::Mat RTABMAP_EXP computeNormals(
|
cv::Mat RTABMAP_EXP computeNormals(
|
||||||
const cv::Mat & laserScan,
|
const cv::Mat & laserScan,
|
||||||
int searchK,
|
int searchK,
|
||||||
|
|||||||
@@ -2043,6 +2043,45 @@ cv::Mat mergeTextures(
|
|||||||
return globalTextures;
|
return globalTextures;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void fixTextureMeshForVisualization(pcl::TextureMesh & textureMesh)
|
||||||
|
{
|
||||||
|
// VTK issue:
|
||||||
|
// tex_coordinates should be linked to points, not
|
||||||
|
// polygon vertices. Points linked to multiple different TCoords (different textures) should
|
||||||
|
// be duplicated.
|
||||||
|
for (unsigned int t = 0; t < textureMesh.tex_coordinates.size(); ++t)
|
||||||
|
{
|
||||||
|
if(textureMesh.tex_polygons[t].size())
|
||||||
|
{
|
||||||
|
pcl::PointCloud<pcl::PointXYZ>::Ptr originalCloud(new pcl::PointCloud<pcl::PointXYZ>);
|
||||||
|
pcl::fromPCLPointCloud2(textureMesh.cloud, *originalCloud);
|
||||||
|
|
||||||
|
// make a cloud with as many points than polygon vertices
|
||||||
|
unsigned int nPoints = textureMesh.tex_coordinates[t].size();
|
||||||
|
UASSERT(nPoints == textureMesh.tex_polygons[t].size()*textureMesh.tex_polygons[t][0].vertices.size()); // assuming polygon size is constant!
|
||||||
|
|
||||||
|
pcl::PointCloud<pcl::PointXYZ>::Ptr newCloud(new pcl::PointCloud<pcl::PointXYZ>);
|
||||||
|
newCloud->resize(nPoints);
|
||||||
|
|
||||||
|
unsigned int oi = 0;
|
||||||
|
for (unsigned int i = 0; i < textureMesh.tex_polygons[t].size(); ++i)
|
||||||
|
{
|
||||||
|
pcl::Vertices & vertices = textureMesh.tex_polygons[t][i];
|
||||||
|
|
||||||
|
for(unsigned int j=0; j<vertices.vertices.size(); ++j)
|
||||||
|
{
|
||||||
|
UASSERT(oi < newCloud->size());
|
||||||
|
UASSERT_MSG(vertices.vertices[j] < originalCloud->size(), uFormat("%d vs %d", vertices.vertices[j], (int)originalCloud->size()).c_str());
|
||||||
|
newCloud->at(oi) = originalCloud->at(vertices.vertices[j]);
|
||||||
|
vertices.vertices[j] = oi; // new vertex index
|
||||||
|
++oi;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pcl::toPCLPointCloud2(*newCloud, textureMesh.cloud);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
LaserScan computeNormals(
|
LaserScan computeNormals(
|
||||||
const LaserScan & laserScan,
|
const LaserScan & laserScan,
|
||||||
int searchK,
|
int searchK,
|
||||||
|
|||||||
Reference in New Issue
Block a user