Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/objdetect/perf/perf_qrcode_pipeline.cpp
16339 views
1
// This file is part of OpenCV project.
2
// It is subject to the license terms in the LICENSE file found in the top-level directory
3
// of this distribution and at http://opencv.org/license.html.
4
5
#include "perf_precomp.hpp"
6
7
namespace opencv_test
8
{
9
namespace
10
{
11
12
typedef ::perf::TestBaseWithParam< std::string > Perf_Objdetect_QRCode;
13
14
PERF_TEST_P_(Perf_Objdetect_QRCode, detect)
15
{
16
const std::string name_current_image = GetParam();
17
const std::string root = "cv/qrcode/";
18
19
std::string image_path = findDataFile(root + name_current_image);
20
Mat src = imread(image_path, IMREAD_GRAYSCALE), straight_barcode;
21
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
22
23
std::vector< Point > corners;
24
TEST_CYCLE() ASSERT_TRUE(detectQRCode(src, corners));
25
SANITY_CHECK(corners);
26
}
27
28
#ifdef HAVE_QUIRC
29
PERF_TEST_P_(Perf_Objdetect_QRCode, decode)
30
{
31
const std::string name_current_image = GetParam();
32
const std::string root = "cv/qrcode/";
33
34
std::string image_path = findDataFile(root + name_current_image);
35
Mat src = imread(image_path, IMREAD_GRAYSCALE), straight_barcode;
36
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
37
38
std::vector< Point > corners;
39
std::string decoded_info;
40
ASSERT_TRUE(detectQRCode(src, corners));
41
TEST_CYCLE() ASSERT_TRUE(decodeQRCode(src, corners, decoded_info, straight_barcode));
42
43
std::vector<uint8_t> decoded_info_uint8_t(decoded_info.begin(), decoded_info.end());
44
SANITY_CHECK(decoded_info_uint8_t);
45
SANITY_CHECK(straight_barcode);
46
47
}
48
#endif
49
50
INSTANTIATE_TEST_CASE_P(/*nothing*/, Perf_Objdetect_QRCode,
51
::testing::Values(
52
"version_1_down.jpg", "version_1_left.jpg", "version_1_right.jpg", "version_1_up.jpg", "version_1_top.jpg",
53
"version_5_down.jpg", "version_5_left.jpg", "version_5_right.jpg", "version_5_up.jpg", "version_5_top.jpg",
54
"russian.jpg", "kanji.jpg", "link_github_ocv.jpg", "link_ocv.jpg", "link_wiki_cv.jpg"
55
)
56
);
57
58
typedef ::perf::TestBaseWithParam< tuple< std::string, Size > > Perf_Objdetect_Not_QRCode;
59
60
PERF_TEST_P_(Perf_Objdetect_Not_QRCode, detect)
61
{
62
std::vector<Point> corners;
63
std::string type_gen = get<0>(GetParam());
64
Size resolution = get<1>(GetParam());
65
Mat not_qr_code(resolution, CV_8UC1, Scalar(0));
66
if (type_gen == "random")
67
{
68
RNG rng;
69
rng.fill(not_qr_code, RNG::UNIFORM, Scalar(0), Scalar(1));
70
}
71
72
TEST_CYCLE() ASSERT_FALSE(detectQRCode(not_qr_code, corners));
73
SANITY_CHECK_NOTHING();
74
}
75
76
#ifdef HAVE_QUIRC
77
PERF_TEST_P_(Perf_Objdetect_Not_QRCode, decode)
78
{
79
Mat straight_barcode;
80
std::string decoded_info;
81
std::vector< Point > corners;
82
corners.push_back(Point( 0, 0)); corners.push_back(Point( 0, 5));
83
corners.push_back(Point(10, 0)); corners.push_back(Point(15, 15));
84
85
std::string type_gen = get<0>(GetParam());
86
Size resolution = get<1>(GetParam());
87
Mat not_qr_code(resolution, CV_8UC1, Scalar(0));
88
if (type_gen == "random")
89
{
90
RNG rng;
91
rng.fill(not_qr_code, RNG::UNIFORM, Scalar(0), Scalar(1));
92
}
93
94
TEST_CYCLE() ASSERT_FALSE(decodeQRCode(not_qr_code, corners, decoded_info, straight_barcode));
95
SANITY_CHECK_NOTHING();
96
}
97
#endif
98
99
INSTANTIATE_TEST_CASE_P(/*nothing*/, Perf_Objdetect_Not_QRCode,
100
::testing::Combine(
101
::testing::Values("zero", "random"),
102
::testing::Values(Size(640, 480), Size(1280, 720), Size(1920, 1080))
103
));
104
105
}
106
} // namespace
107
108