diff --git a/modules/calib3d/src/fundam.cpp b/modules/calib3d/src/fundam.cpp index e107332c95..c6020fcc8f 100644 --- a/modules/calib3d/src/fundam.cpp +++ b/modules/calib3d/src/fundam.cpp @@ -806,7 +806,7 @@ public: Mat F(count == 7 ? 9 : 3, 3, CV_64F, f); int n = count == 7 ? run7Point(m1, m2, F) : run8Point(m1, m2, F); - if( n == 0 ) + if( n <= 0 ) _model.release(); else F.rowRange(0, n*3).copyTo(_model); diff --git a/modules/calib3d/test/test_fundam.cpp b/modules/calib3d/test/test_fundam.cpp index ab987ffcea..58a57dba4a 100644 --- a/modules/calib3d/test/test_fundam.cpp +++ b/modules/calib3d/test/test_fundam.cpp @@ -1673,5 +1673,13 @@ TEST(Calib3d_FindFundamentalMat, correctMatches) cout << np2 << endl; } +TEST(Calib3d_FindFundamentalMat, Crash) +{ + vector m1 = {{245, 128},{284, 226},{140, 60},{133, 127},{71, 218},{152, 138},{181, 106}}; + vector m2 = m1; + vector mask; + findFundamentalMat(m1, m2, mask, FM_LMEDS, 1, 0.99); +} + }} // namespace /* End of file. */