mirror of
https://github.com/zebrajr/opencv.git
synced 2025-12-06 00:19:46 +01:00
Merge pull request #27476 from s-trinh:LSD_drawSegments_avoid_exception_empty_vec
Check for empty vector to avoid throwing an exception in LineSegmentDetectorImpl::drawSegments()
This commit is contained in:
commit
e392b3843e
|
|
@ -1076,6 +1076,10 @@ void LineSegmentDetectorImpl::drawSegments(InputOutputArray _image, InputArray l
|
|||
}
|
||||
|
||||
Mat _lines = lines.getMat();
|
||||
if (_lines.empty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
const int N = _lines.checkVector(4);
|
||||
|
||||
CV_Assert(_lines.depth() == CV_32F || _lines.depth() == CV_32S);
|
||||
|
|
|
|||
|
|
@ -402,4 +402,18 @@ TEST_F(Imgproc_LSD_Common, compareSegmentsVec4i)
|
|||
ASSERT_EQ(result2, 11);
|
||||
}
|
||||
|
||||
TEST_F(Imgproc_LSD_Common, drawSegmentsEmpty)
|
||||
{
|
||||
Ptr<LineSegmentDetector> detector = createLineSegmentDetector(LSD_REFINE_STD);
|
||||
Mat1b img = Mat1b::zeros(240, 320);
|
||||
|
||||
std::vector<Vec4i> lines_4i;
|
||||
detector->detect(img, lines_4i);
|
||||
|
||||
Mat3b img_color = Mat3b::zeros(240, 320);
|
||||
ASSERT_NO_THROW(
|
||||
detector->drawSegments(img_color, lines_4i);
|
||||
);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user