From 44db2eea703ef71004033b1315af36031573030c Mon Sep 17 00:00:00 2001 From: Suleyman TURKMEN Date: Sun, 13 Feb 2022 11:18:30 +0300 Subject: [PATCH 1/7] update HOGDescriptor documentation --- .../objdetect/include/opencv2/objdetect.hpp | 22 +++++++++++-------- modules/objdetect/src/hog.cpp | 12 +++++----- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/modules/objdetect/include/opencv2/objdetect.hpp b/modules/objdetect/include/opencv2/objdetect.hpp index 7c7f7d90d3..031f1fbf99 100644 --- a/modules/objdetect/include/opencv2/objdetect.hpp +++ b/modules/objdetect/include/opencv2/objdetect.hpp @@ -376,7 +376,7 @@ public: }; enum { DEFAULT_NLEVELS = 64 //!< Default nlevels value. }; - /**@brief Creates the HOG descriptor and detector with default params. + /**@brief Creates the HOG descriptor and detector with default parameters. aqual to HOGDescriptor(Size(64,128), Size(16,16), Size(8,8), Size(8,8), 9, 1 ) */ @@ -412,6 +412,8 @@ public: {} /** @overload + + Creates the HOG descriptor and detector and loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file. @param filename the file name containing HOGDescriptor properties and coefficients of the trained classifier */ CV_WRAP HOGDescriptor(const String& filename) @@ -450,24 +452,24 @@ public: */ CV_WRAP virtual void setSVMDetector(InputArray _svmdetector); - /** @brief Reads HOGDescriptor parameters from a file node. + /** @brief Reads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file node. @param fn File node */ virtual bool read(FileNode& fn); - /** @brief Stores HOGDescriptor parameters in a file storage. + /** @brief Stores HOGDescriptor parameters and coefficients for the linear SVM classifier in a file storage. @param fs File storage @param objname Object name */ virtual void write(FileStorage& fs, const String& objname) const; - /** @brief loads coefficients for the linear SVM classifier from a file + /** @brief loads HOGDescriptor parameters and coefficients for the linear SVM classifier from a file @param filename Name of the file to read. @param objname The optional name of the node to read (if empty, the first top-level node will be used). */ CV_WRAP virtual bool load(const String& filename, const String& objname = String()); - /** @brief saves coefficients for the linear SVM classifier to a file + /** @brief saves HOGDescriptor parameters and coefficients for the linear SVM classifier to a file @param filename File name @param objname Object name */ @@ -535,13 +537,14 @@ public: @param winStride Window stride. It must be a multiple of block stride. @param padding Padding @param scale Coefficient of the detection window increase. - @param finalThreshold Final threshold + @param groupThreshold Coefficient to regulate the similarity threshold. When detected, some objects can be covered + by many rectangles. 0 means not to perform grouping. @param useMeanshiftGrouping indicates grouping algorithm */ CV_WRAP virtual void detectMultiScale(InputArray img, CV_OUT std::vector& foundLocations, CV_OUT std::vector& foundWeights, double hitThreshold = 0, Size winStride = Size(), Size padding = Size(), double scale = 1.05, - double finalThreshold = 2.0,bool useMeanshiftGrouping = false) const; + double groupThreshold = 2.0, bool useMeanshiftGrouping = false) const; /** @brief Detects objects of different sizes in the input image. The detected objects are returned as a list of rectangles. @@ -553,13 +556,14 @@ public: @param winStride Window stride. It must be a multiple of block stride. @param padding Padding @param scale Coefficient of the detection window increase. - @param finalThreshold Final threshold + @param groupThreshold Coefficient to regulate the similarity threshold. When detected, some objects can be covered + by many rectangles. 0 means not to perform grouping. @param useMeanshiftGrouping indicates grouping algorithm */ virtual void detectMultiScale(InputArray img, CV_OUT std::vector& foundLocations, double hitThreshold = 0, Size winStride = Size(), Size padding = Size(), double scale = 1.05, - double finalThreshold = 2.0, bool useMeanshiftGrouping = false) const; + double groupThreshold = 2.0, bool useMeanshiftGrouping = false) const; /** @brief Computes gradients and quantized gradient orientations. @param img Matrix contains the image to be computed diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index 1ff2191dd0..aa468acfee 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -1884,7 +1884,7 @@ static bool ocl_detectMultiScale(InputArray _img, std::vector &found_locat void HOGDescriptor::detectMultiScale( InputArray _img, std::vector& foundLocations, std::vector& foundWeights, double hitThreshold, Size winStride, Size padding, - double scale0, double finalThreshold, bool useMeanshiftGrouping) const + double scale0, double groupThreshold, bool useMeanshiftGrouping) const { CV_INSTRUMENT_REGION(); @@ -1910,7 +1910,7 @@ void HOGDescriptor::detectMultiScale( CV_OCL_RUN(_img.dims() <= 2 && _img.type() == CV_8UC1 && scale0 > 1 && winStride.width % blockStride.width == 0 && winStride.height % blockStride.height == 0 && padding == Size(0,0) && _img.isUMat(), - ocl_detectMultiScale(_img, foundLocations, levelScale, hitThreshold, winStride, finalThreshold, oclSvmDetector, + ocl_detectMultiScale(_img, foundLocations, levelScale, hitThreshold, winStride, groupThreshold, oclSvmDetector, blockSize, cellSize, nbins, blockStride, winSize, gammaCorrection, L2HysThreshold, (float)getWinSigma(), free_coef, signedGradient)); std::vector allCandidates; @@ -1931,21 +1931,21 @@ void HOGDescriptor::detectMultiScale( std::copy(tempWeights.begin(), tempWeights.end(), back_inserter(foundWeights)); if ( useMeanshiftGrouping ) - groupRectangles_meanshift(foundLocations, foundWeights, foundScales, finalThreshold, winSize); + groupRectangles_meanshift(foundLocations, foundWeights, foundScales, groupThreshold, winSize); else - groupRectangles(foundLocations, foundWeights, (int)finalThreshold, 0.2); + groupRectangles(foundLocations, foundWeights, (int)groupThreshold, 0.2); clipObjects(imgSize, foundLocations, 0, &foundWeights); } void HOGDescriptor::detectMultiScale(InputArray img, std::vector& foundLocations, double hitThreshold, Size winStride, Size padding, - double scale0, double finalThreshold, bool useMeanshiftGrouping) const + double scale0, double groupThreshold, bool useMeanshiftGrouping) const { CV_INSTRUMENT_REGION(); std::vector foundWeights; detectMultiScale(img, foundLocations, foundWeights, hitThreshold, winStride, - padding, scale0, finalThreshold, useMeanshiftGrouping); + padding, scale0, groupThreshold, useMeanshiftGrouping); } template struct RTTIImpl From 8d88bb06b230b5c4b5bca78d84102f5d1adf48cf Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 15 Feb 2022 07:23:32 +0300 Subject: [PATCH 2/7] core(vsx): update vec_absd() workaround condition --- modules/core/include/opencv2/core/vsx_utils.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/modules/core/include/opencv2/core/vsx_utils.hpp b/modules/core/include/opencv2/core/vsx_utils.hpp index 68863ffb36..5cbc066784 100644 --- a/modules/core/include/opencv2/core/vsx_utils.hpp +++ b/modules/core/include/opencv2/core/vsx_utils.hpp @@ -684,7 +684,8 @@ VSX_IMPL_LOAD_L8(vec_double2, double) #endif // absolute difference -#ifndef vec_absd +#ifndef _ARCH_PWR9 +# undef vec_absd # define vec_absd(a, b) vec_sub(vec_max(a, b), vec_min(a, b)) #endif From a2514741447bb55067a06fc98fe49dd48e00c540 Mon Sep 17 00:00:00 2001 From: Maksim Shabunin Date: Tue, 8 Feb 2022 20:32:55 +0300 Subject: [PATCH 3/7] Update filters in ONNX tests --- ...conformance_layer_filter__openvino.inl.hpp | 102 +++++++++--------- 1 file changed, 54 insertions(+), 48 deletions(-) diff --git a/modules/dnn/test/test_onnx_conformance_layer_filter__openvino.inl.hpp b/modules/dnn/test/test_onnx_conformance_layer_filter__openvino.inl.hpp index 4bde85100f..218211eb4a 100644 --- a/modules/dnn/test/test_onnx_conformance_layer_filter__openvino.inl.hpp +++ b/modules/dnn/test/test_onnx_conformance_layer_filter__openvino.inl.hpp @@ -59,6 +59,12 @@ EOF_LABEL: bool filterApplied = false; +#if INF_ENGINE_VER_MAJOR_EQ(2021040000) || INF_ENGINE_VER_MAJOR_EQ(2022010000) +#define SKIP_SET_1 1 +#else +#define SKIP_SET_1 0 +#endif + // Update note: execute /testdata/dnn/onnx/generate_conformance_list.py BEGIN_SWITCH() CASE(test_abs) @@ -82,7 +88,7 @@ CASE(test_adam_multiple) CASE(test_add) // no filter CASE(test_add_bcast) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_add_uint8) @@ -190,11 +196,11 @@ CASE(test_averagepool_2d_ceil) CASE(test_averagepool_2d_default) // no filter CASE(test_averagepool_2d_pads) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_averagepool_2d_pads_count_include_pad) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_CPU; // MYRIAD is ok SKIP_OPENCL; @@ -203,7 +209,7 @@ CASE(test_averagepool_2d_pads_count_include_pad) CASE(test_averagepool_2d_precomputed_pads) // no filter CASE(test_averagepool_2d_precomputed_pads_count_include_pad) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_averagepool_2d_precomputed_same_upper) @@ -211,7 +217,7 @@ CASE(test_averagepool_2d_precomputed_same_upper) CASE(test_averagepool_2d_precomputed_strides) // no filter CASE(test_averagepool_2d_same_lower) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_averagepool_2d_same_upper) @@ -221,11 +227,11 @@ CASE(test_averagepool_2d_strides) CASE(test_averagepool_3d_default) // no filter CASE(test_basic_conv_with_padding) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_basic_conv_without_padding) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_basic_convinteger) @@ -283,11 +289,11 @@ CASE(test_cast_FLOAT_to_DOUBLE) CASE(test_cast_FLOAT_to_FLOAT16) // no filter CASE(test_cast_FLOAT_to_STRING) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_cast_STRING_to_FLOAT) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_castlike_BFLOAT16_to_FLOAT) @@ -325,13 +331,13 @@ CASE(test_castlike_FLOAT_to_FLOAT16_expanded) CASE(test_castlike_FLOAT_to_STRING) // no filter CASE(test_castlike_FLOAT_to_STRING_expanded) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_castlike_STRING_to_FLOAT) // no filter CASE(test_castlike_STRING_to_FLOAT_expanded) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_ceil) @@ -375,7 +381,7 @@ CASE(test_compress_negative_axis) CASE(test_concat_1d_axis_0) // no filter CASE(test_concat_1d_axis_negative_1) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_concat_2d_axis_0) @@ -409,19 +415,19 @@ CASE(test_constantofshape_int_shape_zero) CASE(test_constantofshape_int_zeros) // no filter CASE(test_conv_with_autopad_same) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_conv_with_strides_and_asymmetric_padding) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_conv_with_strides_no_padding) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_conv_with_strides_padding) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_convinteger_with_padding) @@ -489,7 +495,7 @@ CASE(test_det_nd) CASE(test_div) // no filter CASE(test_div_bcast) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_div_example) @@ -505,7 +511,7 @@ CASE(test_dropout_default_mask_ratio) CASE(test_dropout_default_old) // no filter CASE(test_dropout_default_ratio) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_dropout_random_old) @@ -629,11 +635,11 @@ CASE(test_globalaveragepool) CASE(test_globalaveragepool_precomputed) // no filter CASE(test_globalmaxpool) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_globalmaxpool_precomputed) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_greater) @@ -743,12 +749,12 @@ CASE(test_log) CASE(test_log_example) // no filter CASE(test_logsoftmax_axis_0) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_OPENCL; SKIP_OPENCL_FP16; #endif CASE(test_logsoftmax_axis_0_expanded) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_OPENCL; SKIP_OPENCL_FP16; #endif @@ -761,7 +767,7 @@ CASE(test_logsoftmax_axis_2) CASE(test_logsoftmax_axis_2_expanded) // no filter CASE(test_logsoftmax_default_axis) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_logsoftmax_default_axis_expanded) @@ -771,12 +777,12 @@ CASE(test_logsoftmax_example_1) CASE(test_logsoftmax_example_1_expanded) // no filter CASE(test_logsoftmax_large_number) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_OPENCL_FP16; SKIP_MYRIAD; #endif CASE(test_logsoftmax_large_number_expanded) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_OPENCL_FP16; SKIP_MYRIAD; #endif @@ -839,67 +845,67 @@ CASE(test_max_uint64) CASE(test_max_uint8) // no filter CASE(test_maxpool_1d_default) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_maxpool_2d_ceil) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_maxpool_2d_default) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_maxpool_2d_dilations) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_maxpool_2d_pads) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_maxpool_2d_precomputed_pads) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_maxpool_2d_precomputed_same_upper) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_maxpool_2d_precomputed_strides) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_maxpool_2d_same_lower) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_maxpool_2d_same_upper) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_maxpool_2d_strides) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_MYRIAD; #endif CASE(test_maxpool_2d_uint8) // no filter CASE(test_maxpool_3d_default) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_NON_CPU; #endif CASE(test_maxpool_with_argmax_2d_precomputed_pads) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_maxpool_with_argmax_2d_precomputed_strides) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_maxunpool_export_with_output_shape) // no filter CASE(test_maxunpool_export_without_output_shape) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_mean_example) @@ -969,7 +975,7 @@ CASE(test_momentum_multiple) CASE(test_mul) // no filter CASE(test_mul_bcast) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_mul_example) @@ -1643,12 +1649,12 @@ CASE(test_slice_negative_axes) CASE(test_slice_start_out_of_bounds) // no filter CASE(test_softmax_axis_0) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_OPENCL; SKIP_OPENCL_FP16; #endif CASE(test_softmax_axis_0_expanded) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_OPENCL; SKIP_OPENCL_FP16; #endif @@ -1661,7 +1667,7 @@ CASE(test_softmax_axis_2) CASE(test_softmax_axis_2_expanded) // no filter CASE(test_softmax_default_axis) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_softmax_default_axis_expanded) @@ -1671,12 +1677,12 @@ CASE(test_softmax_example) CASE(test_softmax_example_expanded) // no filter CASE(test_softmax_large_number) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_OPENCL_FP16; SKIP_MYRIAD; #endif CASE(test_softmax_large_number_expanded) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP_OPENCL_FP16; SKIP_MYRIAD; #endif @@ -1733,7 +1739,7 @@ CASE(test_strnormalizer_nostopwords_nochangecase) CASE(test_sub) // no filter CASE(test_sub_bcast) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_sub_example) @@ -1873,7 +1879,7 @@ CASE(test_unsqueeze_two_axes) CASE(test_unsqueeze_unsorted_axes) // no filter CASE(test_upsample_nearest) -#if INF_ENGINE_VER_MAJOR_EQ(2021040000) +#if SKIP_SET_1 SKIP; #endif CASE(test_where_example) From 2b7803dbacbc487119207016575764aa85f69658 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 15 Feb 2022 11:48:09 +0000 Subject: [PATCH 4/7] imgcodecs: add runtime checks to validate input backport of commit: f9b1dbe2ac3da4ed87647ea27d9060879acc20fe --- modules/imgcodecs/src/grfmt_pam.cpp | 8 ++++++++ modules/imgcodecs/src/grfmt_tiff.cpp | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/modules/imgcodecs/src/grfmt_pam.cpp b/modules/imgcodecs/src/grfmt_pam.cpp index 2a0a5665d3..3b45d8f164 100644 --- a/modules/imgcodecs/src/grfmt_pam.cpp +++ b/modules/imgcodecs/src/grfmt_pam.cpp @@ -470,7 +470,11 @@ bool PAMDecoder::readHeader() selected_fmt = CV_IMWRITE_PAM_FORMAT_GRAYSCALE; else if (m_channels == 3 && m_maxval < 256) selected_fmt = CV_IMWRITE_PAM_FORMAT_RGB; + else + CV_Error(Error::StsError, "Can't determine selected_fmt (IMWRITE_PAM_FORMAT_NULL)"); } + CV_CheckDepth(m_sampledepth, m_sampledepth == CV_8U || m_sampledepth == CV_16U, ""); + CV_Check(m_channels, m_channels >= 1 && m_channels <= 4, "Unsupported number of channels"); m_type = CV_MAKETYPE(m_sampledepth, m_channels); m_offset = m_strm.getPos(); @@ -567,6 +571,10 @@ bool PAMDecoder::readData(Mat& img) FillColorRow1( data, src, m_width, palette ); } } + else + { + CV_Error(Error::StsError, cv::format("Unsupported value of target_channels: %d", target_channels)); + } } else { for (int y = 0; y < m_height; y++, data += imp_stride) { diff --git a/modules/imgcodecs/src/grfmt_tiff.cpp b/modules/imgcodecs/src/grfmt_tiff.cpp index a18ba09897..d6f05f7a65 100644 --- a/modules/imgcodecs/src/grfmt_tiff.cpp +++ b/modules/imgcodecs/src/grfmt_tiff.cpp @@ -145,8 +145,8 @@ bool TiffDecoder::checkSignature( const String& signature ) const int TiffDecoder::normalizeChannelsNumber(int channels) const { - CV_Assert(channels <= 4); - return channels > 4 ? 4 : channels; + CV_Check(channels, channels >= 1 && channels <= 4, "Unsupported number of channels"); + return channels; } ImageDecoder TiffDecoder::newDecoder() const From 0898f372b134caec4576eb3ce8a345e79eebfefc Mon Sep 17 00:00:00 2001 From: Yuriy Chernyshov Date: Fri, 18 Feb 2022 17:57:46 +0300 Subject: [PATCH 5/7] =?UTF-8?q?=D0=90ix=20-Winvalid-noreturn=20under=20cla?= =?UTF-8?q?ng-cl?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/core/include/opencv2/core/base.hpp | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/modules/core/include/opencv2/core/base.hpp b/modules/core/include/opencv2/core/base.hpp index 19d496080c..3abefff2ee 100644 --- a/modules/core/include/opencv2/core/base.hpp +++ b/modules/core/include/opencv2/core/base.hpp @@ -297,37 +297,17 @@ It is possible to alternate error processing by using redirectError(). */ CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line); -#if defined(__clang__) && defined(_MSC_VER) // MSVC-Clang -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Winvalid-noreturn" -#elif defined(__GNUC__) -# if defined __clang__ || defined __APPLE__ -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Winvalid-noreturn" -# endif -#endif - /** same as cv::error, but does not return */ CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const char* _func, const char* _file, int _line) { error(_code, _err, _func, _file, _line); -#ifdef __GNUC__ -# if !defined __clang__ && !defined __APPLE__ +#if defined(__GNUC__) || defined(__clang__) // this suppresses this warning: "noreturn" function does return [enabled by default] __builtin_trap(); // or use infinite loop: for (;;) {} -# endif #endif } -#if defined(__clang__) && defined(_MSC_VER) // MSVC-Clang -# pragma clang diagnostic pop -#elif defined(__GNUC__) -# if defined __clang__ || defined __APPLE__ -# pragma GCC diagnostic pop -# endif -#endif - #ifdef CV_STATIC_ANALYSIS // In practice, some macro are not processed correctly (noreturn is not detected). From 1890157faa99b247cb0ba096c85beed44788e8ba Mon Sep 17 00:00:00 2001 From: Artem Saratovtsev <46279571+DumDereDum@users.noreply.github.com> Date: Fri, 18 Feb 2022 17:58:58 +0300 Subject: [PATCH 6/7] Merge pull request #21635 from DumDereDum:issue_21595_3.4 Issue 21595 fix 3.4 branch * bug fix; add test * rewrite tests avoiding vector in tests --- modules/imgproc/src/histogram.cpp | 3 ++- modules/imgproc/test/test_histograms.cpp | 32 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index e66e2e2d23..404bd43188 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -909,7 +909,8 @@ static bool ipp_calchist(const Mat &image, Mat &hist, int histSize, const float* #endif // IPP_DISABLE_HISTOGRAM - https://github.com/opencv/opencv/issues/11544 - if (uniform && (ranges[0][1] - ranges[0][0]) != histSize) + // and https://github.com/opencv/opencv/issues/21595 + if ((uniform && (ranges[0][1] - ranges[0][0]) != histSize) || abs(ranges[0][0]) != cvFloor(ranges[0][0])) return false; Mat ihist = hist; diff --git a/modules/imgproc/test/test_histograms.cpp b/modules/imgproc/test/test_histograms.cpp index afe6e53603..e3316df026 100644 --- a/modules/imgproc/test/test_histograms.cpp +++ b/modules/imgproc/test/test_histograms.cpp @@ -1993,6 +1993,38 @@ TEST(Imgproc_Hist_Calc, badarg) EXPECT_NO_THROW(cv::calcBackProject(&img, 1, channels, hist, backProj, NULL, 1, true)); } +TEST(Imgproc_Hist_Calc, IPP_ranges_with_equal_exponent_21595) +{ + const int channels[] = { 0 }; + float range1[] = { -0.5f, 1.5f }; + const float* ranges[] = { range1 }; + const int hist_size[] = { 2 }; + + uint8_t m[1][6] = { { 0, 1, 0, 1 , 1, 1 } }; + cv::Mat images_u = Mat(1, 6, CV_8UC1, m); + cv::Mat histogram_u; + cv::calcHist(&images_u, 1, channels, noArray(), histogram_u, 1, hist_size, ranges); + + ASSERT_EQ(histogram_u.at(0), 2.f) << "0 not counts correctly, res: " << histogram_u.at(0); + ASSERT_EQ(histogram_u.at(1), 4.f) << "1 not counts correctly, res: " << histogram_u.at(0); +} + +TEST(Imgproc_Hist_Calc, IPP_ranges_with_nonequal_exponent_21595) +{ + const int channels[] = { 0 }; + float range1[] = { -1.3f, 1.5f }; + const float* ranges[] = { range1 }; + const int hist_size[] = { 3 }; + + uint8_t m[1][6] = { { 0, 1, 0, 1 , 1, 1 } }; + cv::Mat images_u = Mat(1, 6, CV_8UC1, m); + cv::Mat histogram_u; + cv::calcHist(&images_u, 1, channels, noArray(), histogram_u, 1, hist_size, ranges); + + ASSERT_EQ(histogram_u.at(0), 0.f) << "not equal to zero, res: " << histogram_u.at(0); + ASSERT_EQ(histogram_u.at(1), 2.f) << "0 not counts correctly, res: " << histogram_u.at(1); + ASSERT_EQ(histogram_u.at(2), 4.f) << "1 not counts correctly, res: " << histogram_u.at(2); +} }} // namespace /* End Of File */ From 9198e306884f11b5461fa17ff7385d7da775aa01 Mon Sep 17 00:00:00 2001 From: KaurkerDevourer Date: Fri, 11 Feb 2022 14:38:48 +0300 Subject: [PATCH 7/7] Fix DpSeamFinder::hasOnlyOneNeighbor std::lower_bound is linear for set https://en.cppreference.com/w/cpp/algorithm/lower_bound --- modules/stitching/src/seam_finders.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/stitching/src/seam_finders.cpp b/modules/stitching/src/seam_finders.cpp index c8a320dc74..a19f5a6cfc 100644 --- a/modules/stitching/src/seam_finders.cpp +++ b/modules/stitching/src/seam_finders.cpp @@ -554,8 +554,8 @@ void DpSeamFinder::computeGradients(const Mat &image1, const Mat &image2) bool DpSeamFinder::hasOnlyOneNeighbor(int comp) { std::set >::iterator begin, end; - begin = lower_bound(edges_.begin(), edges_.end(), std::make_pair(comp, std::numeric_limits::min())); - end = upper_bound(edges_.begin(), edges_.end(), std::make_pair(comp, std::numeric_limits::max())); + begin = edges_.lower_bound(std::make_pair(comp, std::numeric_limits::min())); + end = edges_.upper_bound(std::make_pair(comp, std::numeric_limits::max())); return ++begin == end; }