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 {namespace {
8+
9+ typedef ::perf::TestBaseWithParam< string > Perf_Barcode_multi;
10+ typedef ::perf::TestBaseWithParam< string > Perf_Barcode_single;
11+
12+ PERF_TEST_P_ (Perf_Barcode_multi, detect)
13+ {
14+ const string name_current_image = GetParam ();
15+ const string root = " cv/barcode/multiple/" ;
16+
17+ auto bardet = barcode::BarcodeDetector ();
18+ vector< Point > corners;
19+ string image_path = findDataFile (root + name_current_image);
20+ Mat src = imread (image_path);
21+ ASSERT_FALSE (src.empty ()) << " Can't read image: " << image_path;
22+
23+ cout << src.size << endl;
24+ TEST_CYCLE () ASSERT_TRUE (bardet.detect (src, corners));
25+
26+ SANITY_CHECK_NOTHING ();
27+ }
28+
29+ PERF_TEST_P_ (Perf_Barcode_multi, decode)
30+ {
31+ const string name_current_image = GetParam ();
32+ const string root = " cv/barcode/multiple/" ;
33+
34+ auto bardet = barcode::BarcodeDetector ();
35+ vector<cv::String> decoded_info;
36+ vector<barcode::BarcodeType> decoded_type;
37+ vector< Point > corners;
38+ string image_path = findDataFile (root + name_current_image);
39+
40+ Mat src = imread (image_path);
41+ ASSERT_FALSE (src.empty ()) << " Can't read image: " << image_path;
42+
43+ cout << src.size << endl;
44+ bardet.detect (src, corners);
45+
46+ TEST_CYCLE () ASSERT_TRUE (bardet.decode (src, corners, decoded_info, decoded_type));
47+ SANITY_CHECK_NOTHING ();
48+ }
49+
50+ PERF_TEST_P_ (Perf_Barcode_single, detect)
51+ {
52+ const string name_current_image = GetParam ();
53+ const string root = " cv/barcode/single/" ;
54+ auto bardet = barcode::BarcodeDetector ();
55+ vector< Point > corners;
56+ string image_path = findDataFile (root + name_current_image);
57+ Mat src = imread (image_path);
58+ ASSERT_FALSE (src.empty ()) << " Can't read image: " << image_path;
59+
60+ cout << src.size << endl;
61+ TEST_CYCLE () ASSERT_TRUE (bardet.detect (src, corners));
62+ SANITY_CHECK_NOTHING ();
63+ }
64+
65+ PERF_TEST_P_ (Perf_Barcode_single, decode)
66+ {
67+ const string name_current_image = GetParam ();
68+ const string root = " cv/barcode/single/" ;
69+
70+ auto bardet = barcode::BarcodeDetector ();
71+ vector<cv::String> decoded_info;
72+ vector<barcode::BarcodeType> decoded_type;
73+
74+ string image_path = findDataFile (root + name_current_image);
75+ Mat src = imread (image_path);
76+ ASSERT_FALSE (src.empty ()) << " Can't read image: " << image_path;
77+ vector< Point > corners;
78+
79+ cout << src.size << endl;
80+ bardet.detect (src, corners);
81+
82+ TEST_CYCLE () ASSERT_TRUE (bardet.decode (src, corners, decoded_info, decoded_type));
83+ SANITY_CHECK_NOTHING ();
84+ }
85+
86+ INSTANTIATE_TEST_CASE_P (/* nothing*/ , Perf_Barcode_multi, ::testing::Values(" 4_barcodes.jpg" ));
87+ INSTANTIATE_TEST_CASE_P (/* nothing*/ , Perf_Barcode_single, ::testing::Values(" book.jpg" , " bottle_1.jpg" , " bottle_2.jpg" ));
88+
89+ }} // namespace
0 commit comments