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

findContours crashes on very large images #7449

Closed
reunanen opened this issue Oct 11, 2016 · 1 comment · Fixed by #7451
Closed

findContours crashes on very large images #7449

reunanen opened this issue Oct 11, 2016 · 1 comment · Fixed by #7451

Comments

@reunanen
Copy link
Contributor

System information (version)
  • OpenCV => 2.4.13 (official binaries)
  • Operating System / Platform => Windows, 64-bit
  • Compiler => Visual Studio 2013, Update 4
Detailed description

Function findContours crashes my program for very large images (e.g. 79925 * 49955), apparently regardless of the image contents.

Steps to reproduce

Code:

cv::Mat largeImage(79925, 49955, CV_8UC1);
largeImage.setTo(0);

// this is not really even needed to reproduce
cv::circle(largeImage, cv::Point(largeImage.cols, largeImage.rows), 1000, 255, CV_FILLED);

std::vector<std::vector<cv::Point>> contours;
cv::findContours(largeImage, contours, cv::RETR_EXTERNAL, cv::CHAIN_APPROX_SIMPLE);

The last line crashes the program. Works great for smaller images (didn't find the exact limit though).

I don't think I'm running out of memory (have multiple gigabytes left), and even if I was, it'd be better to receive an exception of course.

Can anyone reproduce this?

Haven't tried on version 3 yet.

@reunanen
Copy link
Contributor Author

Seems to be coming from here:

The calculation step * (size.height - 1) overflows (the type is int).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants