Texturing: ignore polygons not facing the camera

This commit is contained in:
matlabbe
2017-02-01 00:29:13 -05:00
parent bfb9feaf07
commit a1ceff8ce8
2 changed files with 47 additions and 27 deletions

View File

@@ -1131,7 +1131,19 @@ pcl::TextureMapping<PointInT>::checkPointInsideTriangle(const pcl::PointXY &p1,
template<typename PointInT> inline bool template<typename PointInT> inline bool
pcl::TextureMapping<PointInT>::isFaceProjected (const Camera &camera, const PointInT &p1, const PointInT &p2, const PointInT &p3, pcl::PointXY &proj1, pcl::PointXY &proj2, pcl::PointXY &proj3) pcl::TextureMapping<PointInT>::isFaceProjected (const Camera &camera, const PointInT &p1, const PointInT &p2, const PointInT &p3, pcl::PointXY &proj1, pcl::PointXY &proj2, pcl::PointXY &proj3)
{ {
return (getPointUVCoordinates(p1, camera, proj1) // check if the polygon is facing the camera, assuming counterclockwise normal
Eigen::Vector3f v0(
p2.x - p1.x,
p2.y - p1.y,
p2.z - p1.z);
Eigen::Vector3f v1(
p3.x - p1.x,
p3.y - p1.y,
p3.z - p1.z);
Eigen::Vector3f normal = v0.cross(v1);
return normal.dot(Eigen::Vector3f(0.0f,0.0f,-1.0f)) > 0.0f && // toward the camera
(getPointUVCoordinates(p1, camera, proj1)
&& &&
getPointUVCoordinates(p2, camera, proj2) getPointUVCoordinates(p2, camera, proj2)
&& &&

View File

@@ -668,7 +668,8 @@ void ExportCloudsDialog::viewClouds(
// be duplicated. // be duplicated.
for (unsigned int t = 0; t < mesh->tex_coordinates.size(); ++t) for (unsigned int t = 0; t < mesh->tex_coordinates.size(); ++t)
{ {
UASSERT(mesh->tex_polygons[t].size()); if(mesh->tex_polygons[t].size())
{
pcl::PointCloud<pcl::PointXYZ>::Ptr originalCloud(new pcl::PointCloud<pcl::PointXYZ>); pcl::PointCloud<pcl::PointXYZ>::Ptr originalCloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::fromPCLPointCloud2(mesh->cloud, *originalCloud); pcl::fromPCLPointCloud2(mesh->cloud, *originalCloud);
@@ -696,6 +697,11 @@ void ExportCloudsDialog::viewClouds(
} }
pcl::toPCLPointCloud2(*cloud, mesh->cloud); pcl::toPCLPointCloud2(*cloud, mesh->cloud);
} }
else
{
UWARN("No polygons for texture %d of mesh %d?!", t, iter->first);
}
}
if (globalTexture.empty()) if (globalTexture.empty())
{ {
@@ -898,6 +904,7 @@ bool ExportCloudsDialog::getExportedClouds(
_progressDialog->appendText(tr("Gain compensation of %1 clouds...").arg(clouds.size())); _progressDialog->appendText(tr("Gain compensation of %1 clouds...").arg(clouds.size()));
} }
QApplication::processEvents(); QApplication::processEvents();
uSleep(100);
QApplication::processEvents(); QApplication::processEvents();
if(!_ui->checkBox_gainLinkedLocationsOnly->isChecked()) if(!_ui->checkBox_gainLinkedLocationsOnly->isChecked())
@@ -1011,6 +1018,7 @@ bool ExportCloudsDialog::getExportedClouds(
_progressDialog->appendText(tr("Smoothing the surface using Moving Least Squares (MLS) algorithm... " _progressDialog->appendText(tr("Smoothing the surface using Moving Least Squares (MLS) algorithm... "
"[search radius=%1m voxel=%2m]").arg(_ui->doubleSpinBox_mlsRadius->value()).arg(_ui->doubleSpinBox_voxelSize_assembled->value())); "[search radius=%1m voxel=%2m]").arg(_ui->doubleSpinBox_mlsRadius->value()).arg(_ui->doubleSpinBox_voxelSize_assembled->value()));
QApplication::processEvents(); QApplication::processEvents();
uSleep(100);
QApplication::processEvents(); QApplication::processEvents();
// Adjust view points with local transforms // Adjust view points with local transforms