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

imgproc: use double to determine whether the corners points are within src #3778

Merged
merged 1 commit into from
Aug 23, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions modules/face/samples/sample_face_swapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ void divideIntoTriangles(Rect rect, vector<Point2f> &points, vector< vector<int>
pt[0] = Point2f(triangle[0], triangle[1]);
pt[1] = Point2f(triangle[2], triangle[3]);
pt[2] = Point2f(triangle[4], triangle[5]);
if ( rect.contains(pt[0]) && rect.contains(pt[1]) && rect.contains(pt[2])){
// Workaround for https://github.com/opencv/opencv/issues/26016
// To keep its behaviour, pt casts to Point_<int>.
if ( rect.contains(Point_<int>(pt[0])) && rect.contains(Point_<int>(pt[1])) && rect.contains(Point_<int>(pt[2]))){
for(int j = 0; j < 3; j++)
for(size_t k = 0; k < points.size(); k++)
if(abs(pt[j].x - points[k].x) < 1.0 && abs(pt[j].y - points[k].y) < 1)
Expand Down Expand Up @@ -199,4 +201,4 @@ int main( int argc, char** argv)
destroyAllWindows();
}
return 0;
}
}
9 changes: 7 additions & 2 deletions modules/rapid/src/rapid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ static std::vector<int> getSilhoutteVertices(const Size& imsize, const std::vect
Mat_<int> img1(imsize, 0);
Rect img_rect({0, 0}, imsize);
for (int i = 0; i < pts2d.rows; i++) {
if (img_rect.contains(pts2d(i))) {
// Workaround for https://github.com/opencv/opencv/issues/26016
// To keep its behaviour, pts2d casts to Point_<int>.
if (img_rect.contains(Point_<int>(pts2d(i)))) {
img1(pts2d(i)) = i + 1;
}
}
Expand Down Expand Up @@ -132,7 +134,10 @@ static void sampleControlPoints(int num, Contour3DSampler& sampler, const Rect&
auto pt2d = sampler.current2D();

// skip points too close to border
if (!roi.contains(pt2d))
//
// Workaround for https://github.com/opencv/opencv/issues/26016
// To keep its behaviour, pt2d casts to Point_<int>.
if (!roi.contains(Point_<int>(pt2d)))
continue;

opts3d.push_back(sampler.current3D());
Expand Down
4 changes: 3 additions & 1 deletion modules/xfeatures2d/test/test_features2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ class FeatureDetectorUsingMaskTest : public cvtest::BaseTest

for(size_t k=0; k<points.size(); ++k)
{
if ( !whiteArea.contains(points[k]) )
// Workaround for https://github.com/opencv/opencv/issues/26016
// To keep its behaviour, points casts to Point_<int>.
if ( !whiteArea.contains(Point_<int>(points[k])) )
{
ts->printf(cvtest::TS::LOG, "The feature point is outside of the mask.");
ts->set_failed_test_info(cvtest::TS::FAIL_INVALID_OUTPUT);
Expand Down
4 changes: 3 additions & 1 deletion modules/xfeatures2d/test/test_keypoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ class CV_FeatureDetectorKeypointsTest : public cvtest::BaseTest
{
const KeyPoint& kp = keypoints[i];

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