From 55698548ddf405bdbc2a9ca9a4a7a48cd373f806 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Tue, 12 Mar 2013 22:36:00 +0400 Subject: [PATCH 1/2] Avoid assert in lapac.cpp if findHomography fails in BestOf2NearestMatcher::match --- modules/core/src/lapack.cpp | 1 + modules/stitching/src/matchers.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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 From 7e50d3e5712812e386074c689524a2de0d5df842 Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Wed, 13 Mar 2013 11:34:04 +0400 Subject: [PATCH 2/2] Fixed MSVC warnings --- 3rdparty/libwebp/CMakeLists.txt | 1 + modules/highgui/src/grfmt_webp.cpp | 2 +- modules/imgproc/src/convhull.cpp | 8 ++++---- modules/imgproc/src/demosaicing.cpp | 2 +- modules/imgproc/test/test_color.cpp | 2 +- modules/softcascade/src/softcascade.cpp | 2 +- 6 files changed, 9 insertions(+), 8 deletions(-) diff --git a/3rdparty/libwebp/CMakeLists.txt b/3rdparty/libwebp/CMakeLists.txt index 6c6c1a662b..54bda495b9 100644 --- a/3rdparty/libwebp/CMakeLists.txt +++ b/3rdparty/libwebp/CMakeLists.txt @@ -41,6 +41,7 @@ if(UNIX) endif() ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-variable -Wshadow) +ocv_warnings_disable(CMAKE_C_FLAGS /wd4244 /wd4267) # vs2005 set_target_properties(${WEBP_LIBRARY} PROPERTIES OUTPUT_NAME ${WEBP_LIBRARY} diff --git a/modules/highgui/src/grfmt_webp.cpp b/modules/highgui/src/grfmt_webp.cpp index b2722ccea6..40ed595de1 100644 --- a/modules/highgui/src/grfmt_webp.cpp +++ b/modules/highgui/src/grfmt_webp.cpp @@ -176,7 +176,7 @@ bool WebPEncoder::write(const Mat& img, const std::vector& params) const Mat *image = &img; Mat temp; - int size = 0; + size_t size = 0; bool comp_lossless = true; int quality = 100; diff --git a/modules/imgproc/src/convhull.cpp b/modules/imgproc/src/convhull.cpp index 7fad264e7f..019c996320 100644 --- a/modules/imgproc/src/convhull.cpp +++ b/modules/imgproc/src/convhull.cpp @@ -206,9 +206,9 @@ void convexHull( InputArray _points, OutputArray _hull, bool clockwise, bool ret } for( i = 0; i < tl_count-1; i++ ) - hullbuf[nout++] = pointer[tl_stack[i]] - data0; + hullbuf[nout++] = int(pointer[tl_stack[i]] - data0); for( i = tr_count - 1; i > 0; i-- ) - hullbuf[nout++] = pointer[tr_stack[i]] - data0; + hullbuf[nout++] = int(pointer[tr_stack[i]] - data0); int stop_idx = tr_count > 2 ? tr_stack[1] : tl_count > 2 ? tl_stack[tl_count - 2] : -1; // lower half @@ -244,9 +244,9 @@ void convexHull( InputArray _points, OutputArray _hull, bool clockwise, bool ret } for( i = 0; i < bl_count-1; i++ ) - hullbuf[nout++] = pointer[bl_stack[i]] - data0; + hullbuf[nout++] = int(pointer[bl_stack[i]] - data0); for( i = br_count-1; i > 0; i-- ) - hullbuf[nout++] = pointer[br_stack[i]] - data0; + hullbuf[nout++] = int(pointer[br_stack[i]] - data0); } if( !returnPoints ) diff --git a/modules/imgproc/src/demosaicing.cpp b/modules/imgproc/src/demosaicing.cpp index 14bcea61fa..a3156dd49c 100644 --- a/modules/imgproc/src/demosaicing.cpp +++ b/modules/imgproc/src/demosaicing.cpp @@ -316,7 +316,7 @@ public: _mm_storel_epi64((__m128i*)(dst+6*6), g1); } - return bayer - (bayer_end - width); + return int(bayer - (bayer_end - width)); } bool use_simd; diff --git a/modules/imgproc/test/test_color.cpp b/modules/imgproc/test/test_color.cpp index 33b5bcf20f..86f9c67564 100644 --- a/modules/imgproc/test/test_color.cpp +++ b/modules/imgproc/test/test_color.cpp @@ -1960,7 +1960,7 @@ static void test_Bayer2RGB_EdgeAware_8u(const Mat& src, Mat& dst, int code) int dcn = dst.channels(); CV_Assert(dcn == 3); - int step = src.step; + int step = (int)src.step; const uchar* S = src.ptr(1) + 1; uchar* D = dst.ptr(1) + dcn; diff --git a/modules/softcascade/src/softcascade.cpp b/modules/softcascade/src/softcascade.cpp index 43772449ac..197230d752 100644 --- a/modules/softcascade/src/softcascade.cpp +++ b/modules/softcascade/src/softcascade.cpp @@ -53,7 +53,7 @@ namespace { struct SOctave { SOctave(const int i, const cv::Size& origObjSize, const cv::FileNode& fn) - : index(i), weaks((int)fn[SC_OCT_WEAKS]), scale(std::pow(2,(float)fn[SC_OCT_SCALE])), + : index(i), weaks((int)fn[SC_OCT_WEAKS]), scale((float)std::pow(2,(float)fn[SC_OCT_SCALE])), size(cvRound(origObjSize.width * scale), cvRound(origObjSize.height * scale)) {} int index;