Skip to content

Commit

Permalink
FIX: numerical instability in KLT response
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Aug 31, 2024
1 parent 301d301 commit 705026c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion doc/source/doxygen-docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- pymrpt:
- Fix all C++ build warnings in pymrpt.
- BUG FIXES:
- Avoid failing KLT unit tests in the loong64 architecture.
- Fix unstable keypoint KLT response values leading to NaN in some architectures.
- Fix tons of typos and Debian-specific spare install files (lintian --pedantic).
- Fix segfault in arm64 EKF unit tests.

Expand Down
3 changes: 2 additions & 1 deletion libs/img/src/CImage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2076,8 +2076,9 @@ float CImage::KLT_response(
// mrpt::math::detail::eigenVectorsMatrix_special_2x2():
const float t = Gxx + Gyy; // Trace
const float de = Gxx * Gyy - Gxy * Gxy; // Det
const float discr = std::max<float>(.0f, t * t - 4.0f * de);
// The smallest eigenvalue is:
return 0.5f * (t - std::sqrt(t * t - 4.0f * de));
return 0.5f * (t - std::sqrt(discr));
#else
return 0;
#endif
Expand Down

0 comments on commit 705026c

Please sign in to comment.