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 * Test merging of two line segments into a new line segment
56 * @param testDuration Number of seconds for each test, with range (0, infinity)
57 * @return True, if succeeded
58 */
59 static bool testLineFusion(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 testMergeGreedyBruteForce(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 testMerge(const double testDuration);
74
75 protected:
76
77 /**
78 * Generate a random 2D line segment inside the boundaries of an image/rectangle.
79 * @param randomGenerator The random generator to be used for the generation of the test data
80 * @param imageWidth Width of the image
81 * @param imageHeight Height of the image
82 * @return A line segment within the image boundaries
83 */
84 static FiniteLine2 generateRandomFiniteLine2(RandomGenerator& randomGenerator, const unsigned int imageWidth, const unsigned int imageHeight);
85
86 /**
87 * Generate a random 2D line segment inside the boundaries of an image/rectangle that is orthogonal to a reference line segment.
88 * @param randomGenerator The random generator to be used for the generation of the test data
89 * @param line Line for which a orthogonal line will be generated randomly
90 * @param imageWidth Width of the image
91 * @param imageHeight Height of the image
92 * @param minLineLength Minimum length of the random line segments that are generated, default: 0.5, range: (0, infinity)
93 * @return A line segment within the image boundaries
94 */
95 static FiniteLine2 generateRandomOrthogonalFiniteLine2(RandomGenerator& randomGenerator, const FiniteLine2& line, const unsigned int imageWidth, const unsigned int imageHeight, const Scalar minLineLength = Scalar(0.5));
96
97 /**
98 * Generate a random 2D line segment inside the boundaries of an image/rectangle that is collinear with a reference line segment.
99 * @param randomGenerator The random generator to be used for the generation of the test data
100 * @param line Line for which a collinear line will be generated randomly
101 * @param imageWidth Width of the image
102 * @param imageHeight Height of the image
103 * @param minLineLength Minimum length of the random line segments that are generated, default: 0.5, range: (0, infinity)
104 * @return A line segment within the image boundaries
105 */
106 static FiniteLine2 generateRandomCollinearFiniteLine2(RandomGenerator& randomGenerator, const FiniteLine2& line, const unsigned int imageWidth, const unsigned int imageHeight, const Scalar minLineLength = Scalar(0.5));
107
108 /**
109 * Validation for line merging function
110 * @param testLine Result of merging parameter `lines` with `HemiCube::fuse()`.
111 * @param lines Lines to be merged.
112 * @return True if the result of this function is sufficiently close to `testLine`, otherwise false.
113 */
114 static bool validateLineFusion(const FiniteLine2& testLine, const FiniteLines2& lines);
115};
116
117} // namespace TestDetector
118
119} // namespace TestCV
120
121} // namespace Test
122
123} // namespace Ocean
124
125#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 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