1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470
|
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
//
// Tencent is pleased to support the open source community by making WeChat QRCode available.
// Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
#include "test_precomp.hpp"
#include "opencv2/objdetect.hpp"
namespace opencv_test {
namespace {
std::string qrcode_images_name[] = {
"version_1_down.jpg", /*"version_1_left.jpg", "version_1_right.jpg", "version_1_up.jpg",*/
"version_1_top.jpg",
/*"version_2_down.jpg",*/ "version_2_left.jpg", /*"version_2_right.jpg",*/
"version_2_up.jpg",
"version_2_top.jpg",
"version_3_down.jpg",
"version_3_left.jpg",
/*"version_3_right.jpg",*/ "version_3_up.jpg",
"version_3_top.jpg",
"version_4_down.jpg",
"version_4_left.jpg",
/*"version_4_right.jpg",*/ "version_4_up.jpg",
"version_4_top.jpg",
"version_5_down.jpg",
"version_5_left.jpg",
/*"version_5_right.jpg",*/ "version_5_up.jpg",
"version_5_top.jpg",
"russian.jpg",
"kanji.jpg", /*"link_github_ocv.jpg",*/
"link_ocv.jpg",
"link_wiki_cv.jpg"};
std::string qrcode_images_close[] = {/*"close_1.png",*/ "close_2.png", "close_3.png", "close_4.png",
"close_5.png"};
std::string qrcode_images_monitor[] = {"monitor_1.png", "monitor_2.png", "monitor_3.png",
"monitor_4.png", "monitor_5.png"};
std::string qrcode_images_curved[] = {"curved_1.jpg", /*"curved_2.jpg", "curved_3.jpg",
"curved_4.jpg",*/
"curved_5.jpg", "curved_6.jpg",
/*"curved_7.jpg", "curved_8.jpg"*/};
std::string qrcode_images_multiple[] = {/*"2_qrcodes.png",*/ "3_close_qrcodes.png", /*"3_qrcodes.png",
"4_qrcodes.png", "5_qrcodes.png", "6_qrcodes.png",*/
"7_qrcodes.png"/*, "8_close_qrcodes.png"*/};
typedef testing::TestWithParam<std::string> Objdetect_QRCode;
TEST_P(Objdetect_QRCode, regression) {
const std::string name_current_image = GetParam();
const std::string root = "qrcode/";
std::string image_path = findDataFile(root + name_current_image);
Mat src = imread(image_path, IMREAD_GRAYSCALE);
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
vector<Mat> points;
// can not find the model file
// so we temporarily comment it out
// auto detector = wechat_qrcode::WeChatQRCode(
// findDataFile("detect.prototxt", false), findDataFile("detect.caffemodel", false),
// findDataFile("sr.prototxt", false), findDataFile("sr.caffemodel", false));
auto detector = wechat_qrcode::WeChatQRCode();
auto decoded_info = detector.detectAndDecode(src, points);
const std::string dataset_config = findDataFile(root + "dataset_config.json");
FileStorage file_config(dataset_config, FileStorage::READ);
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
{
FileNode images_list = file_config["test_images"];
size_t images_count = static_cast<size_t>(images_list.size());
ASSERT_GT(images_count, 0u)
<< "Can't find validation data entries in 'test_images': " << dataset_config;
for (size_t index = 0; index < images_count; index++) {
FileNode config = images_list[(int)index];
std::string name_test_image = config["image_name"];
if (name_test_image == name_current_image) {
std::string original_info = config["info"];
string decoded_str;
if (decoded_info.size()) {
decoded_str = decoded_info[0];
}
EXPECT_EQ(decoded_str, original_info);
return; // done
}
}
std::cerr << "Not found results for '" << name_current_image
<< "' image in config file:" << dataset_config << std::endl
<< "Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data."
<< std::endl;
}
}
typedef testing::TestWithParam<std::string> Objdetect_QRCode_Close;
TEST_P(Objdetect_QRCode_Close, regression) {
const std::string name_current_image = GetParam();
const std::string root = "qrcode/close/";
std::string image_path = findDataFile(root + name_current_image);
Mat src = imread(image_path, IMREAD_GRAYSCALE);
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
vector<Mat> points;
// can not find the model file
// so we temporarily comment it out
// auto detector = wechat_qrcode::WeChatQRCode(
// findDataFile("detect.prototxt", false), findDataFile("detect.caffemodel", false),
// findDataFile("sr.prototxt", false), findDataFile("sr.caffemodel", false));
auto detector = wechat_qrcode::WeChatQRCode();
auto decoded_info = detector.detectAndDecode(src, points);
const std::string dataset_config = findDataFile(root + "dataset_config.json");
FileStorage file_config(dataset_config, FileStorage::READ);
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
{
FileNode images_list = file_config["close_images"];
size_t images_count = static_cast<size_t>(images_list.size());
ASSERT_GT(images_count, 0u)
<< "Can't find validation data entries in 'close_images': " << dataset_config;
for (size_t index = 0; index < images_count; index++) {
FileNode config = images_list[(int)index];
std::string name_test_image = config["image_name"];
if (name_test_image == name_current_image) {
std::string original_info = config["info"];
string decoded_str;
if (decoded_info.size()) {
decoded_str = decoded_info[0];
}
EXPECT_EQ(decoded_str, original_info);
return; // done
}
}
std::cerr << "Not found results for '" << name_current_image
<< "' image in config file:" << dataset_config << std::endl
<< "Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data."
<< std::endl;
}
}
typedef testing::TestWithParam<std::string> Objdetect_QRCode_Monitor;
TEST_P(Objdetect_QRCode_Monitor, regression) {
const std::string name_current_image = GetParam();
const std::string root = "qrcode/monitor/";
std::string image_path = findDataFile(root + name_current_image);
Mat src = imread(image_path, IMREAD_GRAYSCALE);
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
vector<Mat> points;
// can not find the model file
// so we temporarily comment it out
// auto detector = wechat_qrcode::WeChatQRCode(
// findDataFile("detect.prototxt", false), findDataFile("detect.caffemodel", false),
// findDataFile("sr.prototxt", false), findDataFile("sr.caffemodel", false));
auto detector = wechat_qrcode::WeChatQRCode();
auto decoded_info = detector.detectAndDecode(src, points);
const std::string dataset_config = findDataFile(root + "dataset_config.json");
FileStorage file_config(dataset_config, FileStorage::READ);
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
{
FileNode images_list = file_config["monitor_images"];
size_t images_count = static_cast<size_t>(images_list.size());
ASSERT_GT(images_count, 0u)
<< "Can't find validation data entries in 'monitor_images': " << dataset_config;
for (size_t index = 0; index < images_count; index++) {
FileNode config = images_list[(int)index];
std::string name_test_image = config["image_name"];
if (name_test_image == name_current_image) {
std::string original_info = config["info"];
string decoded_str;
if (decoded_info.size()) {
decoded_str = decoded_info[0];
}
EXPECT_EQ(decoded_str, original_info);
return; // done
}
}
std::cerr << "Not found results for '" << name_current_image
<< "' image in config file:" << dataset_config << std::endl
<< "Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data."
<< std::endl;
}
}
typedef testing::TestWithParam<std::string> Objdetect_QRCode_Curved;
TEST_P(Objdetect_QRCode_Curved, regression) {
const std::string name_current_image = GetParam();
const std::string root = "qrcode/curved/";
std::string image_path = findDataFile(root + name_current_image);
Mat src = imread(image_path, IMREAD_GRAYSCALE);
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
vector<Mat> points;
// can not find the model file
// so we temporarily comment it out
// auto detector = wechat_qrcode::WeChatQRCode(
// findDataFile("detect.prototxt", false), findDataFile("detect.caffemodel", false),
// findDataFile("sr.prototxt", false), findDataFile("sr.caffemodel", false));
auto detector = wechat_qrcode::WeChatQRCode();
auto decoded_info = detector.detectAndDecode(src, points);
const std::string dataset_config = findDataFile(root + "dataset_config.json");
FileStorage file_config(dataset_config, FileStorage::READ);
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
{
FileNode images_list = file_config["test_images"];
size_t images_count = static_cast<size_t>(images_list.size());
ASSERT_GT(images_count, 0u)
<< "Can't find validation data entries in 'test_images': " << dataset_config;
for (size_t index = 0; index < images_count; index++) {
FileNode config = images_list[(int)index];
std::string name_test_image = config["image_name"];
if (name_test_image == name_current_image) {
std::string original_info = config["info"];
string decoded_str;
if (decoded_info.size()) {
decoded_str = decoded_info[0];
}
EXPECT_EQ(decoded_str, original_info);
return; // done
}
}
std::cerr << "Not found results for '" << name_current_image
<< "' image in config file:" << dataset_config << std::endl
<< "Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data."
<< std::endl;
}
}
typedef testing::TestWithParam<std::string> Objdetect_QRCode_Multi;
TEST_P(Objdetect_QRCode_Multi, regression) {
const std::string name_current_image = GetParam();
const std::string root = "qrcode/multiple/";
string path_detect_prototxt, path_detect_caffemodel, path_sr_prototxt, path_sr_caffemodel;
string model_version = "_2021-01";
path_detect_prototxt = findDataFile("dnn/wechat"+model_version+"/detect.prototxt", false);
path_detect_caffemodel = findDataFile("dnn/wechat"+model_version+"/detect.caffemodel", false);
path_sr_prototxt = findDataFile("dnn/wechat"+model_version+"/sr.prototxt", false);
path_sr_caffemodel = findDataFile("dnn/wechat"+model_version+"/sr.caffemodel", false);
std::string image_path = findDataFile(root + name_current_image);
Mat src = imread(image_path);
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
vector<Mat> points;
auto detector = wechat_qrcode::WeChatQRCode(path_detect_prototxt, path_detect_caffemodel, path_sr_prototxt,
path_sr_caffemodel);
vector<string> decoded_info = detector.detectAndDecode(src, points);
const std::string dataset_config = findDataFile(root + "dataset_config.json");
FileStorage file_config(dataset_config, FileStorage::READ);
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
{
FileNode images_list = file_config["multiple_images"];
size_t images_count = static_cast<size_t>(images_list.size());
ASSERT_GT(images_count, 0u)
<< "Can't find validation data entries in 'test_images': " << dataset_config;
for (size_t index = 0; index < images_count; index++) {
FileNode config = images_list[(int)index];
std::string name_test_image = config["image_name"];
if (name_test_image == name_current_image) {
size_t count_eq_info = 0;
for (int i = 0; i < int(decoded_info.size()); i++) {
for (int j = 0; j < int(config["info"].size()); j++) {
std::string original_info = config["info"][j];
if (original_info == decoded_info[i]) {
count_eq_info++;
break;
}
}
}
EXPECT_EQ(config["info"].size(), count_eq_info);
return; // done
}
}
std::cerr << "Not found results for '" << name_current_image
<< "' image in config file:" << dataset_config << std::endl
<< "Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data."
<< std::endl;
}
}
TEST(Objdetect_QRCode_points_position, rotate45) {
string path_detect_prototxt, path_detect_caffemodel, path_sr_prototxt, path_sr_caffemodel;
string model_version = "_2021-01";
path_detect_prototxt = findDataFile("dnn/wechat"+model_version+"/detect.prototxt", false);
path_detect_caffemodel = findDataFile("dnn/wechat"+model_version+"/detect.caffemodel", false);
path_sr_prototxt = findDataFile("dnn/wechat"+model_version+"/sr.prototxt", false);
path_sr_caffemodel = findDataFile("dnn/wechat"+model_version+"/sr.caffemodel", false);
auto detector = wechat_qrcode::WeChatQRCode(path_detect_prototxt, path_detect_caffemodel, path_sr_prototxt,
path_sr_caffemodel);
const cv::String expect_msg = "OpenCV";
QRCodeEncoder::Params params;
params.version = 5; // 37x37
Ptr<QRCodeEncoder> qrcode_enc = cv::QRCodeEncoder::create(params);
Mat qrImage;
qrcode_enc->encode(expect_msg, qrImage);
Mat image(800, 800, CV_8UC1, Scalar(0));
const int pixInBlob = 4;
Size qrSize = Size((21+(params.version-1)*4)*pixInBlob,(21+(params.version-1)*4)*pixInBlob);
Rect2f rec(static_cast<float>((image.cols - qrSize.width)/2),
static_cast<float>((image.rows - qrSize.height)/2),
static_cast<float>(qrSize.width),
static_cast<float>(qrSize.height));
vector<float> goldCorners = {rec.x, rec.y,
rec.x+rec.width, rec.y,
rec.x+rec.width, rec.y+rec.height,
rec.x, rec.y+rec.height};
Mat roiImage = image(rec);
cv::resize(qrImage, roiImage, qrSize, 1., 1., INTER_NEAREST);
vector<Mat> points1;
auto decoded_info1 = detector.detectAndDecode(image, points1);
ASSERT_EQ(1ull, decoded_info1.size());
ASSERT_EQ(expect_msg, decoded_info1[0]);
EXPECT_NEAR(0, cvtest::norm(Mat(goldCorners), points1[0].reshape(1, 8), NORM_INF), 8.);
const double angle = 45;
Point2f pc(image.cols/2.f, image.rows/2.f);
Mat rot = getRotationMatrix2D(pc, angle, 1.);
warpAffine(image, image, rot, image.size());
vector<float> rotateGoldCorners;
for (int i = 0; i < static_cast<int>(goldCorners.size()); i+= 2) {
rotateGoldCorners.push_back(static_cast<float>(rot.at<double>(0, 0) * goldCorners[i] +
rot.at<double>(0, 1) * goldCorners[i+1] + rot.at<double>(0, 2)));
rotateGoldCorners.push_back(static_cast<float>(rot.at<double>(1, 0) * goldCorners[i] +
rot.at<double>(1, 1) * goldCorners[i+1] + rot.at<double>(1, 2)));
}
vector<Mat> points2;
auto decoded_info2 = detector.detectAndDecode(image, points2);
ASSERT_EQ(1ull, decoded_info2.size());
ASSERT_EQ(expect_msg, decoded_info2[0]);
EXPECT_NEAR(0, cvtest::norm(Mat(rotateGoldCorners), points2[0].reshape(1, 8), NORM_INF), 11.);
}
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode, testing::ValuesIn(qrcode_images_name));
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Close, testing::ValuesIn(qrcode_images_close));
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Monitor, testing::ValuesIn(qrcode_images_monitor));
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Curved, testing::ValuesIn(qrcode_images_curved));
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Multi, testing::ValuesIn(qrcode_images_multiple));
TEST(Objdetect_QRCode_Big, regression) {
string path_detect_prototxt, path_detect_caffemodel, path_sr_prototxt, path_sr_caffemodel;
string model_version = "_2021-01";
path_detect_prototxt = findDataFile("dnn/wechat"+model_version+"/detect.prototxt", false);
path_detect_caffemodel = findDataFile("dnn/wechat"+model_version+"/detect.caffemodel", false);
path_sr_prototxt = findDataFile("dnn/wechat"+model_version+"/sr.prototxt", false);
path_sr_caffemodel = findDataFile("dnn/wechat"+model_version+"/sr.caffemodel", false);
auto detector = wechat_qrcode::WeChatQRCode(path_detect_prototxt, path_detect_caffemodel, path_sr_prototxt,
path_sr_caffemodel);
const cv::String expect_msg = "OpenCV";
QRCodeEncoder::Params params;
params.version = 4; // 33x33
Ptr<QRCodeEncoder> qrcode_enc = cv::QRCodeEncoder::create(params);
Mat qrImage;
qrcode_enc->encode(expect_msg, qrImage);
Mat largeImage(4032, 3024, CV_8UC1, Scalar(0));
const int pixInBlob = 4;
Size qrSize = Size((21+(params.version-1)*4)*pixInBlob,(21+(params.version-1)*4)*pixInBlob);
Mat roiImage = largeImage(Rect((largeImage.cols - qrSize.width)/2, (largeImage.rows - qrSize.height)/2,
qrSize.width, qrSize.height));
cv::resize(qrImage, roiImage, qrSize, 1., 1., INTER_NEAREST);
vector<Mat> points;
detector.setScaleFactor(0.25f);
auto decoded_info = detector.detectAndDecode(largeImage, points);
ASSERT_EQ(1ull, decoded_info.size());
ASSERT_EQ(expect_msg, decoded_info[0]);
}
TEST(Objdetect_QRCode_Tiny, regression) {
string path_detect_prototxt, path_detect_caffemodel, path_sr_prototxt, path_sr_caffemodel;
string model_version = "_2021-01";
path_detect_prototxt = findDataFile("dnn/wechat"+model_version+"/detect.prototxt", false);
path_detect_caffemodel = findDataFile("dnn/wechat"+model_version+"/detect.caffemodel", false);
path_sr_prototxt = findDataFile("dnn/wechat"+model_version+"/sr.prototxt", false);
path_sr_caffemodel = findDataFile("dnn/wechat"+model_version+"/sr.caffemodel", false);
auto detector = wechat_qrcode::WeChatQRCode(path_detect_prototxt, path_detect_caffemodel, path_sr_prototxt,
path_sr_caffemodel);
const cv::String expect_msg = "OpenCV";
QRCodeEncoder::Params params;
params.version = 4; // 33x33
Ptr<QRCodeEncoder> qrcode_enc = cv::QRCodeEncoder::create(params);
Mat qrImage;
qrcode_enc->encode(expect_msg, qrImage);
Mat tinyImage(80, 80, CV_8UC1, Scalar(0));
const int pixInBlob = 2;
Size qrSize = Size((21+(params.version-1)*4)*pixInBlob,(21+(params.version-1)*4)*pixInBlob);
Mat roiImage = tinyImage(Rect((tinyImage.cols - qrSize.width)/2, (tinyImage.rows - qrSize.height)/2,
qrSize.width, qrSize.height));
cv::resize(qrImage, roiImage, qrSize, 1., 1., INTER_NEAREST);
vector<Mat> points;
auto decoded_info = detector.detectAndDecode(tinyImage, points);
ASSERT_EQ(1ull, decoded_info.size());
ASSERT_EQ(expect_msg, decoded_info[0]);
}
typedef testing::TestWithParam<std::string> Objdetect_QRCode_Easy_Multi;
TEST_P(Objdetect_QRCode_Easy_Multi, regression) {
string path_detect_prototxt, path_detect_caffemodel, path_sr_prototxt, path_sr_caffemodel;
string model_path = GetParam();
if (!model_path.empty()) {
path_detect_prototxt = findDataFile(model_path + "/detect.prototxt", false);
path_detect_caffemodel = findDataFile(model_path + "/detect.caffemodel", false);
path_sr_prototxt = findDataFile(model_path + "/sr.prototxt", false);
path_sr_caffemodel = findDataFile(model_path + "/sr.caffemodel", false);
}
auto detector = wechat_qrcode::WeChatQRCode(path_detect_prototxt, path_detect_caffemodel, path_sr_prototxt,
path_sr_caffemodel);
const cv::String expect_msg1 = "OpenCV1", expect_msg2 = "OpenCV2";
QRCodeEncoder::Params params;
params.version = 4; // 33x33
Ptr<QRCodeEncoder> qrcode_enc = cv::QRCodeEncoder::create(params);
Mat qrImage1, qrImage2;
qrcode_enc->encode(expect_msg1, qrImage1);
qrcode_enc->encode(expect_msg2, qrImage2);
const int pixInBlob = 2;
const int offset = 14;
const int qr_size = (params.version - 1) * 4 + 21;
Mat tinyImage = Mat::zeros(qr_size*pixInBlob+offset, (qr_size*pixInBlob+offset)*2, CV_8UC1);
Size qrSize = Size(qrImage1.cols, qrImage1.rows);
Mat roiImage = tinyImage(Rect((tinyImage.cols/2 - qrSize.width)/2, (tinyImage.rows - qrSize.height)/2,
qrSize.width, qrSize.height));
cv::resize(qrImage1, roiImage, qrSize, 1., 1., INTER_NEAREST);
roiImage = tinyImage(Rect((tinyImage.cols/2 - qrSize.width)/2+tinyImage.cols/2, (tinyImage.rows - qrSize.height)/2,
qrSize.width, qrSize.height));
cv::resize(qrImage2, roiImage, qrSize, 1., 1., INTER_NEAREST);
vector<Mat> points;
auto decoded_info = detector.detectAndDecode(tinyImage, points);
ASSERT_EQ(2ull, decoded_info.size());
ASSERT_TRUE((expect_msg1 == decoded_info[0] && expect_msg2 == decoded_info[1]) ||
(expect_msg1 == decoded_info[1] && expect_msg2 == decoded_info[0]));
}
std::string qrcode_model_path[] = {"", "dnn/wechat_2021-01"};
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Easy_Multi, testing::ValuesIn(qrcode_model_path));
TEST(Objdetect_QRCode_bug, issue_3478) {
auto detector = wechat_qrcode::WeChatQRCode();
std::string image_path = findDataFile("qrcode/issue_3478.png");
Mat src = imread(image_path, IMREAD_GRAYSCALE);
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
std::vector<std::string> outs = detector.detectAndDecode(src);
ASSERT_EQ(1, (int) outs.size());
ASSERT_EQ(16, (int) outs[0].size());
ASSERT_EQ("KFCVW50 ", outs[0]);
}
} // namespace
} // namespace opencv_test
|