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