diff --git a/modules/core/include/opencv2/core/hal/intrin_avx.hpp b/modules/core/include/opencv2/core/hal/intrin_avx.hpp index 09ff566473..979b6163d8 100644 --- a/modules/core/include/opencv2/core/hal/intrin_avx.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_avx.hpp @@ -1390,11 +1390,21 @@ OPENCV_HAL_IMPL_AVX_CHECK_SHORT(v_int16x16) ////////// Other math ///////// /** Some frequent operations **/ +#if CV_FMA3 #define OPENCV_HAL_IMPL_AVX_MULADD(_Tpvec, suffix) \ inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ { return _Tpvec(_mm256_fmadd_##suffix(a.val, b.val, c.val)); } \ inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ - { return _Tpvec(_mm256_fmadd_##suffix(a.val, b.val, c.val)); } \ + { return _Tpvec(_mm256_fmadd_##suffix(a.val, b.val, c.val)); } +#else +#define OPENCV_HAL_IMPL_AVX_MULADD(_Tpvec, suffix) \ + inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm256_add_##suffix(_mm256_mul_##suffix(a.val, b.val), c.val)); } \ + inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm256_add_##suffix(_mm256_mul_##suffix(a.val, b.val), c.val)); } +#endif + +#define OPENCV_HAL_IMPL_AVX_MISC(_Tpvec, suffix) \ inline _Tpvec v_sqrt(const _Tpvec& x) \ { return _Tpvec(_mm256_sqrt_##suffix(x.val)); } \ inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ @@ -1404,6 +1414,8 @@ OPENCV_HAL_IMPL_AVX_CHECK_SHORT(v_int16x16) OPENCV_HAL_IMPL_AVX_MULADD(v_float32x8, ps) OPENCV_HAL_IMPL_AVX_MULADD(v_float64x4, pd) +OPENCV_HAL_IMPL_AVX_MISC(v_float32x8, ps) +OPENCV_HAL_IMPL_AVX_MISC(v_float64x4, pd) inline v_int32x8 v_fma(const v_int32x8& a, const v_int32x8& b, const v_int32x8& c) { diff --git a/modules/core/include/opencv2/core/hal/intrin_avx512.hpp b/modules/core/include/opencv2/core/hal/intrin_avx512.hpp index 75a3bd4b85..d20d6dd1ff 100644 --- a/modules/core/include/opencv2/core/hal/intrin_avx512.hpp +++ b/modules/core/include/opencv2/core/hal/intrin_avx512.hpp @@ -1385,11 +1385,21 @@ inline v_uint64x8 v_popcount(const v_uint64x8& a) { return v_popcount(v_reinte ////////// Other math ///////// /** Some frequent operations **/ +#if CV_FMA3 #define OPENCV_HAL_IMPL_AVX512_MULADD(_Tpvec, suffix) \ inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ { return _Tpvec(_mm512_fmadd_##suffix(a.val, b.val, c.val)); } \ inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ - { return _Tpvec(_mm512_fmadd_##suffix(a.val, b.val, c.val)); } \ + { return _Tpvec(_mm512_fmadd_##suffix(a.val, b.val, c.val)); } +#else +#define OPENCV_HAL_IMPL_AVX512_MULADD(_Tpvec, suffix) \ + inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm512_add_##suffix(_mm512_mul_##suffix(a.val, b.val), c.val)); } \ + inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \ + { return _Tpvec(_mm512_add_##suffix(_mm512_mul_##suffix(a.val, b.val), c.val)); } +#endif + +#define OPENCV_HAL_IMPL_AVX512_MISC(_Tpvec, suffix) \ inline _Tpvec v_sqrt(const _Tpvec& x) \ { return _Tpvec(_mm512_sqrt_##suffix(x.val)); } \ inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \ @@ -1399,6 +1409,8 @@ inline v_uint64x8 v_popcount(const v_uint64x8& a) { return v_popcount(v_reinte OPENCV_HAL_IMPL_AVX512_MULADD(v_float32x16, ps) OPENCV_HAL_IMPL_AVX512_MULADD(v_float64x8, pd) +OPENCV_HAL_IMPL_AVX512_MISC(v_float32x16, ps) +OPENCV_HAL_IMPL_AVX512_MISC(v_float64x8, pd) inline v_int32x16 v_fma(const v_int32x16& a, const v_int32x16& b, const v_int32x16& c) { return a * b + c; } diff --git a/modules/dnn/CMakeLists.txt b/modules/dnn/CMakeLists.txt index c1236c4653..f0f29182db 100644 --- a/modules/dnn/CMakeLists.txt +++ b/modules/dnn/CMakeLists.txt @@ -14,9 +14,6 @@ ocv_add_dispatched_file_force_all("int8layers/layers_common" AVX2 AVX512_SKX) ocv_add_module(dnn opencv_core opencv_imgproc WRAP python java objc js) ocv_option(OPENCV_DNN_OPENCL "Build with OpenCL support" HAVE_OPENCL AND NOT APPLE) -if(HAVE_TENGINE) - add_definitions(-DHAVE_TENGINE=1) -endif() if(OPENCV_DNN_OPENCL AND HAVE_OPENCL) add_definitions(-DCV_OCL4DNN=1) @@ -44,6 +41,10 @@ endif() ocv_cmake_hook_append(INIT_MODULE_SOURCES_opencv_dnn "${CMAKE_CURRENT_LIST_DIR}/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake") +if(HAVE_TENGINE) + add_definitions(-DHAVE_TENGINE=1) +endif() + if(MSVC) add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 ) ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146 diff --git a/modules/dnn/src/caffe/caffe_importer.cpp b/modules/dnn/src/caffe/caffe_importer.cpp index 9cf989f2fc..7fb64c7c0d 100644 --- a/modules/dnn/src/caffe/caffe_importer.cpp +++ b/modules/dnn/src/caffe/caffe_importer.cpp @@ -49,6 +49,7 @@ #include #include #include +#include #include "caffe_io.hpp" #endif @@ -57,8 +58,7 @@ namespace dnn { CV__DNN_INLINE_NS_BEGIN #ifdef HAVE_PROTOBUF -using ::google::protobuf::RepeatedField; -using ::google::protobuf::RepeatedPtrField; +using ::google::protobuf::RepeatedFieldRef; using ::google::protobuf::Message; using ::google::protobuf::Descriptor; using ::google::protobuf::FieldDescriptor; @@ -136,7 +136,7 @@ public: #define SET_UP_FILED(getter, arrayConstr, gtype) \ if (isRepeated) { \ - const RepeatedField &v = refl->GetRepeatedField(msg, field); \ + const RepeatedFieldRef v = refl->GetRepeatedFieldRef(msg, field); \ params.set(name, DictValue::arrayConstr(v.begin(), (int)v.size())); \ } \ else { \ @@ -168,7 +168,7 @@ public: break; case FieldDescriptor::CPPTYPE_STRING: if (isRepeated) { - const RepeatedPtrField &v = refl->GetRepeatedPtrField(msg, field); + const RepeatedFieldRef v = refl->GetRepeatedFieldRef(msg, field); params.set(name, DictValue::arrayString(v.begin(), (int)v.size())); } else { diff --git a/modules/dnn/src/tensorflow/tf_importer.cpp b/modules/dnn/src/tensorflow/tf_importer.cpp index 4010c5ef28..3a2b69747c 100644 --- a/modules/dnn/src/tensorflow/tf_importer.cpp +++ b/modules/dnn/src/tensorflow/tf_importer.cpp @@ -2888,14 +2888,21 @@ DataLayout TFImporter::predictOutputDataLayout(const tensorflow::NodeDef& layer) void TFImporter::populateNet() { - CV_Assert(netBin.ByteSize() || netTxt.ByteSize()); +#if GOOGLE_PROTOBUF_VERSION < 3005000 + size_t netBinSize = saturate_cast(netBin.ByteSize()); + size_t netTxtSize = saturate_cast(netTxt.ByteSize()); +#else + size_t netBinSize = netBin.ByteSizeLong(); + size_t netTxtSize = netTxt.ByteSizeLong(); +#endif + CV_Assert(netBinSize || netTxtSize); CV_LOG_INFO(NULL, "DNN/TF: parsing model" << (netBin.has_versions() ? cv::format(" produced by TF v%d (min_consumer=%d)", (int)netBin.versions().producer(), (int)netBin.versions().min_consumer()) : cv::String(" (N/A version info)")) << ". Number of nodes = " << netBin.node_size() ); - if (netTxt.ByteSize()) + if (netTxtSize) { CV_LOG_INFO(NULL, "DNN/TF: parsing config" << (netTxt.has_versions() ? cv::format(" produced by TF v%d (min_consumer=%d)", (int)netTxt.versions().producer(), (int)netTxt.versions().min_consumer()) : cv::String(" (N/A version info)")) @@ -2924,7 +2931,7 @@ void TFImporter::populateNet() CV_LOG_DEBUG(NULL, "DNN/TF: sortByExecutionOrder(model) => " << netBin.node_size() << " nodes"); } - tensorflow::GraphDef& net = netTxt.ByteSize() != 0 ? netTxt : netBin; + tensorflow::GraphDef& net = netTxtSize != 0 ? netTxt : netBin; int layersSize = net.node_size(); @@ -3027,7 +3034,12 @@ void TFImporter::addPermuteLayer(const int* order, const std::string& permName, void TFImporter::parseNode(const tensorflow::NodeDef& layer) { - tensorflow::GraphDef& net = netTxt.ByteSize() != 0 ? netTxt : netBin; +#if GOOGLE_PROTOBUF_VERSION < 3005000 + size_t netTxtSize = saturate_cast(netTxt.ByteSize()); +#else + size_t netTxtSize = netTxt.ByteSizeLong(); +#endif + tensorflow::GraphDef& net = netTxtSize != 0 ? netTxt : netBin; const std::string& name = layer.name(); const std::string& type = layer.op(); diff --git a/modules/imgproc/doc/colors.markdown b/modules/imgproc/doc/colors.markdown index 47d97a7263..c1c2abfce7 100644 --- a/modules/imgproc/doc/colors.markdown +++ b/modules/imgproc/doc/colors.markdown @@ -151,16 +151,23 @@ sources on the web, primarily from the Charles Poynton site QRDetect::searchHorizontalLines() } } pixels_position.push_back(width_bin_barcode - 1); - for (size_t i = 2; i < pixels_position.size() - 4; i+=2) + for (size_t i = 2; i < pixels_position.size() - 3; i+=2) { test_lines[0] = static_cast(pixels_position[i - 1] - pixels_position[i - 2]); test_lines[1] = static_cast(pixels_position[i ] - pixels_position[i - 1]); diff --git a/modules/objdetect/test/test_qrcode.cpp b/modules/objdetect/test/test_qrcode.cpp index fc55498740..19a9f76260 100644 --- a/modules/objdetect/test/test_qrcode.cpp +++ b/modules/objdetect/test/test_qrcode.cpp @@ -649,6 +649,26 @@ TEST(Objdetect_QRCode_decodeMulti, check_output_parameters_type_19363) #endif } +TEST(Objdetect_QRCode_detect, detect_regression_20882) +{ + const std::string name_current_image = "qrcode_near_the_end.jpg"; + const std::string root = "qrcode/"; + + std::string image_path = findDataFile(root + name_current_image); + Mat src = imread(image_path); + ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path; + + QRCodeDetector qrcode; + std::vector corners; + Mat straight_barcode; + cv::String decoded_info; + EXPECT_TRUE(qrcode.detect(src, corners)); + EXPECT_TRUE(!corners.empty()); +#ifdef HAVE_QUIRC + EXPECT_NO_THROW(qrcode.decode(src, corners, straight_barcode)); +#endif +} + TEST(Objdetect_QRCode_basic, not_found_qrcode) { std::vector corners; diff --git a/modules/videoio/src/cap_dshow.cpp b/modules/videoio/src/cap_dshow.cpp index 175f1d0329..2f2ff51413 100644 --- a/modules/videoio/src/cap_dshow.cpp +++ b/modules/videoio/src/cap_dshow.cpp @@ -93,8 +93,9 @@ Thanks to: #pragma warning(disable: 4995) #endif -#ifdef __MINGW32__ -// MinGW does not understand COM interfaces +#if defined(__clang__) // clang or MSVC clang +#pragma clang diagnostic ignored "-Wnon-virtual-dtor" +#elif defined(__GNUC__) // MinGW #pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #define STRSAFE_NO_DEPRECATE #endif