Ocean
TestFrameInterpolatorBilinearAlpha.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_FRAME_INTERPOLATOR_BILINEAR_ALPHA_H
9 #define META_OCEAN_TEST_TESTCV_TEST_FRAME_INTERPOLATOR_BILINEAR_ALPHA_H
10 
12 
13 #include "ocean/base/Worker.h"
14 
15 #include "ocean/math/Vector2.h"
16 
17 namespace Ocean
18 {
19 
20 namespace Test
21 {
22 
23 namespace TestCV
24 {
25 
26 /**
27  * This class implements a bilinear frame interpolator test for frames holding an alpha channel.
28  * @ingroup testcv
29  */
30 class OCEAN_TEST_CV_EXPORT TestFrameInterpolatorBilinearAlpha
31 {
32  public:
33 
34  /**
35  * Tests all bilinear interpolation filter functions.
36  * @param width The width of the source frame in pixel, with range [1, infinity)
37  * @param height The height of the source frame in pixel, with range [1, infinity)
38  * @param testDuration Number of seconds for each test, with range (0, infinity)
39  * @param worker The worker object to distribute the CPU load
40  * @return True, if succeeded
41  */
42  static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
43 
44  /**
45  * Tests the bilinear pixel interpolation function.
46  * @param testDuration Number of seconds for each test, with range (0, infinity)
47  * @return True, if succeeded
48  */
49  static bool testInterpolatePixel8BitPerChannel(const double testDuration);
50 
51  /**
52  * Tests the bilinear pixel interpolation function.
53  * @param pixelCenter The pixel center to be used
54  * @param testDuration Number of seconds for each test, with range (0, infinity)
55  * @return True, if succeeded
56  * @tparam TScalar The data type of the scalar to be used, either 'float' or 'double'
57  */
58  template <typename TScalar>
59  static bool testInterpolatePixel8BitPerChannel(const CV::PixelCenter pixelCenter, const double testDuration);
60 
61  /**
62  * Tests the bilinear infinite border interpolation function.
63  * @param width The width of the frame in pixel, with range [1, infinity)
64  * @param height The height of the frame in pixel, with range [1, infinity)
65  * @param testDuration Number of seconds for each test, with range (0, infinity)
66  * @return True, if succeeded
67  */
68  static bool testInterpolateInfiniteBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
69 
70  /**
71  * Tests the bilinear infinite border interpolation function.
72  * @param width The width of the frame in pixel, with range [1, infinity)
73  * @param height The height of the frame in pixel, with range [1, infinity)
74  * @param testDuration Number of seconds for each test, with range (0, infinity)
75  * @return True, if succeeded
76  * @tparam tChannels The number of frame channels, with range [1, infinity)
77  */
78  template <unsigned int tChannels>
79  static bool testInterpolateInfiniteBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration);
80 
81  protected:
82 
83  /**
84  * Determines the interpolation for one pixel.
85  * @param frame The frame that is used for interpolation, must be valid
86  * @param alphaAtFront True, if the alpha channel is at the front of the data channels
87  * @param transparentIs0xFF True, if 0xFF is interpreted as fully transparent
88  * @param position The position for which the interpolated pixel will be determined, with ranges [0, frame.width() - 1]x[0, frame.height() - 1] for PC_TOP_LEFT, [0, frame.width()]x[0, frame.height()] for PC_CENTER
89  * @param pixelCenter The pixel center to be used during interpolation
90  * @param result The resulting interpolated pixel value, must be valid
91  * @return True, if succeeded
92  * @tparam TScalar The data type of a scalar, either 'float' or 'double'
93  */
94  template <typename TScalar>
95  static bool interpolatePixel8BitPerChannel(const Frame& frame, const bool alphaAtFront, const bool transparentIs0xFF, const VectorT2<TScalar>& position, const CV::PixelCenter pixelCenter, uint8_t* result);
96 
97  /**
98  * Returns the infinite border interpolation result for a given frame and interpolation position.
99  * @param frame The frame that is used for interpolation, must be valid
100  * @param alphaAtFront True, if the alpha channel is at the front of the data channels
101  * @param transparentIs0xFF True, if 0xFF is interpreted as fully transparent
102  * @param position Interpolation position, must be valid
103  * @param result Resulting interpolation value, must be valid
104  * @return True, if the interpolation position is inside the frame area
105  */
106  static bool infiniteBorderInterpolation8BitPerChannel(const Frame& frame, const bool alphaAtFront, const bool transparentIs0xFF, const Vector2& position, uint8_t* result);
107 };
108 
109 }
110 
111 }
112 
113 }
114 
115 #endif // META_OCEAN_TEST_TESTCV_TEST_FRAME_INTERPOLATOR_BILINEAR_ALPHA_H
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements a bilinear frame interpolator test for frames holding an alpha channel.
Definition: TestFrameInterpolatorBilinearAlpha.h:31
static bool infiniteBorderInterpolation8BitPerChannel(const Frame &frame, const bool alphaAtFront, const bool transparentIs0xFF, const Vector2 &position, uint8_t *result)
Returns the infinite border interpolation result for a given frame and interpolation position.
static bool testInterpolateInfiniteBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the bilinear infinite border interpolation function.
static bool testInterpolatePixel8BitPerChannel(const CV::PixelCenter pixelCenter, const double testDuration)
Tests the bilinear pixel interpolation function.
static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests all bilinear interpolation filter functions.
static bool interpolatePixel8BitPerChannel(const Frame &frame, const bool alphaAtFront, const bool transparentIs0xFF, const VectorT2< TScalar > &position, const CV::PixelCenter pixelCenter, uint8_t *result)
Determines the interpolation for one pixel.
static bool testInterpolateInfiniteBorder8BitPerChannel(const unsigned int width, const unsigned int height, const double testDuration)
Tests the bilinear infinite border interpolation function.
static bool testInterpolatePixel8BitPerChannel(const double testDuration)
Tests the bilinear pixel interpolation function.
This class implements a vector with two elements.
Definition: Vector2.h:96
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
PixelCenter
Definition of individual centers of pixels.
Definition: CV.h:117
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15