From 38e35d513746818c50697ac9e6b3c5380e2686cf Mon Sep 17 00:00:00 2001 From: Giles Payne Date: Mon, 24 Apr 2023 22:01:53 +0900 Subject: [PATCH 1/7] Fix ocl::device::isIntel implementation --- modules/core/src/ocl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/src/ocl.cpp b/modules/core/src/ocl.cpp index 91661270a2..4056afd33f 100644 --- a/modules/core/src/ocl.cpp +++ b/modules/core/src/ocl.cpp @@ -1240,7 +1240,7 @@ struct Device::Impl if (vendorName_ == "Advanced Micro Devices, Inc." || vendorName_ == "AMD") vendorID_ = VENDOR_AMD; - else if (vendorName_ == "Intel(R) Corporation" || vendorName_ == "Intel" || strstr(name_.c_str(), "Iris") != 0) + else if (vendorName_ == "Intel(R) Corporation" || vendorName_ == "Intel" || vendorName_ == "Intel Inc." || strstr(name_.c_str(), "Iris") != 0) vendorID_ = VENDOR_INTEL; else if (vendorName_ == "NVIDIA Corporation") vendorID_ = VENDOR_NVIDIA; From 658f18c713ec28e31f345537fb0100c6c9994346 Mon Sep 17 00:00:00 2001 From: Maxim Smolskiy Date: Sun, 30 Apr 2023 17:30:01 +0300 Subject: [PATCH 2/7] Fix function name in comment --- modules/calib3d/src/fisheye.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/calib3d/src/fisheye.cpp b/modules/calib3d/src/fisheye.cpp index 0e9034ca19..b0f0a008c6 100644 --- a/modules/calib3d/src/fisheye.cpp +++ b/modules/calib3d/src/fisheye.cpp @@ -421,7 +421,7 @@ void cv::fisheye::undistortPoints( InputArray distorted, OutputArray undistorted } ////////////////////////////////////////////////////////////////////////////////////////////////////////////// -/// cv::fisheye::undistortPoints +/// cv::fisheye::initUndistortRectifyMap void cv::fisheye::initUndistortRectifyMap( InputArray K, InputArray D, InputArray R, InputArray P, const cv::Size& size, int m1type, OutputArray map1, OutputArray map2 ) From 05084aa63ee970b20e1c47d9f09396755c93a91b Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Tue, 16 May 2023 18:04:09 +0300 Subject: [PATCH 3/7] Restored Java bindings for CPU features management. --- modules/core/misc/java/gen_dict.json | 5 +---- modules/core/misc/java/test/CoreTest.java | 8 ++++++++ 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/modules/core/misc/java/gen_dict.json b/modules/core/misc/java/gen_dict.json index 36b2c58e58..d1267408da 100644 --- a/modules/core/misc/java/gen_dict.json +++ b/modules/core/misc/java/gen_dict.json @@ -122,10 +122,7 @@ "}", "\n" ] - }, - "checkHardwareSupport" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] }, - "setUseOptimized" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] }, - "useOptimized" : {"j_code" : [""], "jn_code" : [""], "cpp_code" : [""] } + } } }, "func_arg_fix" : { diff --git a/modules/core/misc/java/test/CoreTest.java b/modules/core/misc/java/test/CoreTest.java index 42c343b2ba..c63cb23fab 100644 --- a/modules/core/misc/java/test/CoreTest.java +++ b/modules/core/misc/java/test/CoreTest.java @@ -2059,4 +2059,12 @@ public class CoreTest extends OpenCVTestCase { assertEquals(Core.VERSION, Core.getVersionString()); } + public void testHardwareOptions() { + Core.checkHardwareSupport(0); + boolean original_status = Core.useOptimized(); + Core.setUseOptimized(!original_status); + assertEquals(!original_status, Core.useOptimized()); + Core.setUseOptimized(original_status); + assertEquals(original_status, Core.useOptimized()); + } } From 4eec73962410e171a5458bf7f413e5274cddebf4 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 17 May 2023 10:12:02 +0300 Subject: [PATCH 4/7] Build warning fix on Windows for Eigen wrapper. --- modules/core/include/opencv2/core/eigen.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/core/include/opencv2/core/eigen.hpp b/modules/core/include/opencv2/core/eigen.hpp index 51f41474bd..f176409cc3 100644 --- a/modules/core/include/opencv2/core/eigen.hpp +++ b/modules/core/include/opencv2/core/eigen.hpp @@ -52,7 +52,9 @@ #include "opencv2/core.hpp" #if defined _MSC_VER && _MSC_VER >= 1200 +#ifndef NOMINMAX #define NOMINMAX // fix https://github.com/opencv/opencv/issues/17548 +#endif #pragma warning( disable: 4714 ) //__forceinline is not inlined #pragma warning( disable: 4127 ) //conditional expression is constant #pragma warning( disable: 4244 ) //conversion from '__int64' to 'int', possible loss of data From ae8c90301ff93f64fd6d5a0f0399b51e70996eb0 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 17 May 2023 11:02:01 +0300 Subject: [PATCH 5/7] Fixed mask handling in AffineFeature. --- modules/features2d/src/affine_feature.cpp | 4 +++- .../features2d/test/test_affine_feature.cpp | 22 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/modules/features2d/src/affine_feature.cpp b/modules/features2d/src/affine_feature.cpp index 40e03e92ba..5d19d6c6c3 100644 --- a/modules/features2d/src/affine_feature.cpp +++ b/modules/features2d/src/affine_feature.cpp @@ -243,7 +243,7 @@ private: else mask0 = mask; pose = Matx23f(1,0,0, - 0,1,0); + 0,1,0); if( phi == 0 ) image.copyTo(rotImage); @@ -276,6 +276,8 @@ private: } if( phi != 0 || tilt != 1 ) warpAffine(mask0, warpedMask, pose, warpedImage.size(), INTER_NEAREST); + else + warpedMask = mask0; } diff --git a/modules/features2d/test/test_affine_feature.cpp b/modules/features2d/test/test_affine_feature.cpp index f40f21ed8d..75885bd751 100644 --- a/modules/features2d/test/test_affine_feature.cpp +++ b/modules/features2d/test/test_affine_feature.cpp @@ -182,4 +182,26 @@ TEST(Features2d_AFFINE_FEATURE, regression) #endif } +TEST(Features2d_AFFINE_FEATURE, mask) +{ + Mat gray = imread(cvtest::findDataFile("features2d/tsukuba.png"), IMREAD_GRAYSCALE); + ASSERT_FALSE(gray.empty()) << "features2d/tsukuba.png image was not found in test data!"; + + // small tilt range to limit internal mask warping + Ptr ext = AffineFeature::create(SIFT::create(), 1, 0); + Mat mask = Mat::zeros(gray.size(), CV_8UC1); + mask(Rect(50, 50, mask.cols-100, mask.rows-100)).setTo(255); + + // calc and compare keypoints + vector calcKeypoints; + ext->detectAndCompute(gray, mask, calcKeypoints, noArray(), false); + + // added expanded test range to cover sub-pixel coordinates for features on mask border + for( size_t i = 0; i < calcKeypoints.size(); i++ ) + { + ASSERT_TRUE((calcKeypoints[i].pt.x >= 50-1) && (calcKeypoints[i].pt.x <= mask.cols-50+1)); + ASSERT_TRUE((calcKeypoints[i].pt.y >= 50-1) && (calcKeypoints[i].pt.y <= mask.rows-50+1)); + } +} + }} // namespace From d00a96315e74245afd28be0a11f671be60c74d4a Mon Sep 17 00:00:00 2001 From: Christine Poerschke Date: Mon, 22 May 2023 11:34:30 +0100 Subject: [PATCH 6/7] Merge pull request #23612 from cpoerschke:3.4-issue-21532 QRCodeDetector: don't floodFill with outside-of-image seedPoint #23612 Fixes #21532. ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [X] I agree to contribute to the project under Apache 2 License. - [X] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [X] The PR is proposed to the proper branch - [X] There is a reference to the original bug report and related work - [ ] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [ ] The feature is well documented and sample code can be built with the project CMake --- modules/objdetect/src/qrcode.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/modules/objdetect/src/qrcode.cpp b/modules/objdetect/src/qrcode.cpp index 0a4ac5a80c..debdb4ca24 100644 --- a/modules/objdetect/src/qrcode.cpp +++ b/modules/objdetect/src/qrcode.cpp @@ -570,10 +570,11 @@ bool QRDetect::computeTransformationPoints() { Mat mask = Mat::zeros(bin_barcode.rows + 2, bin_barcode.cols + 2, CV_8UC1); uint8_t next_pixel, future_pixel = 255; - int count_test_lines = 0, index = cvRound(localization_points[i].x); - for (; index < bin_barcode.cols - 1; index++) + int count_test_lines = 0, index_c = max(0, min(cvRound(localization_points[i].x), bin_barcode.cols - 1)); + const int index_r = max(0, min(cvRound(localization_points[i].y), bin_barcode.rows - 1)); + for (; index_c < bin_barcode.cols - 1; index_c++) { - next_pixel = bin_barcode.ptr(cvRound(localization_points[i].y))[index + 1]; + next_pixel = bin_barcode.ptr(index_r)[index_c + 1]; if (next_pixel == future_pixel) { future_pixel = static_cast(~future_pixel); @@ -581,7 +582,7 @@ bool QRDetect::computeTransformationPoints() if (count_test_lines == 2) { floodFill(bin_barcode, mask, - Point(index + 1, cvRound(localization_points[i].y)), 255, + Point(index_c + 1, index_r), 255, 0, Scalar(), Scalar(), FLOODFILL_MASK_ONLY); break; } From 98d678c2d20f54233814255c79afab06fe6f05a7 Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Mon, 22 May 2023 15:28:57 +0300 Subject: [PATCH 7/7] Added check that YUYV input of cvtColor has even width. --- modules/imgproc/src/color.simd_helpers.hpp | 6 +++++- modules/imgproc/src/color_yuv.dispatch.cpp | 2 +- modules/imgproc/test/test_cvtyuv.cpp | 11 ++++++++++- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/modules/imgproc/src/color.simd_helpers.hpp b/modules/imgproc/src/color.simd_helpers.hpp index 343491f2c6..3d457d5d14 100644 --- a/modules/imgproc/src/color.simd_helpers.hpp +++ b/modules/imgproc/src/color.simd_helpers.hpp @@ -72,7 +72,7 @@ struct Set enum SizePolicy { - TO_YUV, FROM_YUV, NONE + TO_YUV, FROM_YUV, FROM_UYVY, NONE }; template< typename VScn, typename VDcn, typename VDepth, SizePolicy sizePolicy = NONE > @@ -104,6 +104,10 @@ struct CvtHelper CV_Assert( sz.width % 2 == 0 && sz.height % 3 == 0); dstSz = Size(sz.width, sz.height * 2 / 3); break; + case FROM_UYVY: + CV_Assert( sz.width % 2 == 0); + dstSz = sz; + break; case NONE: default: dstSz = sz; diff --git a/modules/imgproc/src/color_yuv.dispatch.cpp b/modules/imgproc/src/color_yuv.dispatch.cpp index cac4fa1b41..559005e07f 100644 --- a/modules/imgproc/src/color_yuv.dispatch.cpp +++ b/modules/imgproc/src/color_yuv.dispatch.cpp @@ -354,7 +354,7 @@ void cvtColorYUV2BGR(InputArray _src, OutputArray _dst, int dcn, bool swapb, boo void cvtColorOnePlaneYUV2BGR( InputArray _src, OutputArray _dst, int dcn, bool swapb, int uidx, int ycn) { - CvtHelper< Set<2>, Set<3, 4>, Set > h(_src, _dst, dcn); + CvtHelper< Set<2>, Set<3, 4>, Set, FROM_UYVY > h(_src, _dst, dcn); hal::cvtOnePlaneYUVtoBGR(h.src.data, h.src.step, h.dst.data, h.dst.step, h.src.cols, h.src.rows, dcn, swapb, uidx, ycn); diff --git a/modules/imgproc/test/test_cvtyuv.cpp b/modules/imgproc/test/test_cvtyuv.cpp index 2a2f72ffe2..cb49baab0a 100644 --- a/modules/imgproc/test/test_cvtyuv.cpp +++ b/modules/imgproc/test/test_cvtyuv.cpp @@ -724,4 +724,13 @@ INSTANTIATE_TEST_CASE_P(cvt422, Imgproc_ColorYUV, (int)COLOR_YUV2RGBA_YUY2, (int)COLOR_YUV2BGRA_YUY2, (int)COLOR_YUV2RGBA_YVYU, (int)COLOR_YUV2BGRA_YVYU, (int)COLOR_YUV2GRAY_UYVY, (int)COLOR_YUV2GRAY_YUY2)); -}} // namespace +} + +TEST(cvtColorUYVY, size_issue_21035) +{ + Mat input = Mat::zeros(1, 1, CV_8UC2); + Mat output; + EXPECT_THROW(cv::cvtColor(input, output, cv::COLOR_YUV2BGR_UYVY), cv::Exception); +} + +} // namespace