Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(4.x) Merge 3.4 #23667

Merged
merged 14 commits into from
May 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/calib3d/src/fisheye.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,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 )
Expand Down
2 changes: 2 additions & 0 deletions modules/core/include/opencv2/core/eigen.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions modules/core/misc/java/gen_dict.json
Original file line number Diff line number Diff line change
Expand Up @@ -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" : {
Expand Down
8 changes: 8 additions & 0 deletions modules/core/misc/java/test/CoreTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -2059,4 +2059,12 @@ public void testVersion() {
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());
}
}
2 changes: 1 addition & 1 deletion modules/core/src/ocl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1611,7 +1611,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;
Expand Down
4 changes: 3 additions & 1 deletion modules/features2d/src/affine_feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ class skewedDetectAndCompute : public ParallelLoopBody
else
mask0 = mask;
pose = Matx23f(1,0,0,
0,1,0);
0,1,0);

if( phi == 0 )
image.copyTo(rotImage);
Expand Down Expand Up @@ -276,6 +276,8 @@ class skewedDetectAndCompute : public ParallelLoopBody
}
if( phi != 0 || tilt != 1 )
warpAffine(mask0, warpedMask, pose, warpedImage.size(), INTER_NEAREST);
else
warpedMask = mask0;
}


Expand Down
22 changes: 22 additions & 0 deletions modules/features2d/test/test_affine_feature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<AffineFeature> 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<KeyPoint> 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
6 changes: 5 additions & 1 deletion modules/imgproc/src/color.simd_helpers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ struct Set<i0, -1, -1>

enum SizePolicy
{
TO_YUV, FROM_YUV, NONE
TO_YUV, FROM_YUV, FROM_UYVY, NONE
};

template< typename VScn, typename VDcn, typename VDepth, SizePolicy sizePolicy = NONE >
Expand Down Expand Up @@ -108,6 +108,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;
Expand Down
2 changes: 1 addition & 1 deletion modules/imgproc/src/color_yuv.dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CV_8U> > h(_src, _dst, dcn);
CvtHelper< Set<2>, Set<3, 4>, Set<CV_8U>, 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);
Expand Down
11 changes: 10 additions & 1 deletion modules/imgproc/test/test_cvtyuv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 5 additions & 4 deletions modules/objdetect/src/qrcode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,18 +571,19 @@ 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<uint8_t>(cvRound(localization_points[i].y))[index + 1];
next_pixel = bin_barcode.ptr<uint8_t>(index_r)[index_c + 1];
if (next_pixel == future_pixel)
{
future_pixel = static_cast<uint8_t>(~future_pixel);
count_test_lines++;
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;
}
Expand Down