Line segment detector crashes when no keylines found?
For a particularly small .png image (i.e 200x200) which does not have any keylines, the algorith used to detect them crashes. Both cv::line_descriptor::BinaryDescriptor::createBinaryDescriptor();
and LSDdet = cv::line_descriptor::LSDDetector::createLSDDetector();
detectors. I expected a more graceful behavior, if the only problem is that no keylines are detected. The code fails at line 2475 of binary_descriptor.cpp, with an
Access violation writing location 0x0000000000000000
error. The image producing the error is the following: Note that this is not the only image that produces the exact same error. Can someone please reproduce the problem, and confirm that it is not just mine? Is there something i missed about how to handle the descriptor, or a requirement it might have about image sizes?
Pasting a minimal example that reproduces the error here:
cv::Mat Image = cv::imread("Image filename here", CV_LOAD_IMAGE_COLOR);
std::vector<cv::line_descriptor::KeyLine> keylines;
Ptr<cv::line_descriptor::BinaryDescriptor> LINES = cv::line_descriptor::BinaryDescriptor::createBinaryDescriptor();
LINES->detect(Image, keylines);
i can reproduce the problem, with the BinaryDescriptor, both offsetPFirst and offsetPSecond are 0 in line 2204, thus line 2207 throws a "vector iterator not dereferencable" in DEBUG mode.
probably the prior check in line 2194 should be extended to check for 0 values, too.
Thanks for the prompt answer! now, do we fight this on our own, or declare a bug? I wouldn't want to break more things :P Also (spoiler alert!) similar bugs probably exist in other descriptors, e.g. surf, but i have not confirmed it 100% yet.
well, watch it a bit, maybe someone else has a good idea..
at some point, it will need an issue here: https://github.com/Itseez/opencv_cont...
(if you're able to fix it, dare to make a pr there, too !)
thanks for making the issue !