Texturing: add distanceToCamPolicy option

This commit is contained in:
matlabbe
2020-11-03 16:11:37 -05:00
parent 596cd10b69
commit e269067d4c
7 changed files with 61 additions and 28 deletions

View File

@@ -148,7 +148,8 @@ pcl::TextureMesh::Ptr RTABMAP_EXP createTextureMesh(
int minClusterSize = 50, // minimum size of polygons clusters textured
const std::vector<float> & roiRatios = std::vector<float>(), // [left, right, top, bottom] region of interest (in ratios) of the image projected.
const ProgressState * state = 0,
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels = 0);
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels = 0,
bool distanceToCamPolicy = false);
pcl::TextureMesh::Ptr RTABMAP_EXP createTextureMesh(
const pcl::PolygonMesh::Ptr & mesh,
const std::map<int, Transform> & poses,
@@ -160,7 +161,8 @@ pcl::TextureMesh::Ptr RTABMAP_EXP createTextureMesh(
int minClusterSize = 50, // minimum size of polygons clusters textured
const std::vector<float> & roiRatios = std::vector<float>(), // [left, right, top, bottom] region of interest (in ratios) of the image projected.
const ProgressState * state = 0,
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels = 0);
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels = 0,
bool distanceToCamPolicy = false);
/**
* Remove not textured polygon clusters. If minClusterSize<0, only the largest cluster is kept.

View File

@@ -1055,7 +1055,8 @@ pcl::TextureMapping<PointInT>::textureMeshwithMultipleCameras2 (
pcl::TextureMesh &mesh,
const pcl::texture_mapping::CameraVector &cameras,
const rtabmap::ProgressState * state,
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels)
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels,
bool distanceToCamPolicy)
{
if (mesh.tex_polygons.size () != 1)
@@ -1386,10 +1387,15 @@ pcl::TextureMapping<PointInT>::textureMeshwithMultipleCameras2 (
//UDEBUG("Process polygon %d cam =%d distanceToCam=%f", idx_face, current_cam, distanceToCam);
if(distanceToCenter <= smallestWeight || (!depthSet && currentDepthSet))
float distance = distanceToCenter;
if(distanceToCamPolicy)
{
distance = distanceToCam;
}
if(distance <= smallestWeight || (!depthSet && currentDepthSet))
{
cameraIndex = current_cam;
smallestWeight = distanceToCenter;
smallestWeight = distance;
uv_coords[0] = iter->second.uv_coord1;
uv_coords[1] = iter->second.uv_coord2;
uv_coords[2] = iter->second.uv_coord3;

View File

@@ -366,7 +366,8 @@ namespace pcl
textureMeshwithMultipleCameras2 (pcl::TextureMesh &mesh,
const pcl::texture_mapping::CameraVector &cameras,
const rtabmap::ProgressState * callback = 0,
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels = 0);
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels = 0,
bool distanceToCamPolicy = false);
protected:
/** \brief mesh scale control. */

View File

@@ -676,7 +676,8 @@ pcl::TextureMesh::Ptr createTextureMesh(
int minClusterSize,
const std::vector<float> & roiRatios,
const ProgressState * state,
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels)
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels,
bool distanceToCamPolicy)
{
std::map<int, std::vector<CameraModel> > cameraSubModels;
for(std::map<int, CameraModel>::const_iterator iter=cameraModels.begin(); iter!=cameraModels.end(); ++iter)
@@ -697,7 +698,8 @@ pcl::TextureMesh::Ptr createTextureMesh(
minClusterSize,
roiRatios,
state,
vertexToPixels);
vertexToPixels,
distanceToCamPolicy);
}
pcl::TextureMesh::Ptr createTextureMesh(
@@ -711,7 +713,8 @@ pcl::TextureMesh::Ptr createTextureMesh(
int minClusterSize,
const std::vector<float> & roiRatios,
const ProgressState * state,
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels)
std::vector<std::map<int, pcl::PointXY> > * vertexToPixels,
bool distanceToCamPolicy)
{
UASSERT(mesh->polygons.size());
pcl::TextureMesh::Ptr textureMesh(new pcl::TextureMesh);
@@ -776,7 +779,7 @@ pcl::TextureMesh::Ptr createTextureMesh(
tm.setMaxDepthError(maxDepthError);
}
tm.setMinClusterSize(minClusterSize);
if(tm.textureMeshwithMultipleCameras2(*textureMesh, cameras, state, vertexToPixels))
if(tm.textureMeshwithMultipleCameras2(*textureMesh, cameras, state, vertexToPixels, distanceToCamPolicy))
{
// compute normals for the mesh if not already here
bool hasNormals = false;