mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 19:20:28 +08:00
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:
parent
17fe63446f
commit
4e4dfffe06
@ -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)
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user