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;

View File

@@ -371,6 +371,7 @@ void ExportCloudsDialog::saveSettings(QSettings & settings, const QString & grou
settings.setValue("mesh_textureMaxAngle", _ui->doubleSpinBox_meshingTextureMaxAngle->value());
settings.setValue("mesh_textureMinCluster", _ui->spinBox_mesh_minTextureClusterSize->value());
settings.setValue("mesh_textureRoiRatios", _ui->lineEdit_meshingTextureRoiRatios->text());
settings.setValue("mesh_textureDistanceToCamPolicy", _ui->checkBox_distanceToCamPolicy->isChecked());
settings.setValue("mesh_textureCameraFiltering", _ui->checkBox_cameraFilter->isChecked());
settings.setValue("mesh_textureCameraFilteringRadius", _ui->doubleSpinBox_cameraFilterRadius->value());
settings.setValue("mesh_textureCameraFilteringAngle", _ui->doubleSpinBox_cameraFilterAngle->value());
@@ -510,6 +511,7 @@ void ExportCloudsDialog::loadSettings(QSettings & settings, const QString & grou
_ui->doubleSpinBox_meshingTextureMaxAngle->setValue(settings.value("mesh_textureMaxAngle", _ui->doubleSpinBox_meshingTextureMaxAngle->value()).toDouble());
_ui->spinBox_mesh_minTextureClusterSize->setValue(settings.value("mesh_textureMinCluster", _ui->spinBox_mesh_minTextureClusterSize->value()).toDouble());
_ui->lineEdit_meshingTextureRoiRatios->setText(settings.value("mesh_textureRoiRatios", _ui->lineEdit_meshingTextureRoiRatios->text()).toString());
_ui->checkBox_distanceToCamPolicy->setChecked(settings.value("mesh_textureDistanceToCamPolicy", _ui->checkBox_distanceToCamPolicy->isChecked()).toBool());
_ui->checkBox_cameraFilter->setChecked(settings.value("mesh_textureCameraFiltering", _ui->checkBox_cameraFilter->isChecked()).toBool());
_ui->doubleSpinBox_cameraFilterRadius->setValue(settings.value("mesh_textureCameraFilteringRadius", _ui->doubleSpinBox_cameraFilterRadius->value()).toDouble());
_ui->doubleSpinBox_cameraFilterAngle->setValue(settings.value("mesh_textureCameraFilteringAngle", _ui->doubleSpinBox_cameraFilterAngle->value()).toDouble());
@@ -646,6 +648,7 @@ void ExportCloudsDialog::restoreDefaults()
_ui->doubleSpinBox_meshingTextureMaxAngle->setValue(0.0);
_ui->spinBox_mesh_minTextureClusterSize->setValue(50);
_ui->lineEdit_meshingTextureRoiRatios->setText("0.0 0.0 0.0 0.0");
_ui->checkBox_distanceToCamPolicy->setChecked(false);
_ui->checkBox_cameraFilter->setChecked(false);
_ui->doubleSpinBox_cameraFilterRadius->setValue(0);
_ui->doubleSpinBox_cameraFilterAngle->setValue(30);
@@ -2930,7 +2933,8 @@ bool ExportCloudsDialog::getExportedClouds(
_ui->spinBox_mesh_minTextureClusterSize->value(),
roiRatios,
&texturingState,
cameraPoses.size()>1?&textureVertexToPixels:0); // only get vertexToPixels if merged clouds with multi textures
cameraPoses.size()>1?&textureVertexToPixels:0, // only get vertexToPixels if merged clouds with multi textures
_ui->checkBox_distanceToCamPolicy->isChecked());
if(_canceled)
{

View File

@@ -23,9 +23,9 @@
<property name="geometry">
<rect>
<x>0</x>
<y>-2339</y>
<y>-2387</y>
<width>780</width>
<height>4823</height>
<height>4880</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout_13">
@@ -1595,7 +1595,7 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
<layout class="QVBoxLayout" name="verticalLayout_16">
<item>
<layout class="QGridLayout" name="gridLayout_15" columnstretch="0,1">
<item row="12" column="0">
<item row="13" column="0">
<widget class="QSpinBox" name="spinBox_textureBrightnessContrastRatioHigh">
<property name="suffix">
<string> %</string>
@@ -1608,7 +1608,7 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
</property>
</widget>
</item>
<item row="12" column="1">
<item row="13" column="1">
<widget class="QLabel" name="label_meshingTextureSize_6">
<property name="text">
<string>Brightness and contrast balance high ratio. Only used when textures are merged.</string>
@@ -1618,7 +1618,7 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
</property>
</widget>
</item>
<item row="10" column="0">
<item row="11" column="0">
<widget class="QComboBox" name="comboBox_blendingDecimation">
<item>
<property name="text">
@@ -1662,14 +1662,14 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
</item>
</widget>
</item>
<item row="9" column="0">
<item row="10" column="0">
<widget class="QCheckBox" name="checkBox_blending">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="10" column="1">
<item row="11" column="1">
<widget class="QLabel" name="label_exposureFusion_3">
<property name="text">
<string>Blending decimation. </string>
@@ -1699,7 +1699,7 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
</property>
</widget>
</item>
<item row="9" column="1">
<item row="10" column="1">
<widget class="QLabel" name="label_exposureFusion_2">
<property name="text">
<string>Blending. Only used with dense reconstruction flavor and if clouds are assembled.</string>
@@ -1741,7 +1741,7 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
</property>
</widget>
</item>
<item row="11" column="1">
<item row="12" column="1">
<widget class="QLabel" name="label_meshingTextureSize_5">
<property name="text">
<string>Brightness and contrast balance low ratio. Only used when textures are merged.</string>
@@ -1824,7 +1824,7 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
</item>
</widget>
</item>
<item row="14" column="0">
<item row="15" column="0">
<widget class="QCheckBox" name="checkBox_exposureFusion">
<property name="text">
<string/>
@@ -1854,14 +1854,14 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
</property>
</widget>
</item>
<item row="8" column="0">
<item row="9" column="0">
<widget class="QCheckBox" name="checkBox_cameraFilter">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="11" column="0">
<item row="12" column="0">
<widget class="QSpinBox" name="spinBox_textureBrightnessContrastRatioLow">
<property name="suffix">
<string> %</string>
@@ -1884,7 +1884,7 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
</property>
</widget>
</item>
<item row="8" column="1">
<item row="9" column="1">
<widget class="QLabel" name="label_meshingTextureSize_3">
<property name="text">
<string>Camera filtering. Some criteria to select which cameras are used for texturing.</string>
@@ -1894,7 +1894,7 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
</property>
</widget>
</item>
<item row="14" column="1">
<item row="15" column="1">
<widget class="QLabel" name="label_exposureFusion">
<property name="text">
<string>Exposure fusion. Only used when textures are merged and brightness/contrast balance ratios are used (merging original texture + 1 for each ratios).</string>
@@ -1978,7 +1978,7 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
</property>
</widget>
</item>
<item row="15" column="1">
<item row="16" column="1">
<widget class="QLabel" name="label_multiband">
<property name="text">
<string>MultiBand texturing. Only available on export and RTAB-Map should be built with AliceVision support.</string>
@@ -1988,13 +1988,30 @@ Guidelines: 4 times the voxel size, 0.025 for voxel=0.</string>
</property>
</widget>
</item>
<item row="15" column="0">
<item row="16" column="0">
<widget class="QCheckBox" name="checkBox_multiband">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="8" column="1">
<widget class="QLabel" name="label_meshingTextureSize_11">
<property name="text">
<string>Distance to camera policy. The closest camera from a polygon is used to texture the polygon. If disabled, the camera for which the polygon projection is the closest of the image center is used to texture the polygon.</string>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
<item row="8" column="0">
<widget class="QCheckBox" name="checkBox_distanceToCamPolicy">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@@ -305,7 +305,7 @@ int main(int argc, char * argv[])
std::multimap<int, Link> links;
printf("Optimizing the map...\n");
rtabmap.getGraph(optimizedPoses, links, true, true, &nodes, true, true, true, true);
printf("Optimizing the map... done (%fs).\n", timer.ticks());
printf("Optimizing the map... done (%fs, poses=%d).\n", timer.ticks(), (int)optimizedPoses.size());
std::string outputDirectory = UDirectory::getDir(dbPath);
std::string baseName = uSplit(UFile::getName(dbPath), '.').front();