Ocean
TestCanvas.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_TEST_CANVAS_H
9 #define META_OCEAN_TEST_TESTCV_TEST_CANVAS_H
10 
12 
13 namespace Ocean
14 {
15 
16 namespace Test
17 {
18 
19 namespace TestCV
20 {
21 
22 /**
23  * This class implements tests for the Canvas class.
24  * @ingroup testcv
25  */
26 class OCEAN_TEST_CV_EXPORT TestCanvas
27 {
28  protected:
29 
30  /**
31  * Definition of an unordered map mapping distances to pixel values.
32  */
33  using DistanceMap = std::unordered_map<CV::PixelPosition, const uint8_t*, CV::PixelPosition>;
34 
35  public:
36 
37  /**
38  * Invokes all tests.
39  * @param testDuration Number of seconds for each test, with range (0, infinity)
40  * @return True, if succeeded
41  */
42  static bool test(const double testDuration);
43 
44  /**
45  * Tests the color value functions.
46  * @return True, if succeeded
47  */
48  static bool testColors();
49 
50  /**
51  * Tests the line drawing function with pixel accuracy.
52  * @param testDuration Number of seconds for each test, with range (0, infinity)
53  * @return True, if succeeded
54  */
55  static bool testLinePixelAccuracy(const double testDuration);
56 
57  /**
58  * Tests the point function when using a point location without fraction (perfectly placed in the center of a pixel).
59  * @param testDuration Number of seconds for each test, with range (0, infinity)
60  * @return True, if succeeded
61  */
62  static bool testPointNoFraction(const double testDuration);
63 
64  /**
65  * Tests the point function when using a point location with fraction (with arbitrary location).
66  * @param testDuration Number of seconds for each test, with range (0, infinity)
67  * @return True, if succeeded
68  */
69  static bool testPointWithFraction(const double testDuration);
70 
71  protected:
72 
73  /**
74  * Returns the sum of squared differences between the color values of two pixels.
75  * @param pixel0 The first pixel, must be valid
76  * @param pixel1 The second pixel, must be valid
77  * @param channels The number of channels, with range [1, infinity)
78  */
79  static unsigned int ssd(const uint8_t* pixel0, const uint8_t* pixel1, const unsigned int channels);
80 };
81 
82 }
83 
84 }
85 
86 }
87 
88 #endif // META_OCEAN_TEST_TESTCV_TEST_CANVAS_H
This class implements tests for the Canvas class.
Definition: TestCanvas.h:27
std::unordered_map< CV::PixelPosition, const uint8_t *, CV::PixelPosition > DistanceMap
Definition of an unordered map mapping distances to pixel values.
Definition: TestCanvas.h:33
static bool testPointWithFraction(const double testDuration)
Tests the point function when using a point location with fraction (with arbitrary location).
static unsigned int ssd(const uint8_t *pixel0, const uint8_t *pixel1, const unsigned int channels)
Returns the sum of squared differences between the color values of two pixels.
static bool testPointNoFraction(const double testDuration)
Tests the point function when using a point location without fraction (perfectly placed in the center...
static bool test(const double testDuration)
Invokes all tests.
static bool testColors()
Tests the color value functions.
static bool testLinePixelAccuracy(const double testDuration)
Tests the line drawing function with pixel accuracy.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15