diff --git a/modules/stitching/src/motion_estimators.cpp b/modules/stitching/src/motion_estimators.cpp index 2ba691b7d7..5ae14b7e9a 100644 --- a/modules/stitching/src/motion_estimators.cpp +++ b/modules/stitching/src/motion_estimators.cpp @@ -616,7 +616,14 @@ void waveCorrect(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);