Ocean
TestMicroQRCodeDetector2D.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 
16 namespace Ocean
17 {
18 
19 namespace Test
20 {
21 
22 namespace TestCV
23 {
24 
25 namespace TestDetector
26 {
27 
28 namespace TestQRCodes
29 {
30 
31 /**
32  * This class implements a test for the Micro QR code detector.
33  * @ingroup testcvdetectorqrcodes
34  */
35 class OCEAN_TEST_CV_DETECTOR_QRCODES_EXPORT TestMicroQRCodeDetector2D : protected CV::Detector::QRCodes::MicroQRCodeDetector2D
36 {
37  protected:
38 
39  /**
40  * Definition of a struct holding the parameters describing a portion of the Micro QR code encoding space
41  */
43  {
44  /// The encoding mode of the Micro QR code
46 
47  /// The minimum length of the message
48  unsigned int minimumMessageLength;
49 
50  /// The maximum length of the message
51  unsigned int maximumMessageLength;
52 
53  /// The error correction capacity
55  };
56 
57  public:
58 
59  /**
60  * Invokes all test for the Micro QR code detector.
61  * @param testDuration Number of seconds for each test, with range (0, infinity)
62  * @param worker A worker object
63  * @return True, if succeeded
64  */
65  static bool test(const double testDuration, Worker& worker);
66 
67  /**
68  * Applies a stress test with random input data just ensuring that the detector does not crash.
69  * @param testDuration Number of seconds for each test, with range (0, infinity)
70  * @param worker A worker object
71  * @return True, if succeeded
72  */
73  static bool testStressTest(const double testDuration, Worker& worker);
74 
75  /**
76  * Test for the detection of Micro QR codes using synthetic test images with small dimensions
77  * @param gaussianFilterSize Size of a Gaussian filter that is applied to the synthesized data; no filter is applied for the value 0, range: [0, infinity), must be an odd value
78  * @param testDuration Number of seconds for each test, with range (0, infinity)
79  * @param worker A worker object
80  * @return True, if succeeded
81  */
82  static bool testDetectMicroQRCodesSmallImageSyntheticData(const unsigned int gaussianFilterSize, const double testDuration, Worker& worker);
83 
84  /**
85  * Test for the detection of Micro QR codes using synthetic test images with large dimensions
86  * @param gaussianFilterSize Size of a Gaussian filter that is applied to the synthesized data; no filter is applied for the value 0, range: [0, infinity), must be an odd value
87  * @param testDuration Number of seconds for each test, with range (0, infinity)
88  * @param worker A worker object
89  * @return True, if succeeded
90  */
91  static bool testDetectMicroQRCodesLargeImageSyntheticData(const unsigned int gaussianFilterSize, const double testDuration, Worker& worker);
92 
93  protected:
94 
95  /**
96  * Test for the detection of Micro QR codes using synthetic test images
97  * @param gaussianFilterSize Size of a Gaussian filter that is applied to the synthesized data; no filter is applied for the value 0, range: [0, infinity), must be an odd value
98  * @param testDuration Number of seconds for each test, with range (0, infinity)
99  * @param worker A worker object
100  * @param testLable Label specified by caller test function, used in log messages and within generated file names. Must be alphanumeric.
101  * @param detectionValidationThreshold Proportion of Micro QR code detection attempts that must succeed for the test to pass, range: [0, 1]
102  * @param groundtruthComparisonValidationThreshold Proportion of Micro QR code detection attempts that must succeed with exact match to groundtruth for the test to pass, range: [0, detectionValidationThreshold]
103  * @param moduleSizePixelsMin Minimum module size in pixels, range: [1, infinity)
104  * @param moduleSizePixelsMax Maximum module size in pixels, range: [moduleSizePixelsMin, infinity)
105  * @param imageDimPixelsMin Hard limit on how small width or height of generated image can be, in terms of pixels, range: [0, infinity)
106  * @param imageDimPixelsMax Soft limit on how large width or height of generated image can be, in terms of pixels, range: [0, infinity)
107  * @return True, if succeeded
108  * @remark Images generated may have width or height greater than `imageDimPixelsMax` if the image needs to be larger to fit the Micro QR code generated due to other parameter values
109  */
110  static bool testDetectMicroQRCodesSyntheticData_Internal(const unsigned int gaussianFilterSize, const double testDuration, Worker& worker, const std::string& testLabel, const double detectionValidationThreshold, const double groundtruthComparisonValidationThreshold, const unsigned int moduleSizePixelsMin = 6u, const unsigned int moduleSizePixelsMax = 8u, const unsigned int imageDimPixelsMin = 0u, const unsigned int imageDimPixelsMax = 720u);
111 };
112 
113 } // namespace TestQRCodes
114 
115 } // namespace TestDetector
116 
117 } // namespace TestCV
118 
119 } // namespace Test
120 
121 } // namespace Test
This class implements a detector for Micro QR Codes.
Definition: MicroQRCodeDetector2D.h:38
EncodingMode
Definition of encoding modes.
Definition: QRCodeBase.h:72
ErrorCorrectionCapacity
Enumeration of the levels of error correction The value of the enums correspond to the standard-defin...
Definition: QRCodeBase.h:53
@ ECC_DETECTION_ONLY
Indicates that the capacity is limited to error detection only (used only by Micro QR Code version M1...
Definition: QRCodeBase.h:63
This class implements a test for the Micro QR code detector.
Definition: TestMicroQRCodeDetector2D.h:36
static bool testDetectMicroQRCodesSmallImageSyntheticData(const unsigned int gaussianFilterSize, const double testDuration, Worker &worker)
Test for the detection of Micro QR codes using synthetic test images with small dimensions.
static bool testDetectMicroQRCodesSyntheticData_Internal(const unsigned int gaussianFilterSize, const double testDuration, Worker &worker, const std::string &testLabel, const double detectionValidationThreshold, const double groundtruthComparisonValidationThreshold, const unsigned int moduleSizePixelsMin=6u, const unsigned int moduleSizePixelsMax=8u, const unsigned int imageDimPixelsMin=0u, const unsigned int imageDimPixelsMax=720u)
Test for the detection of Micro QR codes using synthetic test images.
static bool testDetectMicroQRCodesLargeImageSyntheticData(const unsigned int gaussianFilterSize, const double testDuration, Worker &worker)
Test for the detection of Micro QR codes using synthetic test images with large dimensions.
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 test(const double testDuration, Worker &worker)
Invokes all test for the Micro QR code detector.
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15
Definition of a struct holding the parameters describing a portion of the Micro QR code encoding spac...
Definition: TestMicroQRCodeDetector2D.h:43
CV::Detector::QRCodes::MicroQRCode::EncodingMode encodingMode
The encoding mode of the Micro QR code.
Definition: TestMicroQRCodeDetector2D.h:45
unsigned int maximumMessageLength
The maximum length of the message.
Definition: TestMicroQRCodeDetector2D.h:51
unsigned int minimumMessageLength
The minimum length of the message.
Definition: TestMicroQRCodeDetector2D.h:48