2023-06-02 21:18:24 +08:00
|
|
|
// 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.
|
|
|
|
#include "test_precomp.hpp"
|
|
|
|
|
|
|
|
namespace opencv_test {
|
|
|
|
|
|
|
|
static inline
|
|
|
|
void check_qr(const string& root, const string& name_current_image, const string& config_name,
|
|
|
|
const std::vector<Point>& corners,
|
|
|
|
const std::vector<string>& decoded_info, const int max_pixel_error,
|
|
|
|
bool isMulti = false) {
|
|
|
|
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[config_name];
|
|
|
|
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) {
|
|
|
|
if (isMulti) {
|
|
|
|
for(int j = 0; j < int(corners.size()); j += 4) {
|
|
|
|
bool ok = false;
|
|
|
|
for (int k = 0; k < int(corners.size() / 4); k++) {
|
|
|
|
int count_eq_points = 0;
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
int x = config["x"][k][i];
|
|
|
|
int y = config["y"][k][i];
|
|
|
|
if(((abs(corners[j + i].x - x)) <= max_pixel_error) && ((abs(corners[j + i].y - y)) <= max_pixel_error))
|
|
|
|
count_eq_points++;
|
|
|
|
}
|
|
|
|
if (count_eq_points == 4) {
|
|
|
|
ok = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPECT_TRUE(ok);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
for (int i = 0; i < (int)corners.size(); i++) {
|
|
|
|
int x = config["x"][i];
|
|
|
|
int y = config["y"][i];
|
|
|
|
EXPECT_NEAR(x, corners[i].x, max_pixel_error);
|
|
|
|
EXPECT_NEAR(y, corners[i].y, max_pixel_error);
|
|
|
|
}
|
|
|
|
}
|
Merge pull request #24299 from dkurt:qrcode_decode
In-house QR codes decoding #24299
### Pull Request Readiness Checklist
QR codes decoding pipeline without 3rdparty dependency (Quirc library). Implemented according to standard https://github.com/yansikeim/QR-Code/blob/master/ISO%20IEC%2018004%202015%20Standard.pdf
**Merge with extra**: https://github.com/opencv/opencv_extra/pull/1124
resolves https://github.com/opencv/opencv/issues/24225
resolves https://github.com/opencv/opencv/issues/17290
resolves https://github.com/opencv/opencv/issues/24318 https://github.com/opencv/opencv/issues/24346
Resources:
* https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders
* https://en.wikipedia.org/wiki/Berlekamp%E2%80%93Massey_algorithm
```
Geometric mean (ms)
Name of Test quirc new2 new2
vs
quirc
(x-factor)
decode::Perf_Objdetect_Not_QRCode::("chessboard", 640x480) 9.151 9.157 1.00
decode::Perf_Objdetect_Not_QRCode::("chessboard", 1280x720) 21.609 21.609 1.00
decode::Perf_Objdetect_Not_QRCode::("chessboard", 1920x1080) 42.088 41.924 1.00
decode::Perf_Objdetect_Not_QRCode::("chessboard", 3840x2160) 169.737 169.050 1.00
decode::Perf_Objdetect_Not_QRCode::("random", 640x480) 8.552 8.611 0.99
decode::Perf_Objdetect_Not_QRCode::("random", 1280x720) 21.264 21.581 0.99
decode::Perf_Objdetect_Not_QRCode::("random", 1920x1080) 42.415 43.468 0.98
decode::Perf_Objdetect_Not_QRCode::("random", 3840x2160) 175.003 174.294 1.00
decode::Perf_Objdetect_Not_QRCode::("zero", 640x480) 8.528 8.421 1.01
decode::Perf_Objdetect_Not_QRCode::("zero", 1280x720) 21.548 21.209 1.02
decode::Perf_Objdetect_Not_QRCode::("zero", 1920x1080) 42.581 42.529 1.00
decode::Perf_Objdetect_Not_QRCode::("zero", 3840x2160) 176.231 174.410 1.01
decode::Perf_Objdetect_QRCode::"kanji.jpg" 6.105 6.072 1.01
decode::Perf_Objdetect_QRCode::"link_github_ocv.jpg" 6.069 6.076 1.00
decode::Perf_Objdetect_QRCode::"link_ocv.jpg" 6.143 6.240 0.98
decode::Perf_Objdetect_QRCode::"link_wiki_cv.jpg" 6.369 6.420 0.99
decode::Perf_Objdetect_QRCode::"russian.jpg" 6.558 6.549 1.00
decode::Perf_Objdetect_QRCode::"version_1_down.jpg" 5.634 5.621 1.00
decode::Perf_Objdetect_QRCode::"version_1_left.jpg" 5.560 5.609 0.99
decode::Perf_Objdetect_QRCode::"version_1_right.jpg" 5.539 5.631 0.98
decode::Perf_Objdetect_QRCode::"version_1_top.jpg" 5.622 5.566 1.01
decode::Perf_Objdetect_QRCode::"version_1_up.jpg" 5.569 5.534 1.01
decode::Perf_Objdetect_QRCode::"version_5_down.jpg" 6.514 6.436 1.01
decode::Perf_Objdetect_QRCode::"version_5_left.jpg" 6.668 6.479 1.03
decode::Perf_Objdetect_QRCode::"version_5_top.jpg" 6.481 6.484 1.00
decode::Perf_Objdetect_QRCode::"version_5_up.jpg" 7.011 6.513 1.08
decodeMulti::Perf_Objdetect_QRCode_Multi::("2_qrcodes.png", "aruco_based") 14.885 15.089 0.99
decodeMulti::Perf_Objdetect_QRCode_Multi::("2_qrcodes.png", "contours_based") 14.896 14.906 1.00
decodeMulti::Perf_Objdetect_QRCode_Multi::("3_close_qrcodes.png", "aruco_based") 6.661 6.663 1.00
decodeMulti::Perf_Objdetect_QRCode_Multi::("3_close_qrcodes.png", "contours_based") 6.614 6.592 1.00
decodeMulti::Perf_Objdetect_QRCode_Multi::("3_qrcodes.png", "aruco_based") 14.814 14.592 1.02
decodeMulti::Perf_Objdetect_QRCode_Multi::("3_qrcodes.png", "contours_based") 15.245 15.135 1.01
decodeMulti::Perf_Objdetect_QRCode_Multi::("4_qrcodes.png", "aruco_based") 10.923 10.881 1.00
decodeMulti::Perf_Objdetect_QRCode_Multi::("4_qrcodes.png", "contours_based") 10.680 10.128 1.05
decodeMulti::Perf_Objdetect_QRCode_Multi::("5_qrcodes.png", "contours_based") 11.788 11.576 1.02
decodeMulti::Perf_Objdetect_QRCode_Multi::("6_qrcodes.png", "aruco_based") 25.887 25.979 1.00
decodeMulti::Perf_Objdetect_QRCode_Multi::("6_qrcodes.png", "contours_based") 26.183 25.627 1.02
decodeMulti::Perf_Objdetect_QRCode_Multi::("7_qrcodes.png", "aruco_based") 32.786 32.253 1.02
decodeMulti::Perf_Objdetect_QRCode_Multi::("7_qrcodes.png", "contours_based") 24.290 24.435 0.99
decodeMulti::Perf_Objdetect_QRCode_Multi::("8_close_qrcodes.png", "aruco_based") 89.696 89.247 1.01
decodeMulti::Perf_Objdetect_QRCode_Multi::("8_close_qrcodes.png", "contours_based") 89.872 89.600 1.00
```
2023-11-24 16:35:36 +08:00
|
|
|
|
2023-06-02 21:18:24 +08:00
|
|
|
if (decoded_info.size() == 0ull)
|
|
|
|
return;
|
|
|
|
if (isMulti) {
|
|
|
|
size_t count_eq_info = 0;
|
|
|
|
for(int i = 0; i < int(decoded_info.size()); i++) {
|
|
|
|
for(int j = 0; j < int(decoded_info.size()); j++) {
|
|
|
|
std::string original_info = config["info"][j];
|
|
|
|
if(original_info == decoded_info[i]) {
|
|
|
|
count_eq_info++;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
EXPECT_EQ(decoded_info.size(), count_eq_info);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
std::string original_info = config["info"];
|
|
|
|
EXPECT_EQ(decoded_info[0], original_info);
|
|
|
|
}
|
Merge pull request #24299 from dkurt:qrcode_decode
In-house QR codes decoding #24299
### Pull Request Readiness Checklist
QR codes decoding pipeline without 3rdparty dependency (Quirc library). Implemented according to standard https://github.com/yansikeim/QR-Code/blob/master/ISO%20IEC%2018004%202015%20Standard.pdf
**Merge with extra**: https://github.com/opencv/opencv_extra/pull/1124
resolves https://github.com/opencv/opencv/issues/24225
resolves https://github.com/opencv/opencv/issues/17290
resolves https://github.com/opencv/opencv/issues/24318 https://github.com/opencv/opencv/issues/24346
Resources:
* https://en.wikiversity.org/wiki/Reed%E2%80%93Solomon_codes_for_coders
* https://en.wikipedia.org/wiki/Berlekamp%E2%80%93Massey_algorithm
```
Geometric mean (ms)
Name of Test quirc new2 new2
vs
quirc
(x-factor)
decode::Perf_Objdetect_Not_QRCode::("chessboard", 640x480) 9.151 9.157 1.00
decode::Perf_Objdetect_Not_QRCode::("chessboard", 1280x720) 21.609 21.609 1.00
decode::Perf_Objdetect_Not_QRCode::("chessboard", 1920x1080) 42.088 41.924 1.00
decode::Perf_Objdetect_Not_QRCode::("chessboard", 3840x2160) 169.737 169.050 1.00
decode::Perf_Objdetect_Not_QRCode::("random", 640x480) 8.552 8.611 0.99
decode::Perf_Objdetect_Not_QRCode::("random", 1280x720) 21.264 21.581 0.99
decode::Perf_Objdetect_Not_QRCode::("random", 1920x1080) 42.415 43.468 0.98
decode::Perf_Objdetect_Not_QRCode::("random", 3840x2160) 175.003 174.294 1.00
decode::Perf_Objdetect_Not_QRCode::("zero", 640x480) 8.528 8.421 1.01
decode::Perf_Objdetect_Not_QRCode::("zero", 1280x720) 21.548 21.209 1.02
decode::Perf_Objdetect_Not_QRCode::("zero", 1920x1080) 42.581 42.529 1.00
decode::Perf_Objdetect_Not_QRCode::("zero", 3840x2160) 176.231 174.410 1.01
decode::Perf_Objdetect_QRCode::"kanji.jpg" 6.105 6.072 1.01
decode::Perf_Objdetect_QRCode::"link_github_ocv.jpg" 6.069 6.076 1.00
decode::Perf_Objdetect_QRCode::"link_ocv.jpg" 6.143 6.240 0.98
decode::Perf_Objdetect_QRCode::"link_wiki_cv.jpg" 6.369 6.420 0.99
decode::Perf_Objdetect_QRCode::"russian.jpg" 6.558 6.549 1.00
decode::Perf_Objdetect_QRCode::"version_1_down.jpg" 5.634 5.621 1.00
decode::Perf_Objdetect_QRCode::"version_1_left.jpg" 5.560 5.609 0.99
decode::Perf_Objdetect_QRCode::"version_1_right.jpg" 5.539 5.631 0.98
decode::Perf_Objdetect_QRCode::"version_1_top.jpg" 5.622 5.566 1.01
decode::Perf_Objdetect_QRCode::"version_1_up.jpg" 5.569 5.534 1.01
decode::Perf_Objdetect_QRCode::"version_5_down.jpg" 6.514 6.436 1.01
decode::Perf_Objdetect_QRCode::"version_5_left.jpg" 6.668 6.479 1.03
decode::Perf_Objdetect_QRCode::"version_5_top.jpg" 6.481 6.484 1.00
decode::Perf_Objdetect_QRCode::"version_5_up.jpg" 7.011 6.513 1.08
decodeMulti::Perf_Objdetect_QRCode_Multi::("2_qrcodes.png", "aruco_based") 14.885 15.089 0.99
decodeMulti::Perf_Objdetect_QRCode_Multi::("2_qrcodes.png", "contours_based") 14.896 14.906 1.00
decodeMulti::Perf_Objdetect_QRCode_Multi::("3_close_qrcodes.png", "aruco_based") 6.661 6.663 1.00
decodeMulti::Perf_Objdetect_QRCode_Multi::("3_close_qrcodes.png", "contours_based") 6.614 6.592 1.00
decodeMulti::Perf_Objdetect_QRCode_Multi::("3_qrcodes.png", "aruco_based") 14.814 14.592 1.02
decodeMulti::Perf_Objdetect_QRCode_Multi::("3_qrcodes.png", "contours_based") 15.245 15.135 1.01
decodeMulti::Perf_Objdetect_QRCode_Multi::("4_qrcodes.png", "aruco_based") 10.923 10.881 1.00
decodeMulti::Perf_Objdetect_QRCode_Multi::("4_qrcodes.png", "contours_based") 10.680 10.128 1.05
decodeMulti::Perf_Objdetect_QRCode_Multi::("5_qrcodes.png", "contours_based") 11.788 11.576 1.02
decodeMulti::Perf_Objdetect_QRCode_Multi::("6_qrcodes.png", "aruco_based") 25.887 25.979 1.00
decodeMulti::Perf_Objdetect_QRCode_Multi::("6_qrcodes.png", "contours_based") 26.183 25.627 1.02
decodeMulti::Perf_Objdetect_QRCode_Multi::("7_qrcodes.png", "aruco_based") 32.786 32.253 1.02
decodeMulti::Perf_Objdetect_QRCode_Multi::("7_qrcodes.png", "contours_based") 24.290 24.435 0.99
decodeMulti::Perf_Objdetect_QRCode_Multi::("8_close_qrcodes.png", "aruco_based") 89.696 89.247 1.01
decodeMulti::Perf_Objdetect_QRCode_Multi::("8_close_qrcodes.png", "contours_based") 89.872 89.600 1.00
```
2023-11-24 16:35:36 +08:00
|
|
|
|
2023-06-02 21:18:24 +08:00
|
|
|
return; // done
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FAIL() << "Not found results for '" << name_current_image << "' image in config file:" << dataset_config <<
|
|
|
|
"Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data.\n";
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|