mirror of
https://github.com/introlab/rtabmap.git
synced 2026-09-02 01:20:25 +08:00
Fixed a bug where camera facing polygons were not textured
This commit is contained in:
@@ -1103,17 +1103,16 @@ pcl::TextureMapping<PointInT>::textureMeshwithMultipleCameras2 (
|
||||
{
|
||||
// check if the polygon is facing the camera, assuming counterclockwise normal
|
||||
Eigen::Vector3f v0(
|
||||
pt1.x - pt0.x,
|
||||
pt1.y - pt0.y,
|
||||
pt1.z - pt0.z);
|
||||
uv_coords2.x - uv_coords1.x,
|
||||
uv_coords2.y - uv_coords1.y,
|
||||
0);
|
||||
Eigen::Vector3f v1(
|
||||
pt2.x - pt0.x,
|
||||
pt2.y - pt0.y,
|
||||
pt2.z - pt0.z);
|
||||
uv_coords3.x - uv_coords1.x,
|
||||
uv_coords3.y - uv_coords1.y,
|
||||
0);
|
||||
Eigen::Vector3f normal = v0.cross(v1);
|
||||
float angle = normal.dot(Eigen::Vector3f(0.0f,0.0f,-1.0f));
|
||||
float angle = normal.dot(Eigen::Vector3f(0.0f,0.0f,1.0f));
|
||||
bool facingTheCam = angle>0.0f;
|
||||
|
||||
float distanceToCam = std::min(std::min(pt0.z, pt1.z), pt2.z);
|
||||
pcl::PointXY center;
|
||||
center.x = (uv_coords1.x+uv_coords2.x+uv_coords3.x)/3.0f;
|
||||
@@ -1254,12 +1253,13 @@ pcl::TextureMapping<PointInT>::textureMeshwithMultipleCameras2 (
|
||||
UWARN("Texturing cancelled!");
|
||||
return false;
|
||||
}
|
||||
int textured = 0;
|
||||
for(unsigned int idx_face=0; idx_face<faces.size(); ++idx_face)
|
||||
{
|
||||
if((idx_face+1)%10000 == 0)
|
||||
{
|
||||
UDEBUG("face %d/%d", idx_face+1, (int)faces.size());
|
||||
if(state && !state->callback(uFormat("Textured %d/%d polygons", (int)idx_face+1, (int)faces.size())))
|
||||
if(state && !state->callback(uFormat("Textured %d/%d of %d polygons", textured, idx_face+1, (int)faces.size())))
|
||||
{
|
||||
//cancelled!
|
||||
UWARN("Texturing cancelled!");
|
||||
@@ -1293,6 +1293,7 @@ pcl::TextureMapping<PointInT>::textureMeshwithMultipleCameras2 (
|
||||
|
||||
if(cameraIndex >= 0)
|
||||
{
|
||||
++textured;
|
||||
mesh.tex_polygons[cameraIndex].push_back(face);
|
||||
mesh.tex_coordinates[cameraIndex].push_back(Eigen::Vector2f(uv_coords[0].x, uv_coords[0].y));
|
||||
mesh.tex_coordinates[cameraIndex].push_back(Eigen::Vector2f(uv_coords[1].x, uv_coords[1].y));
|
||||
@@ -1306,7 +1307,7 @@ pcl::TextureMapping<PointInT>::textureMeshwithMultipleCameras2 (
|
||||
mesh.tex_coordinates[cameras.size()].push_back(Eigen::Vector2f(-1.0,-1.0));
|
||||
}
|
||||
}
|
||||
UINFO("Process %d polygons...done!", (int)faces.size());
|
||||
UINFO("Process %d polygons...done! (%d textured)", (int)faces.size(), textured);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ protected:
|
||||
|
||||
public slots:
|
||||
void appendText(const QString & text ,const QColor & color = Qt::black);
|
||||
void incrementStep();
|
||||
void incrementStep(int steps = 1);
|
||||
void clear();
|
||||
void resetProgress();
|
||||
|
||||
|
||||
@@ -889,7 +889,6 @@ bool ExportCloudsDialog::getExportedClouds(
|
||||
{
|
||||
mul+=1;
|
||||
}
|
||||
mul+=1; // normals
|
||||
if(_ui->checkBox_textureMapping->isChecked())
|
||||
{
|
||||
mul+=1;
|
||||
@@ -1720,7 +1719,7 @@ bool ExportCloudsDialog::getExportedClouds(
|
||||
|
||||
meshes.insert(std::make_pair(iter->first, mesh));
|
||||
|
||||
_progressDialog->incrementStep();
|
||||
_progressDialog->incrementStep(_ui->checkBox_assemble->isChecked()?poses.size():1);
|
||||
QApplication::processEvents();
|
||||
if(_canceled)
|
||||
{
|
||||
@@ -1877,6 +1876,7 @@ bool ExportCloudsDialog::getExportedClouds(
|
||||
}
|
||||
|
||||
TexturingState texturingState(_progressDialog);
|
||||
_progressDialog->setMaximumSteps(_progressDialog->maximumSteps()+iter->second->polygons.size()/10000+1);
|
||||
textureMesh = util3d::createTextureMesh(
|
||||
iter->second,
|
||||
cameraPoses,
|
||||
|
||||
@@ -133,14 +133,14 @@ void ProgressDialog::setMaximumSteps(int steps)
|
||||
_progressBar->setMaximum(steps);
|
||||
}
|
||||
|
||||
void ProgressDialog::incrementStep()
|
||||
void ProgressDialog::incrementStep(int steps)
|
||||
{
|
||||
//incremental progress bar (if we don't know how many items will be added)
|
||||
if(_progressBar->value() == _progressBar->maximum()-1)
|
||||
if(_progressBar->value() >= _progressBar->maximum()-steps)
|
||||
{
|
||||
_progressBar->setMaximum(_progressBar->maximum()+1);
|
||||
_progressBar->setMaximum(_progressBar->maximum()+steps+1);
|
||||
}
|
||||
_progressBar->setValue(_progressBar->value()+1);
|
||||
_progressBar->setValue(_progressBar->value()+steps);
|
||||
}
|
||||
|
||||
void ProgressDialog::clear()
|
||||
|
||||
@@ -50,6 +50,7 @@ public:
|
||||
if(!msg.empty())
|
||||
{
|
||||
dialog_->appendText(msg.c_str());
|
||||
dialog_->incrementStep();
|
||||
}
|
||||
QApplication::processEvents();
|
||||
return !canceled_;
|
||||
|
||||
Reference in New Issue
Block a user