Ocean
TestQRCodeDetector2D.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 QR code detector.
33  * @ingroup testcvdetectorqrcodes
34  */
35 class OCEAN_TEST_CV_DETECTOR_QRCODES_EXPORT TestQRCodeDetector2D : protected CV::Detector::QRCodes::QRCodeDetector2D
36 {
37  public:
38 
39  /**
40  * Invokes all test for the QR code detector.
41  * @param testDuration Number of seconds for each test, with range (0, infinity)
42  * @param worker A worker object
43  * @return True, if succeeded
44  */
45  static bool test(const double testDuration, Worker& worker);
46 
47  /**
48  * Applies a stress test with random input data just ensuring that the detector does not crash.
49  * @param testDuration Number of seconds for each test, with range (0, infinity)
50  * @param worker A worker object
51  * @return True, if succeeded
52  */
53  static bool testStressTest(const double testDuration, Worker& worker);
54 
55  /**
56  * Test for the detection of QR codes using synthetic test images with small dimensions
57  * @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
58  * @param testDuration Number of seconds for each test, with range (0, infinity)
59  * @param worker A worker object
60  * @return True, if succeeded
61  */
62  static bool testDetectQRCodesSmallImageSyntheticData(const unsigned int gaussianFilterSize, const double testDuration, Worker& worker);
63 
64  /**
65  * Test for the detection of QR codes using synthetic test images with large dimensions
66  * @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
67  * @param testDuration Number of seconds for each test, with range (0, infinity)
68  * @param worker A worker object
69  * @return True, if succeeded
70  */
71  static bool testDetectQRCodesLargeImageSyntheticData(const unsigned int gaussianFilterSize, const double testDuration, Worker& worker);
72 
73  protected:
74 
75  /**
76  * Test for the detection of QR codes using synthetic test images
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  * @param testLable Label specified by caller test function, used in log messages and within generated file names. Must be alphanumeric.
81  * @param validationPrecisionThreshold Proportion of QR code detection attempts that must succeed for the test to pass, range: [0, 1]
82  * @param moduleSizePixelsMin Minimum module size in pixels, range: [1, infinity)
83  * @param moduleSizePixelsMax Maximum module size in pixels, range: [moduleSizePixelsMin, infinity)
84  * @param imageDimPixelsMin Hard limit on how small width or height of generated image can be, in terms of pixels, range: [0, infinity)
85  * @param imageDimPixelsMax Soft limit on how large width or height of generated image can be, in terms of pixels, range: [0, infinity)
86  * @return True, if succeeded
87  * @remark Images generated may have width or height greater than `imageDimPixelsMax` if the image needs to be larger to fit the QR code generated due to other parameter values
88  */
89  static bool testDetectQRCodesSyntheticData_Internal(const unsigned int gaussianFilterSize, const double testDuration, Worker& worker, const std::string& testLabel, const double validationPrecisionThreshold = 0.99, const unsigned int moduleSizePixelsMin = 6u, const unsigned int moduleSizePixelsMax = 8u, const unsigned int imageDimPixelsMin = 0u, const unsigned int imageDimPixelsMax = 720u);
90 };
91 
92 } // namespace TestQRCodes
93 
94 } // namespace TestDetector
95 
96 } // namespace TestCV
97 
98 } // namespace Test
99 
100 } // namespace Test
This class implements a detector for QR Codes.
Definition: QRCodeDetector2D.h:42
This class implements a test for the QR code detector.
Definition: TestQRCodeDetector2D.h:36
static bool testDetectQRCodesSmallImageSyntheticData(const unsigned int gaussianFilterSize, const double testDuration, Worker &worker)
Test for the detection of QR codes using synthetic test images with small dimensions.
static bool testDetectQRCodesSyntheticData_Internal(const unsigned int gaussianFilterSize, const double testDuration, Worker &worker, const std::string &testLabel, const double validationPrecisionThreshold=0.99, 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 QR codes using synthetic test images.
static bool test(const double testDuration, Worker &worker)
Invokes all test for the QR code detector.
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 testDetectQRCodesLargeImageSyntheticData(const unsigned int gaussianFilterSize, const double testDuration, Worker &worker)
Test for the detection of QR codes using synthetic test images with large dimensions.
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