Ocean
TestLegacyQRCodeDetector2D.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #pragma once
9 
11 
13 
15 
18 
19 #ifdef OCEAN_USE_LOCAL_TEST_DATA_COLLECTION
20  #ifndef OCEAN_USE_TEST_DATA_COLLECTION
21  #define OCEAN_USE_TEST_DATA_COLLECTION
22  #endif
23 #endif // OCEAN_USE_LOCAL_TEST_DATA_COLLECTION
24 
25 namespace Ocean
26 {
27 
28 namespace Test
29 {
30 
31 namespace TestCV
32 {
33 
34 namespace TestDetector
35 {
36 
37 namespace TestQRCodes
38 {
39 
40 /**
41  * This class implements a test for the QR code detector.
42  * @ingroup testcvdetectorqrcodes
43  */
44 class OCEAN_TEST_CV_DETECTOR_QRCODES_EXPORT TestLegacyQRCodeDetector2D : protected CV::Detector::QRCodes::LegacyQRCodeDetector2D
45 {
46  public:
47 
48  /**
49  * This class implements a test data collection based on local files.
50  */
52  {
53  public:
54 
55  /**
56  * Creates a new test data collection object.
57  * @param imageFilenames The filenames of all local images which will be part of the test collection
58  */
59  explicit FileDataCollection(std::vector<std::string>&& imageFilenames);
60 
61  /**
62  * Returns the test data object associated with a specified index.
63  * @see TestDataCollection::data().
64  */
65  SharedTestData data(const size_t index) override;
66 
67  /**
68  * Returns the number of data object objects this collection holds.
69  * @see TestDataCollection::size().
70  */
71  size_t size() override;
72 
73  protected:
74 
75  /// The filenames of all local images belonging to this test collection.
76  std::vector<std::string> filenames_;
77  };
78 
79  public:
80 
81  /**
82  * Invokes all test for the QR code detector.
83  * @param testDuration Number of seconds for each test, with range (0, infinity)
84  * @param worker The worker object
85  * @return True, if succeeded
86  */
87  static bool test(const double testDuration, Worker& worker);
88 
89  /**
90  * Applies a stress test with random input data just ensuring that the detector does not crash.
91  * @param testDuration Number of seconds for each test, with range (0, infinity)
92  * @param worker The worker object
93  * @return True, if succeeded
94  */
95  static bool testStressTest(const double testDuration, Worker& worker);
96 
97  /**
98  * Tests the detection of QR codes in images without QR codes (avoid false-positive detections).
99  * The images needs to be provided via a test data collection with name "legacyqrCodedetector2d_0code".
100  * @param testDuration Number of seconds for each test, with range (0, infinity)
101  * @param worker The worker object
102  * @param forceFullTest If true, the test will ignore the test duration and will continue until all images have been tested, otherwise test success/failure will be determined after the test duration has been reached.
103  * @return True, if succeeded
104  */
105  static bool testDetectQRCodes_0_qrcodes(const double testDuration, Worker& worker, const bool forceFullTest);
106 
107  /**
108  * Tests the detection of QR codes in images.
109  * The images needs to be provided via a test data collection with name "legacyqrCodedetector2d_1code".
110  * @param testDuration Number of seconds for each test, with range (0, infinity)
111  * @param worker The worker object
112  * @param forceFullTest If true, the test will ignore the test duration and will continue until all images have been tested, otherwise test success/failure will be determined after the test duration has been reached.
113  * @return True, if succeeded
114  */
115  static bool testDetectQRCodes_1_qrcode(const double testDuration, Worker& worker, const bool forceFullTest);
116 };
117 
118 #ifdef OCEAN_USE_TEST_DATA_COLLECTION
119 
120 /**
121  * Registers the data collections for the LegacyQRCodeDetector2D test.
122  * @return The scoped subscriptions for the registered data collections
123  */
125 
126 #endif // OCEAN_USE_LOCAL_TEST_DATA_COLLECTION
127 
128 } // namespace TestQRCodes
129 
130 } // namespace TestDetector
131 
132 } // namespace TestCV
133 
134 } // namespace Test
135 
136 } // namespace Ocean
Deprecated: use QRCodeDetector2D instead.
Definition: LegacyQRCodeDetector2D.h:49
This class implements a test data collection based on local files.
Definition: TestLegacyQRCodeDetector2D.h:52
size_t size() override
Returns the number of data object objects this collection holds.
std::vector< std::string > filenames_
The filenames of all local images belonging to this test collection.
Definition: TestLegacyQRCodeDetector2D.h:76
SharedTestData data(const size_t index) override
Returns the test data object associated with a specified index.
FileDataCollection(std::vector< std::string > &&imageFilenames)
Creates a new test data collection object.
This class implements a test for the QR code detector.
Definition: TestLegacyQRCodeDetector2D.h:45
static bool testStressTest(const double testDuration, Worker &worker)
Applies a stress test with random input data just ensuring that the detector does not crash.
static bool testDetectQRCodes_0_qrcodes(const double testDuration, Worker &worker, const bool forceFullTest)
Tests the detection of QR codes in images without QR codes (avoid false-positive detections).
static bool test(const double testDuration, Worker &worker)
Invokes all test for the QR code detector.
static bool testDetectQRCodes_1_qrcode(const double testDuration, Worker &worker, const bool forceFullTest)
Tests the detection of QR codes in images.
This class is the base class for all TestDataCollection objects.
Definition: TestDataCollection.h:35
std::vector< ScopedSubscription > ScopedSubscriptions
Definition of a vector holding scoped subscription objects.
Definition: TestDataManager.h:43
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
std::shared_ptr< TestData > SharedTestData
Definition of a shared pointer holding a TestData object.
Definition: TestData.h:29
TestDataManager::ScopedSubscriptions TestLegacyQRCodeDetector2D_registerTestDataCollections()
Registers the data collections for the LegacyQRCodeDetector2D test.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15