Ocean
Loading...
Searching...
No Matches
TestHemiCube.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_HEMI_CUBE_H
9#define META_OCEAN_TEST_TESTCV_TESTDETECTOR_TEST_HEMI_CUBE_H
10
12
14
16
18
19namespace Ocean
20{
21
22namespace Test
23{
24
25namespace TestCV
26{
27
28namespace TestDetector
29{
30
31/**
32 * This class implements tests for the Hemi cube.
33 * @ingroup testcvdetector
34 */
35class OCEAN_TEST_CV_DETECTOR_EXPORT TestHemiCube
36{
37 public:
38 /**
39 * Invokes all test for the Hemi cube.
40 * @param testDuration Number of seconds for each test, with range (0, infinity)
41 * @param worker The worker object
42 * @param selector The test selector to filter tests
43 * @return True, if succeeded
44 */
45 static bool test(const double testDuration, Worker& worker, const TestSelector& selector);
46
47 /**
48 * Tests the add lines to the Hemi cube.
49 * @param testDuration Number of seconds for each test, with range (0, infinity)
50 * @return True, if succeeded
51 */
52 static bool testAdd(const double testDuration);
53
54 /**
55 * Tests the search for similar lines in the Hemi cube.
56 * @param testDuration Number of seconds for each test, with range (0, infinity)
57 * @return True, if succeeded
58 */
59 static bool testFind(const double testDuration);
60
61 /**
62 * Test merging of two line segments into a new line segment
63 * @param testDuration Number of seconds for each test, with range (0, infinity)
64 * @return True, if succeeded
65 */
66 static bool testLineFusion(const double testDuration);
67
68 /**
69 * Test merging of two line segments into a new line segment
70 * @param testDuration Number of seconds for each test, with range (0, infinity)
71 * @return True, if succeeded
72 */
73 static bool testMergeGreedyBruteForce(const double testDuration);
74
75 /**
76 * Test merging of two line segments into a new line segment
77 * @param testDuration Number of seconds for each test, with range (0, infinity)
78 * @return True, if succeeded
79 */
80 static bool testMerge(const double testDuration);
81
82 protected:
83
84 /**
85 * Generate a random 2D line segment inside the boundaries of an image/rectangle.
86 * @param randomGenerator The random generator to be used for the generation of the test data
87 * @param imageWidth Width of the image
88 * @param imageHeight Height of the image
89 * @return A line segment within the image boundaries
90 */
91 static FiniteLine2 generateRandomFiniteLine2(RandomGenerator& randomGenerator, const unsigned int imageWidth, const unsigned int imageHeight);
92
93 /**
94 * Generate a random 2D line segment inside the boundaries of an image/rectangle that is orthogonal to a reference line segment.
95 * @param randomGenerator The random generator to be used for the generation of the test data
96 * @param line Line for which a orthogonal line will be generated randomly
97 * @param imageWidth Width of the image
98 * @param imageHeight Height of the image
99 * @param minLineLength Minimum length of the random line segments that are generated, default: 0.5, range: (0, infinity)
100 * @return A line segment within the image boundaries
101 */
102 static FiniteLine2 generateRandomOrthogonalFiniteLine2(RandomGenerator& randomGenerator, const FiniteLine2& line, const unsigned int imageWidth, const unsigned int imageHeight, const Scalar minLineLength = Scalar(0.5));
103
104 /**
105 * Generate a random 2D line segment inside the boundaries of an image/rectangle that is collinear with a reference line segment.
106 * @param randomGenerator The random generator to be used for the generation of the test data
107 * @param line Line for which a collinear line will be generated randomly
108 * @param imageWidth Width of the image
109 * @param imageHeight Height of the image
110 * @param minLineLength Minimum length of the random line segments that are generated, default: 0.5, range: (0, infinity)
111 * @return A line segment within the image boundaries
112 */
113 static FiniteLine2 generateRandomCollinearFiniteLine2(RandomGenerator& randomGenerator, const FiniteLine2& line, const unsigned int imageWidth, const unsigned int imageHeight, const Scalar minLineLength = Scalar(0.5));
114
115 /**
116 * Validation for line merging function
117 * @param testLine Result of merging parameter `lines` with `HemiCube::fuse()`.
118 * @param lines Lines to be merged.
119 * @return True if the result of this function is sufficiently close to `testLine`, otherwise false.
120 */
121 static bool validateLineFusion(const FiniteLine2& testLine, const FiniteLines2& lines);
122};
123
124} // namespace TestDetector
125
126} // namespace TestCV
127
128} // namespace Test
129
130} // namespace Ocean
131
132#endif // META_OCEAN_TEST_TESTCV_TESTDETECTOR_TEST_HEMI_CUBE_H
This class implements a generator for random numbers.
Definition RandomGenerator.h:42
This class implements tests for the Hemi cube.
Definition TestHemiCube.h:36
static bool testMerge(const double testDuration)
Test merging of two line segments into a new line segment.
static FiniteLine2 generateRandomOrthogonalFiniteLine2(RandomGenerator &randomGenerator, const FiniteLine2 &line, const unsigned int imageWidth, const unsigned int imageHeight, const Scalar minLineLength=Scalar(0.5))
Generate a random 2D line segment inside the boundaries of an image/rectangle that is orthogonal to a...
static FiniteLine2 generateRandomFiniteLine2(RandomGenerator &randomGenerator, const unsigned int imageWidth, const unsigned int imageHeight)
Generate a random 2D line segment inside the boundaries of an image/rectangle.
static bool testFind(const double testDuration)
Tests the search for similar lines in the Hemi cube.
static FiniteLine2 generateRandomCollinearFiniteLine2(RandomGenerator &randomGenerator, const FiniteLine2 &line, const unsigned int imageWidth, const unsigned int imageHeight, const Scalar minLineLength=Scalar(0.5))
Generate a random 2D line segment inside the boundaries of an image/rectangle that is collinear with ...
static bool testMergeGreedyBruteForce(const double testDuration)
Test merging of two line segments into a new line segment.
static bool test(const double testDuration, Worker &worker, const TestSelector &selector)
Invokes all test for the Hemi cube.
static bool testAdd(const double testDuration)
Tests the add lines to the Hemi cube.
static bool testLineFusion(const double testDuration)
Test merging of two line segments into a new line segment.
static bool validateLineFusion(const FiniteLine2 &testLine, const FiniteLines2 &lines)
Validation for line merging function.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
float Scalar
Definition of a scalar type.
Definition Math.h:129
std::vector< FiniteLine2 > FiniteLines2
Definition of a vector holding FiniteLine2 objects.
Definition FiniteLine2.h:57
The namespace covering the entire Ocean framework.
Definition Accessor.h:15