Ocean
TestORBDetector.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 #ifndef META_OCEAN_TEST_TESTCV_TESTDETECTOR_TEST_ORB_DETECTOR_H
9 #define META_OCEAN_TEST_TESTCV_TESTDETECTOR_TEST_ORB_DETECTOR_H
10 
12 
14 
15 namespace Ocean
16 {
17 
18 namespace Test
19 {
20 
21 namespace TestCV
22 {
23 
24 namespace TestDetector
25 {
26 
27 /**
28  * This class implements a ORB detector test.
29  * @ingroup testcvdetector
30  */
31 class OCEAN_TEST_CV_DETECTOR_EXPORT TestORBDetector
32 {
33  public:
34 
35  /**
36  * Tests all ORB descriptor functions.
37  * @param frame Test frame to be used for feature detection, invalid to use a random image
38  * @param testDuration Number of seconds for each test, with range (0, infinity)
39  * @param worker The worker object
40  * @return True, if succeeded
41  */
42  static bool test(const Frame& frame, const double testDuration, Worker& worker);
43 
44  /**
45  * Tests the determination of the orientation of all given features.
46  * @param testDuration Number of seconds for each test, with range (0, infinity)
47  * @param worker The worker object
48  * @param yFrameTest Optional explicit frame to be used for testing, otherwise a random image will be used
49  * @return True, if succeeded
50  */
51  static bool testOrientationDetermination(const double testDuration, Worker& worker, const Frame& yFrameTest = Frame());
52 
53  /**
54  * Tests the determination of the descriptor of all given features.
55  * @param testDuration Number of seconds for each test, with range (0, infinity)
56  * @param worker The worker object
57  * @param yFrameTest Optional explicit frame to be used for testing, otherwise a random image will be used
58  * @return True, if succeeded
59  */
60  static bool testDescriptorDetermination(const double testDuration, Worker& worker, const Frame& yFrameTest = Frame());
61 
62  /**
63  * Tests the detection and description of reference features.
64  * This test is mainly a stress test.
65  * @param testDuration Number of seconds for each test, with range (0, infinity)
66  * @param worker The worker object
67  * @return True, if succeeded
68  */
69  static bool testDetectReferenceFeaturesAndDetermineDescriptors(const double testDuration, Worker& worker);
70 
71  /**
72  * Tests the determination of the hamming distance between two randomized descriptors.
73  * @param testDuration Number of seconds for each test, with range (0, infinity)
74  * @return True, if succeeded
75  */
76  static bool testHammingDistanceDetermination(const double testDuration);
77 
78  /**
79  * Tests the matching of randomized descriptors
80  * @param testDuration Number of seconds for each test, with range (0, infinity)
81  * @param worker The worker object
82  * @return True, if succeeded
83  */
84  static bool testDescriptorMatching(const double testDuration, Worker& worker);
85 
86  protected:
87 
88  /**
89  * Validate the calculation of the orientation.
90  * @param linedIntegralFrame Pointer to the (lined) integral frame of the actual 8 bit frame for which the feature descriptors will be calculated, the integral frame has an extra line with zero pixels on the left and top of the integral frame
91  * @param width The width of the original frame in pixel (not the width of the lined-integral frame), with range [1, infinity)
92  * @param height The height of the original frame in pixel (not the height of the lined-integral frame), with range [1, infinity)
93  * @param features The features to validate
94  * @return The success percentage, with range [0, 1]
95  */
96  static double validateOrientation(const uint32_t* linedIntegralFrame, const unsigned int width, const unsigned int height, CV::Detector::ORBFeatures& features);
97 
98  /**
99  * Validate the calculation of the descriptor.
100  * @param linedIntegralFrame Pointer to the (lined) integral frame of the actual 8 bit frame for which the feature descriptors will be calculated, the integral frame has an extra line with zero pixels on the left and top of the integral frame
101  * @param width The width of the original frame in pixel (not the width of the lined-integral frame), with range [1, infinity)
102  * @param height The height of the original frame in pixel (not the height of the lined-integral frame), with range [1, infinity)
103  * @param features The features to validate
104  * @return True, if succeeded
105  */
106  static bool validateDescriptors(const uint32_t* linedIntegralFrame, const unsigned int width, const unsigned int height, CV::Detector::ORBFeatures& features);
107 
108  /**
109  * Validate the calculation of the hamming distance.
110  * @param descriptors1 First descriptor to validate
111  * @param descriptors2 Second descriptor to validate
112  * @return True, if succeeded
113  */
114  static bool validateHammingDistance(const std::vector<CV::Detector::ORBDescriptor>& descriptors1, const std::vector<CV::Detector::ORBDescriptor>& descriptors2);
115 
116  /**
117  * Validate the descriptor matching.
118  * @param matches Calculated indices of matches to check the validation for
119  * @param checkMatches Pre calculated correct indices of matches
120  * @return True, if succeeded
121  */
122  static bool validateDescriptorMatching(const IndexPairs32& matches, const IndexPairs32& checkMatches);
123 };
124 
125 }
126 
127 }
128 
129 }
130 
131 }
132 
133 #endif // META_OCEAN_TEST_TESTCV_TESTDETECTOR_TEST_ORB_DETECTOR_H
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements a ORB detector test.
Definition: TestORBDetector.h:32
static bool validateDescriptorMatching(const IndexPairs32 &matches, const IndexPairs32 &checkMatches)
Validate the descriptor matching.
static bool testHammingDistanceDetermination(const double testDuration)
Tests the determination of the hamming distance between two randomized descriptors.
static bool testDetectReferenceFeaturesAndDetermineDescriptors(const double testDuration, Worker &worker)
Tests the detection and description of reference features.
static bool testDescriptorDetermination(const double testDuration, Worker &worker, const Frame &yFrameTest=Frame())
Tests the determination of the descriptor of all given features.
static bool testOrientationDetermination(const double testDuration, Worker &worker, const Frame &yFrameTest=Frame())
Tests the determination of the orientation of all given features.
static bool validateDescriptors(const uint32_t *linedIntegralFrame, const unsigned int width, const unsigned int height, CV::Detector::ORBFeatures &features)
Validate the calculation of the descriptor.
static bool testDescriptorMatching(const double testDuration, Worker &worker)
Tests the matching of randomized descriptors.
static bool test(const Frame &frame, const double testDuration, Worker &worker)
Tests all ORB descriptor functions.
static bool validateHammingDistance(const std::vector< CV::Detector::ORBDescriptor > &descriptors1, const std::vector< CV::Detector::ORBDescriptor > &descriptors2)
Validate the calculation of the hamming distance.
static double validateOrientation(const uint32_t *linedIntegralFrame, const unsigned int width, const unsigned int height, CV::Detector::ORBFeatures &features)
Validate the calculation of the orientation.
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
std::vector< IndexPair32 > IndexPairs32
Definition of a vector holding 32 bit index pairs.
Definition: Base.h:144
std::vector< ORBFeature > ORBFeatures
Definition of a vector holding ORB features.
Definition: ORBFeature.h:26
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15