diff --git a/modules/core/src/lapack.cpp b/modules/core/src/lapack.cpp index 62206fac4c..bf376c8753 100644 --- a/modules/core/src/lapack.cpp +++ b/modules/core/src/lapack.cpp @@ -878,6 +878,7 @@ double cv::determinant( InputArray _mat ) size_t step = mat.step; const uchar* m = mat.data; + CV_Assert( !mat.empty() ); CV_Assert( mat.rows == mat.cols && (type == CV_32F || type == CV_64F)); #define Mf(y, x) ((float*)(m + y*step))[x] diff --git a/modules/stitching/src/matchers.cpp b/modules/stitching/src/matchers.cpp index 9584d4811f..c5f3a5908e 100644 --- a/modules/stitching/src/matchers.cpp +++ b/modules/stitching/src/matchers.cpp @@ -573,7 +573,7 @@ void BestOf2NearestMatcher::match(const ImageFeatures &features1, const ImageFea // Find pair-wise motion matches_info.H = findHomography(src_points, dst_points, matches_info.inliers_mask, CV_RANSAC); - if (std::abs(determinant(matches_info.H)) < std::numeric_limits::epsilon()) + if (matches_info.H.empty() || std::abs(determinant(matches_info.H)) < std::numeric_limits::epsilon()) return; // Find number of inliers