diff options
Diffstat (limited to 'meowpp.test/src/autostitch.cpp')
-rw-r--r-- | meowpp.test/src/autostitch.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/meowpp.test/src/autostitch.cpp b/meowpp.test/src/autostitch.cpp index b62d13b..e6b473b 100644 --- a/meowpp.test/src/autostitch.cpp +++ b/meowpp.test/src/autostitch.cpp @@ -250,6 +250,8 @@ bool kmatch() { //////////////////////////// **# RANSAC #** ////////////////////////// bool ransac() { messagePrintf( 1, "RANSAC"); + aspect_t = inRange(0.000001, 9999.0, atof(usg.optionValue("match-aspect", 0).c_str())); + angle_t = inRange(0.1,999.0, atof(usg.optionValue("match-angle", 0).c_str()))/180 * PI; MyRansacCheck::usage(usg); // tmp output p0 = inRange(0.00001, 0.9999, atof(usg.optionValue("ransac-p0", 0).c_str())); @@ -258,7 +260,9 @@ bool ransac() { for (size_t j = 0, J = input_bitmap.size(); j < J; j++) { size_t num = 4u; // !!!!!!!!!!!!!!!!!!! messagePrintf( 1, "ransac %lu --- %lu", i, j); - MyRansacCheck chk(&(fpsv[i]), &(fpsv[j])); + MyRansacCheck chk(&(fpsv[i]), &(fpsv[j]), + input_bitmap[i].width(), input_bitmap[i].height(), + aspect_t, angle_t); FeaturePointIndexPairs ret = ransac(pairs[i][j], chk, num, p0, P); if (!ret.empty()) { chk.rememberVCalc(ret); @@ -288,6 +292,8 @@ bool ransac() { return true; } + + //////////////////// **# checking match again #** //////////////////// bool match_check() { q = inRange(0.00001, 0.99999, atof(usg.optionValue("prob-p1", 0).c_str())); @@ -306,9 +312,15 @@ bool match_check() { continue; } double ni = pairs[i][j].size(), nf = 0; - MyRansacCheck chk(&(fpsv[i]), &(fpsv[j])); + size_t num = 4u; + MyRansacCheck chk(&(fpsv[i]), &(fpsv[j]), + input_bitmap[i].width(), input_bitmap[i].height(), + aspect_t, angle_t); + FeaturePointIndexPairs ret = ransac(pairs[i][j], chk, num, p0, P); + chk.rememberVCalc(pairs[i][j]); - if (chk.check(aspect_t, angle_t)) { + if (chk.check()) { + chk.print(); for (size_t k = 0, K = fpsv[i].size(); k < K; k++) { Vector2D<double> to(chk.to(Vector2D<double>(fpsv[i][k](0), fpsv[i][k](1)))); @@ -370,7 +382,9 @@ bool pair_output(){ for(size_t i = 0, I = input_bitmap.size(); i < I; i++){ for(size_t j = 0, J = input_bitmap.size(); j < J; j++){ if(pairs[i][j].empty()) continue; - MyRansacCheck chk(&(fpsv[i]), &(fpsv[j])); + MyRansacCheck chk(&(fpsv[i]), &(fpsv[j]), + (double)input_bitmap[i].width(), (double)input_bitmap[i].height(), + aspect_t, angle_t); chk.rememberVCalc(pairs[i][j]); size_t index = output_bitmap.size(); output_bitmap.push_back(input_bitmap[i]); @@ -378,8 +392,8 @@ bool pair_output(){ for(ssize_t y = 0, Y = input_bitmap[i].height(); y < Y; y++) { Vector2D<double> to(chk.to(Vector2D<double>(x, y))); ssize_t x2 = to.x(), y2 = to.y(); - if (0 <= x2 && x2 <= (ssize_t)input_bitmap[j].width() && - 0 <= y2 && y2 <= (ssize_t)input_bitmap[j].height()) { + if (0 <= x2 && x2 < (ssize_t)input_bitmap[j].width() && + 0 <= y2 && y2 < (ssize_t)input_bitmap[j].height()) { output_bitmap[index].pixel(y, x, (input_bitmap[i].pixel(y, x) + input_bitmap[j].pixel(y2,x2)) / 2 ); |