Skip to content

Commit

Permalink
Replace deprecated Eigen nonZeros() call for most recent Eigen versio…
Browse files Browse the repository at this point in the history
…ns. (colmap#1494)

* Remove nonZeros() call from Eigen::DenseBase

Removal of nonZeros() call which was deprecated in https://gitlab.com/libeigen/eigen/-/commit/08da52eb8537107e2853452bb13c369856d1f84a corresponding to a redundant function call to size().

Issue: COLMAP does not build on Eigen 3.4.90
Fix: Adjust nonZeros() call to be size().

https://gitlab.com/libeigen/eigen/-/issues/2382

* Compute l1-norm to check for non-zeros

Compute the L1-norm of the vectors to check for non-zeros. If vector has no non-zero elements, the norm will be zero, else the norm will be greater than zero.

Updated with clarification from COLMAP devs re: checking for nonZero elements following Eigen implementation deprecation (and clarifying that original nonZeros() always returned size()).
  • Loading branch information
nackjaylor authored Apr 20, 2022
1 parent f9dc48d commit 4d737b8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/exe/model.cc
Original file line number Diff line number Diff line change
Expand Up @@ -765,10 +765,10 @@ int RunModelOrientationAligner(int argc, char** argv) {
const Eigen::Matrix3d frame = EstimateManhattanWorldFrame(
frame_estimation_options, reconstruction, *options.image_path);

if (frame.col(0).nonZeros() == 0) {
if (frame.col(0).lpNorm<1>() == 0) {
std::cout << "Only aligning vertical axis" << std::endl;
tform = RotationFromUnitVectors(frame.col(1), Eigen::Vector3d(0, 1, 0));
} else if (frame.col(1).nonZeros() == 0) {
} else if (frame.col(1).lpNorm<1>() == 0) {
tform = RotationFromUnitVectors(frame.col(0), Eigen::Vector3d(1, 0, 0));
std::cout << "Only aligning horizontal axis" << std::endl;
} else {
Expand Down

0 comments on commit 4d737b8

Please sign in to comment.