diff options
Diffstat (limited to 'meowpp.test/src/autostitch_RansacCheck.cpp')
-rw-r--r-- | meowpp.test/src/autostitch_RansacCheck.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/meowpp.test/src/autostitch_RansacCheck.cpp b/meowpp.test/src/autostitch_RansacCheck.cpp index becc7da..e728958 100644 --- a/meowpp.test/src/autostitch_RansacCheck.cpp +++ b/meowpp.test/src/autostitch_RansacCheck.cpp @@ -4,6 +4,7 @@ #include "meowpp/math/Vector.h" #include <utility> #include <cmath> +#include <cstdio> #include <algorithm> @@ -37,9 +38,14 @@ _to(__rc._to){ MyRansacCheck::MyRansacCheck(std::vector<Vector<double> > const* __from, - std::vector<Vector<double> > const* __to): + std::vector<Vector<double> > const* __to, + double w_max, double h_max, + double rr, double aa): _from(__from), -_to(__to){ +_to(__to), +_w(w_max), +_h(h_max), +r_(rr), ang(aa) { } @@ -122,6 +128,7 @@ double MyRansacCheck::operator()(std::vector<FeaturePointIndexPair> } } ((MyRansacCheck*)this)->rememberVCalc(__sample); + if (!((MyRansacCheck*)this)->check()) return -999; size_t ret = 0; for (size_t i = 0, I = __data.size(); i < I; i++) { if (ok(__data[i])) { @@ -131,21 +138,31 @@ double MyRansacCheck::operator()(std::vector<FeaturePointIndexPair> return 0.001 + ret; } -bool MyRansacCheck::check(double r, double a) { +bool MyRansacCheck::check() { return true; Vector2D<double> v_x(a_, b_); Vector2D<double> v_y(c_, d_); - double len1 = v_x.length() * r; - double len2 = v_x.length() / r; + double xx[2] = {0, _w}, yy[2] = {0, _h}; + for (size_t i = 0; i < 2; ++i) { + for (size_t j = 0; j < 2; ++j) { + if (A_ * xx[i] + B_ * yy[j] + 1 <= 0) return false; + } + } + double len1 = v_x.length() * r_; + double len2 = v_x.length() / r_; double len = v_y.length(); if (len1 > len2) std::swap(len1, len2); if (len < len1 || len2 < len) return false; - double sn = fabs(sin(a)); + double sn = fabs(sin(ang)); double msn = fabs(v_x.cross(v_y) / v_x.length() / v_y.length()); if (msn < sn) return false; return true; } +void MyRansacCheck::print() const { + printf("%f %f %f %f %f %f %f %f 1\n", a_, b_, c_, d_, e_, f_, A_, B_); +} + Vector2D<double> MyRansacCheck::to(Vector2D<double> const& v) const { return Vector2D<double>( (v.x() * a_ + v.y() * b_ + c_) / (A_ * v.x() + B_ * v.y() + 1), |