Ocean
TestFrameBlender.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_BLENDER_H
9 #define META_OCEAN_TEST_TESTCV_TEST_FRAME_BLENDER_H
10 
12 
13 namespace Ocean
14 {
15 
16 namespace Test
17 {
18 
19 namespace TestCV
20 {
21 
22 /**
23  * This class implements a test for the frame blender class.
24  * @ingroup testcv
25  */
26 class OCEAN_TEST_CV_EXPORT TestFrameBlender
27 {
28  public:
29 
30  /**
31  * Tests the frame blender functions.
32  * @param testDuration Test duration in seconds, with range (0, infinity)
33  * @param worker The worker object to distribute the computation
34  * @return True, if this test succeeded
35  */
36  static bool test(const double testDuration, Worker& worker);
37 
38  /**
39  * Tests the blending two images with constant alpha value.
40  * @param testDuration Test duration in seconds, with range (0, infinity)
41  * @param worker The worker object to distribute the computation
42  * @return True, if this test succeeded
43  */
44  static bool testConstantAlpha(const double testDuration, Worker& worker);
45 
46  /**
47  * Tests the blending two images with a separate alpha channel.
48  * @param testDuration Test duration in seconds, with range (0, infinity)
49  * @param worker The worker object to distribute the computation
50  * @return True, if this test succeeded
51  * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
52  */
53  template <bool tTransparentIs0xFF>
54  static bool testSeparateAlphaChannel(const double testDuration, Worker& worker);
55 
56  /**
57  * Tests the blend function with alpha channel at the front or at the back.
58  * @param testDuration Test duration in seconds, with range (0, infinity)
59  * @param worker The worker object to distribute the computation
60  * @return True, if this test succeeded
61  * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
62  */
63  template <bool tTransparentIs0xFF>
64  static bool testBlend(const double testDuration, Worker& worker);
65 
66  /**
67  * Tests the blend function with constant value.
68  * @param testDuration Test duration in seconds, with range (0, infinity)
69  * @param worker The worker object to distribute the computation
70  * @return True, if this test succeeded
71  * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
72  */
73  template <bool tTransparentIs0xFF>
74  static bool testBlendWithConstantValue(const double testDuration, Worker& worker);
75 
76  protected:
77 
78  /**
79  * Tests the blending two images with a separate alpha channel.
80  * @param testDuration Test duration in seconds, with range (0, infinity)
81  * @param worker The worker object to distribute the computation
82  * @return True, if this test succeeded
83  * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
84  */
85  template <bool tTransparentIs0xFF>
86  static bool testSeparateAlphaChannelSubFrame(const double testDuration, Worker& worker);
87 
88  /**
89  * Tests the blending two images with a separate alpha channel.
90  * @param testDuration Test duration in seconds, with range (0, infinity)
91  * @param worker The worker object to distribute the computation
92  * @return True, if this test succeeded
93  * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
94  */
95  template <bool tTransparentIs0xFF>
96  static bool testSeparateAlphaChannelFullFrame(const double testDuration, Worker& worker);
97 
98  /**
99  * Tests the sub-region transparent blend function.
100  * @param sourcePixelFormat Source pixel format
101  * @param targetPixelFormat Target pixel format
102  * @param targetWidth Width of the target test frame in pixel
103  * @param targetHeight Height of the target test frame in pixel
104  * @param testDuration Test duration in seconds, with range (0, infinity)
105  * @param worker The worker object to distribute the computation
106  * @return True, if this test succeeded
107  * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
108  */
109  template <bool tTransparentIs0xFF>
110  static bool testSubFrame(const FrameType::PixelFormat sourcePixelFormat, const FrameType::PixelFormat targetPixelFormat, const unsigned int targetWidth, const unsigned int targetHeight, const double testDuration, Worker& worker);
111 
112  /**
113  * Tests the transparent blend function.
114  * @param sourcePixelFormat Source pixel format
115  * @param targetPixelFormat Target pixel format
116  * @param width The width of the test frame in pixel
117  * @param height The height of the test frame in pixel
118  * @param testDuration Test duration in seconds, with range (0, infinity)
119  * @param worker The worker object to distribute the computation
120  * @return True, if this test succeeded
121  * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
122  */
123  template <bool tTransparentIs0xFF>
124  static bool testFullFrame(const FrameType::PixelFormat sourcePixelFormat, const FrameType::PixelFormat targetPixelFormat, const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
125 
126  /**
127  * Validates the blend function with alpha channel.
128  * @param sourceWithAlpha The source frame with alpha channel, must be valid
129  * @param target The target frame, must be valid
130  * @param blendResult The blend result, must be valid
131  * @param sourceLeft Horizontal start position inside the source frame, with range [0, sourceWithAlpha.width() - 1]
132  * @param sourceTop Vertical start position inside the source frame, with range [0, sourceWithAlpha.height() - 1]
133  * @param targetLeft Horizontal start position inside the target frame, with range [0, target.width() - 1]
134  * @param targetTop Vertical start position inside the target frame, with range [0, target.height() - 1]
135  * @param width The width of the blending sub-region in pixel, with range [1, min(sourceWithAlpha.width() - sourceLeft, target.width() - targetLeft)]
136  * @param height The height of the blending sub-region in pixel, with range [1, min(sourceWithAlpha.height() - sourceTop, target.height() - targetTop)]
137  * @return True, if succeeded
138  * @tparam tTransparentIs0xFF True, if 0xFF is interpreted as fully transparent value; False, if 0x00 is interpreted as fully transparent
139  */
140  template <bool tTransparentIs0xFF>
141  static bool validateBlendResult(const Frame& sourceWithAlpha, const Frame& target, const Frame& blendResult, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height);
142 };
143 
144 }
145 
146 }
147 
148 }
149 
150 #endif // META_OCEAN_TEST_TESTCV_TEST_FRAME_BLENDER_H
This class implements Ocean's image class.
Definition: Frame.h:1792
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition: Frame.h:183
This class implements a test for the frame blender class.
Definition: TestFrameBlender.h:27
static bool testSeparateAlphaChannelSubFrame(const double testDuration, Worker &worker)
Tests the blending two images with a separate alpha channel.
static bool test(const double testDuration, Worker &worker)
Tests the frame blender functions.
static bool testConstantAlpha(const double testDuration, Worker &worker)
Tests the blending two images with constant alpha value.
static bool validateBlendResult(const Frame &sourceWithAlpha, const Frame &target, const Frame &blendResult, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height)
Validates the blend function with alpha channel.
static bool testSeparateAlphaChannel(const double testDuration, Worker &worker)
Tests the blending two images with a separate alpha channel.
static bool testFullFrame(const FrameType::PixelFormat sourcePixelFormat, const FrameType::PixelFormat targetPixelFormat, const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests the transparent blend function.
static bool testBlend(const double testDuration, Worker &worker)
Tests the blend function with alpha channel at the front or at the back.
static bool testBlendWithConstantValue(const double testDuration, Worker &worker)
Tests the blend function with constant value.
static bool testSubFrame(const FrameType::PixelFormat sourcePixelFormat, const FrameType::PixelFormat targetPixelFormat, const unsigned int targetWidth, const unsigned int targetHeight, const double testDuration, Worker &worker)
Tests the sub-region transparent blend function.
static bool testSeparateAlphaChannelFullFrame(const double testDuration, Worker &worker)
Tests the blending two images with a separate alpha channel.
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15