opencv_contrib
opencv_contrib copied to clipboard
LSDDetector scale input parameter is useless, can only be set to 2
Detailed description
The LSDDetector::detect function takes in input, among others, the scale parameter, which should be the scale factor used in pyramids generation, according to the documentation (see here)
In fact, the called pyramid generation function pyrDown only accepts half scale destination sizes (see the pyrDown documentation page).
Thus, any scale factor different from 2 passed to the LSDDetector::detect function will result in an assertion failure.
If this input parameter cannot be removed for any reason, it should be at least documented that it can only be set to 2.
Steps to reproduce
This simple code snippet can reproduce the error:
#include <opencv2/line_descriptor.hpp>
int main(int argc, char* argv[])
{
cv::Mat image(320, 240, CV_8UC1, cv::Scalar(0, 0, 0)); // Can be any input image
cv::Ptr<cv::line_descriptor::LSDDetector> det = cv::line_descriptor::LSDDetector::createLSDDetector();
std::vector<cv::line_descriptor::KeyLine> lines;
det->detect(image, lines, 2, 2); // Works
det->detect(image, lines, 3, 2); // Assertion fail
return 0;
}
The exception raised is:
terminating with uncaught exception of type cv::Exception: OpenCV(4.5.5) .../opencv-4.5.5/modules/imgproc/src/pyramids.cpp:759: error: (-215:Assertion failed) ssize.width > 0 && ssize.height > 0 && std::abs(dsize.width*2 - ssize.width) <= 2 && std::abs(dsize.height*2 - ssize.height) <= 2 in function 'pyrDown_'
Issue submission checklist
- [x] I report the issue, it's not a question
- [x] I checked the problem with documentation, FAQ, open issues, answers.opencv.org, Stack Overflow, etc and have not found solution
- [x] I updated to latest OpenCV version and the issue is still there
- [x] There is reproducer code and related data files: videos, images, onnx, etc