Merge pull request #16491 from rayonnant14:objdetect_decodeMulti_issue

* fixed issue with Mat reshape in decodeMulti()

* added test for decodeMulti

* used assign
This commit is contained in:
Polina Smolnikova 2020-02-04 19:31:11 +03:00 committed by GitHub
parent 17fe63446f
commit 4e4dfffe06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 1 deletions

View File

@ -2304,7 +2304,8 @@ bool QRCodeDetector::decodeMulti(
CV_Assert((points.size().width % 4) == 0);
vector< vector< Point2f > > src_points ;
Mat qr_points = points.getMat();
for (int i = 0; i < points.size().width ; i += 4)
qr_points = qr_points.reshape(2, 1);
for (int i = 0; i < qr_points.size().width ; i += 4)
{
vector<Point2f> tempMat = qr_points.colRange(i, i + 4);
if (contourArea(tempMat) > 0.0)

View File

@ -481,6 +481,26 @@ INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Close, testing::ValuesIn(qrcode_i
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Monitor, testing::ValuesIn(qrcode_images_monitor));
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Multi, testing::ValuesIn(qrcode_images_multiple));
TEST(Objdetect_QRCode_decodeMulti, decode_regression_16491)
{
#ifdef HAVE_QUIRC
Mat zero_image = Mat::zeros(256, 256, CV_8UC1);
Point corners_[] = {Point(16, 16), Point(128, 16), Point(128, 128), Point(16, 128),
Point(16, 16), Point(128, 16), Point(128, 128), Point(16, 128)};
std::vector<Point> vec_corners;
int array_size = 8;
vec_corners.assign(corners_, corners_ + array_size);
std::vector<cv::String> decoded_info;
std::vector<Mat> straight_barcode;
QRCodeDetector vec_qrcode;
EXPECT_NO_THROW(vec_qrcode.decodeMulti(zero_image, vec_corners, decoded_info, straight_barcode));
Mat mat_corners(2, 4, CV_32SC2, (void*)&vec_corners[0]);
QRCodeDetector mat_qrcode;
EXPECT_NO_THROW(mat_qrcode.decodeMulti(zero_image, mat_corners, decoded_info, straight_barcode));
#endif
}
TEST(Objdetect_QRCode_basic, not_found_qrcode)
{
std::vector<Point> corners;