QRCodeDetector::decodeMulti() fixed invalid usage fixedType()#19407
QRCodeDetector::decodeMulti() fixed invalid usage fixedType()#19407alalek merged 4 commits intoopencv:3.4from
Conversation
modules/objdetect/src/qrcode.cpp
Outdated
| vector<Mat> tmp_straight_qrcodes; | ||
| if (straight_qrcode.needed()) | ||
| if (straight_qrcode.needed() && | ||
| (straight_barcode.size() > 0)) |
There was a problem hiding this comment.
straight_barcode.size() > 0
if (straight_qrcode.needed() && straight_barcode.size() == 0)
{
straight_qrcode.release()
}
else if (...)
modules/objdetect/src/qrcode.cpp
Outdated
| ((OutputArray)tmp_straight_qrcodes[i]).type() : CV_32FC2); | ||
| straight_barcode[i].convertTo(tmp_straight_qrcodes[i], | ||
| straight_qrcode.fixedType() ? | ||
| straight_qrcode.type() : CV_32FC2); |
There was a problem hiding this comment.
CV_32FC2
What is stored here?
Documentation says:
The optional output vector of images containing rectified and binarized QR codes
The optional output image containing rectified and binarized QR code
What is about simple tests for checking output parameter types?
There was a problem hiding this comment.
binarized
https://en.wikipedia.org/wiki/Binary_image
Why do we need floating point type here? 8UC1 is enough.
changed default barcode type to CV_8UC1 added tests added assert in case multi channel straight barcode input
dc3211f to
57e0eb1
Compare
modules/objdetect/src/qrcode.cpp
Outdated
| qrdec.getStraightBarcode().convertTo(straight_qrcode, | ||
| straight_qrcode.fixedType() ? | ||
| straight_qrcode.type() : CV_32FC2); | ||
| straight_qrcode.type() : CV_8UC1); |
There was a problem hiding this comment.
Perhaps we should ignore this .fixedType() check and force 8UC1 only.
Exception would be raised in case of type mismatch (by convertTo).
The assertion check above about channels is not necessary too.
There was a problem hiding this comment.
@alalek convertTo isn't raise a exception in case type or channel number mismatch, but there will be exception later Mat::type() == traits::Type<_Tp>::value if we don't use .fixedType() check.
By this reason, it is better to continue use assertion check about channels number and .fixedType() check
modules/objdetect/src/qrcode.cpp
Outdated
| } | ||
| straight_qrcode.createSameSize(tmp_straight_qrcodes, CV_32FC2); | ||
| straight_qrcode.create(OutputArray(tmp_straight_qrcodes).size(), | ||
| OutputArray(tmp_straight_qrcodes).type()); |
There was a problem hiding this comment.
OutputArray(tmp_straight_qrcodes)
No need to wrap into OutputArray.
You already have all necessary values.
Merge with extra: opencv/opencv_extra#845
fix #19363
Pull Request Readiness Checklist
See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.