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
17namespace Ocean
18{
19
20namespace Test
21{
22
23namespace TestCV
24{
25
26namespace TestDetector
27{
28
29/**
30 * This class implements tests for the Hemi cube.
31 * @ingroup testcvdetector
32 */
33class OCEAN_TEST_CV_DETECTOR_EXPORT TestHemiCube
34{
35 public:
36 /**
37 * Invokes all test for the Hemi cube.
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 double testDuration, Worker& worker);
43
44 /**
45 * Tests the add lines to the Hemi cube.
46 * @param testDuration Number of seconds for each test, with range (0, infinity)
47 * @return True, if succeeded
48 */
49 static bool testAdd(const double testDuration);
50
51 /**
52 * Test merging of two line segments into a new line segment
53 * @param testDuration Number of seconds for each test, with range (0, infinity)
54 * @return True, if succeeded
55 */
56 static bool testLineFusion(const double testDuration);
57
58 /**
59 * Test merging of two line segments into a new line segment
60 * @param testDuration Number of seconds for each test, with range (0, infinity)
61 * @return True, if succeeded
62 */
63 static bool testMergeGreedyBruteForce(const double testDuration);
64
65 /**
66 * Test merging of two line segments into a new line segment
67 * @param testDuration Number of seconds for each test, with range (0, infinity)
68 * @return True, if succeeded
69 */
70 static bool testMerge(const double testDuration);
71
72 protected:
73
74 /**
75 * Generate a random 2D line segment inside the boundaries of an image/rectangle.
76 * @param randomGenerator The random generator to be used for the generation of the test data
77 * @param imageWidth Width of the image
78 * @param imageHeight Height of the image
79 * @return A line segment within the image boundaries
80 */
81 static FiniteLine2 generateRandomFiniteLine2(RandomGenerator& randomGenerator, const unsigned int imageWidth, const unsigned int imageHeight);
82
83 /**
84 * Generate a random 2D line segment inside the boundaries of an image/rectangle that is orthogonal to a reference line segment.
85 * @param randomGenerator The random generator to be used for the generation of the test data
86 * @param line Line for which a orthogonal line will be generated randomly
87 * @param imageWidth Width of the image
88 * @param imageHeight Height of the image
89 * @param minLineLength Minimum length of the random line segments that are generated, default: 0.5, range: (0, infinity)
90 * @return A line segment within the image boundaries
91 */
92 static FiniteLine2 generateRandomOrthogonalFiniteLine2(RandomGenerator& randomGenerator, const FiniteLine2& line, const unsigned int imageWidth, const unsigned int imageHeight, const Scalar minLineLength = Scalar(0.5));
93
94 /**
95 * Generate a random 2D line segment inside the boundaries of an image/rectangle that is collinear with a reference line segment.
96 * @param randomGenerator The random generator to be used for the generation of the test data
97 * @param line Line for which a collinear line will be generated randomly
98 * @param imageWidth Width of the image
99 * @param imageHeight Height of the image
100 * @param minLineLength Minimum length of the random line segments that are generated, default: 0.5, range: (0, infinity)
101 * @return A line segment within the image boundaries
102 */
103 static FiniteLine2 generateRandomCollinearFiniteLine2(RandomGenerator& randomGenerator, const FiniteLine2& line, const unsigned int imageWidth, const unsigned int imageHeight, const Scalar minLineLength = Scalar(0.5));
104
105 /**
106 * Validation for line merging function
107 * @param testLine Result of merging parameter `lines` with `HemiCube::fuse()`.
108 * @param lines Lines to be merged.
109 * @return True if the result of this function is sufficiently close to `testLine`, otherwise false.
110 */
111 static bool validateLineFusion(const FiniteLine2& testLine, const FiniteLines2& lines);
112};
113
114} // namespace TestDetector
115
116} // namespace TestCV
117
118} // namespace Test
119
120} // namespace Ocean
121
122#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:34
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 bool test(const double testDuration, Worker &worker)
Invokes all test for the Hemi cube.
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 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 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