Merge pull request #20823 from AleksandrPanov:fix_orb_integer_overflow

Fix ORB integer overflow

* set size_t step to fix integer overflow in ptr0 offset

* added issue_537 test

* minor fix tags, points

* added size_t_step and offset to remove mixed unsigned and signed operations

* features2d: update ORB checks

Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
This commit is contained in:
Alexander Panov
2021-10-08 01:46:25 +03:00
committed by GitHub
parent fac895d7ba
commit dfc94c58f0
2 changed files with 34 additions and 3 deletions
+26
View File
@@ -141,5 +141,31 @@ TEST(Features2D_ORB, regression_16197)
ASSERT_NO_THROW(orbPtr->detectAndCompute(img, noArray(), kps, fv));
}
// https://github.com/opencv/opencv-python/issues/537
BIGDATA_TEST(Features2D_ORB, regression_opencv_python_537) // memory usage: ~3 Gb
{
applyTestTag(
CV_TEST_TAG_LONG,
CV_TEST_TAG_DEBUG_VERYLONG,
CV_TEST_TAG_MEMORY_6GB
);
const int width = 25000;
const int height = 25000;
Mat img(Size(width, height), CV_8UC1, Scalar::all(0));
const int border = 23, num_lines = 23;
for (int i = 0; i < num_lines; i++)
{
cv::Point2i point1(border + i * 100, border + i * 100);
cv::Point2i point2(width - border - i * 100, height - border * i * 100);
cv::line(img, point1, point2, 255, 1, LINE_AA);
}
Ptr<ORB> orbPtr = ORB::create(31);
std::vector<KeyPoint> kps;
Mat fv;
ASSERT_NO_THROW(orbPtr->detectAndCompute(img, noArray(), kps, fv));
}
}} // namespace