Skip to content

Commit 94cda4b

Browse files
authored
Merge pull request #3778 from Kumataro:fix26016
imgproc: use double to determine whether the corners points are within src
2 parents 2413f86 + b1c2e4b commit 94cda4b

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

modules/face/samples/sample_face_swapping.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ void divideIntoTriangles(Rect rect, vector<Point2f> &points, vector< vector<int>
4747
pt[0] = Point2f(triangle[0], triangle[1]);
4848
pt[1] = Point2f(triangle[2], triangle[3]);
4949
pt[2] = Point2f(triangle[4], triangle[5]);
50-
if ( rect.contains(pt[0]) && rect.contains(pt[1]) && rect.contains(pt[2])){
50+
// Workaround for https://github.com/opencv/opencv/issues/26016
51+
// To keep its behaviour, pt casts to Point_<int>.
52+
if ( rect.contains(Point_<int>(pt[0])) && rect.contains(Point_<int>(pt[1])) && rect.contains(Point_<int>(pt[2]))){
5153
for(int j = 0; j < 3; j++)
5254
for(size_t k = 0; k < points.size(); k++)
5355
if(abs(pt[j].x - points[k].x) < 1.0 && abs(pt[j].y - points[k].y) < 1)
@@ -199,4 +201,4 @@ int main( int argc, char** argv)
199201
destroyAllWindows();
200202
}
201203
return 0;
202-
}
204+
}

modules/rapid/src/rapid.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ static std::vector<int> getSilhoutteVertices(const Size& imsize, const std::vect
1616
Mat_<int> img1(imsize, 0);
1717
Rect img_rect({0, 0}, imsize);
1818
for (int i = 0; i < pts2d.rows; i++) {
19-
if (img_rect.contains(pts2d(i))) {
19+
// Workaround for https://github.com/opencv/opencv/issues/26016
20+
// To keep its behaviour, pts2d casts to Point_<int>.
21+
if (img_rect.contains(Point_<int>(pts2d(i)))) {
2022
img1(pts2d(i)) = i + 1;
2123
}
2224
}
@@ -132,7 +134,10 @@ static void sampleControlPoints(int num, Contour3DSampler& sampler, const Rect&
132134
auto pt2d = sampler.current2D();
133135

134136
// skip points too close to border
135-
if (!roi.contains(pt2d))
137+
//
138+
// Workaround for https://github.com/opencv/opencv/issues/26016
139+
// To keep its behaviour, pt2d casts to Point_<int>.
140+
if (!roi.contains(Point_<int>(pt2d)))
136141
continue;
137142

138143
opts3d.push_back(sampler.current3D());

modules/xfeatures2d/test/test_features2d.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,9 @@ class FeatureDetectorUsingMaskTest : public cvtest::BaseTest
438438

439439
for(size_t k=0; k<points.size(); ++k)
440440
{
441-
if ( !whiteArea.contains(points[k]) )
441+
// Workaround for https://github.com/opencv/opencv/issues/26016
442+
// To keep its behaviour, points casts to Point_<int>.
443+
if ( !whiteArea.contains(Point_<int>(points[k])) )
442444
{
443445
ts->printf(cvtest::TS::LOG, "The feature point is outside of the mask.");
444446
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);

modules/xfeatures2d/test/test_keypoints.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,9 @@ class CV_FeatureDetectorKeypointsTest : public cvtest::BaseTest
8686
{
8787
const KeyPoint& kp = keypoints[i];
8888

89-
if(!r.contains(kp.pt))
89+
// Workaround for https://github.com/opencv/opencv/issues/26016
90+
// To keep its behaviour, kp.pt casts to Point_<int>.
91+
if(!r.contains(Point_<int>(kp.pt)))
9092
{
9193
ts->printf(cvtest::TS::LOG, "KeyPoint::pt is out of image (x=%f, y=%f).\n", kp.pt.x, kp.pt.y);
9294
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);

0 commit comments

Comments
 (0)