Line segment detector crashes when no keylines found?

asked 2016-04-26 04:36:48 -0500

BT gravatar image

updated 2016-04-26 04:38:13 -0500

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: image description 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);
edit retag flag offensive close merge delete

Comments

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.

berak gravatar imageberak ( 2016-04-26 05:04:29 -0500 )edit

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.

BT gravatar imageBT ( 2016-04-26 05:16:43 -0500 )edit
1

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 !)

berak gravatar imageberak ( 2016-04-26 05:30:19 -0500 )edit

thanks for making the issue !

berak gravatar imageberak ( 2016-04-28 00:25:28 -0500 )edit