Skip to content

Instantly share code, notes, and snippets.

@matlabbe
Last active September 27, 2021 23:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matlabbe/1df724465106c056ca4cc195c81d8cf0 to your computer and use it in GitHub Desktop.
Save matlabbe/1df724465106c056ca4cc195c81d8cf0 to your computer and use it in GitHub Desktop.
Patches to make latest AliceVision (as Sept 13 2021) works with rtabmap library (no crash, all unwrapping methods working)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3a5c91d30..015421d2f 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -343,7 +343,7 @@ find_package(Eigen3 3.3 REQUIRED)
if(Eigen3_FOUND OR EIGEN3_FOUND)
# message(STATUS "EIGEN_INCLUDE_DIR: ${EIGEN_INCLUDE_DIR}")
# See https://eigen.tuxfamily.org/dox/group__TopicUnalignedArrayAssert.html
- set(AV_EIGEN_DEFINITIONS -DEIGEN_MAX_ALIGN_BYTES=0 -DEIGEN_MAX_STATIC_ALIGN_BYTES=0)
+ #set(AV_EIGEN_DEFINITIONS -DEIGEN_MAX_ALIGN_BYTES=0 -DEIGEN_MAX_STATIC_ALIGN_BYTES=0)
else()
message(FATAL_ERROR " EIGEN NOT FOUND. EIGEN_INCLUDE_DIR: ${EIGEN_INCLUDE_DIR}")
endif()
diff --git a/src/aliceVision/mesh/Texturing.cpp b/src/aliceVision/mesh/Texturing.cpp
index 7891b146c..e40be063b 100644
--- a/src/aliceVision/mesh/Texturing.cpp
+++ b/src/aliceVision/mesh/Texturing.cpp
@@ -961,7 +961,7 @@ void Texturing::replaceMesh(const std::string& otherMeshPath, bool flipNormals)
// keep previous mesh/visibilities as reference
Mesh* refMesh = mesh;
// set pointers to null to avoid deallocation by 'loadFromObj'
- mesh->pointsVisibilities.resize(0);
+ //mesh->pointsVisibilities.resize(0);
mesh = nullptr;
// load input obj file
diff --git a/src/aliceVision/numeric/numeric.hpp b/src/aliceVision/numeric/numeric.hpp
index 1475c13e9..7a187fe05 100644
--- a/src/aliceVision/numeric/numeric.hpp
+++ b/src/aliceVision/numeric/numeric.hpp
@@ -10,17 +10,17 @@
// AliceVision does not support Eigen with alignment,
// So ensure Eigen is used with the correct flags.
-#ifndef EIGEN_MAX_ALIGN_BYTES
-#error "EIGEN_MAX_ALIGN_BYTES is not defined"
-#elif EIGEN_MAX_ALIGN_BYTES != 0
-#error "EIGEN_MAX_ALIGN_BYTES is defined but not 0"
-#endif
-
-#ifndef EIGEN_MAX_STATIC_ALIGN_BYTES
-#error "EIGEN_MAX_STATIC_ALIGN_BYTES is not defined"
-#elif EIGEN_MAX_STATIC_ALIGN_BYTES != 0
-#error "EIGEN_MAX_STATIC_ALIGN_BYTES is defined but not 0"
-#endif
+//#ifndef EIGEN_MAX_ALIGN_BYTES
+//#error "EIGEN_MAX_ALIGN_BYTES is not defined"
+//#elif EIGEN_MAX_ALIGN_BYTES != 0
+//#error "EIGEN_MAX_ALIGN_BYTES is defined but not 0"
+//#endif
+
+//#ifndef EIGEN_MAX_STATIC_ALIGN_BYTES
+//#error "EIGEN_MAX_STATIC_ALIGN_BYTES is not defined"
+//#elif EIGEN_MAX_STATIC_ALIGN_BYTES != 0
+//#error "EIGEN_MAX_STATIC_ALIGN_BYTES is defined but not 0"
+//#endif
//--
diff --git a/src/aliceVision/sfmData/SfMData.cpp b/src/aliceVision/sfmData/SfMData.cpp
index f6822215a..7e4580135 100644
--- a/src/aliceVision/sfmData/SfMData.cpp
+++ b/src/aliceVision/sfmData/SfMData.cpp
@@ -252,6 +252,11 @@ void SfMData::setPose(const View& view, const CameraPose& absolutePose)
throw std::runtime_error("SfMData::setPose: dependant view pose not part of an initialized rig.");
}
+void SfMData::setAbsolutePose(IndexT poseId, const CameraPose& pose)
+{
+ _poses[poseId] = pose;
+}
+
void SfMData::combine(const SfMData& sfmData)
{
diff --git a/src/aliceVision/sfmData/SfMData.hpp b/src/aliceVision/sfmData/SfMData.hpp
index 9ea7da88d..8d24d6e7b 100644
--- a/src/aliceVision/sfmData/SfMData.hpp
+++ b/src/aliceVision/sfmData/SfMData.hpp
@@ -24,13 +24,13 @@ namespace aliceVision {
namespace sfmData {
/// Define a collection of View
-using Views = HashMap<IndexT, std::shared_ptr<View> >;
+using Views = std::map<IndexT, std::shared_ptr<View> >;
/// Define a collection of Pose (indexed by view.getPoseId())
using Poses = HashMap<IndexT, CameraPose>;
/// Define a collection of IntrinsicParameter (indexed by view.getIntrinsicId())
-using Intrinsics = HashMap<IndexT, std::shared_ptr<camera::IntrinsicBase> >;
+using Intrinsics = std::map<IndexT, std::shared_ptr<camera::IntrinsicBase> >;
/// Define a collection of landmarks are indexed by their TrackId
using Landmarks = HashMap<IndexT, Landmark>;
@@ -478,10 +478,7 @@ public:
* @param[in] poseId The given poseId
* @param[in] pose The given pose
*/
- void setAbsolutePose(IndexT poseId, const CameraPose& pose)
- {
- _poses[poseId] = pose;
- }
+ void setAbsolutePose(IndexT poseId, const CameraPose& pose);
/**
* @brief Erase yhe pose for the given poseId
diff --git a/src/lib/geogram/parameterization/mesh_atlas_maker.cpp b/src/lib/geogram/parameterization/mesh_atlas_maker.cpp
index e13f028..5ba7b95 100644
--- a/src/lib/geogram/parameterization/mesh_atlas_maker.cpp
+++ b/src/lib/geogram/parameterization/mesh_atlas_maker.cpp
@@ -176,6 +176,7 @@ namespace {
index_t total_f = mesh_.facets.nb();
index_t param_f = 0;
segment_mesh();
+
for(index_t f: mesh_.facets) {
while(chart_[f] >= chart_queue_.size()) {
chart_queue_.push_back(Chart(mesh_, chart_[f]));
@@ -360,7 +361,7 @@ namespace {
index_t f2=mesh_.facet_corners.adjacent_facet(c);
if(
f2 != NO_FACET &&
- chart_[f2] != nb_charts_ &&
+ chart_[f2] == index_t(-1) &&
Geom::mesh_unsigned_normal_angle(
mesh_,cur_f,f2) < hard_angles_threshold_
) {
diff --git a/src/lib/geogram/parameterization/mesh_param_packer.cpp b/src/lib/geogram/parameterization/mesh_param_packer.cpp
index e9841b0..e250874 100755
--- a/src/lib/geogram/parameterization/mesh_param_packer.cpp
+++ b/src/lib/geogram/parameterization/mesh_param_packer.cpp
@@ -1051,20 +1051,20 @@ namespace GEO {
vector<Chart> charts;
index_t nb_charts=0;
for(index_t f: mesh.facets) {
- nb_charts = std::max(nb_charts, chart_attr_[f]);
+ nb_charts = (index_t)std::max((int)nb_charts, (int)chart_attr_[f]);
}
++nb_charts;
for(index_t i=0; i<nb_charts; ++i) {
charts.push_back(Chart(mesh, i));
}
-
for(index_t f: mesh.facets) {
- charts[chart_attr_[f]].facets.push_back(f);
+ if(chart_attr_[f] != (index_t)-1)
+ charts[chart_attr_[f]].facets.push_back(f);
}
Logger::out("Packer") << "Packing " << charts.size() << " charts" << std::endl;
-
+
// Sanity check
for(index_t i=0; i<nb_charts; ++i) {
if(!chart_is_ok(charts[i], tex_coord_)) {
@@ -1097,6 +1097,7 @@ namespace GEO {
tex_coord_.unbind();
chart_attr_.unbind();
+
}
diff --git a/src/lib/geogram/parameterization/mesh_param_validator.cpp b/src/lib/geogram/parameterization/mesh_param_validator.cpp
index 8208e59..c4cd2e0 100644
--- a/src/lib/geogram/parameterization/mesh_param_validator.cpp
+++ b/src/lib/geogram/parameterization/mesh_param_validator.cpp
@@ -182,6 +182,11 @@ namespace GEO {
}
}
+ if(facet_scaling.empty()) {
+ printf("chart_scaling failed (chart.id=%d), return NaN\n", chart.id);
+ return NAN;
+ }
+
// Ignore 1% of the values at each end.
std::sort(facet_scaling.begin(), facet_scaling.end());
index_t offset = index_t(double(facet_scaling.size()) * 0.01);
diff --git a/src/lib/geogram/parameterization/mesh_segmentation.cpp b/src/lib/geogram/parameterization/mesh_segmentation.cpp
index 4d53f06..ee03d84 100644
--- a/src/lib/geogram/parameterization/mesh_segmentation.cpp
+++ b/src/lib/geogram/parameterization/mesh_segmentation.cpp
@@ -261,11 +261,16 @@ namespace GEO {
if(chart_id[f] == new_chart_1.id) {
new_chart_1.facets.push_back(f);
++nb1;
- } else {
+ } else if(chart_id[f] == new_chart_2.id) {
+
geo_assert(chart_id[f] == new_chart_2.id);
new_chart_2.facets.push_back(f);
++nb2;
}
+ else
+ {
+ printf("Ignoring face %d from chart (chart_id = %d) \n", f, chart_id[f]);
+ }
}
if(verbose) {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment