diff --git a/.gitignore b/.gitignore
index f2045dc4..40869556 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,7 +4,8 @@ include/
lib/
logs/
src/
-
+odm_texturing-build/
+*.user
cmvs.tar.gz
parallel.tar.bz2
pcl.tar.gz
diff --git a/odm_texturing/CMakeLists.txt.user b/odm_texturing/CMakeLists.txt.user
deleted file mode 100644
index cfc3ea3a..00000000
--- a/odm_texturing/CMakeLists.txt.user
+++ /dev/null
@@ -1,203 +0,0 @@
-
-
-
-
-
- ProjectExplorer.Project.ActiveTarget
- 0
-
-
- ProjectExplorer.Project.EditorSettings
-
- true
- false
-
- Cpp
-
- CppGlobal
-
-
-
- QmlJS
-
- QmlJSGlobal
-
-
- 2
- System
- false
- 4
- true
- 1
- true
- 0
- true
- 0
- 8
- true
- 1
- true
- true
- true
- false
-
-
-
- ProjectExplorer.Project.PluginSettings
-
-
-
- ProjectExplorer.Project.Target.0
-
- Desktop
-
- CMakeProjectManager.DefaultCMakeTarget
- 0
- 0
- 0
-
- /home/spotscale/odm/OpenDroneMap_spotscale/odm_texturing4-build
- ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb
- ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb
-
-
-
-
- false
- Make
-
- CMakeProjectManager.MakeStep
-
- 1
- Build
-
- ProjectExplorer.BuildSteps.Build
-
-
-
- clean
-
- true
- Make
-
- CMakeProjectManager.MakeStep
-
- 1
- Clean
-
- ProjectExplorer.BuildSteps.Clean
-
- 2
- false
-
- all
-
- CMakeProjectManager.CMakeBuildConfiguration
-
- 1
-
-
- 0
- Deploy
-
- ProjectExplorer.BuildSteps.Deploy
-
- 1
- No deployment
-
- ProjectExplorer.DefaultDeployConfiguration
-
- 1
-
- true
- true
-
-
- false
- false
- false
- false
- false
- false
- false
- false
- true
- true
- 0.01
- 0.01
- 10
- 10
- true
- true
- 25
- 25
-
-
- true
- true
- valgrind
- valgrind
-
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
-
-
- 0
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
-
- 2
- odm_texturing
- -verbose -bundleFile "../../../shared_folder/copr2/reconstruction-with-image-size-1200/bundle/bundle.out" -imagesPath "../../../shared_folder/copr2" -imagesListPath "../../../shared_folder/copr2/reconstruction-with-image-size-1200/list.txt" -inputModelPath "../../../shared_folder/copr2/reconstruction-with-image-size-1200-results/odm_mesh-0000.ply" -outputFolder "../../../shared_folder/copr2/reconstruction-with-image-size-1200-results/odm_texturing/" -textureResolution 4096 -textureWithSize 3600 -bundleResizedTo 1200
- false
-
-
- odm_texturing
-
- CMakeProjectManager.CMakeRunConfiguration.
- 3768
- true
- false
- false
-
- 1
-
-
-
- ProjectExplorer.Project.TargetCount
- 1
-
-
- ProjectExplorer.Project.Updater.EnvironmentId
- {785a73be-b55f-490c-9d46-e1451c235840}
-
-
- ProjectExplorer.Project.Updater.FileVersion
- 10
-
-
diff --git a/odm_texturing/src/OdmTexturing.cpp b/odm_texturing/src/OdmTexturing.cpp
index 188d206b..b83589ea 100644
--- a/odm_texturing/src/OdmTexturing.cpp
+++ b/odm_texturing/src/OdmTexturing.cpp
@@ -397,6 +397,11 @@ void OdmTexturing::triangleToImageAssignment()
// Vector containing information if the face has been given an optimal camera or not
std::vector hasOptimalCamera = std::vector(mesh_->tex_polygons[0].size());
+ //Vector containing minimal distances to optimal camera
+ std::vector tTIA_distances(mesh_->tex_polygons[0].size(),DBL_MAX);
+ //Vector containing minimal angles of face to cameraplane normals
+ std::vector tTIA_angles(mesh_->tex_polygons[0].size(),DBL_MAX);
+
// Set default value that no face has an optimal camera
for (size_t faceIndex = 0; faceIndex < hasOptimalCamera.size(); ++faceIndex)
{
@@ -419,7 +424,7 @@ void OdmTexturing::triangleToImageAssignment()
{
// Move vertices in mesh into the camera coordinate system
pcl::PointCloud::Ptr cameraCloud (new pcl::PointCloud);
- pcl::transformPointCloud (*meshCloud, *cameraCloud, cameras_[cameraIndex].pose.inverse());
+ pcl::transformPointCloud (*meshCloud, *cameraCloud, cameras_[cameraIndex].pose);
// Cloud to contain points projected into current camera
pcl::PointCloud::Ptr projections (new pcl::PointCloud);
@@ -484,7 +489,8 @@ void OdmTexturing::triangleToImageAssignment()
}
-
+ std::vector local_tTIA_distances(mesh_->tex_polygons[0].size(),DBL_MAX);
+ std::vector local_tTIA_angles(mesh_->tex_polygons[0].size(),DBL_MAX);
// If any faces are visible in the current camera perform occlusion culling
if (countInsideFrustum > 0)
{
@@ -518,16 +524,46 @@ void OdmTexturing::triangleToImageAssignment()
// Perform radius search in the acceleration structure
int radiusSearch = kdTree.radiusSearch(center, radius, neighbors, neighborsSquaredDistance);
+ // Extract distances for all vertices for face to camera
+ double d0 = cameraCloud->points[mesh_->tex_polygons[0][faceIndex].vertices[0]].z;
+ double d1 = cameraCloud->points[mesh_->tex_polygons[0][faceIndex].vertices[1]].z;
+ double d2 = cameraCloud->points[mesh_->tex_polygons[0][faceIndex].vertices[2]].z;
+
+ // Calculate largest distance and store in distance variable
+ double distance = std::max(d0, std::max(d1,d2));
+
+ //Get points
+ pcl::PointXYZ p0=cameraCloud->points[mesh_->tex_polygons[0][faceIndex].vertices[0]];
+ pcl::PointXYZ p1=cameraCloud->points[mesh_->tex_polygons[0][faceIndex].vertices[1]];
+ pcl::PointXYZ p2=cameraCloud->points[mesh_->tex_polygons[0][faceIndex].vertices[2]];
+ //Calculate face normal
+
+ pcl::PointXYZ diff0;
+ pcl::PointXYZ diff1;
+ diff0.x=p1.x-p0.x;
+ diff0.y=p1.y-p0.y;
+ diff0.z=p1.z-p0.z;
+ diff1.x=p2.x-p0.x;
+ diff1.y=p2.y-p0.y;
+ diff1.z=p2.z-p0.z;
+ pcl::PointXYZ normal;
+ normal.x=diff0.y*diff1.z-diff0.z*diff1.y;
+ normal.y=-(diff0.x*diff1.z-diff0.z*diff1.x);
+ normal.z=diff0.x*diff1.y-diff0.y*diff1.x;
+ double norm=sqrt(normal.x*normal.x+normal.y*normal.y+normal.z*normal.z);
+ //Angle of face to camera
+ double cos=normal.z/norm;
+
+ //Save distance of faceIndex to current camera
+ local_tTIA_distances[faceIndex]=distance;
+
+ //Save angle of faceIndex to current camera
+ if(normal.z>=0)
+ local_tTIA_angles[faceIndex]=sqrt(1.0-cos*cos);
// If other projections are found inside the radius
if (radiusSearch > 0)
{
- // Extract distances for all vertices for face to camera
- double d0 = cameraCloud->points[mesh_->tex_polygons[0][faceIndex].vertices[0]].z;
- double d1 = cameraCloud->points[mesh_->tex_polygons[0][faceIndex].vertices[1]].z;
- double d2 = cameraCloud->points[mesh_->tex_polygons[0][faceIndex].vertices[2]].z;
- // Calculate largest distance and store in distance variable
- double distance = std::max(d0, std::max(d1,d2));
// Compare distance to all neighbors inside radius
for (size_t i = 0; i < neighbors.size(); ++i)
@@ -559,9 +595,14 @@ void OdmTexturing::triangleToImageAssignment()
{
if (visibility[faceIndex])
{
- hasOptimalCamera[faceIndex] = true;
- tTIA_[faceIndex] = cameraIndex;
- ++count;
+ if(local_tTIA_distances[faceIndex]