From 4df6e39babab51534ac5c692ba28c00faa07176e Mon Sep 17 00:00:00 2001 From: Lukas Weber Date: Tue, 3 Jan 2023 22:45:49 +0100 Subject: [PATCH 1/9] add GraphCutSeamFinder --- samples/python/stitching_detailed.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/samples/python/stitching_detailed.py b/samples/python/stitching_detailed.py index f8f580dd56..1daef4d314 100644 --- a/samples/python/stitching_detailed.py +++ b/samples/python/stitching_detailed.py @@ -49,6 +49,8 @@ except AttributeError: print("AKAZE not available") SEAM_FIND_CHOICES = OrderedDict() +SEAM_FIND_CHOICES['gc_color'] = cv.detail_GraphCutSeamFinder('COST_COLOR') +SEAM_FIND_CHOICES['gc_colorgrad'] = cv.detail_GraphCutSeamFinder('COST_COLOR_GRAD') SEAM_FIND_CHOICES['dp_color'] = cv.detail_DpSeamFinder('COLOR') SEAM_FIND_CHOICES['dp_colorgrad'] = cv.detail_DpSeamFinder('COLOR_GRAD') SEAM_FIND_CHOICES['voronoi'] = cv.detail.SeamFinder_createDefault(cv.detail.SeamFinder_VORONOI_SEAM) From 82616eec41f6a6989a3b507822c17fc81a10e296 Mon Sep 17 00:00:00 2001 From: zihaomu Date: Mon, 9 Jan 2023 13:40:04 +0800 Subject: [PATCH 2/9] fix possible segmentation fault error in winograd on x86 --- .../src/layers/fast_convolution/fast_convolution.avx2.cpp | 2 +- .../dnn/src/layers/fast_convolution/fast_convolution.cpp | 8 +++++++- .../src/layers/fast_convolution/winograd_3x3s1_f63.cpp | 4 ++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/dnn/src/layers/fast_convolution/fast_convolution.avx2.cpp b/modules/dnn/src/layers/fast_convolution/fast_convolution.avx2.cpp index 0d3c144762..c98fbe72bd 100644 --- a/modules/dnn/src/layers/fast_convolution/fast_convolution.avx2.cpp +++ b/modules/dnn/src/layers/fast_convolution/fast_convolution.avx2.cpp @@ -119,7 +119,7 @@ void convBlock_AVX2(int np, const float* a, const float* b, float* c, int ldc, b void _fx_winograd_accum_f32(const float* inwptr, const float* wptr, float* outbuf, int Cg, int iblock) { - CV_Assert(_FX_WINO_IBLOCK == 6 && _FX_WINO_KBLOCK == 4);// && _FX_WINO_ATOM_F32 == 8); + CV_Assert(_FX_WINO_IBLOCK == 6 && _FX_WINO_KBLOCK == 4 && _FX_WINO_ATOM_F32 == 8); if (iblock > 3) { for (int atom_id = 0; atom_id < _FX_WINO_NATOMS_F32; atom_id++, diff --git a/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp b/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp index 1cde7b324f..946980bebe 100644 --- a/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp +++ b/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp @@ -105,6 +105,12 @@ Ptr initFastConv( conv->conv_type = _FX_CONV_TYPE_GENERIC; #endif +#if CV_TRY_AVX2 + // Disabel Winograd when CV_TRY_AVX2 is true, but conv->useAVX2 is false. + if (conv->conv_type == _FX_CONV_TYPE_WINOGRAD3X3 && !conv->useAVX2) + conv->conv_type = _FX_CONV_TYPE_GENERIC; +#endif + Mat weightsMat = _weightsMat.getMat(); auto wShape = shape(weightsMat); const size_t wstep = weightsMat.step1(); @@ -257,7 +263,7 @@ Ptr initFastConv( // we can always read MR elements starting from any valid index { int k = 0, nbias = K + VEC_ALIGN; - conv->biasBuf.reserve(nbias); + conv->biasBuf.resize(nbias); float* biasBufPtr = conv->biasBuf.data(); for(; k < K; k++) biasBufPtr[k] = srcBias ? srcBias[k] : 0.f; diff --git a/modules/dnn/src/layers/fast_convolution/winograd_3x3s1_f63.cpp b/modules/dnn/src/layers/fast_convolution/winograd_3x3s1_f63.cpp index e3b8088410..b0ccfd0cd2 100644 --- a/modules/dnn/src/layers/fast_convolution/winograd_3x3s1_f63.cpp +++ b/modules/dnn/src/layers/fast_convolution/winograd_3x3s1_f63.cpp @@ -22,7 +22,7 @@ _fx_winograd_accum_f32(const float* inwptr, const float* wptr, float* outbuf, int Cg, int iblock) { #if CV_NEON && CV_NEON_AARCH64 - CV_Assert(_FX_WINO_IBLOCK == 6 && _FX_WINO_KBLOCK == 4); + CV_Assert(_FX_WINO_IBLOCK == 6 && _FX_WINO_KBLOCK == 4 && _FX_WINO_ATOM_F32 == 4); if (iblock > 3) { for (int atom_id = 0; atom_id < _FX_WINO_NATOMS_F32; atom_id++, @@ -144,7 +144,7 @@ _fx_winograd_accum_f32(const float* inwptr, const float* wptr, } } #elif CV_SIMD128 - CV_Assert(_FX_WINO_IBLOCK == 3 && _FX_WINO_KBLOCK == 4); + CV_Assert(_FX_WINO_IBLOCK == 3 && _FX_WINO_KBLOCK == 4 && _FX_WINO_ATOM_F32 == 4); for (int atom_id = 0; atom_id < _FX_WINO_NATOMS_F32; atom_id++, outbuf += _FX_WINO_ATOM_F32) { From b5a0d2b580097383c30522bfba26fa2c5f9aa87b Mon Sep 17 00:00:00 2001 From: smeng9 <38666763+smeng9@users.noreply.github.com> Date: Sun, 8 Jan 2023 23:58:54 -0600 Subject: [PATCH 3/9] fix typo: stetDictionary to setDictionary --- platforms/js/opencv_js.config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/platforms/js/opencv_js.config.py b/platforms/js/opencv_js.config.py index 23f26a50d0..903d1dd6fa 100644 --- a/platforms/js/opencv_js.config.py +++ b/platforms/js/opencv_js.config.py @@ -112,7 +112,7 @@ objdetect = {'': ['groupRectangles'], 'HOGDescriptor': ['load', 'HOGDescriptor', 'getDefaultPeopleDetector', 'getDaimlerPeopleDetector', 'setSVMDetector', 'detectMultiScale'], 'CascadeClassifier': ['load', 'detectMultiScale2', 'CascadeClassifier', 'detectMultiScale3', 'empty', 'detectMultiScale'], 'QRCodeDetector': ['QRCodeDetector', 'decode', 'decodeCurved', 'detect', 'detectAndDecode', 'detectMulti', 'setEpsX', 'setEpsY'], - 'ArucoDetector': ['getPredefinedDictionary', 'detectMarkers', 'refineDetectedMarkers', 'getDictionary', 'stetDictionary', 'getDetectorParameters', 'setDetectorParameters', 'getRefineParameters', 'setRefineParameters'], + 'ArucoDetector': ['getPredefinedDictionary', 'detectMarkers', 'refineDetectedMarkers', 'getDictionary', 'setDictionary', 'getDetectorParameters', 'setDetectorParameters', 'getRefineParameters', 'setRefineParameters'], 'GridBoard': ['create','generateImage', 'getGridSize', 'getMarkerLength', 'getMarkerSeparation'], 'CharucoBoard': ['create', 'generateImage', 'getChessboardCorners', 'getNearestMarkerCorners', 'checkCharucoCornersCollinear'] } From 927aa1e617f7c8f0878847d46d6856c0d59e00be Mon Sep 17 00:00:00 2001 From: cudawarped <12133430+cudawarped@users.noreply.github.com> Date: Fri, 30 Dec 2022 09:14:11 +0200 Subject: [PATCH 4/9] cuda: add ada lovelace and hopper cuda arch --- cmake/OpenCVDetectCUDA.cmake | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/cmake/OpenCVDetectCUDA.cmake b/cmake/OpenCVDetectCUDA.cmake index a3d987a2b8..140244ff54 100644 --- a/cmake/OpenCVDetectCUDA.cmake +++ b/cmake/OpenCVDetectCUDA.cmake @@ -101,18 +101,20 @@ if(CUDA_FOUND) message(STATUS "CUDA detected: " ${CUDA_VERSION}) OCV_OPTION(CUDA_ENABLE_DEPRECATED_GENERATION "Enable deprecated generations in the list" OFF) - set(_generations "Maxwell" "Pascal" "Volta" "Turing" "Ampere") + set(_generations "Maxwell" "Pascal" "Volta" "Turing" "Ampere" "Lovelace" "Hopper") if(CUDA_ENABLE_DEPRECATED_GENERATION) set(_generations "Fermi" "${_generations}") set(_generations "Kepler" "${_generations}") endif() - set(_arch_fermi "2.0") - set(_arch_kepler "3.0;3.5;3.7") - set(_arch_maxwell "5.0;5.2") - set(_arch_pascal "6.0;6.1") - set(_arch_volta "7.0") - set(_arch_turing "7.5") - set(_arch_ampere "8.0;8.6") + set(_arch_fermi "2.0") + set(_arch_kepler "3.0;3.5;3.7") + set(_arch_maxwell "5.0;5.2") + set(_arch_pascal "6.0;6.1") + set(_arch_volta "7.0") + set(_arch_turing "7.5") + set(_arch_ampere "8.0;8.6") + set(_arch_lovelace "8.9") + set(_arch_hopper "9.0") if(NOT CMAKE_CROSSCOMPILING) list(APPEND _generations "Auto") endif() @@ -241,6 +243,10 @@ if(CUDA_FOUND) set(__cuda_arch_bin ${_arch_turing}) elseif(CUDA_GENERATION STREQUAL "Ampere") set(__cuda_arch_bin ${_arch_ampere}) + elseif(CUDA_GENERATION STREQUAL "Lovelace") + set(__cuda_arch_bin ${_arch_lovelace}) + elseif(CUDA_GENERATION STREQUAL "Hopper") + set(__cuda_arch_bin ${_arch_hopper}) elseif(CUDA_GENERATION STREQUAL "Auto") ocv_detect_native_cuda_arch(_nvcc_res _nvcc_out) if(NOT _nvcc_res EQUAL 0) @@ -286,6 +292,8 @@ if(CUDA_FOUND) ${_arch_volta} ${_arch_turing} ${_arch_ampere} + ${_arch_lovelace} + ${_arch_hopper} ) endif() endif() From 840b1d5c94325eac6158a5a3cd1d57bee2c25aa1 Mon Sep 17 00:00:00 2001 From: zihaomu Date: Wed, 11 Jan 2023 08:42:51 +0800 Subject: [PATCH 5/9] add depthwise add fuse --- .../depthwise_convolution.cpp | 40 +++++++++++++++---- .../fast_convolution/fast_convolution.cpp | 4 +- .../fast_convolution/fast_convolution.hpp | 2 +- modules/dnn/test/test_onnx_importer.cpp | 5 +++ 4 files changed, 41 insertions(+), 10 deletions(-) diff --git a/modules/dnn/src/layers/fast_convolution/depthwise_convolution.cpp b/modules/dnn/src/layers/fast_convolution/depthwise_convolution.cpp index 0c471e8920..4566c880c9 100644 --- a/modules/dnn/src/layers/fast_convolution/depthwise_convolution.cpp +++ b/modules/dnn/src/layers/fast_convolution/depthwise_convolution.cpp @@ -24,7 +24,7 @@ static void depthWiseBlockConv2D(const float* wptr, const float* inptr_, int height, int width, float* outptr_, - int out_d, int outH, int outW) + int out_d, int outH, int outW, bool fusedAdd) { const float w00_ = wptr[0], w01_ = wptr[1], w02_ = wptr[2], w10 = wptr[3], w11 = wptr[4], w12 = wptr[5], @@ -57,6 +57,8 @@ static void depthWiseBlockConv2D(const float* wptr, out = imgptr0[0]*w01 + imgptr0[dilation_w]*w02 + imgptr1[0]*w11 + imgptr1[dilation_w]*w12 + imgptr2[0]*w21 + imgptr2[dilation_w]*w22 + bias; + if (fusedAdd) + out += outptr[0]; if (relu) out = out > 0.f ? out : out*relu_coeff; outptr[0] = out; @@ -65,6 +67,10 @@ static void depthWiseBlockConv2D(const float* wptr, #if CV_SIMD128 const int VEC_NLANES = 4; + + if (fusedAdd) + outW1 = max(out_j, outW1 - outW1%VEC_NLANES); + v_float32x4 vw00 = v_setall_f32(w00); v_float32x4 vw01 = v_setall_f32(w01); v_float32x4 vw02 = v_setall_f32(w02); @@ -104,6 +110,8 @@ static void depthWiseBlockConv2D(const float* wptr, v_float32x4 vout = v00*vw00 + v01*vw01 + v02*vw02 + v10*vw10 + v11*vw11 + v12*vw12 + v20*vw20 + v21*vw21 + v22*vw22 + vbias; + if (fusedAdd) + vout = v_load(outptr + out_j) + vout; if (relu) vout = v_select(vout > z, vout, vout*vrc); v_store(outptr + out_j, vout); @@ -134,6 +142,8 @@ static void depthWiseBlockConv2D(const float* wptr, v10 * vw10 + v11 * vw11 + v12 * vw12 + v20 * vw20 + v21 * vw21 + v22 * vw22 + vbias; + if (fusedAdd) + vout = v_load(outptr + out_j) + vout; if (relu) vout = v_select(vout > z, vout, vout*vrc); v_store(outptr + out_j, vout); @@ -148,6 +158,8 @@ static void depthWiseBlockConv2D(const float* wptr, out = imgptr0[in_j]*w00 + imgptr0[in_j + dilation_w]*w01 + imgptr0[in_j + dilation_w*2]*w02 + imgptr1[in_j]*w10 + imgptr1[in_j + dilation_w]*w11 + imgptr1[in_j + dilation_w*2]*w12 + imgptr2[in_j]*w20 + imgptr2[in_j + dilation_w]*w21 + imgptr2[in_j + dilation_w*2]*w22 + bias; + if (fusedAdd) + out += outptr[out_j]; if (relu) out = out > 0.f ? out : out*relu_coeff; outptr[out_j] = out; @@ -175,6 +187,8 @@ static void depthWiseBlockConv2D(const float* wptr, out = imgptr0[in_j0]*w00*s0 + imgptr0[in_j1]*w01*s1 + imgptr0[in_j2]*w02*s2 + imgptr1[in_j0]*w10*s0 + imgptr1[in_j1]*w11*s1 + imgptr1[in_j2]*w12*s2 + imgptr2[in_j0]*w20*s0 + imgptr2[in_j1]*w21*s1 + imgptr2[in_j2]*w22*s2 + bias; + if (fusedAdd) + out += outptr[out_j]; if (relu) out = out > 0.f ? out : out*relu_coeff; outptr[out_j] = out; @@ -187,7 +201,7 @@ static void depthWiseBlockConv1D(const float* wptr, const float* biasptr, const float* relu, const float* inptr_, int width, float* outptr_, - int out_d, int outW) + int out_d, int outW, bool fusedAdd) { const float w00_ = wptr[0], w01_ = wptr[1], w02_ = wptr[2]; int outW1 = min(outW, (width - dilation_w * (kernel_w - 1) + pad_l)/stride_w); @@ -201,7 +215,8 @@ static void depthWiseBlockConv1D(const float* wptr, if (pad_l > 0) { out = imgptr0[0]*w01 + imgptr0[dilation_w]*w02 + bias; - + if (fusedAdd) + out += outptr[0]; if (relu) out = out > 0.f ? out : out*relu_coeff; outptr[0] = out; @@ -210,6 +225,8 @@ static void depthWiseBlockConv1D(const float* wptr, #if CV_SIMD128 const int VEC_NLANES = 4; + if (fusedAdd) + outW1 = max(out_j, outW1 - outW1%VEC_NLANES); v_float32x4 vw00 = v_setall_f32(w00); v_float32x4 vw01 = v_setall_f32(w01); v_float32x4 vw02 = v_setall_f32(w02); @@ -235,6 +252,8 @@ static void depthWiseBlockConv1D(const float* wptr, v02 = v_load(imgptr0 + in_j + dilation_w*2); v_float32x4 vout = v00*vw00 + v01*vw01 + v02*vw02 + vbias; + if (fusedAdd) + vout = v_load(outptr + out_j) + vout; if (relu) vout = v_select(vout > z, vout, vout*vrc); v_store(outptr + out_j, vout); @@ -258,6 +277,9 @@ static void depthWiseBlockConv1D(const float* wptr, v_float32x4 vout = v00 * vw00 + v01 * vw01 + v02 * vw02 + vbias; + if (fusedAdd) + vout = v_load(outptr + out_j) + vout; + if (relu) vout = v_select(vout > z, vout, vout*vrc); v_store(outptr + out_j, vout); @@ -270,6 +292,8 @@ static void depthWiseBlockConv1D(const float* wptr, { int in_j = out_j * stride_w - pad_l; out = imgptr0[in_j]*w00 + imgptr0[in_j + dilation_w]*w01 + imgptr0[in_j + dilation_w*2]*w02 + bias; + if (fusedAdd) + out += outptr[out_j]; if (relu) out = out > 0.f ? out : out*relu_coeff; outptr[out_j] = out; @@ -295,6 +319,8 @@ static void depthWiseBlockConv1D(const float* wptr, s2 = 0.f; } out = imgptr0[in_j0]*w00*s0 + imgptr0[in_j1]*w01*s1 + imgptr0[in_j2]*w02*s2 + bias; + if (fusedAdd) + out += outptr[out_j]; if (relu) out = out > 0.f ? out : out*relu_coeff; outptr[out_j] = out; @@ -302,7 +328,7 @@ static void depthWiseBlockConv1D(const float* wptr, } void runDepthwise(InputArray _input, OutputArray _output, const Ptr& conv, ActivationLayer* activ_, - const std::vector& reluslope) + const std::vector& reluslope, bool fusedAdd) { Mat input = _input.getMat(); Mat output = _output.getMat(); @@ -349,7 +375,7 @@ void runDepthwise(InputArray _input, OutputArray _output, const Ptr& c #if CV_TRY_AVX2 || CV_TRY_AVX || CV_TRY_RVV // TODO: remove the following limitation, need change code in layers_common.simd.hpp. - bool canRunOpt = Wi >= 16 + dilation_w*(Wk - 1); + bool canRunOpt = Wi >= 16 + dilation_w*(Wk - 1) && !fusedAdd; #endif std::vector ofstab_(3 * ksize, 0); int *ofstab = ofstab_.data(); @@ -399,11 +425,11 @@ void runDepthwise(InputArray _input, OutputArray _output, const Ptr& c else #endif depthWiseBlockConv2D(weights, Hk, Wk, stride_h, stride_w, dilation_h, dilation_w, - pad_top, pad_left, bias, relu, inptr0, Hi, Wi, outptr0, c, H0, W0); + pad_top, pad_left, bias, relu, inptr0, Hi, Wi, outptr0, c, H0, W0, fusedAdd); } else // conv_dim == CONV_1D, spatial branch for depth-wise Conv1D. { - depthWiseBlockConv1D(weights, Wk, stride_w, dilation_w, pad_left, bias, relu, inptr0, Wi, outptr0, c, W0); + depthWiseBlockConv1D(weights, Wk, stride_w, dilation_w, pad_left, bias, relu, inptr0, Wi, outptr0, c, W0, fusedAdd); } if (activ) diff --git a/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp b/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp index 1cde7b324f..feda70a598 100644 --- a/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp +++ b/modules/dnn/src/layers/fast_convolution/fast_convolution.cpp @@ -369,8 +369,8 @@ void runFastConv(InputArray _input, OutputArray _output, const Ptr& co if (conv->conv_type == _FX_CONV_TYPE_DEPTHWISE) { // Depthwise-Convolution layer should not be followed by Add layer. - CV_Assert(fusedAddMat.empty() && (conv_dim == CONV_1D || conv_dim == CONV_2D)); - return runDepthwise(input, output, conv,actLayer.get(), reluslope); + CV_Assert((conv_dim == CONV_1D || conv_dim == CONV_2D)); + return runDepthwise(input, output, conv, actLayer.get(), reluslope, fusedAdd); } MatShape inputShape = shape(input); diff --git a/modules/dnn/src/layers/fast_convolution/fast_convolution.hpp b/modules/dnn/src/layers/fast_convolution/fast_convolution.hpp index 895ad562bb..7794078bb4 100644 --- a/modules/dnn/src/layers/fast_convolution/fast_convolution.hpp +++ b/modules/dnn/src/layers/fast_convolution/fast_convolution.hpp @@ -100,7 +100,7 @@ void runFastConv(InputArray _input, OutputArray _output, const Ptr& co const Ptr& actLayer, const std::vector& reluslope, bool fusedAdd); void runDepthwise(InputArray _input, OutputArray _output, const Ptr& conv, ActivationLayer* activ, - const std::vector& reluslope); + const std::vector& reluslope, bool fusedAdd); int runWinograd63(InputArray _input, InputArray _fusedAddMat, OutputArray _output, const Ptr& conv, int ntasks, float minval, float maxval, ActivationLayer* activ, bool ifMinMaxAct); diff --git a/modules/dnn/test/test_onnx_importer.cpp b/modules/dnn/test/test_onnx_importer.cpp index 12dc3987b9..0ffa252c71 100644 --- a/modules/dnn/test/test_onnx_importer.cpp +++ b/modules/dnn/test/test_onnx_importer.cpp @@ -1726,6 +1726,11 @@ TEST_P(Test_ONNX_layers, ConvResizePool1d) testONNXModels("conv_resize_pool_1d"); } +TEST_P(Test_ONNX_layers, DepthWiseAdd) +{ + testONNXModels("depthwiseconv_add"); +} + TEST_P(Test_ONNX_layers, SubFromConst) { testONNXModels("sub_from_const1"); From b5bf756ca0339f3f09d0f28b45f68b58c59471cc Mon Sep 17 00:00:00 2001 From: cudawarped <12133430+cudawarped@users.noreply.github.com> Date: Tue, 10 Jan 2023 08:40:08 +0200 Subject: [PATCH 6/9] core: define cuda test size with row/col of 1 --- modules/ts/include/opencv2/ts/cuda_test.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/ts/include/opencv2/ts/cuda_test.hpp b/modules/ts/include/opencv2/ts/cuda_test.hpp index f1851c5f8f..87b217fc13 100644 --- a/modules/ts/include/opencv2/ts/cuda_test.hpp +++ b/modules/ts/include/opencv2/ts/cuda_test.hpp @@ -212,6 +212,8 @@ namespace cvtest #define DIFFERENT_SIZES testing::Values(cv::Size(128, 128), cv::Size(113, 113)) + #define DIFFERENT_SIZES_EXTRA testing::Values(cv::Size(13, 1), cv::Size(1, 13), cv::Size(128, 128), cv::Size(113, 113)) + // Depth using perf::MatDepth; From ef0fcb92389655c6f66eee8dac5b551d10d6f68e Mon Sep 17 00:00:00 2001 From: Xxfore Date: Wed, 11 Jan 2023 22:11:16 +0800 Subject: [PATCH 7/9] Merge pull request #22938 from Xxfore:4.x Use reinterpret instead of c-style casting for GCC Co-authored-by: Xu Zhang Co-authored-by: Maksim Shabunin --- cmake/checks/cpu_rvv.cpp | 3 + .../include/opencv2/core/hal/intrin_rvv.hpp | 75 ++++++++----------- 2 files changed, 35 insertions(+), 43 deletions(-) diff --git a/cmake/checks/cpu_rvv.cpp b/cmake/checks/cpu_rvv.cpp index 684b2ecbeb..b9f19c17fd 100644 --- a/cmake/checks/cpu_rvv.cpp +++ b/cmake/checks/cpu_rvv.cpp @@ -9,6 +9,9 @@ int test() { const float src[] = { 0.0f, 0.0f, 0.0f, 0.0f }; + uint64_t ptr[2] = {0x0908060504020100, 0xFFFFFFFF0E0D0C0A}; + vuint8m1_t a = vreinterpret_v_u64m1_u8m1(vle64_v_u64m1(ptr, 2)); + //vuint8m1_t a = (vuint8m1_t)vle64_v_u64m1(ptr, 2); vfloat32m1_t val = vle32_v_f32m1((const float*)(src), 4); return (int)vfmv_f_s_f32m1_f32(val); } diff --git a/modules/core/include/opencv2/core/hal/intrin_rvv.hpp b/modules/core/include/opencv2/core/hal/intrin_rvv.hpp index dca54a27d1..3e7ce51f6b 100644 --- a/modules/core/include/opencv2/core/hal/intrin_rvv.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_rvv.hpp @@ -1920,20 +1920,29 @@ inline v_float64x2 v_muladd(const v_float64x2& a, const v_float64x2& b, const v_ #define OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(_Tpvec, suffix, shift, vl) \ inline bool v_check_all(const _Tpvec& a) \ { \ - v_uint64x2 v = v_uint64x2((vuint64m1_t)vsrl_vx_##suffix##m1(vnot_v_##suffix##m1(a, vl), shift, vl)); \ + v_uint64x2 v = v_uint64x2(vreinterpret_v_##suffix##m1_u64m1(vsrl_vx_##suffix##m1(vnot_v_##suffix##m1(a, vl), shift, vl))); \ return (v.val[0] | v.val[1]) == 0; \ } \ inline bool v_check_any(const _Tpvec& a) \ { \ - v_uint64x2 v = v_uint64x2((vuint64m1_t)vsrl_vx_##suffix##m1(a, shift, vl)); \ + v_uint64x2 v = v_uint64x2(vreinterpret_v_##suffix##m1_u64m1(vsrl_vx_##suffix##m1(a, shift, vl))); \ return (v.val[0] | v.val[1]) != 0; \ } OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint8x16, u8, 7, 16) OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint16x8, u16, 15, 8) OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint32x4, u32, 31, 4) -OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint64x2, u64, 63, 2) - +//OPENCV_HAL_IMPL_RVV_CHECK_ALLANY(v_uint64x2, u64, 63, 2) +inline bool v_check_all(const v_uint64x2& a) +{ + v_uint64x2 v = v_uint64x2(vsrl_vx_u64m1(vnot_v_u64m1(a, 2), 63, 2)); + return (v.val[0] | v.val[1]) == 0; +} +inline bool v_check_any(const v_uint64x2& a) +{ + v_uint64x2 v = v_uint64x2(vsrl_vx_u64m1(a, 63, 2)); + return (v.val[0] | v.val[1]) != 0; +} inline bool v_check_all(const v_int8x16& a) { return v_check_all(v_reinterpret_as_u8(a)); } @@ -2035,15 +2044,15 @@ OPENCV_HAL_IMPL_RVV_ABSDIFF(v_int16x8, absdiffs) // use reinterpret instead of c-style casting. #ifndef __clang__ -#define OPENCV_HAL_IMPL_RVV_ABSDIFF_S(_Tpvec, _rTpvec, _nwTpvec, sub, rshr, vl) \ +#define OPENCV_HAL_IMPL_RVV_ABSDIFF_S(_Tpvec, _rTpvec, _nwTpvec, sub, rshr, width, vl) \ inline _rTpvec v_absdiff(const _Tpvec& a, const _Tpvec& b) \ { \ - return _rTpvec(rshr((_nwTpvec)sub(v_max(a, b), v_min(a, b), vl), 0, vl)); \ + return _rTpvec(rshr(vreinterpret_v_i##width##m2_u##width##m2(sub(v_max(a, b), v_min(a, b), vl)), 0, vl)); \ } -OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int8x16, v_uint8x16, vuint16m2_t, vwsub_vv_i16m2, vnclipu_wx_u8m1, 16) -OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int16x8, v_uint16x8, vuint32m2_t, vwsub_vv_i32m2, vnclipu_wx_u16m1, 8) -OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int32x4, v_uint32x4, vuint64m2_t, vwsub_vv_i64m2, vnclipu_wx_u32m1, 4) +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int8x16, v_uint8x16, vuint16m2_t, vwsub_vv_i16m2, vnclipu_wx_u8m1, 16, 16) +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int16x8, v_uint16x8, vuint32m2_t, vwsub_vv_i32m2, vnclipu_wx_u16m1, 32, 8) +OPENCV_HAL_IMPL_RVV_ABSDIFF_S(v_int32x4, v_uint32x4, vuint64m2_t, vwsub_vv_i64m2, vnclipu_wx_u32m1, 64, 4) #else #define OPENCV_HAL_IMPL_RVV_ABSDIFF_S(_Tpvec, _rTpvec, _nwTpvec, sub, rshr, width, vl) \ inline _rTpvec v_absdiff(const _Tpvec& a, const _Tpvec& b) \ @@ -2806,12 +2815,15 @@ OPENCV_HAL_IMPL_RVV_SCAN_FORWOARD_OP(v_float64x2, double, f64) //////////// Pack triplets //////////// -// use reinterpret instead of c-style casting. -#ifndef __clang__ inline v_int8x16 v_pack_triplets(const v_int8x16& vec) { - uint64 ptr[2] = {0x0908060504020100, 0xFFFFFF0F0E0D0C0A}; - return v_int8x16((vint8m1_t)vrgather_vv_u8m1((vuint8m1_t)vint8m1_t(vec), (vuint8m1_t)vle64_v_u64m1(ptr, 2), 16)); + const uint64 ptr[2] = {0x0908060504020100, 0xFFFFFF0F0E0D0C0A}; + const v_uint64x2 flags(vle64_v_u64m1(ptr, 2)); + return v_reinterpret_as_s8(v_uint8x16( + vrgather_vv_u8m1( + v_reinterpret_as_u8(vec), + v_reinterpret_as_u8(flags), + 16))); } inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) { @@ -2820,8 +2832,13 @@ inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) inline v_int16x8 v_pack_triplets(const v_int16x8& vec) { - uint64 ptr[2] = {0x0908050403020100, 0xFFFF0F0E0D0C0B0A}; - return v_int16x8((vint16m1_t)vrgather_vv_u8m1((vuint8m1_t)vint16m1_t(vec), (vuint8m1_t)vle64_v_u64m1(ptr, 2), 16)); + const uint64 ptr[2] = {0x0908050403020100, 0xFFFF0F0E0D0C0B0A}; + const v_uint64x2 flags(vle64_v_u64m1(ptr, 2)); + return v_reinterpret_as_s16(v_uint8x16( + vrgather_vv_u8m1( + v_reinterpret_as_u8(vec), + v_reinterpret_as_u8(flags), + 16))); } inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) { @@ -2832,34 +2849,6 @@ inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } -#else - -inline v_int8x16 v_pack_triplets(const v_int8x16& vec) -{ - uint64 ptr[2] = {0x0908060504020100, 0xFFFFFF0F0E0D0C0A}; - return v_int8x16(vreinterpret_i8m1(vrgather_vv_u8m1(v_reinterpret_as_u8(vec), vreinterpret_u8m1(vle64_v_u64m1(ptr, 2)), 16))); -} -inline v_uint8x16 v_pack_triplets(const v_uint8x16& vec) -{ - return v_reinterpret_as_u8(v_pack_triplets(v_reinterpret_as_s8(vec))); -} - -inline v_int16x8 v_pack_triplets(const v_int16x8& vec) -{ - uint64 ptr[2] = {0x0908050403020100, 0xFFFF0F0E0D0C0B0A}; - return v_int16x8(v_reinterpret_as_s16(v_uint8x16(vrgather_vv_u8m1(v_reinterpret_as_u8(vec), vreinterpret_u8m1(vle64_v_u64m1(ptr, 2)), 16)))); -} -inline v_uint16x8 v_pack_triplets(const v_uint16x8& vec) -{ - return v_reinterpret_as_u16(v_pack_triplets(v_reinterpret_as_s16(vec))); -} - -inline v_int32x4 v_pack_triplets(const v_int32x4& vec) { return vec; } -inline v_uint32x4 v_pack_triplets(const v_uint32x4& vec) { return vec; } -inline v_float32x4 v_pack_triplets(const v_float32x4& vec) { return vec; } - -#endif - ////// FP16 support /////// #if CV_FP16 From c63d79c5b16fcbbec46f1b8bb871dab2274e2b01 Mon Sep 17 00:00:00 2001 From: Yuantao Feng Date: Mon, 16 Jan 2023 17:44:13 +0800 Subject: [PATCH 8/9] Merge pull request #23095 from fengyuentau:fix_omp_macos * fix openmp include and link issue on macos * turn off have_openmp if OpenMP_CXX_INCLUDE_DIRS is empty * test commit * use condition HAVE_OPENMP and OpenMP_CXX_LIBRARIES for linking * remove trailing whitespace * remove notes * update conditions * use OpenMP_CXX_LIBRARIES for linking --- cmake/OpenCVFindFrameworks.cmake | 3 +++ modules/core/CMakeLists.txt | 4 ++++ modules/video/CMakeLists.txt | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/cmake/OpenCVFindFrameworks.cmake b/cmake/OpenCVFindFrameworks.cmake index 19f6d66340..741267d269 100644 --- a/cmake/OpenCVFindFrameworks.cmake +++ b/cmake/OpenCVFindFrameworks.cmake @@ -32,6 +32,9 @@ if(WITH_OPENMP) if(OPENMP_FOUND) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") + if(DEFINED OpenMP_CXX_INCLUDE_DIRS AND OpenMP_CXX_INCLUDE_DIRS) + ocv_include_directories(${OpenMP_CXX_INCLUDE_DIRS}) + endif() endif() set(HAVE_OPENMP "${OPENMP_FOUND}") endif() diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index eab909843b..fe747540e8 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -168,6 +168,10 @@ if(HAVE_HPX) ocv_target_link_libraries(${the_module} LINK_PRIVATE "${HPX_LIBRARIES}") endif() +if(HAVE_OPENMP AND DEFINED OpenMP_CXX_LIBRARIES AND OpenMP_CXX_LIBRARIES) + ocv_target_link_libraries(${the_module} LINK_PRIVATE "${OpenMP_CXX_LIBRARIES}") +endif() + ocv_add_accuracy_tests() ocv_add_perf_tests() diff --git a/modules/video/CMakeLists.txt b/modules/video/CMakeLists.txt index 8499de9169..a302e5a5d1 100644 --- a/modules/video/CMakeLists.txt +++ b/modules/video/CMakeLists.txt @@ -10,3 +10,7 @@ ocv_define_module(video python js ) + +if(HAVE_OPENMP AND DEFINED OpenMP_CXX_LIBRARIES AND OpenMP_CXX_LIBRARIES) + ocv_target_link_libraries(${the_module} LINK_PRIVATE "${OpenMP_CXX_LIBRARIES}") +endif() From c1e5c16ff3e95b822df9c6406048e5db58f05cf0 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Mon, 16 Jan 2023 23:29:50 +0300 Subject: [PATCH 9/9] Backport C-API cleanup (imgproc) from 5.x --- .../erosion_dilatation.markdown | 6 +- .../histogram_comparison.markdown | 8 +- modules/calib3d/src/calibinit.cpp | 151 +----------------- modules/calib3d/test/test_undistort.cpp | 6 +- modules/core/include/opencv2/core/cuda.hpp | 8 +- modules/gapi/include/opencv2/gapi/core.hpp | 2 +- modules/imgproc/doc/pics/polar_remap_doc.svg | 6 +- .../imgproc/misc/java/test/ImgprocTest.java | 12 +- .../perf/opencl/perf_matchTemplate.cpp | 4 +- modules/imgproc/perf/perf_houghcircles.cpp | 6 +- modules/imgproc/src/_geom.h | 10 -- modules/imgproc/src/canny.cpp | 3 +- modules/imgproc/src/drawing.cpp | 28 ++-- modules/imgproc/src/linefit.cpp | 24 +-- modules/imgproc/src/segmentation.cpp | 2 - modules/imgproc/src/templmatch.cpp | 54 +++---- .../imgproc/test/ocl/test_match_template.cpp | 2 +- modules/imgproc/test/test_canny.cpp | 2 +- modules/imgproc/test/test_drawing.cpp | 46 +++--- modules/imgproc/test/test_houghcircles.cpp | 2 +- modules/imgproc/test/test_imgwarp_strict.cpp | 20 +-- modules/imgproc/test/test_pc.cpp | 4 +- modules/imgproc/test/test_templmatch.cpp | 28 ++-- modules/imgproc/test/test_templmatchmask.cpp | 26 +-- modules/photo/src/inpaint.cpp | 15 +- modules/ts/src/ocl_test.cpp | 2 +- modules/ts/src/ts_func.cpp | 10 +- modules/video/test/test_camshift.cpp | 32 +--- modules/videoio/src/cap_avfoundation.mm | 30 ++-- modules/videoio/src/cap_avfoundation_mac.mm | 38 ++--- modules/videoio/src/cap_openni2.cpp | 2 +- .../samples/puzzle15/Puzzle15Processor.java | 4 +- samples/cpp/mask_tmpl.cpp | 2 +- .../erosion_dilatation/MorphologyDemo1.java | 8 +- 34 files changed, 206 insertions(+), 397 deletions(-) diff --git a/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown b/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown index 086bceb542..a9826c54d8 100644 --- a/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown +++ b/doc/tutorials/imgproc/erosion_dilatation/erosion_dilatation.markdown @@ -204,9 +204,9 @@ receives three arguments: We can choose any of three shapes for our kernel: - - Rectangular box: CV_SHAPE_RECT - - Cross: CV_SHAPE_CROSS - - Ellipse: CV_SHAPE_ELLIPSE + - Rectangular box: Imgproc.SHAPE_RECT + - Cross: Imgproc.SHAPE_CROSS + - Ellipse: Imgproc.SHAPE_ELLIPSE Together with the shape we specify the size of our kernel and the *anchor point*. If the anchor point is not specified, it is assumed to be in the center. diff --git a/doc/tutorials/imgproc/histograms/histogram_comparison/histogram_comparison.markdown b/doc/tutorials/imgproc/histograms/histogram_comparison/histogram_comparison.markdown index efcb4284f3..9fcb0a46f9 100644 --- a/doc/tutorials/imgproc/histograms/histogram_comparison/histogram_comparison.markdown +++ b/doc/tutorials/imgproc/histograms/histogram_comparison/histogram_comparison.markdown @@ -27,19 +27,19 @@ Theory (\f$d(H_{1}, H_{2})\f$) to express how well both histograms match. - OpenCV implements the function @ref cv::compareHist to perform a comparison. It also offers 4 different metrics to compute the matching: - -# **Correlation ( CV_COMP_CORREL )** + -# **Correlation ( cv::HISTCMP_CORREL )** \f[d(H_1,H_2) = \frac{\sum_I (H_1(I) - \bar{H_1}) (H_2(I) - \bar{H_2})}{\sqrt{\sum_I(H_1(I) - \bar{H_1})^2 \sum_I(H_2(I) - \bar{H_2})^2}}\f] where \f[\bar{H_k} = \frac{1}{N} \sum _J H_k(J)\f] and \f$N\f$ is the total number of histogram bins. - -# **Chi-Square ( CV_COMP_CHISQR )** + -# **Chi-Square ( cv::HISTCMP_CHISQR )** \f[d(H_1,H_2) = \sum _I \frac{\left(H_1(I)-H_2(I)\right)^2}{H_1(I)}\f] - -# **Intersection ( method=CV_COMP_INTERSECT )** + -# **Intersection ( method=cv::HISTCMP_INTERSECT )** \f[d(H_1,H_2) = \sum _I \min (H_1(I), H_2(I))\f] - -# **Bhattacharyya distance ( CV_COMP_BHATTACHARYYA )** + -# **Bhattacharyya distance ( cv::HISTCMP_BHATTACHARYYA )** \f[d(H_1,H_2) = \sqrt{1 - \frac{1}{\sqrt{\bar{H_1} \bar{H_2} N^2}} \sum_I \sqrt{H_1(I) \cdot H_2(I)}}\f] Code diff --git a/modules/calib3d/src/calibinit.cpp b/modules/calib3d/src/calibinit.cpp index 7b5e1db9f9..135519e776 100644 --- a/modules/calib3d/src/calibinit.cpp +++ b/modules/calib3d/src/calibinit.cpp @@ -101,8 +101,6 @@ namespace cv { #define MAX_CONTOUR_APPROX 7 -#define USE_CV_FINDCONTOURS // switch between cv::findContours() and legacy C API -#ifdef USE_CV_FINDCONTOURS struct QuadCountour { Point pt[4]; int parent_contour; @@ -113,18 +111,6 @@ struct QuadCountour { pt[0] = pt_[0]; pt[1] = pt_[1]; pt[2] = pt_[2]; pt[3] = pt_[3]; } }; -#else - -} // namespace -#include "opencv2/imgproc/imgproc_c.h" -namespace cv { - -struct CvContourEx -{ - CV_CONTOUR_FIELDS() - int counter; -}; -#endif /** This structure stores information about the chessboard corner.*/ @@ -552,13 +538,7 @@ bool findChessboardCorners(InputArray image_, Size pattern_size, rectangle( thresh_img_new, Point(0,0), Point(thresh_img_new.cols-1, thresh_img_new.rows-1), Scalar(255,255,255), 3, LINE_8); detector.reset(); - -#ifdef USE_CV_FINDCONTOURS - Mat binarized_img = thresh_img_new; -#else - Mat binarized_img = thresh_img_new.clone(); // make clone because cvFindContours modifies the source image -#endif - detector.generateQuads(binarized_img, flags); + detector.generateQuads(thresh_img_new, flags); DPRINTF("Quad count: %d/%d", detector.all_quads_count, (pattern_size.width/2+1)*(pattern_size.height/2+1)); SHOW_QUADS("New quads", thresh_img_new, &detector.all_quads[0], detector.all_quads_count); if (detector.processQuads(out_corners, prev_sqr_size)) @@ -623,13 +603,7 @@ bool findChessboardCorners(InputArray image_, Size pattern_size, rectangle( thresh_img, Point(0,0), Point(thresh_img.cols-1, thresh_img.rows-1), Scalar(255,255,255), 3, LINE_8); detector.reset(); - -#ifdef USE_CV_FINDCONTOURS - Mat binarized_img = thresh_img; -#else - Mat binarized_img = (useAdaptive) ? thresh_img : thresh_img.clone(); // make clone because cvFindContours modifies the source image -#endif - detector.generateQuads(binarized_img, flags); + detector.generateQuads(thresh_img, flags); DPRINTF("Quad count: %d/%d", detector.all_quads_count, (pattern_size.width/2+1)*(pattern_size.height/2+1)); SHOW_QUADS("Old quads", thresh_img, &detector.all_quads[0], detector.all_quads_count); if (detector.processQuads(out_corners, prev_sqr_size)) @@ -1376,7 +1350,6 @@ int ChessBoardDetector::checkQuadGroup(std::vector& quad_group, for (int j = 0; j < 4; ++j) { - //cvLine( debug_img, cvPointFrom32f(q->corners[j]->pt), cvPointFrom32f(q->corners[(j+1)&3]->pt), color, 1, CV_AA, 0 ); if (q->neighbors[j]) { int next_j = (j + 1) & 3; @@ -1465,7 +1438,6 @@ int ChessBoardDetector::checkQuadGroup(std::vector& quad_group, goto finalize; cur->row = 0; - //cvCircle( debug_img, cvPointFrom32f(cur->pt), 3, cvScalar(0,255,0), -1, 8, 0 ); first = below; // remember the first corner in the next row @@ -1474,7 +1446,6 @@ int ChessBoardDetector::checkQuadGroup(std::vector& quad_group, { right->row = 0; out_corners.push_back(right); - //cvCircle( debug_img, cvPointFrom32f(right->pt), 3, cvScalar(0,255-j*10,0), -1, 8, 0 ); if( right->count == 2 ) break; if( right->count != 3 || (int)out_corners.size() >= std::max(pattern_size.width,pattern_size.height) ) @@ -1519,7 +1490,6 @@ int ChessBoardDetector::checkQuadGroup(std::vector& quad_group, { cur->row = i; out_corners.push_back(cur); - //cvCircle( debug_img, cvPointFrom32f(cur->pt), 3, cvScalar(0,0,255-j*10), -1, 8, 0 ); if (cur->count == 2 + (i < height-1) && j > 0) break; @@ -1764,7 +1734,6 @@ void ChessBoardDetector::generateQuads(const cv::Mat& image_, int flags) int min_size = 25; //cvRound( image->cols * image->rows * .03 * 0.01 * 0.92 ); bool filterQuads = (flags & CALIB_CB_FILTER_QUADS) != 0; -#ifdef USE_CV_FINDCONTOURS // use cv::findContours std::vector > contours; std::vector hierarchy; @@ -1879,122 +1848,6 @@ void ChessBoardDetector::generateQuads(const cv::Mat& image_, int flags) } } -#else // use legacy API: cvStartFindContours / cvFindNextContour / cvEndFindContours - - CvMat image_old = cvMat(image_), *image = &image_old; - - CvContourEx* board = 0; - - // create temporary storage for contours and the sequence of pointers to found quadrangles - cv::Ptr temp_storage(cvCreateMemStorage(0)); - CvSeq *root = cvCreateSeq(0, sizeof(CvSeq), sizeof(CvSeq*), temp_storage); - - // initialize contour retrieving routine - CvContourScanner scanner = cvStartFindContours(image, temp_storage, sizeof(CvContourEx), - CV_RETR_CCOMP, CV_CHAIN_APPROX_SIMPLE); - - // get all the contours one by one - CvSeq* src_contour = NULL; - while ((src_contour = cvFindNextContour(scanner)) != NULL) - { - CvSeq *dst_contour = 0; - CvRect rect = ((CvContour*)src_contour)->rect; - - // reject contours with too small perimeter - if( CV_IS_SEQ_HOLE(src_contour) && rect.width*rect.height >= min_size ) - { - const int min_approx_level = 1, max_approx_level = MAX_CONTOUR_APPROX; - for (int approx_level = min_approx_level; approx_level <= max_approx_level; approx_level++ ) - { - dst_contour = cvApproxPoly( src_contour, sizeof(CvContour), temp_storage, - CV_POLY_APPROX_DP, (float)approx_level ); - if( dst_contour->total == 4 ) - break; - - // we call this again on its own output, because sometimes - // cvApproxPoly() does not simplify as much as it should. - dst_contour = cvApproxPoly( dst_contour, sizeof(CvContour), temp_storage, - CV_POLY_APPROX_DP, (float)approx_level ); - - if( dst_contour->total == 4 ) - break; - } - - // reject non-quadrangles - if( dst_contour->total == 4 && cvCheckContourConvexity(dst_contour) ) - { - cv::Point2i pt[4]; - double p = cvContourPerimeter(dst_contour); - double area = fabs(cvContourArea(dst_contour, CV_WHOLE_SEQ)); - - for (int i = 0; i < 4; ++i) - pt[i] = *(CvPoint*)cvGetSeqElem(dst_contour, i); - CV_LOG_VERBOSE(NULL, 9, "... contours(" << root->total << " added):" << pt[0] << " " << pt[1] << " " << pt[2] << " " << pt[3]); - - double d1 = sqrt(normL2Sqr(pt[0] - pt[2])); - double d2 = sqrt(normL2Sqr(pt[1] - pt[3])); - - // philipg. Only accept those quadrangles which are more square - // than rectangular and which are big enough - double d3 = sqrt(normL2Sqr(pt[0] - pt[1])); - double d4 = sqrt(normL2Sqr(pt[1] - pt[2])); - if (!filterQuads || - (d3*4 > d4 && d4*4 > d3 && d3*d4 < area*1.5 && area > min_size && - d1 >= 0.15 * p && d2 >= 0.15 * p)) - { - CvContourEx* parent = (CvContourEx*)(src_contour->v_prev); - parent->counter++; - if( !board || board->counter < parent->counter ) - board = parent; - dst_contour->v_prev = (CvSeq*)parent; - //for( i = 0; i < 4; i++ ) cvLine( debug_img, pt[i], pt[(i+1)&3], cvScalar(200,255,255), 1, CV_AA, 0 ); - cvSeqPush( root, &dst_contour ); - } - } - } - } - - // finish contour retrieving - cvEndFindContours( &scanner ); - - // allocate quad & corner buffers - int total = root->total; - size_t max_quad_buf_size = std::max((size_t)2, (size_t)total * 3); - all_quads.allocate(max_quad_buf_size); - all_corners.allocate(max_quad_buf_size * 4); - - // Create array of quads structures - for (int idx = 0; idx < total; ++idx) - { - /* CvSeq* */src_contour = *(CvSeq**)cvGetSeqElem(root, idx); - if (filterQuads && src_contour->v_prev != (CvSeq*)board) - continue; - - int quad_idx = quad_count++; - ChessBoardQuad& q = all_quads[quad_idx]; - - // reset group ID - q = ChessBoardQuad(); - CV_Assert(src_contour->total == 4); - for (int i = 0; i < 4; i++) - { - Point* onePoint = (Point*)cvGetSeqElem(src_contour, i); - CV_Assert(onePoint != NULL); - Point2f pt(*onePoint); - ChessBoardCorner& corner = all_corners[quad_idx*4 + i]; - - corner = ChessBoardCorner(pt); - q.corners[i] = &corner; - } - q.edge_len = FLT_MAX; - for (int i = 0; i < 4; ++i) - { - float d = normL2Sqr(q.corners[i]->pt - q.corners[(i+1)&3]->pt); - q.edge_len = std::min(q.edge_len, d); - } - } -#endif - all_quads_count = quad_count; CV_LOG_VERBOSE(NULL, 3, "Total quad contours: " << total); diff --git a/modules/calib3d/test/test_undistort.cpp b/modules/calib3d/test/test_undistort.cpp index a74971147a..e060b16b4a 100644 --- a/modules/calib3d/test/test_undistort.cpp +++ b/modules/calib3d/test/test_undistort.cpp @@ -998,7 +998,7 @@ TEST(DISABLED_Calib3d_InitInverseRectificationMap, accuracy) { CV_InitInverseRec ////////////////////////////// undistort ///////////////////////////////// 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; @@ -1009,7 +1009,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; @@ -1318,7 +1318,7 @@ void CV_UndistortTest::get_test_array_types_and_sizes( int test_case_idx, vector sizes[INPUT][2] = cvtest::randInt(rng)%2 ? cvSize(4,1) : cvSize(1,4); types[INPUT][3] = types[INPUT][1]; sizes[INPUT][3] = sizes[INPUT][1]; - interpolation = CV_INTER_LINEAR; + interpolation = cv::INTER_LINEAR; } diff --git a/modules/core/include/opencv2/core/cuda.hpp b/modules/core/include/opencv2/core/cuda.hpp index ba4aa290a3..525373cfdf 100644 --- a/modules/core/include/opencv2/core/cuda.hpp +++ b/modules/core/include/opencv2/core/cuda.hpp @@ -609,8 +609,8 @@ Below is an example that utilizes BufferPool with StackAllocator: GpuMat d_src2 = pool2.getBuffer(1024, 1024, CV_8UC1); // 1MB GpuMat d_dst2 = pool2.getBuffer(1024, 1024, CV_8UC3); // 3MB - cvtColor(d_src1, d_dst1, CV_GRAY2BGR, 0, stream1); - cvtColor(d_src2, d_dst2, CV_GRAY2BGR, 0, stream2); + cvtColor(d_src1, d_dst1, cv::COLOR_GRAY2BGR, 0, stream1); + cvtColor(d_src2, d_dst2, cv::COLOR_GRAY2BGR, 0, stream2); } @endcode @@ -675,8 +675,8 @@ and the corresponding memory is automatically returned to the pool for later usa d_src1.setTo(Scalar(i), stream1); d_src2.setTo(Scalar(i), stream2); - cvtColor(d_src1, d_dst1, CV_GRAY2BGR, 0, stream1); - cvtColor(d_src2, d_dst2, CV_GRAY2BGR, 0, stream2); + cvtColor(d_src1, d_dst1, cv::COLOR_GRAY2BGR, 0, stream1); + cvtColor(d_src2, d_dst2, cv::COLOR_GRAY2BGR, 0, stream2); // The order of destruction of the local variables is: // d_dst2 => d_src2 => d_dst1 => d_src1 // LIFO rule is satisfied, this code runs without error diff --git a/modules/gapi/include/opencv2/gapi/core.hpp b/modules/gapi/include/opencv2/gapi/core.hpp index 6351e22114..60bb2c5074 100644 --- a/modules/gapi/include/opencv2/gapi/core.hpp +++ b/modules/gapi/include/opencv2/gapi/core.hpp @@ -1418,7 +1418,7 @@ types. */ GAPI_EXPORTS_W GMat threshold(const GMat& src, const GScalar& thresh, const GScalar& maxval, int type); /** @overload -This function applicable for all threshold types except CV_THRESH_OTSU and CV_THRESH_TRIANGLE +This function applicable for all threshold types except cv::THRESH_OTSU and cv::THRESH_TRIANGLE @note Function textual ID is "org.opencv.core.matrixop.thresholdOT" */ GAPI_EXPORTS_W std::tuple threshold(const GMat& src, const GScalar& maxval, int type); diff --git a/modules/imgproc/doc/pics/polar_remap_doc.svg b/modules/imgproc/doc/pics/polar_remap_doc.svg index 7d7a2f43b1..d6c4951e7e 100644 --- a/modules/imgproc/doc/pics/polar_remap_doc.svg +++ b/modules/imgproc/doc/pics/polar_remap_doc.svg @@ -2351,7 +2351,7 @@ v/yr//0n63/XHTrw/wG8XoGIn8Sc7QAAAABJRU5ErkJggg== x="1408.5438" y="1445.6154" id="tspan10807" - style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.5px;line-height:1.25;font-family:serif;-inkscape-font-specification:'serif Italic'">CV_WARP_FILL_OUTLIERS + style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.5px;line-height:1.25;font-family:serif;-inkscape-font-specification:'serif Italic'">cv::WARP_FILL_OUTLIERS CV_WARP_FILL_OUTLIERS + style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.5px;line-height:1.25;font-family:serif;-inkscape-font-specification:'serif Italic'">cv::WARP_FILL_OUTLIERS CV_WARP_FILL_OUTLIERS + style="font-style:italic;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:17.5px;line-height:1.25;font-family:serif;-inkscape-font-specification:'serif Italic'">cv::WARP_FILL_OUTLIERS > 1; else delta1 = XY_ONE - 1, delta2 = 0; @@ -1181,7 +1181,7 @@ FillConvexPoly( Mat& img, const Point2l* v, int npts, const void* color, int lin do { - if( line_type < CV_AA || y < (int)ymax || y == (int)ymin ) + if( line_type < cv::LINE_AA || y < (int)ymax || y == (int)ymin ) { for( i = 0; i < 2; i++ ) { @@ -1277,7 +1277,7 @@ CollectPolyEdges( Mat& img, const Point2l* v, int count, std::vector& pt1.x = (pt1.x + offset.x) << (XY_SHIFT - shift); pt1.y = (pt1.y + delta) >> shift; - if( line_type < CV_AA ) + if( line_type < cv::LINE_AA ) { t0.y = pt0.y; t1.y = pt1.y; t0.x = (pt0.x + (XY_ONE >> 1)) >> XY_SHIFT; @@ -1632,7 +1632,7 @@ ThickLine( Mat& img, Point2l p0, Point2l p1, const void* color, if( thickness <= 1 ) { - if( line_type < CV_AA ) + if( line_type < cv::LINE_AA ) { if( line_type == 1 || line_type == 4 || shift == 0 ) { @@ -1678,7 +1678,7 @@ ThickLine( Mat& img, Point2l p0, Point2l p1, const void* color, { if( flags & (i+1) ) { - if( line_type < CV_AA ) + if( line_type < cv::LINE_AA ) { Point center; center.x = (int)((p0.x + (XY_ONE>>1)) >> XY_SHIFT); @@ -1796,7 +1796,7 @@ void line( InputOutputArray _img, Point pt1, Point pt2, const Scalar& color, Mat img = _img.getMat(); - if( line_type == CV_AA && img.depth() != CV_8U ) + if( line_type == cv::LINE_AA && img.depth() != CV_8U ) line_type = 8; CV_Assert( 0 < thickness && thickness <= MAX_THICKNESS ); @@ -1835,7 +1835,7 @@ void rectangle( InputOutputArray _img, Point pt1, Point pt2, Mat img = _img.getMat(); - if( lineType == CV_AA && img.depth() != CV_8U ) + if( lineType == cv::LINE_AA && img.depth() != CV_8U ) lineType = 8; CV_Assert( thickness <= MAX_THICKNESS ); @@ -1885,7 +1885,7 @@ void circle( InputOutputArray _img, Point center, int radius, Mat img = _img.getMat(); - if( line_type == CV_AA && img.depth() != CV_8U ) + if( line_type == cv::LINE_AA && img.depth() != CV_8U ) line_type = 8; CV_Assert( radius >= 0 && thickness <= MAX_THICKNESS && @@ -1917,7 +1917,7 @@ void ellipse( InputOutputArray _img, Point center, Size axes, Mat img = _img.getMat(); - if( line_type == CV_AA && img.depth() != CV_8U ) + if( line_type == cv::LINE_AA && img.depth() != CV_8U ) line_type = 8; CV_Assert( axes.width >= 0 && axes.height >= 0 && @@ -1947,7 +1947,7 @@ void ellipse(InputOutputArray _img, const RotatedRect& box, const Scalar& color, Mat img = _img.getMat(); - if( lineType == CV_AA && img.depth() != CV_8U ) + if( lineType == cv::LINE_AA && img.depth() != CV_8U ) lineType = 8; CV_Assert( box.size.width >= 0 && box.size.height >= 0 && @@ -1978,7 +1978,7 @@ void fillConvexPoly( InputOutputArray _img, const Point* pts, int npts, if( !pts || npts <= 0 ) return; - if( line_type == CV_AA && img.depth() != CV_8U ) + if( line_type == cv::LINE_AA && img.depth() != CV_8U ) line_type = 8; double buf[4]; @@ -1996,7 +1996,7 @@ void fillPoly( InputOutputArray _img, const Point** pts, const int* npts, int nc Mat img = _img.getMat(); - if( line_type == CV_AA && img.depth() != CV_8U ) + if( line_type == cv::LINE_AA && img.depth() != CV_8U ) line_type = 8; CV_Assert( pts && npts && ncontours >= 0 && 0 <= shift && shift <= XY_SHIFT ); @@ -2027,7 +2027,7 @@ void polylines( InputOutputArray _img, const Point* const* pts, const int* npts, Mat img = _img.getMat(); - if( line_type == CV_AA && img.depth() != CV_8U ) + if( line_type == cv::LINE_AA && img.depth() != CV_8U ) line_type = 8; CV_Assert( pts && npts && ncontours >= 0 && @@ -2572,7 +2572,7 @@ cvDrawContours( void* _img, CvSeq* contour, cv::Point offset = _offset; double ext_buf[4], hole_buf[4]; - if( line_type == CV_AA && img.depth() != CV_8U ) + if( line_type == cv::LINE_AA && img.depth() != CV_8U ) line_type = 8; if( !contour ) diff --git a/modules/imgproc/src/linefit.cpp b/modules/imgproc/src/linefit.cpp index 97e0d2961a..cd205c60ab 100644 --- a/modules/imgproc/src/linefit.cpp +++ b/modules/imgproc/src/linefit.cpp @@ -331,26 +331,26 @@ static void fitLine2D( const Point2f * points, int count, int dist, switch (dist) { - case CV_DIST_L2: + case cv::DIST_L2: return fitLine2D_wods( points, count, 0, line ); - case CV_DIST_L1: + case cv::DIST_L1: calc_weights = weightL1; break; - case CV_DIST_L12: + case cv::DIST_L12: calc_weights = weightL12; break; - case CV_DIST_FAIR: + case cv::DIST_FAIR: calc_weights_param = weightFair; break; - case CV_DIST_WELSCH: + case cv::DIST_WELSCH: calc_weights_param = weightWelsch; break; - case CV_DIST_HUBER: + case cv::DIST_HUBER: calc_weights_param = weightHuber; break; @@ -475,26 +475,26 @@ static void fitLine3D( Point3f * points, int count, int dist, switch (dist) { - case CV_DIST_L2: + case cv::DIST_L2: return fitLine3D_wods( points, count, 0, line ); - case CV_DIST_L1: + case cv::DIST_L1: calc_weights = weightL1; break; - case CV_DIST_L12: + case cv::DIST_L12: calc_weights = weightL12; break; - case CV_DIST_FAIR: + case cv::DIST_FAIR: calc_weights_param = weightFair; break; - case CV_DIST_WELSCH: + case cv::DIST_WELSCH: calc_weights_param = weightWelsch; break; - case CV_DIST_HUBER: + case cv::DIST_HUBER: calc_weights_param = weightHuber; break; diff --git a/modules/imgproc/src/segmentation.cpp b/modules/imgproc/src/segmentation.cpp index 79cb641e80..f4145c6cfa 100644 --- a/modules/imgproc/src/segmentation.cpp +++ b/modules/imgproc/src/segmentation.cpp @@ -394,7 +394,6 @@ void cv::pyrMeanShiftFiltering( InputArray _src, OutputArray _dst, dst_pyramid[level].create( src_pyramid[level].rows, src_pyramid[level].cols, src_pyramid[level].type() ); cv::pyrDown( src_pyramid[level-1], src_pyramid[level], src_pyramid[level].size() ); - //CV_CALL( cvResize( src_pyramid[level-1], src_pyramid[level], CV_INTER_AREA )); } mask0.create(src0.rows, src0.cols, CV_8UC1); @@ -419,7 +418,6 @@ void cv::pyrMeanShiftFiltering( InputArray _src, OutputArray _dst, m = cv::Mat(size.height, size.width, CV_8UC1, mask0.ptr()); dstep = (int)dst_pyramid[level+1].step; dptr = dst_pyramid[level+1].ptr() + dstep + cn; - //cvResize( dst_pyramid[level+1], dst_pyramid[level], CV_INTER_CUBIC ); cv::pyrUp( dst_pyramid[level+1], dst_pyramid[level], dst_pyramid[level].size() ); m.setTo(cv::Scalar::all(0)); diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index e869f8d4a4..6b192d775f 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -315,7 +315,7 @@ static bool matchTemplate_CCORR(InputArray _image, InputArray _templ, OutputArra static bool matchTemplate_CCORR_NORMED(InputArray _image, InputArray _templ, OutputArray _result) { - matchTemplate(_image, _templ, _result, CV_TM_CCORR); + matchTemplate(_image, _templ, _result, cv::TM_CCORR); int type = _image.type(), cn = CV_MAT_CN(type); @@ -373,7 +373,7 @@ static bool matchTemplate_SQDIFF(InputArray _image, InputArray _templ, OutputArr return( matchTemplateNaive_SQDIFF(_image, _templ, _result)); else { - matchTemplate(_image, _templ, _result, CV_TM_CCORR); + matchTemplate(_image, _templ, _result, cv::TM_CCORR); int type = _image.type(), cn = CV_MAT_CN(type); @@ -404,7 +404,7 @@ static bool matchTemplate_SQDIFF(InputArray _image, InputArray _templ, OutputArr static bool matchTemplate_SQDIFF_NORMED(InputArray _image, InputArray _templ, OutputArray _result) { - matchTemplate(_image, _templ, _result, CV_TM_CCORR); + matchTemplate(_image, _templ, _result, cv::TM_CCORR); int type = _image.type(), cn = CV_MAT_CN(type); @@ -436,7 +436,7 @@ static bool matchTemplate_SQDIFF_NORMED(InputArray _image, InputArray _templ, Ou static bool matchTemplate_CCOEFF(InputArray _image, InputArray _templ, OutputArray _result) { - matchTemplate(_image, _templ, _result, CV_TM_CCORR); + matchTemplate(_image, _templ, _result, cv::TM_CCORR); UMat image_sums, temp; integral(_image, image_sums, CV_32F); @@ -471,7 +471,7 @@ static bool matchTemplate_CCOEFF(InputArray _image, InputArray _templ, OutputArr static bool matchTemplate_CCOEFF_NORMED(InputArray _image, InputArray _templ, OutputArray _result) { - matchTemplate(_image, _templ, _result, CV_TM_CCORR); + matchTemplate(_image, _templ, _result, cv::TM_CCORR); UMat temp, image_sums, image_sqsums; integral(_image, image_sums, image_sqsums, CV_32F, CV_32F); @@ -796,7 +796,7 @@ static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _ merge(maskChannels.data(), templ.channels(), mask); } - if (method == CV_TM_SQDIFF || method == CV_TM_SQDIFF_NORMED) + if (method == cv::TM_SQDIFF || method == cv::TM_SQDIFF_NORMED) { Mat temp_result(corrSize, CV_32F); Mat img2 = img.mul(img); @@ -810,19 +810,19 @@ static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _ // for normalization. result = -2 * result + temp_result + templ2_mask2_sum; - if (method == CV_TM_SQDIFF_NORMED) + if (method == cv::TM_SQDIFF_NORMED) { sqrt(templ2_mask2_sum * temp_result, temp_result); result /= temp_result; } } - else if (method == CV_TM_CCORR || method == CV_TM_CCORR_NORMED) + else if (method == cv::TM_CCORR || method == cv::TM_CCORR_NORMED) { // If the mul() is ever unnested, declare MatExpr, *not* Mat, to be more efficient. Mat templ_mask2 = templ.mul(mask.mul(mask)); crossCorr(img, templ_mask2, result, Point(0,0), 0, 0); - if (method == CV_TM_CCORR_NORMED) + if (method == cv::TM_CCORR_NORMED) { Mat temp_result(corrSize, CV_32F); Mat img2 = img.mul(img); @@ -834,7 +834,7 @@ static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _ result /= temp_result; } } - else if (method == CV_TM_CCOEFF || method == CV_TM_CCOEFF_NORMED) + else if (method == cv::TM_CCOEFF || method == cv::TM_CCOEFF_NORMED) { // Do mul() inline or declare MatExpr where possible, *not* Mat, to be more efficient. @@ -864,7 +864,7 @@ static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _ // transform back, but now with only one channel result -= temp_res.reshape(1, result.rows); } - if (method == CV_TM_CCOEFF_NORMED) + if (method == cv::TM_CCOEFF_NORMED) { // norm(T') double norm_templx = norm(mask.mul(templ - sum(mask.mul(templ)).div(mask_sum)), @@ -905,14 +905,14 @@ static void matchTemplateMask( InputArray _img, InputArray _templ, OutputArray _ static void common_matchTemplate( Mat& img, Mat& templ, Mat& result, int method, int cn ) { - if( method == CV_TM_CCORR ) + if( method == cv::TM_CCORR ) return; - int numType = method == CV_TM_CCORR || method == CV_TM_CCORR_NORMED ? 0 : - method == CV_TM_CCOEFF || method == CV_TM_CCOEFF_NORMED ? 1 : 2; - bool isNormed = method == CV_TM_CCORR_NORMED || - method == CV_TM_SQDIFF_NORMED || - method == CV_TM_CCOEFF_NORMED; + int numType = method == cv::TM_CCORR || method == cv::TM_CCORR_NORMED ? 0 : + method == cv::TM_CCOEFF || method == cv::TM_CCOEFF_NORMED ? 1 : 2; + bool isNormed = method == cv::TM_CCORR_NORMED || + method == cv::TM_SQDIFF_NORMED || + method == cv::TM_CCOEFF_NORMED; double invArea = 1./((double)templ.rows * templ.cols); @@ -921,7 +921,7 @@ static void common_matchTemplate( Mat& img, Mat& templ, Mat& result, int method, double *q0 = 0, *q1 = 0, *q2 = 0, *q3 = 0; double templNorm = 0, templSum2 = 0; - if( method == CV_TM_CCOEFF ) + if( method == cv::TM_CCOEFF ) { integral(img, sum, CV_64F); templMean = mean(templ); @@ -933,7 +933,7 @@ static void common_matchTemplate( Mat& img, Mat& templ, Mat& result, int method, templNorm = templSdv[0]*templSdv[0] + templSdv[1]*templSdv[1] + templSdv[2]*templSdv[2] + templSdv[3]*templSdv[3]; - if( templNorm < DBL_EPSILON && method == CV_TM_CCOEFF_NORMED ) + if( templNorm < DBL_EPSILON && method == cv::TM_CCOEFF_NORMED ) { result = Scalar::all(1); return; @@ -1020,7 +1020,7 @@ static void common_matchTemplate( Mat& img, Mat& templ, Mat& result, int method, else if( fabs(num) < t*1.125 ) num = num > 0 ? 1 : -1; else - num = method != CV_TM_SQDIFF_NORMED ? 0 : 1; + num = method != cv::TM_SQDIFF_NORMED ? 0 : 1; } rrow[j] = (float)num; @@ -1116,30 +1116,30 @@ static bool ipp_matchTemplate( Mat& img, Mat& templ, Mat& result, int method) if(templ.size().area()*4 > img.size().area()) return false; - if(method == CV_TM_SQDIFF) + if(method == cv::TM_SQDIFF) { if(ipp_sqrDistance(img, templ, result)) return true; } - else if(method == CV_TM_SQDIFF_NORMED) + else if(method == cv::TM_SQDIFF_NORMED) { if(ipp_crossCorr(img, templ, result, false)) { - common_matchTemplate(img, templ, result, CV_TM_SQDIFF_NORMED, 1); + common_matchTemplate(img, templ, result, cv::TM_SQDIFF_NORMED, 1); return true; } } - else if(method == CV_TM_CCORR) + else if(method == cv::TM_CCORR) { if(ipp_crossCorr(img, templ, result, false)) return true; } - else if(method == CV_TM_CCORR_NORMED) + else if(method == cv::TM_CCORR_NORMED) { if(ipp_crossCorr(img, templ, result, true)) return true; } - else if(method == CV_TM_CCOEFF || method == CV_TM_CCOEFF_NORMED) + else if(method == cv::TM_CCOEFF || method == cv::TM_CCOEFF_NORMED) { if(ipp_crossCorr(img, templ, result, false)) { @@ -1160,7 +1160,7 @@ void cv::matchTemplate( InputArray _img, InputArray _templ, OutputArray _result, CV_INSTRUMENT_REGION(); int type = _img.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); - CV_Assert( CV_TM_SQDIFF <= method && method <= CV_TM_CCOEFF_NORMED ); + CV_Assert( cv::TM_SQDIFF <= method && method <= cv::TM_CCOEFF_NORMED ); CV_Assert( (depth == CV_8U || depth == CV_32F) && type == _templ.type() && _img.dims() <= 2 ); if (!_mask.empty()) diff --git a/modules/imgproc/test/ocl/test_match_template.cpp b/modules/imgproc/test/ocl/test_match_template.cpp index 3d979e00de..f041e51a6d 100644 --- a/modules/imgproc/test/ocl/test_match_template.cpp +++ b/modules/imgproc/test/ocl/test_match_template.cpp @@ -51,7 +51,7 @@ namespace ocl { ///////////////////////////////////////////// matchTemplate ////////////////////////////////////////////////////////// -CV_ENUM(MatchTemplType, CV_TM_CCORR, CV_TM_CCORR_NORMED, CV_TM_SQDIFF, CV_TM_SQDIFF_NORMED, CV_TM_CCOEFF, CV_TM_CCOEFF_NORMED) +CV_ENUM(MatchTemplType, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED) PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, MatchTemplType, bool) { diff --git a/modules/imgproc/test/test_canny.cpp b/modules/imgproc/test/test_canny.cpp index e040da61ad..7e4fffbf30 100644 --- a/modules/imgproc/test/test_canny.cpp +++ b/modules/imgproc/test/test_canny.cpp @@ -160,7 +160,7 @@ void CV_CannyTest::run_func() { cv::Mat _out = cv::cvarrToMat(test_array[OUTPUT][0]); cv::Canny(cv::cvarrToMat(test_array[INPUT][0]), _out, threshold1, threshold2, - aperture_size + (use_true_gradient ? CV_CANNY_L2_GRADIENT : 0)); + aperture_size, use_true_gradient); } } diff --git a/modules/imgproc/test/test_drawing.cpp b/modules/imgproc/test/test_drawing.cpp index 1d19565288..bb4c32b75b 100644 --- a/modules/imgproc/test/test_drawing.cpp +++ b/modules/imgproc/test/test_drawing.cpp @@ -128,7 +128,7 @@ void CV_DrawingTest_CPP::draw( Mat& img ) p2 = Point(3,imgSize.height+1000); if( clipLine(Rect(0,0,imgSize.width,imgSize.height), p1, p2) && clipLine(imgSize, p1, p2) ) - circle( img, Point(500,300), 50, cvColorToScalar(255,CV_8UC3), 5, 8, 1 ); // draw + circle( img, Point(500,300), 50, Scalar(255, 0, 0), 5, 8, 1 ); // draw p1 = Point(imgSize.width,1), p2 = Point(imgSize.width,3); if( clipLine(Rect(0,0,imgSize.width,imgSize.height), p1, p2) && clipLine(imgSize, p1, p2) ) @@ -144,7 +144,7 @@ void CV_DrawingTest_CPP::draw( Mat& img ) ellipse2Poly( Point(430,180), Size(100,150), 30, 0, 150, 20, polyline ); pts = &polyline[0]; n = (int)polyline.size(); - polylines( img, &pts, &n, 1, false, Scalar(0,0,150), 4, CV_AA ); + polylines( img, &pts, &n, 1, false, Scalar(0,0,150), 4, cv::LINE_AA ); n = 0; for( vector::const_iterator it = polyline.begin(); n < (int)polyline.size()-1; ++it, n++ ) { @@ -192,43 +192,43 @@ void CV_DrawingTest_CPP::draw( Mat& img ) textSize = getTextSize( text2, FONT_HERSHEY_SIMPLEX, fontScale, thickness, &baseline); textOrg = Point(5,5)+Point(0,textSize.height+dist); - putText(img, text2, textOrg, FONT_HERSHEY_SIMPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_SIMPLEX, fontScale, color, thickness, cv::LINE_AA); fontScale = 1; textSize = getTextSize( text2, FONT_HERSHEY_PLAIN, fontScale, thickness, &baseline); textOrg += Point(0,textSize.height+dist); - putText(img, text2, textOrg, FONT_HERSHEY_PLAIN, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_PLAIN, fontScale, color, thickness, cv::LINE_AA); fontScale = 0.5; textSize = getTextSize( text2, FONT_HERSHEY_DUPLEX, fontScale, thickness, &baseline); textOrg += Point(0,textSize.height+dist); - putText(img, text2, textOrg, FONT_HERSHEY_DUPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_DUPLEX, fontScale, color, thickness, cv::LINE_AA); textSize = getTextSize( text2, FONT_HERSHEY_COMPLEX, fontScale, thickness, &baseline); textOrg += Point(0,textSize.height+dist); - putText(img, text2, textOrg, FONT_HERSHEY_COMPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_COMPLEX, fontScale, color, thickness, cv::LINE_AA); textSize = getTextSize( text2, FONT_HERSHEY_TRIPLEX, fontScale, thickness, &baseline); textOrg += Point(0,textSize.height+dist); - putText(img, text2, textOrg, FONT_HERSHEY_TRIPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_TRIPLEX, fontScale, color, thickness, cv::LINE_AA); fontScale = 1; textSize = getTextSize( text2, FONT_HERSHEY_COMPLEX_SMALL, fontScale, thickness, &baseline); textOrg += Point(0,180) + Point(0,textSize.height+dist); - putText(img, text2, textOrg, FONT_HERSHEY_COMPLEX_SMALL, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_COMPLEX_SMALL, fontScale, color, thickness, cv::LINE_AA); textSize = getTextSize( text2, FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, &baseline); textOrg += Point(0,textSize.height+dist); - putText(img, text2, textOrg, FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, color, thickness, cv::LINE_AA); textSize = getTextSize( text2, FONT_HERSHEY_SCRIPT_COMPLEX, fontScale, thickness, &baseline); textOrg += Point(0,textSize.height+dist); - putText(img, text2, textOrg, FONT_HERSHEY_SCRIPT_COMPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_SCRIPT_COMPLEX, fontScale, color, thickness, cv::LINE_AA); dist = 15, fontScale = 0.5; textSize = getTextSize( text2, FONT_ITALIC, fontScale, thickness, &baseline); textOrg += Point(0,textSize.height+dist); - putText(img, text2, textOrg, FONT_ITALIC, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_ITALIC, fontScale, color, thickness, cv::LINE_AA); } int CV_DrawingTest_CPP::checkLineIterator( Mat& img ) @@ -321,7 +321,7 @@ void CV_DrawingTest_Far::draw(Mat& img) p2 = Point(32768 + 3, imgSize.height + 1000); if (clipLine(Rect(32768 + 0, 0, imgSize.width, imgSize.height), p1, p2) && clipLine(imgSize, p1, p2)) - circle(img, Point(65536 + 500, 300), 50, cvColorToScalar(255, CV_8UC3), 5, 8, 1); // draw + circle(img, Point(65536 + 500, 300), 50, Scalar(255, 0, 0), 5, 8, 1); // draw p1 = Point(imgSize.width, 1), p2 = Point(imgSize.width, 3); if (clipLine(Rect(32768 + 0, 0, imgSize.width, imgSize.height), p1, p2) && clipLine(imgSize, p1, p2)) @@ -337,7 +337,7 @@ void CV_DrawingTest_Far::draw(Mat& img) ellipse2Poly(Point(32768 + 430, 180), Size(100, 150), 30, 0, 150, 20, polyline); pts = &polyline[0]; n = (int)polyline.size(); - polylines(img, &pts, &n, 1, false, Scalar(0, 0, 150), 4, CV_AA); + polylines(img, &pts, &n, 1, false, Scalar(0, 0, 150), 4, cv::LINE_AA); n = 0; for (vector::const_iterator it = polyline.begin(); n < (int)polyline.size() - 1; ++it, n++) { @@ -385,43 +385,43 @@ void CV_DrawingTest_Far::draw(Mat& img) textSize = getTextSize(text2, FONT_HERSHEY_SIMPLEX, fontScale, thickness, &baseline); textOrg = Point(32768 + 5, 5) + Point(0, textSize.height + dist); - putText(img, text2, textOrg, FONT_HERSHEY_SIMPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_SIMPLEX, fontScale, color, thickness, cv::LINE_AA); fontScale = 1; textSize = getTextSize(text2, FONT_HERSHEY_PLAIN, fontScale, thickness, &baseline); textOrg += Point(0, textSize.height + dist); - putText(img, text2, textOrg, FONT_HERSHEY_PLAIN, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_PLAIN, fontScale, color, thickness, cv::LINE_AA); fontScale = 0.5; textSize = getTextSize(text2, FONT_HERSHEY_DUPLEX, fontScale, thickness, &baseline); textOrg += Point(0, textSize.height + dist); - putText(img, text2, textOrg, FONT_HERSHEY_DUPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_DUPLEX, fontScale, color, thickness, cv::LINE_AA); textSize = getTextSize(text2, FONT_HERSHEY_COMPLEX, fontScale, thickness, &baseline); textOrg += Point(0, textSize.height + dist); - putText(img, text2, textOrg, FONT_HERSHEY_COMPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_COMPLEX, fontScale, color, thickness, cv::LINE_AA); textSize = getTextSize(text2, FONT_HERSHEY_TRIPLEX, fontScale, thickness, &baseline); textOrg += Point(0, textSize.height + dist); - putText(img, text2, textOrg, FONT_HERSHEY_TRIPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_TRIPLEX, fontScale, color, thickness, cv::LINE_AA); fontScale = 1; textSize = getTextSize(text2, FONT_HERSHEY_COMPLEX_SMALL, fontScale, thickness, &baseline); textOrg += Point(0, 180) + Point(0, textSize.height + dist); - putText(img, text2, textOrg, FONT_HERSHEY_COMPLEX_SMALL, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_COMPLEX_SMALL, fontScale, color, thickness, cv::LINE_AA); textSize = getTextSize(text2, FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, &baseline); textOrg += Point(0, textSize.height + dist); - putText(img, text2, textOrg, FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, color, thickness, cv::LINE_AA); textSize = getTextSize(text2, FONT_HERSHEY_SCRIPT_COMPLEX, fontScale, thickness, &baseline); textOrg += Point(0, textSize.height + dist); - putText(img, text2, textOrg, FONT_HERSHEY_SCRIPT_COMPLEX, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_HERSHEY_SCRIPT_COMPLEX, fontScale, color, thickness, cv::LINE_AA); dist = 15, fontScale = 0.5; textSize = getTextSize(text2, FONT_ITALIC, fontScale, thickness, &baseline); textOrg += Point(0, textSize.height + dist); - putText(img, text2, textOrg, FONT_ITALIC, fontScale, color, thickness, CV_AA); + putText(img, text2, textOrg, FONT_ITALIC, fontScale, color, thickness, cv::LINE_AA); img = img(Rect(32768, 0, 600, 400)).clone(); } @@ -517,7 +517,7 @@ protected: Size textSize = getTextSize(*line, *font | italic, fontScale, thickness, &baseline); Point textOrg(0, textSize.height + 2); Mat img(textSize + Size(0, baseline), CV_8UC3, Scalar(255, 255, 255)); - putText(img, *line, textOrg, *font | italic, fontScale, color, thickness, CV_AA); + putText(img, *line, textOrg, *font | italic, fontScale, color, thickness, cv::LINE_AA); results.push_back(img); bigSize.width = max(bigSize.width, img.size().width); diff --git a/modules/imgproc/test/test_houghcircles.cpp b/modules/imgproc/test/test_houghcircles.cpp index 094963211c..74608112a7 100644 --- a/modules/imgproc/test/test_houghcircles.cpp +++ b/modules/imgproc/test/test_houghcircles.cpp @@ -123,7 +123,7 @@ public: vector circles; const double dp = 1.0; - HoughCircles(src, circles, CV_HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius); + HoughCircles(src, circles, cv::HOUGH_GRADIENT, dp, minDist, edgeThreshold, accumThreshold, minRadius, maxRadius); string imgProc = string(cvtest::TS::ptr()->get_data_path()) + "imgproc/"; #if DEBUG_IMAGES diff --git a/modules/imgproc/test/test_imgwarp_strict.cpp b/modules/imgproc/test/test_imgwarp_strict.cpp index eea5e447e9..da8a197b3f 100644 --- a/modules/imgproc/test/test_imgwarp_strict.cpp +++ b/modules/imgproc/test/test_imgwarp_strict.cpp @@ -163,7 +163,7 @@ void CV_ImageWarpBaseTest::generate_test_data() for (y = 0; y < ssize.height; y += cell_size) for (x = 0; x < ssize.width; x += cell_size) rectangle(src, Point(x, y), Point(x + std::min(cell_size, ssize.width - x), y + - std::min(cell_size, ssize.height - y)), Scalar::all((x + y) % 2 ? 255: 0), CV_FILLED); + std::min(cell_size, ssize.height - y)), Scalar::all((x + y) % 2 ? 255: 0), cv::FILLED); } else { @@ -175,7 +175,7 @@ void CV_ImageWarpBaseTest::generate_test_data() } // generating an interpolation type - interpolation = rng.uniform(0, CV_INTER_LANCZOS4 + 1); + interpolation = rng.uniform(0, cv::INTER_LANCZOS4 + 1); // generating the dst matrix structure double scale_x, scale_y; @@ -288,10 +288,10 @@ void CV_ImageWarpBaseTest::validate_results() const #ifdef SHOW_IMAGE const std::string w1("OpenCV impl (run func)"), w2("Reference func"), w3("Src image"), w4("Diff"); - namedWindow(w1, CV_WINDOW_KEEPRATIO); - namedWindow(w2, CV_WINDOW_KEEPRATIO); - namedWindow(w3, CV_WINDOW_KEEPRATIO); - namedWindow(w4, CV_WINDOW_KEEPRATIO); + namedWindow(w1, cv::WINDOW_KEEPRATIO); + namedWindow(w2, cv::WINDOW_KEEPRATIO); + namedWindow(w3, cv::WINDOW_KEEPRATIO); + namedWindow(w4, cv::WINDOW_KEEPRATIO); Mat diff; absdiff(reference_dst, _dst, diff); @@ -442,7 +442,7 @@ void CV_Resize_Test::generate_test_data() for (y = 0; y < ssize.height; y += cell_size) for (x = 0; x < ssize.width; x += cell_size) rectangle(src, Point(x, y), Point(x + std::min(cell_size, ssize.width - x), y + - std::min(cell_size, ssize.height - y)), Scalar::all((x + y) % 2 ? 255: 0), CV_FILLED); + std::min(cell_size, ssize.height - y)), Scalar::all((x + y) % 2 ? 255: 0), cv::FILLED); } else { @@ -1082,7 +1082,7 @@ void CV_WarpAffine_Test::generate_test_data() // warp_matrix is inverse if (rng.uniform(0., 1.) > 0) - interpolation |= CV_WARP_INVERSE_MAP; + interpolation |= cv::WARP_INVERSE_MAP; } void CV_WarpAffine_Test::run_func() @@ -1123,7 +1123,7 @@ void CV_WarpAffine_Test::warpAffine(const Mat& _src, Mat& _dst) else mapy = Mat(); - if (!(interpolation & CV_WARP_INVERSE_MAP)) + if (!(interpolation & cv::WARP_INVERSE_MAP)) invertAffineTransform(tM.clone(), tM); const int AB_BITS = MAX(10, (int)INTER_BITS); @@ -1239,7 +1239,7 @@ void CV_WarpPerspective_Test::warpPerspective(const Mat& _src, Mat& _dst) M = tmp; } - if (!(interpolation & CV_WARP_INVERSE_MAP)) + if (!(interpolation & cv::WARP_INVERSE_MAP)) { Mat tmp; invert(M, tmp); diff --git a/modules/imgproc/test/test_pc.cpp b/modules/imgproc/test/test_pc.cpp index edfe0701e5..7b06e3bd65 100644 --- a/modules/imgproc/test/test_pc.cpp +++ b/modules/imgproc/test/test_pc.cpp @@ -66,8 +66,8 @@ void CV_PhaseCorrelatorTest::run( int ) double expectedShiftY = -20.0; // draw 10x10 rectangles @ (100, 100) and (90, 80) should see ~(-10, -20) shift here... - cv::rectangle(r1, Point(100, 100), Point(110, 110), Scalar(0, 0, 0), CV_FILLED); - cv::rectangle(r2, Point(90, 80), Point(100, 90), Scalar(0, 0, 0), CV_FILLED); + cv::rectangle(r1, Point(100, 100), Point(110, 110), Scalar(0, 0, 0), cv::FILLED); + cv::rectangle(r2, Point(90, 80), Point(100, 90), Scalar(0, 0, 0), cv::FILLED); Mat hann; createHanningWindow(hann, r1.size(), CV_64F); diff --git a/modules/imgproc/test/test_templmatch.cpp b/modules/imgproc/test/test_templmatch.cpp index 0c5ade20f2..760052aeb4 100644 --- a/modules/imgproc/test/test_templmatch.cpp +++ b/modules/imgproc/test/test_templmatch.cpp @@ -125,7 +125,7 @@ void CV_TemplMatchTest::get_test_array_types_and_sizes( int test_case_idx, double CV_TemplMatchTest::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ ) { if( test_mat[INPUT][1].depth() == CV_8U || - (method >= CV_TM_CCOEFF && test_mat[INPUT][1].cols*test_mat[INPUT][1].rows <= 2) ) + (method >= cv::TM_CCOEFF && test_mat[INPUT][1].cols*test_mat[INPUT][1].rows <= 2) ) return 1e-2; else return 1e-3; @@ -162,7 +162,7 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu if( b_sdv.val[0]*b_sdv.val[0] + b_sdv.val[1]*b_sdv.val[1] + b_sdv.val[2]*b_sdv.val[2] + b_sdv.val[3]*b_sdv.val[3] < DBL_EPSILON && - method == CV_TM_CCOEFF_NORMED ) + method == cv::TM_CCOEFF_NORMED ) { cvSet( result, cvScalarAll(1.) ); return; @@ -171,7 +171,7 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu if( method & 1 ) { b_denom = 0; - if( method != CV_TM_CCOEFF_NORMED ) + if( method != cv::TM_CCOEFF_NORMED ) { b_denom = b_sum2; } @@ -185,7 +185,7 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu b_denom = 1.; } - CV_Assert( CV_TM_SQDIFF <= method && method <= CV_TM_CCOEFF_NORMED ); + CV_Assert( cv::TM_SQDIFF <= method && method <= cv::TM_CCOEFF_NORMED ); for( i = 0; i < result->rows; i++ ) { @@ -200,7 +200,7 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu const uchar* a = img->data.ptr + i*img->step + j*cn; const uchar* b = templ->data.ptr; - if( cn == 1 || method < CV_TM_CCOEFF ) + if( cn == 1 || method < cv::TM_CCOEFF ) { for( k = 0; k < height; k++, a += a_step, b += b_step ) for( l = 0; l < width_n; l++ ) @@ -232,7 +232,7 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu const float* a = (const float*)(img->data.ptr + i*img->step) + j*cn; const float* b = (const float*)templ->data.ptr; - if( cn == 1 || method < CV_TM_CCOEFF ) + if( cn == 1 || method < cv::TM_CCOEFF ) { for( k = 0; k < height; k++, a += a_step, b += b_step ) for( l = 0; l < width_n; l++ ) @@ -262,12 +262,12 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu switch( method ) { - case CV_TM_CCORR: - case CV_TM_CCORR_NORMED: + case cv::TM_CCORR: + case cv::TM_CCORR_NORMED: value = ccorr.val[0]; break; - case CV_TM_SQDIFF: - case CV_TM_SQDIFF_NORMED: + case cv::TM_SQDIFF: + case cv::TM_SQDIFF_NORMED: value = (a_sum2.val[0] + b_sum2 - 2*ccorr.val[0]); break; default: @@ -281,7 +281,7 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu double denom; // calc denominator - if( method != CV_TM_CCOEFF_NORMED ) + if( method != cv::TM_CCOEFF_NORMED ) { denom = a_sum2.val[0] + a_sum2.val[1] + a_sum2.val[2]; } @@ -297,7 +297,7 @@ static void cvTsMatchTemplate( const CvMat* img, const CvMat* templ, CvMat* resu else if( fabs(value) < denom*1.125 ) value = value > 0 ? 1 : -1; else - value = method != CV_TM_SQDIFF_NORMED ? 0 : 1; + value = method != cv::TM_SQDIFF_NORMED ? 0 : 1; } ((float*)(result->data.ptr + result->step*i))[j] = (float)value; @@ -323,7 +323,7 @@ void CV_TemplMatchTest::prepare_to_validation( int /*test_case_idx*/ ) cvReleaseFileStorage( &fs ); }*/ - if( method >= CV_TM_CCOEFF ) + if( method >= cv::TM_CCOEFF ) { // avoid numerical stability problems in singular cases (when the results are near to 0) const double delta = 10.; @@ -420,7 +420,7 @@ TEST(Imgproc_MatchTemplate, bug_9597) { cv::Mat cvimg(cv::Size(61, 82), CV_8UC1, (void*)img, cv::Mat::AUTO_STEP); cv::Mat cvtmpl(cv::Size(17, 17), CV_8UC1, (void*)tmpl, cv::Mat::AUTO_STEP); cv::Mat result; - cv::matchTemplate(cvimg, cvtmpl, result, CV_TM_SQDIFF); + cv::matchTemplate(cvimg, cvtmpl, result, cv::TM_SQDIFF); double minValue; cv::minMaxLoc(result, &minValue, NULL, NULL, NULL); ASSERT_GE(minValue, 0); diff --git a/modules/imgproc/test/test_templmatchmask.cpp b/modules/imgproc/test/test_templmatchmask.cpp index cca110ae22..3c8ab665ae 100644 --- a/modules/imgproc/test/test_templmatchmask.cpp +++ b/modules/imgproc/test/test_templmatchmask.cpp @@ -6,9 +6,9 @@ namespace opencv_test { namespace { -CV_ENUM(MatchTemplType, CV_TM_CCORR, CV_TM_CCORR_NORMED, - CV_TM_SQDIFF, CV_TM_SQDIFF_NORMED, - CV_TM_CCOEFF, CV_TM_CCOEFF_NORMED) +CV_ENUM(MatchTemplType, cv::TM_CCORR, cv::TM_CCORR_NORMED, + cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, + cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED) class Imgproc_MatchTemplateWithMask : public TestWithParam> { @@ -76,7 +76,7 @@ void Imgproc_MatchTemplateWithMask::SetUp() TEST_P(Imgproc_MatchTemplateWithMask, CompareNaiveImplSQDIFF) { - matchTemplate(img_testtype_, templ_testtype_, result_, CV_TM_SQDIFF, mask_testtype_); + matchTemplate(img_testtype_, templ_testtype_, result_, cv::TM_SQDIFF, mask_testtype_); // Naive implementation for one point Mat temp = img_roi_masked_ - templ_masked_; Scalar temp_s = sum(temp.mul(temp)); @@ -87,7 +87,7 @@ TEST_P(Imgproc_MatchTemplateWithMask, CompareNaiveImplSQDIFF) TEST_P(Imgproc_MatchTemplateWithMask, CompareNaiveImplSQDIFF_NORMED) { - matchTemplate(img_testtype_, templ_testtype_, result_, CV_TM_SQDIFF_NORMED, mask_testtype_); + matchTemplate(img_testtype_, templ_testtype_, result_, cv::TM_SQDIFF_NORMED, mask_testtype_); // Naive implementation for one point Mat temp = img_roi_masked_ - templ_masked_; Scalar temp_s = sum(temp.mul(temp)); @@ -106,7 +106,7 @@ TEST_P(Imgproc_MatchTemplateWithMask, CompareNaiveImplSQDIFF_NORMED) TEST_P(Imgproc_MatchTemplateWithMask, CompareNaiveImplCCORR) { - matchTemplate(img_testtype_, templ_testtype_, result_, CV_TM_CCORR, mask_testtype_); + matchTemplate(img_testtype_, templ_testtype_, result_, cv::TM_CCORR, mask_testtype_); // Naive implementation for one point Scalar temp_s = sum(templ_masked_.mul(img_roi_masked_)); double val = temp_s[0] + temp_s[1] + temp_s[2] + temp_s[3]; @@ -116,7 +116,7 @@ TEST_P(Imgproc_MatchTemplateWithMask, CompareNaiveImplCCORR) TEST_P(Imgproc_MatchTemplateWithMask, CompareNaiveImplCCORR_NORMED) { - matchTemplate(img_testtype_, templ_testtype_, result_, CV_TM_CCORR_NORMED, mask_testtype_); + matchTemplate(img_testtype_, templ_testtype_, result_, cv::TM_CCORR_NORMED, mask_testtype_); // Naive implementation for one point Scalar temp_s = sum(templ_masked_.mul(img_roi_masked_)); double val = temp_s[0] + temp_s[1] + temp_s[2] + temp_s[3]; @@ -134,7 +134,7 @@ TEST_P(Imgproc_MatchTemplateWithMask, CompareNaiveImplCCORR_NORMED) TEST_P(Imgproc_MatchTemplateWithMask, CompareNaiveImplCCOEFF) { - matchTemplate(img_testtype_, templ_testtype_, result_, CV_TM_CCOEFF, mask_testtype_); + matchTemplate(img_testtype_, templ_testtype_, result_, cv::TM_CCOEFF, mask_testtype_); // Naive implementation for one point Scalar temp_s = sum(mask_); for (int i = 0; i < 4; i++) @@ -157,7 +157,7 @@ TEST_P(Imgproc_MatchTemplateWithMask, CompareNaiveImplCCOEFF) TEST_P(Imgproc_MatchTemplateWithMask, CompareNaiveImplCCOEFF_NORMED) { - matchTemplate(img_testtype_, templ_testtype_, result_, CV_TM_CCOEFF_NORMED, mask_testtype_); + matchTemplate(img_testtype_, templ_testtype_, result_, cv::TM_CCOEFF_NORMED, mask_testtype_); // Naive implementation for one point Scalar temp_s = sum(mask_); for (int i = 0; i < 4; i++) @@ -265,14 +265,14 @@ INSTANTIATE_TEST_CASE_P(SingleChannelMask, Imgproc_MatchTemplateWithMask2, Combine( Values(CV_32FC1, CV_32FC3, CV_8UC1, CV_8UC3), Values(CV_32FC1, CV_8UC1), - Values(CV_TM_SQDIFF, CV_TM_SQDIFF_NORMED, CV_TM_CCORR, CV_TM_CCORR_NORMED, - CV_TM_CCOEFF, CV_TM_CCOEFF_NORMED))); + Values(cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, + cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED))); INSTANTIATE_TEST_CASE_P(MultiChannelMask, Imgproc_MatchTemplateWithMask2, Combine( Values(CV_32FC3, CV_8UC3), Values(CV_32FC3, CV_8UC3), - Values(CV_TM_SQDIFF, CV_TM_SQDIFF_NORMED, CV_TM_CCORR, CV_TM_CCORR_NORMED, - CV_TM_CCOEFF, CV_TM_CCOEFF_NORMED))); + Values(cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, + cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED))); }} // namespace diff --git a/modules/photo/src/inpaint.cpp b/modules/photo/src/inpaint.cpp index f3fcb47094..b436168212 100644 --- a/modules/photo/src/inpaint.cpp +++ b/modules/photo/src/inpaint.cpp @@ -735,17 +735,13 @@ icvNSInpaintFMM(const CvMat *f, CvMat *t, CvMat *out, int range, CvPriorityQueue }\ } -namespace cv { -template<> struct DefaultDeleter{ void operator ()(IplConvKernel* obj) const { cvReleaseStructuringElement(&obj); } }; -} - static void icvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_img, double inpaintRange, int flags ) { cv::Ptr mask, band, f, t, out; cv::Ptr Heap, Out; - cv::Ptr el_cross, el_range; + cv::Mat el_range, el_cross; // structuring elements for dilate CvMat input_hdr, mask_hdr, output_hdr; CvMat* input_img, *inpaint_mask, *output_img; @@ -780,7 +776,7 @@ icvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_ t.reset(cvCreateMat(erows, ecols, CV_32FC1)); band.reset(cvCreateMat(erows, ecols, CV_8UC1)); mask.reset(cvCreateMat(erows, ecols, CV_8UC1)); - el_cross.reset(cvCreateStructuringElementEx(3,3,1,1,CV_SHAPE_CROSS,NULL)); + el_cross = cv::getStructuringElement(cv::MORPH_CROSS, cv::Size(3, 3), cv::Point(1, 1)); cvCopy( input_img, output_img ); cvSet(mask,cvScalar(KNOWN,0,0,0)); @@ -788,7 +784,7 @@ icvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_ SET_BORDER1_C1(mask,uchar,0); cvSet(f,cvScalar(KNOWN,0,0,0)); cvSet(t,cvScalar(1.0e6f,0,0,0)); - cvDilate(mask,band,el_cross,1); // image with narrow band + cv::dilate(cv::cvarrToMat(mask), cv::cvarrToMat(band), el_cross, cv::Point(1, 1)); Heap=cv::makePtr(); if (!Heap->Init(band)) return; @@ -803,9 +799,8 @@ icvInpaint( const CvArr* _input_img, const CvArr* _inpaint_mask, CvArr* _output_ if( flags == cv::INPAINT_TELEA ) { out.reset(cvCreateMat(erows, ecols, CV_8UC1)); - el_range.reset(cvCreateStructuringElementEx(2*range+1,2*range+1, - range,range,CV_SHAPE_RECT,NULL)); - cvDilate(mask,out,el_range,1); + el_range = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(2 * range + 1, 2 * range + 1)); + cv::dilate(cv::cvarrToMat(mask), cv::cvarrToMat(out), el_range); cvSub(out,mask,out,NULL); Out=cv::makePtr(); if (!Out->Init(out)) diff --git a/modules/ts/src/ocl_test.cpp b/modules/ts/src/ocl_test.cpp index 6d5ff26d7f..07fb1cdc4a 100644 --- a/modules/ts/src/ocl_test.cpp +++ b/modules/ts/src/ocl_test.cpp @@ -81,7 +81,7 @@ double TestUtils::checkNorm2(InputArray m1, InputArray m2, InputArray mask) double TestUtils::checkSimilarity(InputArray m1, InputArray m2) { Mat diff; - matchTemplate(m1.getMat(), m2.getMat(), diff, CV_TM_CCORR_NORMED); + matchTemplate(m1.getMat(), m2.getMat(), diff, cv::TM_CCORR_NORMED); return std::abs(diff.at(0, 0) - 1.f); } diff --git a/modules/ts/src/ts_func.cpp b/modules/ts/src/ts_func.cpp index d64f52927b..cd02766148 100644 --- a/modules/ts/src/ts_func.cpp +++ b/modules/ts/src/ts_func.cpp @@ -3061,7 +3061,7 @@ void threshold( const Mat& _src, Mat& _dst, switch( thresh_type ) { - case CV_THRESH_BINARY: + case cv::THRESH_BINARY: for( i = 0; i < height; i++ ) { if( depth == CV_8U ) @@ -3087,7 +3087,7 @@ void threshold( const Mat& _src, Mat& _dst, } } break; - case CV_THRESH_BINARY_INV: + case cv::THRESH_BINARY_INV: for( i = 0; i < height; i++ ) { if( depth == CV_8U ) @@ -3113,7 +3113,7 @@ void threshold( const Mat& _src, Mat& _dst, } } break; - case CV_THRESH_TRUNC: + case cv::THRESH_TRUNC: for( i = 0; i < height; i++ ) { if( depth == CV_8U ) @@ -3148,7 +3148,7 @@ void threshold( const Mat& _src, Mat& _dst, } } break; - case CV_THRESH_TOZERO: + case cv::THRESH_TOZERO: for( i = 0; i < height; i++ ) { if( depth == CV_8U ) @@ -3183,7 +3183,7 @@ void threshold( const Mat& _src, Mat& _dst, } } break; - case CV_THRESH_TOZERO_INV: + case cv::THRESH_TOZERO_INV: for( i = 0; i < height; i++ ) { if( depth == CV_8U ) diff --git a/modules/video/test/test_camshift.cpp b/modules/video/test/test_camshift.cpp index 24d2ec6c24..57e5bf4c59 100644 --- a/modules/video/test/test_camshift.cpp +++ b/modules/video/test/test_camshift.cpp @@ -274,7 +274,7 @@ int CV_CamShiftTest::validate_test_results( int /*test_case_idx*/ ) cvIsNaN(box.center.y) || cvIsInf(box.center.y) || cvIsNaN(box.angle) || cvIsInf(box.angle) || box.angle < -180 || box.angle > 180 ) { - ts->printf( cvtest::TS::LOG, "Invalid CvBox2D or CvConnectedComp was returned by cvCamShift\n" ); + ts->printf( cvtest::TS::LOG, "Invalid RotatedRect was returned by CamShift\n" ); code = cvtest::TS::FAIL_INVALID_OUTPUT; goto _exit_; } @@ -317,19 +317,6 @@ _exit_: if( code < 0 ) { -#if 0 //defined _DEBUG && defined _WIN32 - IplImage* dst = cvCreateImage( img_size, 8, 3 ); - cvNamedWindow( "test", 1 ); - cvCmpS( img, 0, img, CV_CMP_GT ); - cvCvtColor( img, dst, CV_GRAY2BGR ); - cvRectangle( dst, cvPoint(init_rect.x, init_rect.y), - cvPoint(init_rect.x + init_rect.width, init_rect.y + init_rect.height), - CV_RGB(255,0,0), 3, 8, 0 ); - cvEllipseBox( dst, box, CV_RGB(0,255,0), 3, 8, 0 ); - cvShowImage( "test", dst ); - cvReleaseImage( &dst ); - cvWaitKey(); -#endif ts->set_failed_test_info( code ); } return code; @@ -428,7 +415,7 @@ int CV_MeanShiftTest::validate_test_results( int /*test_case_idx*/ ) rect.y + rect.height > box0.center.y + delta ) { ts->printf( cvtest::TS::LOG, - "Incorrect CvConnectedComp ((%d,%d,%d,%d) is not within (%.1f,%.1f,%.1f,%.1f))\n", + "Incorrect ConnectedComp ((%d,%d,%d,%d) is not within (%.1f,%.1f,%.1f,%.1f))\n", rect.x, rect.y, rect.x + rect.width, rect.y + rect.height, box0.center.x - delta, box0.center.y - delta, box0.center.x + delta, box0.center.y + delta ); code = cvtest::TS::FAIL_BAD_ACCURACY; @@ -438,21 +425,6 @@ _exit_: if( code < 0 ) { -#if 0// defined _DEBUG && defined _WIN32 - IplImage* dst = cvCreateImage( img_size, 8, 3 ); - cvNamedWindow( "test", 1 ); - cvCmpS( img, 0, img, CV_CMP_GT ); - cvCvtColor( img, dst, CV_GRAY2BGR ); - cvRectangle( dst, cvPoint(init_rect.x, init_rect.y), - cvPoint(init_rect.x + init_rect.width, init_rect.y + init_rect.height), - CV_RGB(255,0,0), 3, 8, 0 ); - cvRectangle( dst, cvPoint(comp.rect.x, comp.rect.y), - cvPoint(comp.rect.x + comp.rect.width, comp.rect.y + comp.rect.height), - CV_RGB(0,255,0), 3, 8, 0 ); - cvShowImage( "test", dst ); - cvReleaseImage( &dst ); - cvWaitKey(); -#endif ts->set_failed_test_info( code ); } return code; diff --git a/modules/videoio/src/cap_avfoundation.mm b/modules/videoio/src/cap_avfoundation.mm index ef13dd6d14..12fa42f5b5 100644 --- a/modules/videoio/src/cap_avfoundation.mm +++ b/modules/videoio/src/cap_avfoundation.mm @@ -751,7 +751,7 @@ fromConnection:(AVCaptureConnection *)connection{ bgr_image->imageData = bgr_imagedata; bgr_image->imageSize = (int)currSize; - cvCvtColor(image, bgr_image, CV_BGRA2BGR); + cv::cvtColor(cv::cvarrToMat(image), cv::cvarrToMat(bgr_image), cv::COLOR_BGRA2BGR); // image taken from the buffer is incorrected rotated. I'm using cvTranspose + cvFlip. // There should be an option in iOS API to rotate the buffer output orientation. @@ -1001,11 +1001,11 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { deviceChannels = 4; if (mMode == CV_CAP_MODE_BGR) { - cvtCode = CV_BGRA2BGR; + cvtCode = cv::COLOR_BGRA2BGR; } else if (mMode == CV_CAP_MODE_RGB) { - cvtCode = CV_BGRA2RGB; + cvtCode = cv::COLOR_BGRA2RGB; } else if (mMode == CV_CAP_MODE_GRAY) { - cvtCode = CV_BGRA2GRAY; + cvtCode = cv::COLOR_BGRA2GRAY; } else { CVPixelBufferUnlockBaseAddress(mGrabbedPixels, 0); CVBufferRelease(mGrabbedPixels); @@ -1017,11 +1017,11 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { deviceChannels = 3; if (mMode == CV_CAP_MODE_BGR) { - cvtCode = CV_RGB2BGR; + cvtCode = cv::COLOR_RGB2BGR; } else if (mMode == CV_CAP_MODE_RGB) { cvtCode = 0; } else if (mMode == CV_CAP_MODE_GRAY) { - cvtCode = CV_RGB2GRAY; + cvtCode = cv::COLOR_RGB2GRAY; } else { CVPixelBufferUnlockBaseAddress(mGrabbedPixels, 0); CVBufferRelease(mGrabbedPixels); @@ -1033,11 +1033,11 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { deviceChannels = 2; if (mMode == CV_CAP_MODE_BGR) { - cvtCode = CV_YUV2BGR_UYVY; + cvtCode = cv::COLOR_YUV2BGR_UYVY; } else if (mMode == CV_CAP_MODE_RGB) { - cvtCode = CV_YUV2RGB_UYVY; + cvtCode = cv::COLOR_YUV2RGB_UYVY; } else if (mMode == CV_CAP_MODE_GRAY) { - cvtCode = CV_YUV2GRAY_UYVY; + cvtCode = cv::COLOR_YUV2GRAY_UYVY; } else if (mMode == CV_CAP_MODE_YUYV) { cvtCode = -1; // Copy } else { @@ -1053,11 +1053,11 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { deviceChannels = 1; if (mMode == CV_CAP_MODE_BGR) { - cvtCode = CV_YUV2BGR_YV12; + cvtCode = cv::COLOR_YUV2BGR_YV12; } else if (mMode == CV_CAP_MODE_RGB) { - cvtCode = CV_YUV2RGB_YV12; + cvtCode = cv::COLOR_YUV2RGB_YV12; } else if (mMode == CV_CAP_MODE_GRAY) { - cvtCode = CV_YUV2GRAY_420; + cvtCode = cv::COLOR_YUV2GRAY_420; } else { CVPixelBufferUnlockBaseAddress(mGrabbedPixels, 0); CVBufferRelease(mGrabbedPixels); @@ -1089,7 +1089,7 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { if (cvtCode == -1) { cv::cvarrToMat(mDeviceImage).copyTo(cv::cvarrToMat(mOutImage)); } else { - cvCvtColor(mDeviceImage, mOutImage, cvtCode); + cv::cvtColor(cv::cvarrToMat(mDeviceImage), cv::cvarrToMat(mOutImage), cvtCode); } CVPixelBufferUnlockBaseAddress(mGrabbedPixels, 0); @@ -1383,10 +1383,10 @@ bool CvVideoWriter_AVFoundation::writeFrame(const IplImage* iplimage) { if (movieColor) { //assert(iplimage->nChannels == 3); - cvCvtColor(iplimage, argbimage, CV_BGR2BGRA); + cv::cvtColor(cv::cvarrToMat(iplimage), cv::cvarrToMat(argbimage), cv::COLOR_BGR2BGRA); }else{ //assert(iplimage->nChannels == 1); - cvCvtColor(iplimage, argbimage, CV_GRAY2BGRA); + cv::cvtColor(cv::cvarrToMat(iplimage), cv::cvarrToMat(argbimage), cv::COLOR_GRAY2BGRA); } //IplImage -> CGImage conversion CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); diff --git a/modules/videoio/src/cap_avfoundation_mac.mm b/modules/videoio/src/cap_avfoundation_mac.mm index bd68ff8cfb..c0ad4810d4 100644 --- a/modules/videoio/src/cap_avfoundation_mac.mm +++ b/modules/videoio/src/cap_avfoundation_mac.mm @@ -697,7 +697,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer mDeviceImage->imageData = reinterpret_cast(baseaddress); mDeviceImage->imageSize = int(rowBytes*height); - cvCvtColor(mDeviceImage, mOutImage, CV_BGRA2BGR); + cvtColor(cv::cvarrToMat(mDeviceImage), cv::cvarrToMat(mOutImage), cv::COLOR_BGRA2BGR); } else if ( pixelFormat == kCVPixelFormatType_422YpCbCr8 ) { if ( currSize != width*3*height ) { currSize = width*3*height; @@ -716,7 +716,7 @@ didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer mDeviceImage->imageData = reinterpret_cast(baseaddress); mDeviceImage->imageSize = int(rowBytes*height); - cvCvtColor(mDeviceImage, mOutImage, CV_YUV2BGR_UYVY); + cvtColor(cv::cvarrToMat(mDeviceImage), cv::cvarrToMat(mOutImage), cv::COLOR_YUV2BGR_UYVY); } else { fprintf(stderr, "OpenCV: unknown pixel format 0x%08X\n", pixelFormat); CVPixelBufferUnlockBaseAddress(mGrabbedPixels, 0); @@ -827,7 +827,7 @@ bool CvCaptureFile::setupReadingAt(CMTime position) { // Capture in a pixel format that can be converted efficiently to the output mode. OSType pixelFormat; if (mMode == CV_CAP_MODE_BGR || mMode == CV_CAP_MODE_RGB) { - // For CV_CAP_MODE_BGR, read frames as BGRA (AV Foundation's YUV->RGB conversion is slightly faster than OpenCV's CV_YUV2BGR_YV12) + // For CV_CAP_MODE_BGR, read frames as BGRA (AV Foundation's YUV->RGB conversion is slightly faster than OpenCV's cv::COLOR_YUV2BGR_YV12) // kCVPixelFormatType_32ABGR is reportedly faster on OS X, but OpenCV doesn't have a CV_ABGR2BGR conversion. // kCVPixelFormatType_24RGB is significantly slower than kCVPixelFormatType_32BGRA. pixelFormat = kCVPixelFormatType_32BGRA; @@ -972,11 +972,11 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { deviceChannels = 4; if (mMode == CV_CAP_MODE_BGR) { - cvtCode = CV_BGRA2BGR; + cvtCode = cv::COLOR_BGRA2BGR; } else if (mMode == CV_CAP_MODE_RGB) { - cvtCode = CV_BGRA2RGB; + cvtCode = cv::COLOR_BGRA2RGB; } else if (mMode == CV_CAP_MODE_GRAY) { - cvtCode = CV_BGRA2GRAY; + cvtCode = cv::COLOR_BGRA2GRAY; } else { CVPixelBufferUnlockBaseAddress(mGrabbedPixels, 0); CVBufferRelease(mGrabbedPixels); @@ -988,11 +988,11 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { deviceChannels = 3; if (mMode == CV_CAP_MODE_BGR) { - cvtCode = CV_RGB2BGR; + cvtCode = cv::COLOR_RGB2BGR; } else if (mMode == CV_CAP_MODE_RGB) { cvtCode = 0; } else if (mMode == CV_CAP_MODE_GRAY) { - cvtCode = CV_RGB2GRAY; + cvtCode = cv::COLOR_RGB2GRAY; } else { CVPixelBufferUnlockBaseAddress(mGrabbedPixels, 0); CVBufferRelease(mGrabbedPixels); @@ -1004,11 +1004,11 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { deviceChannels = 2; if (mMode == CV_CAP_MODE_BGR) { - cvtCode = CV_YUV2BGR_UYVY; + cvtCode = cv::COLOR_YUV2BGR_UYVY; } else if (mMode == CV_CAP_MODE_RGB) { - cvtCode = CV_YUV2RGB_UYVY; + cvtCode = cv::COLOR_YUV2RGB_UYVY; } else if (mMode == CV_CAP_MODE_GRAY) { - cvtCode = CV_YUV2GRAY_UYVY; + cvtCode = cv::COLOR_YUV2GRAY_UYVY; } else if (mMode == CV_CAP_MODE_YUYV) { cvtCode = -1; // Copy } else { @@ -1020,17 +1020,17 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { } } else if ( pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange || // 420v pixelFormat == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange ) { // 420f - // cvCvtColor(CV_YUV2GRAY_420) is expecting a single buffer with both the Y plane and the CrCb planes. - // So, lie about the height of the buffer. cvCvtColor(CV_YUV2GRAY_420) will only read the first 2/3 of it. + // cvtColor(cv::COLOR_YUV2GRAY_420) is expecting a single buffer with both the Y plane and the CrCb planes. + // So, lie about the height of the buffer. cvtColor(cv::COLOR_YUV2GRAY_420) will only read the first 2/3 of it. height = height * 3 / 2; deviceChannels = 1; if (mMode == CV_CAP_MODE_BGR) { - cvtCode = CV_YUV2BGR_YV12; + cvtCode = cv::COLOR_YUV2BGR_YV12; } else if (mMode == CV_CAP_MODE_RGB) { - cvtCode = CV_YUV2RGB_YV12; + cvtCode = cv::COLOR_YUV2RGB_YV12; } else if (mMode == CV_CAP_MODE_GRAY) { - cvtCode = CV_YUV2GRAY_420; + cvtCode = cv::COLOR_YUV2GRAY_420; } else { CVPixelBufferUnlockBaseAddress(mGrabbedPixels, 0); CVBufferRelease(mGrabbedPixels); @@ -1063,7 +1063,7 @@ IplImage* CvCaptureFile::retrieveFramePixelBuffer() { // Copy. cv::cvarrToMat(mDeviceImage).copyTo(cv::cvarrToMat(mOutImage)); } else { - cvCvtColor(mDeviceImage, mOutImage, cvtCode); + cvtColor(cv::cvarrToMat(mDeviceImage), cv::cvarrToMat(mOutImage), cvtCode); } @@ -1352,10 +1352,10 @@ bool CvVideoWriter_AVFoundation::writeFrame(const IplImage* iplimage) { if (movieColor) { //assert(iplimage->nChannels == 3); - cvCvtColor(iplimage, argbimage, CV_BGR2BGRA); + cvtColor(cv::cvarrToMat(iplimage), cv::cvarrToMat(argbimage), cv::COLOR_BGR2BGRA); }else{ //assert(iplimage->nChannels == 1); - cvCvtColor(iplimage, argbimage, CV_GRAY2BGRA); + cvtColor(cv::cvarrToMat(iplimage), cv::cvarrToMat(argbimage), cv::COLOR_GRAY2BGRA); } //IplImage -> CGImage conversion CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB(); diff --git a/modules/videoio/src/cap_openni2.cpp b/modules/videoio/src/cap_openni2.cpp index bc17b01a48..d4b3ae4153 100644 --- a/modules/videoio/src/cap_openni2.cpp +++ b/modules/videoio/src/cap_openni2.cpp @@ -1052,7 +1052,7 @@ IplImage* CvCapture_OpenNI2::retrieveGrayImage() cv::Mat rgbImage; getBGRImageFromMetaData(streamFrames[CV_COLOR_STREAM], rgbImage); - cv::cvtColor( rgbImage, outputMaps[CV_CAP_OPENNI_GRAY_IMAGE].mat, CV_BGR2GRAY ); + cv::cvtColor( rgbImage, outputMaps[CV_CAP_OPENNI_GRAY_IMAGE].mat, cv::COLOR_BGR2GRAY ); return outputMaps[CV_CAP_OPENNI_GRAY_IMAGE].getIplImagePtr(); } diff --git a/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Processor.java b/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Processor.java index 83c62f4638..5e1ab01b62 100644 --- a/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Processor.java +++ b/samples/android/15-puzzle/src/org/opencv/samples/puzzle15/Puzzle15Processor.java @@ -64,7 +64,7 @@ public class Puzzle15Processor { } for (int i = 0; i < GRID_AREA; i++) { - Size s = Imgproc.getTextSize(Integer.toString(i + 1), 3/* CV_FONT_HERSHEY_COMPLEX */, 1, 2, null); + Size s = Imgproc.getTextSize(Integer.toString(i + 1), Imgproc.FONT_HERSHEY_COMPLEX, 1, 2, null); mTextHeights[i] = (int) s.height; mTextWidths[i] = (int) s.width; } @@ -100,7 +100,7 @@ public class Puzzle15Processor { cells[idx].copyTo(mCells15[i]); if (mShowTileNumbers) { Imgproc.putText(mCells15[i], Integer.toString(1 + idx), new Point((cols / GRID_SIZE - mTextWidths[idx]) / 2, - (rows / GRID_SIZE + mTextHeights[idx]) / 2), 3/* CV_FONT_HERSHEY_COMPLEX */, 1, new Scalar(255, 0, 0, 255), 2); + (rows / GRID_SIZE + mTextHeights[idx]) / 2), Imgproc.FONT_HERSHEY_COMPLEX, 1, new Scalar(255, 0, 0, 255), 2); } } } diff --git a/samples/cpp/mask_tmpl.cpp b/samples/cpp/mask_tmpl.cpp index 5e374186bc..3c63b15dbc 100644 --- a/samples/cpp/mask_tmpl.cpp +++ b/samples/cpp/mask_tmpl.cpp @@ -52,7 +52,7 @@ int main( int argc, const char** argv ) return -1; } - int method = parser.get("cm"); // default 3 (CV_TM_CCORR_NORMED) + int method = parser.get("cm"); // default 3 (cv::TM_CCORR_NORMED) matchTemplate(img, tmpl, res, method, mask); double minVal, maxVal; diff --git a/samples/java/tutorial_code/ImgProc/erosion_dilatation/MorphologyDemo1.java b/samples/java/tutorial_code/ImgProc/erosion_dilatation/MorphologyDemo1.java index e71400f737..084fc9544d 100644 --- a/samples/java/tutorial_code/ImgProc/erosion_dilatation/MorphologyDemo1.java +++ b/samples/java/tutorial_code/ImgProc/erosion_dilatation/MorphologyDemo1.java @@ -28,7 +28,7 @@ public class MorphologyDemo1 { private static final int MAX_KERNEL_SIZE = 21; private Mat matImgSrc; private Mat matImgDst = new Mat(); - private int elementType = Imgproc.CV_SHAPE_RECT; + private int elementType = Imgproc.MORPH_RECT; private int kernelSize = 0; private boolean doErosion = true; private JFrame frame; @@ -74,11 +74,11 @@ public class MorphologyDemo1 { @SuppressWarnings("unchecked") JComboBox cb = (JComboBox)e.getSource(); if (cb.getSelectedIndex() == 0) { - elementType = Imgproc.CV_SHAPE_RECT; + elementType = Imgproc.MORPH_RECT; } else if (cb.getSelectedIndex() == 1) { - elementType = Imgproc.CV_SHAPE_CROSS; + elementType = Imgproc.MORPH_CROSS; } else if (cb.getSelectedIndex() == 2) { - elementType = Imgproc.CV_SHAPE_ELLIPSE; + elementType = Imgproc.MORPH_ELLIPSE; } update(); }