From ee0da48bd22722f2f48348fc1b9e070bd5131cf5 Mon Sep 17 00:00:00 2001 From: Dmitry Gribanov Date: Fri, 12 Sep 2014 18:07:54 +0400 Subject: [PATCH] Feature based stitching's wave correction bugfix. When we have similar matrices in input, then algorithm returns matrices with NaN values. --- modules/stitching/src/motion_estimators.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/modules/stitching/src/motion_estimators.cpp b/modules/stitching/src/motion_estimators.cpp index d6fd2275d0..873be6caa1 100644 --- a/modules/stitching/src/motion_estimators.cpp +++ b/modules/stitching/src/motion_estimators.cpp @@ -629,7 +629,14 @@ void waveCorrect(std::vector &rmats, WaveCorrectKind kind) for (size_t i = 0; i < rmats.size(); ++i) img_k += rmats[i].col(2); Mat rg0 = rg1.cross(img_k); - rg0 /= norm(rg0); + double rg0_norm = norm(rg0); + + if( rg0_norm <= DBL_MIN ) + { + return; + } + + rg0 /= rg0_norm; Mat rg2 = rg0.cross(rg1); -- GitLab