mirror of
https://github.com/zebrajr/opencv.git
synced 2025-12-06 12:19:50 +01:00
Merge pull request #27837 from jasseeeem:qr-decode-degenerate-quadrilateral-fix
Fix to prevent QR code decoding from throwing exception on degenerate quadrilaterals
This commit is contained in:
commit
0e88b49a53
|
|
@ -2958,7 +2958,12 @@ std::string ImplContour::decode(InputArray in, InputArray points, OutputArray st
|
|||
vector<Point2f> src_points;
|
||||
points.copyTo(src_points);
|
||||
CV_Assert(src_points.size() == 4);
|
||||
CV_CheckGT(contourArea(src_points), 0.0, "Invalid QR code source points");
|
||||
if (contourArea(src_points) <= 0.0)
|
||||
{
|
||||
if (straight_qrcode.needed())
|
||||
straight_qrcode.release();
|
||||
return std::string();
|
||||
}
|
||||
|
||||
QRDecode qrdec(useAlignmentMarkers);
|
||||
qrdec.init(inarr, src_points);
|
||||
|
|
|
|||
|
|
@ -470,7 +470,7 @@ TEST(Objdetect_QRCode_basic, not_found_qrcode)
|
|||
QRCodeDetector qrcode;
|
||||
EXPECT_FALSE(qrcode.detect(zero_image, corners));
|
||||
corners = std::vector<Point>(4);
|
||||
EXPECT_ANY_THROW(qrcode.decode(zero_image, corners, straight_barcode));
|
||||
EXPECT_NO_THROW(qrcode.decode(zero_image, corners, straight_barcode));
|
||||
}
|
||||
|
||||
TEST(Objdetect_QRCode_detect, detect_regression_21287)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user