diff --git a/modules/calib3d/src/fisheye.cpp b/modules/calib3d/src/fisheye.cpp index 7bbddf2838..d1bff24faf 100644 --- a/modules/calib3d/src/fisheye.cpp +++ b/modules/calib3d/src/fisheye.cpp @@ -589,8 +589,8 @@ void cv::fisheye::initUndistortRectifyMap( InputArray K, InputArray D, InputArra if( m1type == CV_16SC2 ) { - int iu = cv::saturate_cast(u*cv::INTER_TAB_SIZE); - int iv = cv::saturate_cast(v*cv::INTER_TAB_SIZE); + int iu = cv::saturate_cast(u*static_cast(cv::INTER_TAB_SIZE)); + int iv = cv::saturate_cast(v*static_cast(cv::INTER_TAB_SIZE)); m1[j*2+0] = (short)(iu >> cv::INTER_BITS); m1[j*2+1] = (short)(iv >> cv::INTER_BITS); m2[j] = (ushort)((iv & (cv::INTER_TAB_SIZE-1))*cv::INTER_TAB_SIZE + (iu & (cv::INTER_TAB_SIZE-1))); diff --git a/modules/calib3d/src/undistort.simd.hpp b/modules/calib3d/src/undistort.simd.hpp index 70bac44702..f944407058 100644 --- a/modules/calib3d/src/undistort.simd.hpp +++ b/modules/calib3d/src/undistort.simd.hpp @@ -259,8 +259,8 @@ public: double v = fy*invProj*vecTilt(1) + v0; if( m1type == CV_16SC2 ) { - int iu = saturate_cast(u*INTER_TAB_SIZE); - int iv = saturate_cast(v*INTER_TAB_SIZE); + int iu = saturate_cast(u*static_cast(INTER_TAB_SIZE)); + int iv = saturate_cast(v*static_cast(INTER_TAB_SIZE)); m1[j*2] = (short)(iu >> INTER_BITS); m1[j*2+1] = (short)(iv >> INTER_BITS); m2[j] = (ushort)((iv & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (iu & (INTER_TAB_SIZE-1))); diff --git a/modules/calib3d/test/test_stereomatching.cpp b/modules/calib3d/test/test_stereomatching.cpp index c17d92292a..ad230509df 100644 --- a/modules/calib3d/test/test_stereomatching.cpp +++ b/modules/calib3d/test/test_stereomatching.cpp @@ -789,7 +789,7 @@ protected: calcROI = getValidDisparityROI(cROI, cROI, params.mindisp, params.ndisp, params.winSize); bm->compute( leftImg, rightImg, tempDisp ); - tempDisp.convertTo(leftDisp, CV_32F, 1./StereoMatcher::DISP_SCALE); + tempDisp.convertTo(leftDisp, CV_32F, 1./static_cast(StereoMatcher::DISP_SCALE)); //check for fixed-type disparity data type Mat_ fixedFloatDisp; @@ -802,7 +802,7 @@ protected: for (int x = 0; x < leftDisp.cols; x++) { if (leftDisp.at(y, x) < params.mindisp) - leftDisp.at(y, x) = -1./StereoMatcher::DISP_SCALE; // treat disparity < mindisp as no disparity + leftDisp.at(y, x) = -1./static_cast(StereoMatcher::DISP_SCALE); // treat disparity < mindisp as no disparity } return params.winSize/2; diff --git a/modules/core/include/opencv2/core/mat.inl.hpp b/modules/core/include/opencv2/core/mat.inl.hpp index aa293255f9..bd0ba637b5 100644 --- a/modules/core/include/opencv2/core/mat.inl.hpp +++ b/modules/core/include/opencv2/core/mat.inl.hpp @@ -460,7 +460,7 @@ CV__DEBUG_NS_END template inline Mat::Mat(const std::vector<_Tp>& vec, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), + : flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if(vec.empty()) @@ -497,7 +497,7 @@ Mat::Mat(const std::initializer_list sizes, const std::initializer_list<_Tp template inline Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()), + : flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()), cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if(arr.empty()) @@ -514,7 +514,7 @@ Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData) template inline Mat::Mat(const Vec<_Tp, n>& vec, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0), + : flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if( !copyData ) @@ -546,7 +546,7 @@ Mat::Mat(const Matx<_Tp,m,n>& M, bool copyData) template inline Mat::Mat(const Point_<_Tp>& pt, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0), + : flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(2), cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if( !copyData ) @@ -565,7 +565,7 @@ Mat::Mat(const Point_<_Tp>& pt, bool copyData) template inline Mat::Mat(const Point3_<_Tp>& pt, bool copyData) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0), + : flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows(3), cols(1), data(0), datastart(0), dataend(0), datalimit(0), allocator(0), u(0), size(&rows), step(0) { if( !copyData ) @@ -585,7 +585,7 @@ Mat::Mat(const Point3_<_Tp>& pt, bool copyData) template inline Mat::Mat(const MatCommaInitializer_<_Tp>& commaInitializer) - : flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0), + : flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(0), rows(0), cols(0), data(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows) { *this = commaInitializer.operator Mat_<_Tp>(); @@ -2090,7 +2090,7 @@ SparseMatConstIterator_<_Tp> SparseMat::end() const template inline SparseMat_<_Tp>::SparseMat_() { - flags = MAGIC_VAL + traits::Type<_Tp>::value; + flags = +MAGIC_VAL + traits::Type<_Tp>::value; } template inline @@ -3248,7 +3248,7 @@ const Mat_<_Tp>& operator /= (const Mat_<_Tp>& a, const MatExpr& b) template inline UMat::UMat(const std::vector<_Tp>& vec, bool copyData) -: flags(MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), +: flags(+MAGIC_VAL + traits::Type<_Tp>::value + CV_MAT_CONT_FLAG), dims(2), rows((int)vec.size()), cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows) { if(vec.empty()) diff --git a/modules/core/src/matrix_sparse.cpp b/modules/core/src/matrix_sparse.cpp index cfc769e791..2c9edf8b3a 100644 --- a/modules/core/src/matrix_sparse.cpp +++ b/modules/core/src/matrix_sparse.cpp @@ -171,7 +171,14 @@ void SparseMat::Hdr::clear() hashtab.clear(); hashtab.resize(HASH_SIZE0); pool.clear(); +#if defined(__GNUC__) && (__GNUC__ == 13) && !defined(__clang__) && (__cplusplus >= 202002L) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wstringop-overflow" +#endif pool.resize(nodeSize); +#if defined(__GNUC__) && (__GNUC__ == 13) && !defined(__clang__) && (__cplusplus >= 202002L) +#pragma GCC diagnostic pop +#endif nodeCount = freeList = 0; } diff --git a/modules/features2d/test/test_matchers_algorithmic.cpp b/modules/features2d/test/test_matchers_algorithmic.cpp index 203b640209..0679d9ce38 100644 --- a/modules/features2d/test/test_matchers_algorithmic.cpp +++ b/modules/features2d/test/test_matchers_algorithmic.cpp @@ -43,9 +43,6 @@ namespace opencv_test { namespace { -const string FEATURES2D_DIR = "features2d"; -const string IMAGE_FILENAME = "tsukuba.png"; - /****************************************************************************************\ * Algorithmic tests for descriptor matchers * \****************************************************************************************/ diff --git a/modules/gapi/src/streaming/gstreamer/gstreamer_media_adapter.cpp b/modules/gapi/src/streaming/gstreamer/gstreamer_media_adapter.cpp index b9fce83427..770f76a4ed 100644 --- a/modules/gapi/src/streaming/gstreamer/gstreamer_media_adapter.cpp +++ b/modules/gapi/src/streaming/gstreamer/gstreamer_media_adapter.cpp @@ -23,7 +23,7 @@ GStreamerMediaAdapter::GStreamerMediaAdapter(const cv::GFrameDesc& frameDesc, { #if GST_VERSION_MINOR >= 10 // Check that GstBuffer has mono-view, so we can retrieve only one video-meta - GAPI_Assert((gst_buffer_get_flags(m_buffer) & GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW) == 0); + GAPI_Assert((gst_buffer_get_flags(m_buffer) & static_cast(GST_VIDEO_BUFFER_FLAG_MULTIPLE_VIEW)) == 0); #endif // GST_VERSION_MINOR >= 10 GstVideoMeta* videoMeta = gst_buffer_get_video_meta(m_buffer); diff --git a/modules/highgui/src/window.cpp b/modules/highgui/src/window.cpp index 4fb2169da9..cf21feefbd 100644 --- a/modules/highgui/src/window.cpp +++ b/modules/highgui/src/window.cpp @@ -219,7 +219,7 @@ CV_IMPL void cvSetWindowProperty(const char* name, int prop_id, double prop_valu //change between fullscreen or not. case cv::WND_PROP_FULLSCREEN: - if (prop_value != cv::WINDOW_NORMAL && prop_value != cv::WINDOW_FULLSCREEN) // bad argument + if ((int)prop_value != cv::WINDOW_NORMAL && (int)prop_value != cv::WINDOW_FULLSCREEN) // bad argument break; #if defined (HAVE_QT) diff --git a/modules/highgui/src/window_gtk.cpp b/modules/highgui/src/window_gtk.cpp index 178d1b7475..3a34983b81 100644 --- a/modules/highgui/src/window_gtk.cpp +++ b/modules/highgui/src/window_gtk.cpp @@ -2177,7 +2177,7 @@ public: switch (prop) { case cv::WND_PROP_FULLSCREEN: - if (value != cv::WINDOW_NORMAL && value != cv::WINDOW_FULLSCREEN) // bad arg + if ((int)value != cv::WINDOW_NORMAL && (int)value != cv::WINDOW_FULLSCREEN) // bad arg break; setModeWindow_(window, value); return true; diff --git a/modules/highgui/src/window_w32.cpp b/modules/highgui/src/window_w32.cpp index 381c9f52a4..fa9e35bd89 100644 --- a/modules/highgui/src/window_w32.cpp +++ b/modules/highgui/src/window_w32.cpp @@ -2805,7 +2805,7 @@ public: switch ((WindowPropertyFlags)prop) { case WND_PROP_FULLSCREEN: - if (value != WINDOW_NORMAL && value != WINDOW_FULLSCREEN) // bad arg + if ((int)value != WINDOW_NORMAL && (int)value != WINDOW_FULLSCREEN) // bad arg break; setModeWindow_(window, (int)value); return true; diff --git a/modules/imgproc/include/opencv2/imgproc/imgproc_c.h b/modules/imgproc/include/opencv2/imgproc/imgproc_c.h index e97b802e69..9085b0fa74 100644 --- a/modules/imgproc/include/opencv2/imgproc/imgproc_c.h +++ b/modules/imgproc/include/opencv2/imgproc/imgproc_c.h @@ -219,7 +219,7 @@ replication border mode. @see cv::warpAffine */ CVAPI(void) cvWarpAffine( const CvArr* src, CvArr* dst, const CvMat* map_matrix, - int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS), + int flags CV_DEFAULT(+CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS), CvScalar fillval CV_DEFAULT(cvScalarAll(0)) ); /** @brief Computes affine transform matrix for mapping src[i] to dst[i] (i=0,1,2) @@ -239,7 +239,7 @@ CVAPI(CvMat*) cv2DRotationMatrix( CvPoint2D32f center, double angle, @see cv::warpPerspective */ CVAPI(void) cvWarpPerspective( const CvArr* src, CvArr* dst, const CvMat* map_matrix, - int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS), + int flags CV_DEFAULT(+CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS), CvScalar fillval CV_DEFAULT(cvScalarAll(0)) ); /** @brief Computes perspective transform matrix for mapping src[i] to dst[i] (i=0,1,2,3) @@ -254,7 +254,7 @@ CVAPI(CvMat*) cvGetPerspectiveTransform( const CvPoint2D32f* src, */ CVAPI(void) cvRemap( const CvArr* src, CvArr* dst, const CvArr* mapx, const CvArr* mapy, - int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS), + int flags CV_DEFAULT(+CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS), CvScalar fillval CV_DEFAULT(cvScalarAll(0)) ); /** @brief Converts mapx & mapy from floating-point to integer formats for cvRemap @@ -268,14 +268,14 @@ CVAPI(void) cvConvertMaps( const CvArr* mapx, const CvArr* mapy, */ CVAPI(void) cvLogPolar( const CvArr* src, CvArr* dst, CvPoint2D32f center, double M, - int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS)); + int flags CV_DEFAULT(+CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS)); /** Performs forward or inverse linear-polar image transform @see cv::warpPolar */ CVAPI(void) cvLinearPolar( const CvArr* src, CvArr* dst, CvPoint2D32f center, double maxRadius, - int flags CV_DEFAULT(CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS)); + int flags CV_DEFAULT(+CV_INTER_LINEAR+CV_WARP_FILL_OUTLIERS)); #ifdef _MSC_VER #pragma warning( pop ) diff --git a/modules/imgproc/src/color_lab.cpp b/modules/imgproc/src/color_lab.cpp index dbca43c8cd..dd6fb52949 100644 --- a/modules/imgproc/src/color_lab.cpp +++ b/modules/imgproc/src/color_lab.cpp @@ -1982,7 +1982,7 @@ struct RGB2Lab_f clipv(bvec0); clipv(bvec1); #undef clipv /* int iR = R*LAB_BASE, iG = G*LAB_BASE, iB = B*LAB_BASE, iL, ia, ib; */ - v_float32 basef = vx_setall_f32(LAB_BASE); + v_float32 basef = vx_setall_f32(static_cast(LAB_BASE)); rvec0 = v_mul(rvec0, basef), gvec0 = v_mul(gvec0, basef), bvec0 = v_mul(bvec0, basef); rvec1 = v_mul(rvec1, basef), gvec1 = v_mul(gvec1, basef), bvec1 = v_mul(bvec1, basef); @@ -2013,14 +2013,14 @@ struct RGB2Lab_f b_vec0 = v_cvt_f32(i_bvec0); b_vec1 = v_cvt_f32(i_bvec1); /* dst[i] = L*100.0f */ - v_float32 v100dBase = vx_setall_f32(100.0f/LAB_BASE); + v_float32 v100dBase = vx_setall_f32(100.0f / static_cast(LAB_BASE)); l_vec0 = v_mul(l_vec0, v100dBase); l_vec1 = v_mul(l_vec1, v100dBase); /* dst[i + 1] = a*256.0f - 128.0f; dst[i + 2] = b*256.0f - 128.0f; */ - v_float32 v256dBase = vx_setall_f32(256.0f/LAB_BASE), vm128 = vx_setall_f32(-128.f); + v_float32 v256dBase = vx_setall_f32(256.0f / static_cast(LAB_BASE)), vm128 = vx_setall_f32(-128.f); a_vec0 = v_fma(a_vec0, v256dBase, vm128); a_vec1 = v_fma(a_vec1, v256dBase, vm128); b_vec0 = v_fma(b_vec0, v256dBase, vm128); @@ -2038,10 +2038,10 @@ struct RGB2Lab_f float G = clip(src[1]); float B = clip(src[bIdx^2]); - int iR = cvRound(R*LAB_BASE), iG = cvRound(G*LAB_BASE), iB = cvRound(B*LAB_BASE); + int iR = cvRound(R*static_cast(LAB_BASE)), iG = cvRound(G*static_cast(LAB_BASE)), iB = cvRound(B*static_cast(LAB_BASE)); int iL, ia, ib; trilinearInterpolate(iR, iG, iB, LABLUVLUTs16.RGB2LabLUT_s16, iL, ia, ib); - float L = iL*1.0f/LAB_BASE, a = ia*1.0f/LAB_BASE, b = ib*1.0f/LAB_BASE; + float L = iL*1.0f/static_cast(LAB_BASE), a = ia*1.0f/static_cast(LAB_BASE), b = ib*1.0f/static_cast(LAB_BASE); dst[i] = L*100.0f; dst[i + 1] = a*256.0f - 128.0f; diff --git a/modules/imgproc/src/drawing.cpp b/modules/imgproc/src/drawing.cpp index 7ba512f7f8..d0368cfa95 100644 --- a/modules/imgproc/src/drawing.cpp +++ b/modules/imgproc/src/drawing.cpp @@ -43,7 +43,6 @@ using namespace cv; namespace cv { - enum { XY_SHIFT = 16, XY_ONE = 1 << XY_SHIFT, DRAWING_STORAGE_BLOCK = (1<<12) - 256 }; static const int MAX_THICKNESS = 32767; @@ -1027,8 +1026,8 @@ EllipseEx( Mat& img, Point2l center, Size2l axes, for (unsigned int i = 0; i < _v.size(); ++i) { Point2l pt; - pt.x = (int64)cvRound(_v[i].x / XY_ONE) << XY_SHIFT; - pt.y = (int64)cvRound(_v[i].y / XY_ONE) << XY_SHIFT; + pt.x = (int64)cvRound(_v[i].x / static_cast(XY_ONE)) << XY_SHIFT; + pt.y = (int64)cvRound(_v[i].y / static_cast(XY_ONE)) << XY_SHIFT; pt.x += cvRound(_v[i].x - pt.x); pt.y += cvRound(_v[i].y - pt.y); if (pt != prevPt) { @@ -1645,7 +1644,7 @@ static void ThickLine( Mat& img, Point2l p0, Point2l p1, const void* color, int thickness, int line_type, int flags, int shift ) { - static const double INV_XY_ONE = 1./XY_ONE; + static const double INV_XY_ONE = 1./static_cast(XY_ONE); p0.x <<= XY_SHIFT - shift; p0.y <<= XY_SHIFT - shift; @@ -1981,8 +1980,8 @@ void ellipse(InputOutputArray _img, const RotatedRect& box, const Scalar& color, int _angle = cvRound(box.angle); Point2l center(cvRound(box.center.x), cvRound(box.center.y)); - center.x = (center.x << XY_SHIFT) + cvRound((box.center.x - center.x)*XY_ONE); - center.y = (center.y << XY_SHIFT) + cvRound((box.center.y - center.y)*XY_ONE); + center.x = (center.x << XY_SHIFT) + cvRound((box.center.x - center.x)*static_cast(XY_ONE)); + center.y = (center.y << XY_SHIFT) + cvRound((box.center.y - center.y)*static_cast(XY_ONE)); Size2l axes(cvRound(box.size.width), cvRound(box.size.height)); axes.width = (axes.width << (XY_SHIFT - 1)) + cvRound((box.size.width - axes.width)*(XY_ONE>>1)); @@ -2303,7 +2302,7 @@ void putText( InputOutputArray _img, const String& text, Point org, scalarToRawData(color, buf, img.type(), 0); int base_line = -(ascii[0] & 15); - int hscale = cvRound(fontScale*XY_ONE), vscale = hscale; + int hscale = cvRound(fontScale * static_cast(XY_ONE)), vscale = hscale; if( line_type == cv::LINE_AA && img.depth() != CV_8U ) line_type = 8; diff --git a/modules/imgproc/src/generalized_hough.cpp b/modules/imgproc/src/generalized_hough.cpp index 5ff9f933ed..6a2ca5f032 100644 --- a/modules/imgproc/src/generalized_hough.cpp +++ b/modules/imgproc/src/generalized_hough.cpp @@ -692,7 +692,11 @@ namespace getContourPoints(edges, dx, dy, points); features.resize(levels_ + 1); - std::for_each(features.begin(), features.end(), [=](std::vector& e) { e.clear(); e.reserve(maxBufferSize_); }); + const size_t maxBufferSize = maxBufferSize_; + std::for_each(features.begin(), features.end(), [maxBufferSize](std::vector& e) { + e.clear(); + e.reserve(maxBufferSize); + }); for (size_t i = 0; i < points.size(); ++i) { diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index 02e97ba129..48c1223059 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -1283,7 +1283,7 @@ void cv::calcHist( InputArrayOfArrays images, const std::vector& channels, CV_OCL_RUN(images.total() == 1 && channels.size() == 1 && images.channels(0) == 1 && channels[0] == 0 && images.isUMatVector() && mask.empty() && !accumulate && histSize.size() == 1 && histSize[0] == BINS && ranges.size() == 2 && - ranges[0] == 0 && ranges[1] == BINS, + ranges[0] == 0 && ranges[1] == static_cast(BINS), ocl_calcHist(images, hist)) int i, dims = (int)histSize.size(), rsz = (int)ranges.size(), csz = (int)channels.size(); diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index f2ece02aa3..dfc718bf87 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -1274,8 +1274,8 @@ public: #endif for( ; x1 < bcols; x1++ ) { - int sx = cvRound(sX[x1]*INTER_TAB_SIZE); - int sy = cvRound(sY[x1]*INTER_TAB_SIZE); + int sx = cvRound(sX[x1]*static_cast(INTER_TAB_SIZE)); + int sy = cvRound(sY[x1]*static_cast(INTER_TAB_SIZE)); int v = (sy & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (sx & (INTER_TAB_SIZE-1)); XY[x1*2] = saturate_cast(sx >> INTER_BITS); XY[x1*2+1] = saturate_cast(sy >> INTER_BITS); @@ -1314,8 +1314,8 @@ public: for( ; x1 < bcols; x1++ ) { - int sx = cvRound(sXY[x1*2]*INTER_TAB_SIZE); - int sy = cvRound(sXY[x1*2+1]*INTER_TAB_SIZE); + int sx = cvRound(sXY[x1*2]*static_cast(INTER_TAB_SIZE)); + int sy = cvRound(sXY[x1*2+1]*static_cast(INTER_TAB_SIZE)); int v = (sy & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (sx & (INTER_TAB_SIZE-1)); XY[x1*2] = saturate_cast(sx >> INTER_BITS); XY[x1*2+1] = saturate_cast(sy >> INTER_BITS); @@ -1991,7 +1991,7 @@ void cv::convertMaps( InputArray _map1, InputArray _map2, bool useSSE4_1 = CV_CPU_HAS_SUPPORT_SSE4_1; #endif - const float scale = 1.f/INTER_TAB_SIZE; + const float scale = 1.f/static_cast(INTER_TAB_SIZE); int x, y; for( y = 0; y < size.height; y++ ) { @@ -2071,8 +2071,8 @@ void cv::convertMaps( InputArray _map1, InputArray _map2, #endif for( ; x < size.width; x++ ) { - int ix = saturate_cast(src1f[x]*INTER_TAB_SIZE); - int iy = saturate_cast(src2f[x]*INTER_TAB_SIZE); + int ix = saturate_cast(src1f[x]*static_cast(INTER_TAB_SIZE)); + int iy = saturate_cast(src2f[x]*static_cast(INTER_TAB_SIZE)); dst1[x*2] = saturate_cast(ix >> INTER_BITS); dst1[x*2+1] = saturate_cast(iy >> INTER_BITS); dst2[x] = (ushort)((iy & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (ix & (INTER_TAB_SIZE-1))); @@ -2117,8 +2117,8 @@ void cv::convertMaps( InputArray _map1, InputArray _map2, #endif for( ; x < size.width; x++ ) { - int ix = saturate_cast(src1f[x*2]*INTER_TAB_SIZE); - int iy = saturate_cast(src1f[x*2+1]*INTER_TAB_SIZE); + int ix = saturate_cast(src1f[x*2]*static_cast(INTER_TAB_SIZE)); + int iy = saturate_cast(src1f[x*2+1]*static_cast(INTER_TAB_SIZE)); dst1[x*2] = saturate_cast(ix >> INTER_BITS); dst1[x*2+1] = saturate_cast(iy >> INTER_BITS); dst2[x] = (ushort)((iy & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (ix & (INTER_TAB_SIZE-1))); @@ -3143,7 +3143,7 @@ void WarpPerspectiveLine_Process_CV_SIMD(const double *M, short* xy, short* alph for( ; x1 < bw; x1++ ) { double W = W0 + M[6]*x1; - W = W ? INTER_TAB_SIZE/W : 0; + W = W ? static_cast(INTER_TAB_SIZE)/W : 0; double fX = std::max((double)INT_MIN, std::min((double)INT_MAX, (X0 + M[0]*x1)*W)); double fY = std::max((double)INT_MIN, std::min((double)INT_MAX, (Y0 + M[3]*x1)*W)); int X = saturate_cast(fX); diff --git a/modules/imgproc/src/imgwarp.sse4_1.cpp b/modules/imgproc/src/imgwarp.sse4_1.cpp index 26ece533bc..9f7ac82fca 100644 --- a/modules/imgproc/src/imgwarp.sse4_1.cpp +++ b/modules/imgproc/src/imgwarp.sse4_1.cpp @@ -132,8 +132,8 @@ void convertMaps_32f1c16s_SSE41(const float* src1f, const float* src2f, short* d } for (; x < width; x++) { - int ix = saturate_cast(src1f[x] * INTER_TAB_SIZE); - int iy = saturate_cast(src2f[x] * INTER_TAB_SIZE); + int ix = saturate_cast(src1f[x] * static_cast(INTER_TAB_SIZE)); + int iy = saturate_cast(src2f[x] * static_cast(INTER_TAB_SIZE)); dst1[x * 2] = saturate_cast(ix >> INTER_BITS); dst1[x * 2 + 1] = saturate_cast(iy >> INTER_BITS); dst2[x] = (ushort)((iy & (INTER_TAB_SIZE - 1))*INTER_TAB_SIZE + (ix & (INTER_TAB_SIZE - 1))); @@ -165,8 +165,8 @@ void convertMaps_32f2c16s_SSE41(const float* src1f, short* dst1, ushort* dst2, i } for (; x < width; x++) { - int ix = saturate_cast(src1f[x * 2] * INTER_TAB_SIZE); - int iy = saturate_cast(src1f[x * 2 + 1] * INTER_TAB_SIZE); + int ix = saturate_cast(src1f[x * 2] * static_cast(INTER_TAB_SIZE)); + int iy = saturate_cast(src1f[x * 2 + 1] * static_cast(INTER_TAB_SIZE)); dst1[x * 2] = saturate_cast(ix >> INTER_BITS); dst1[x * 2 + 1] = saturate_cast(iy >> INTER_BITS); dst2[x] = (ushort)((iy & (INTER_TAB_SIZE - 1))*INTER_TAB_SIZE + (ix & (INTER_TAB_SIZE - 1))); @@ -444,7 +444,7 @@ public: for (; x1 < bw; x1++) { double W = W0 + M[6] * x1; - W = W ? INTER_TAB_SIZE / W : 0; + W = W ? static_cast(INTER_TAB_SIZE) / W : 0; double fX = std::max((double)INT_MIN, std::min((double)INT_MAX, (X0 + M[0] * x1)*W)); double fY = std::max((double)INT_MIN, std::min((double)INT_MAX, (Y0 + M[3] * x1)*W)); int X = saturate_cast(fX); diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index 5998bcbac7..5671025b0f 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -1056,7 +1056,7 @@ static bool ipp_crossCorr(const Mat& src, const Mat& tpl, Mat& dst, bool normed) if (ippiCrossCorrNorm==0) return false; - IppEnum funCfg = (IppEnum)(ippAlgAuto | ippiROIValid); + IppEnum funCfg = (IppEnum)(+ippAlgAuto | ippiROIValid); if(normed) funCfg |= ippiNorm; else @@ -1093,7 +1093,7 @@ static bool ipp_sqrDistance(const Mat& src, const Mat& tpl, Mat& dst) if (ippiSqrDistanceNorm==0) return false; - IppEnum funCfg = (IppEnum)(ippAlgAuto | ippiROIValid | ippiNormNone); + IppEnum funCfg = (IppEnum)(+ippAlgAuto | ippiROIValid | ippiNormNone); status = ippiSqrDistanceNormGetBufferSize(srcRoiSize, tplRoiSize, funCfg, &bufSize); if ( status < 0 ) return false; diff --git a/modules/imgproc/test/test_filter.cpp b/modules/imgproc/test/test_filter.cpp index 4038498062..685743630f 100644 --- a/modules/imgproc/test/test_filter.cpp +++ b/modules/imgproc/test/test_filter.cpp @@ -1865,107 +1865,65 @@ TEST(Imgproc_PreCornerDetect, accuracy) { CV_PreCornerDetectTest test; test.safe TEST(Imgproc_Integral, accuracy) { CV_IntegralTest test; test.safe_run(); } ////////////////////////////////////////////////////////////////////////////////// +typedef std::pair Imgproc_DepthAndDepth; +typedef testing::TestWithParam< Imgproc_DepthAndDepth> Imgproc_FilterSupportedFormats; -class CV_FilterSupportedFormatsTest : public cvtest::BaseTest +TEST_P(Imgproc_FilterSupportedFormats, normal) { -public: - CV_FilterSupportedFormatsTest() {} - ~CV_FilterSupportedFormatsTest() {} -protected: - void run(int) - { - const int depths[][2] = - { - {CV_8U, CV_8U}, - {CV_8U, CV_16U}, - {CV_8U, CV_16S}, - {CV_8U, CV_32F}, - {CV_8U, CV_64F}, - {CV_16U, CV_16U}, - {CV_16U, CV_32F}, - {CV_16U, CV_64F}, - {CV_16S, CV_16S}, - {CV_16S, CV_32F}, - {CV_16S, CV_64F}, - {CV_32F, CV_32F}, - {CV_64F, CV_64F}, - {-1, -1} - }; + // use some "odd" size to do yet another smoke + // testing of the non-SIMD loop tails + Size sz(163, 117); + Mat small_kernel(5, 5, CV_32F), big_kernel(21, 21, CV_32F); + Mat kernelX(11, 1, CV_32F), kernelY(7, 1, CV_32F); + Mat symkernelX(11, 1, CV_32F), symkernelY(7, 1, CV_32F); + randu(small_kernel, -10, 10); + randu(big_kernel, -1, 1); + randu(kernelX, -1, 1); + randu(kernelY, -1, 1); + flip(kernelX, symkernelX, 0); + symkernelX += kernelX; + flip(kernelY, symkernelY, 0); + symkernelY += kernelY; - int i = 0; - volatile int fidx = -1; - try - { - // use some "odd" size to do yet another smoke - // testing of the non-SIMD loop tails - Size sz(163, 117); - Mat small_kernel(5, 5, CV_32F), big_kernel(21, 21, CV_32F); - Mat kernelX(11, 1, CV_32F), kernelY(7, 1, CV_32F); - Mat symkernelX(11, 1, CV_32F), symkernelY(7, 1, CV_32F); - randu(small_kernel, -10, 10); - randu(big_kernel, -1, 1); - randu(kernelX, -1, 1); - randu(kernelY, -1, 1); - flip(kernelX, symkernelX, 0); - symkernelX += kernelX; - flip(kernelY, symkernelY, 0); - symkernelY += kernelY; + Mat elem_ellipse = getStructuringElement(MORPH_ELLIPSE, Size(7, 7)); + Mat elem_rect = getStructuringElement(MORPH_RECT, Size(7, 7)); - Mat elem_ellipse = getStructuringElement(MORPH_ELLIPSE, Size(7, 7)); - Mat elem_rect = getStructuringElement(MORPH_RECT, Size(7, 7)); + int sdepth = std::get<0>(GetParam()); + int ddepth = std::get<1>(GetParam()); + Mat src(sz, CV_MAKETYPE(sdepth, 5)), dst; + randu(src, 0, 100); + // non-separable filtering with a small kernel + EXPECT_NO_THROW(cv::filter2D(src, dst, ddepth, small_kernel)); + EXPECT_NO_THROW(cv::filter2D(src, dst, ddepth, big_kernel)); + EXPECT_NO_THROW(cv::sepFilter2D(src, dst, ddepth, kernelX, kernelY)); + EXPECT_NO_THROW(cv::sepFilter2D(src, dst, ddepth, symkernelX, symkernelY)); + EXPECT_NO_THROW(cv::Sobel(src, dst, ddepth, 2, 0, 5)); + EXPECT_NO_THROW(cv::Scharr(src, dst, ddepth, 0, 1)); + if( sdepth != ddepth ) + return; + EXPECT_NO_THROW(cv::GaussianBlur(src, dst, Size(5, 5), 1.2, 1.2)); + EXPECT_NO_THROW(cv::blur(src, dst, Size(11, 11))); + EXPECT_NO_THROW(cv::morphologyEx(src, dst, MORPH_GRADIENT, elem_ellipse)); + EXPECT_NO_THROW(cv::morphologyEx(src, dst, MORPH_GRADIENT, elem_rect)); +} - for( i = 0; depths[i][0] >= 0; i++ ) - { - int sdepth = depths[i][0]; - int ddepth = depths[i][1]; - Mat src(sz, CV_MAKETYPE(sdepth, 5)), dst; - randu(src, 0, 100); - // non-separable filtering with a small kernel - fidx = 0; - cv::filter2D(src, dst, ddepth, small_kernel); - fidx++; - cv::filter2D(src, dst, ddepth, big_kernel); - fidx++; - cv::sepFilter2D(src, dst, ddepth, kernelX, kernelY); - fidx++; - cv::sepFilter2D(src, dst, ddepth, symkernelX, symkernelY); - fidx++; - cv::Sobel(src, dst, ddepth, 2, 0, 5); - fidx++; - cv::Scharr(src, dst, ddepth, 0, 1); - if( sdepth != ddepth ) - continue; - fidx++; - cv::GaussianBlur(src, dst, Size(5, 5), 1.2, 1.2); - fidx++; - cv::blur(src, dst, Size(11, 11)); - fidx++; - cv::morphologyEx(src, dst, MORPH_GRADIENT, elem_ellipse); - fidx++; - cv::morphologyEx(src, dst, MORPH_GRADIENT, elem_rect); - } - } - catch(...) - { - ts->printf(cvtest::TS::LOG, "Combination of depths %d => %d in %s is not supported (yet it should be)", - depths[i][0], depths[i][1], - fidx == 0 ? "filter2D (small kernel)" : - fidx == 1 ? "filter2D (large kernel)" : - fidx == 2 ? "sepFilter2D" : - fidx == 3 ? "sepFilter2D (symmetrical/asymmetrical kernel)" : - fidx == 4 ? "Sobel" : - fidx == 5 ? "Scharr" : - fidx == 6 ? "GaussianBlur" : - fidx == 7 ? "blur" : - fidx == 8 || fidx == 9 ? "morphologyEx" : - "unknown???"); - - ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH); - } - } -}; - -TEST(Imgproc_Filtering, supportedFormats) { CV_FilterSupportedFormatsTest test; test.safe_run(); } +INSTANTIATE_TEST_CASE_P(/**/, Imgproc_FilterSupportedFormats, + testing::Values( + make_pair( CV_8U, CV_8U ), + make_pair( CV_8U, CV_16U ), + make_pair( CV_8U, CV_16S ), + make_pair( CV_8U, CV_32F), + make_pair( CV_8U, CV_64F), + make_pair( CV_16U, CV_16U), + make_pair( CV_16U, CV_32F), + make_pair( CV_16U, CV_64F), + make_pair( CV_16S, CV_16S), + make_pair( CV_16S, CV_32F), + make_pair( CV_16S, CV_64F), + make_pair( CV_32F, CV_32F), + make_pair( CV_64F, CV_64F) + ) +); TEST(Imgproc_Blur, borderTypes) { diff --git a/modules/imgproc/test/test_imgwarp.cpp b/modules/imgproc/test/test_imgwarp.cpp index 3bc89b8a13..4cf99b4704 100644 --- a/modules/imgproc/test/test_imgwarp.cpp +++ b/modules/imgproc/test/test_imgwarp.cpp @@ -282,7 +282,7 @@ void CV_ResizeTest::prepare_to_validation( int /*test_case_idx*/ ) int elem_size = CV_ELEM_SIZE(src->type); int drows = dst->rows, dcols = dst->cols; - if( interpolation == CV_INTER_NN ) + if( interpolation == cv::INTER_NEAREST ) { for( j = 0; j < dcols; j++ ) { @@ -373,7 +373,7 @@ void CV_ResizeExactTest::get_test_array_types_and_sizes(int test_case_idx, vecto ///////////////////////// static void test_remap( const Mat& src, Mat& dst, const Mat& mapx, const Mat& mapy, - Mat* mask=0, int interpolation=CV_INTER_LINEAR ) + Mat* mask=0, int interpolation=cv::INTER_LINEAR ) { int x, y, k; int drows = dst.rows, dcols = dst.cols; @@ -384,7 +384,7 @@ static void test_remap( const Mat& src, Mat& dst, const Mat& mapx, const Mat& ma int step = (int)(src.step / CV_ELEM_SIZE(depth)); int delta; - if( interpolation != CV_INTER_CUBIC ) + if( interpolation != cv::INTER_CUBIC ) { delta = 0; scols -= 1; srows -= 1; @@ -762,7 +762,7 @@ void CV_RemapTest::get_test_array_types_and_sizes( int test_case_idx, vector