Ocean
FrameConverterTestUtilities.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_FRAME_CONVERTER_TEST_UTILITIES_H
9 #define META_OCEAN_TEST_TESTCV_FRAME_CONVERTER_TEST_UTILITIES_H
10 
12 
13 #include "ocean/base/Frame.h"
15 #include "ocean/base/Memory.h"
16 #include "ocean/base/RandomI.h"
17 #include "ocean/base/Timestamp.h"
18 #include "ocean/base/Worker.h"
19 
20 #include "ocean/cv/CVUtilities.h"
22 
23 #include "ocean/math/Matrix.h"
24 
25 #include <functional>
26 #include <numeric>
27 
28 namespace Ocean
29 {
30 
31 namespace Test
32 {
33 
34 namespace TestCV
35 {
36 
37 /**
38  * This class implements frame converter test utilities.
39  * @ingroup testcv
40  */
41 class OCEAN_TEST_CV_EXPORT FrameConverterTestUtilities : protected CV::FrameConverter
42 {
43  public:
44 
45  /**
46  * This class is a helper class simply offering random values which are constant during process execution.
47  */
48  class ValueProvider : public Singleton<ValueProvider>
49  {
50  friend class Singleton<ValueProvider>;
51 
52  public:
53 
54  /**
55  * Returns the random (but constant during process execution) alpha value.
56  * @return The alpha value, with range [0, infinity)
57  */
58  inline uint8_t alphaValue() const;
59 
60  /**
61  * Returns the random (but constant during process execution) gamma value.
62  * @return The gamma value, with range [0.4, 1.0]
63  */
64  inline float gammaValue() const;
65 
66  protected:
67 
68  /**
69  * Protected constructor.
70  */
71  inline ValueProvider();
72 
73  protected:
74 
75  /// The alpha value.
76  uint8_t alphaValue_;
77 
78  /// The gamma value.
79  float gammaValue_;
80  };
81 
82  /**
83  * This class is a wrapper for function pointers.
84  */
86  {
87  public:
88 
89  /**
90  * Definition of individual types of conversion functions.
91  */
92  enum FunctionType : uint32_t
93  {
94  /// And invalid function type.
95  FT_INVALID = 0u,
96  /// 1-plane uint8 to 1-plane uint8 conversion function.
98  /// 1-plane uint8 to 1-plane uint16 conversion function.
100  /// 1-plane uint8 plus constant gamma to 1-plane uint8 conversion function.
102  /// 1-plane uint8 to 1-plane plus constant alpha uint8 conversion function.
104  /// 1-plane uint8 to 1-plane uint8 plus constant black level, white balance, and gamma conversion function.
106  /// 1-plane uint16 to 1-plane uint8 conversion function.
108  /// 1-plane uint16 to 1-plane uint16 conversion function.
110  /// 1-plane uint32 to 1-plane uint8 conversion function.
112  /// 1-plane uint32 to 1-plane uint16 conversion function.
114  /// 1-plane uint8 to 2-plane uint8 conversion function.
116  /// 1-plane uint8 to 3-plane uint8 conversion function.
118  /// 2-plane uint8 to 1-plane uint8 conversion function.
120  /// 2-plane uint8 to 1-plane plus constant alpha uint8 conversion function.
122  /// 2-plane uint8 to 3-plane plus constant alpha uint8 conversion function.
124  /// 3-plane uint8 to 1-plane uint8 conversion function.
126  /// 3-plane uint8 to 3-plane uint8 conversion function.
128  /// 3-plane uint8 to 1-plane plus constant alpha uint8 conversion function.
129  FT_3_UINT8_TO_1_UINT8_ALPHA
130  };
131 
132  /**
133  * Definition of a function pointer to a conversion function with one source plane and one target plane.
134  */
135  template <typename TSource, typename TTarget>
136  using OneSourceOneTargetConversionFunction = void(*)(const TSource* source, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker* worker);
137 
138  /**
139  * Definition of a function pointer to a conversion function with one source plane and one target plane plus constant alpha.
140  */
141  template <typename TSource, typename TTarget>
142  using OneSourceGammaOneTargetConversionFunction = void(*)(const TSource* source, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const float gamma, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker* worker);
143 
144  /**
145  * Definition of a function pointer to a conversion function with one source plane and one target plane plus constant alpha.
146  */
147  template <typename TSource, typename TTarget>
148  using OneSourceOneTargetAlphaConversionFunction = void(*)(const TSource* source, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, const TTarget alpha, Worker* worker);
149 
150  /**
151  * Definition of a function pointer to a conversion function with one source plane and one target plane plus constant black level, white balance, and gamma.
152  */
153  template <typename TSource, typename TTarget>
154  using OneSourceOneTargetBlackLevelWhiteBalanceGammaConversionFunction = void(*)(const TSource* source, TTarget* target, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const uint16_t blackLevel, const float* whiteBalance, const float gamma, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker* worker);
155 
156  /**
157  * Definition of a function pointer to a conversion function with one source plane and two target planes.
158  */
159  template <typename TSource, typename TTarget>
160  using OneSourceTwoTargetsConversionFunction = void(*)(const TSource* source, TTarget* target0, TTarget* target1, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, Worker* worker);
161 
162  /**
163  * Definition of a function pointer to a conversion function with one source plane and three target planes.
164  */
165  template <typename TSource, typename TTarget>
166  using OneSourceThreeTargetsConversionFunction = void(*)(const TSource* source, TTarget* target0, TTarget* target1, TTarget* target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, const uint32_t target2PaddingElements, Worker* worker);
167 
168  /**
169  * Definition of a function pointer to a conversion function with two source planes and one target plane.
170  */
171  template <typename TSource, typename TTarget>
172  using TwoSourcesOneTargetConversionFunction = void(*)(const TSource* source0, const TSource* source1, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements, Worker* worker);
173 
174  /**
175  * Definition of a function pointer to a conversion function with two source planes and three target planes.
176  */
177  template <typename TSource, typename TTarget>
178  using TwoSourcesThreeTargetConversionFunction = void(*)(const TSource* source0, const TSource* source1, TTarget* target0, TTarget* target1, TTarget* target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements0, const uint32_t targetPaddingElements1, const uint32_t targetPaddingElements2, Worker* worker);
179 
180  /**
181  * Definition of a function pointer to a conversion function with two source planes and one target plane plus constant alpha.
182  */
183  template <typename TSource, typename TTarget>
184  using TwoSourcesOneTargetAlphaConversionFunction = void(*)(const TSource* source0, const TSource* source1, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements, const TTarget alpha, Worker* worker);
185 
186  /**
187  * Definition of a function pointer to a conversion function with three source planes and one target plane.
188  */
189  template <typename TSource, typename TTarget>
190  using ThreeSourcesOneTargetConversionFunction = void(*)(const TSource* source0, const TSource* source1, const TSource* source2, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements, Worker* worker);
191 
192  /**
193  * Definition of a function pointer to a conversion function with three source planes and three target planes.
194  */
195  template <typename TSource, typename TTarget>
196  using ThreeSourcesThreeTargetConversionFunction = void(*)(const TSource* source0, const TSource* source1, const TSource* source2, TTarget* target0, TTarget* target1, TTarget* target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements0, const uint32_t targetPaddingElements1, const uint32_t targetPaddingElements2, Worker* worker);
197 
198  /**
199  * Definition of a function pointer to a conversion function with three source planes and one target plane plus constant alpha.
200  */
201  template <typename TSource, typename TTarget>
202  using ThreeSourcesOneTargetAlphaConversionFunction = void(*)(const TSource* source0, const TSource* source1, const TSource* source2, TTarget* target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements, const TTarget alpha, Worker* worker);
203 
204  public:
205 
206  /**
207  * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8 function.
208  * @param function The pointer to the conversion function, must be valid
209  */
211 
212  /**
213  * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT16 function.
214  * @param function The pointer to the conversion function, must be valid
215  */
217 
218  /**
219  * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_GAMMA_TO_1_UINT8 function.
220  * @param function The pointer to the conversion function, must be valid
221  */
223 
224  /**
225  * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8_ALPHA function.
226  * @param function The pointer to the conversion function, must be valid
227  */
229 
230  /**
231  * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8_BLACKLEVEL_WHITEBALANCE_GAMMA function.
232  * @param function The pointer to the conversion function, must be valid
233  */
235 
236  /**
237  * Creates a new wrapper object and stores a function pointer to a FT_1_UINT16_TO_1_UINT8 function.
238  * @param function The pointer to the conversion function, must be valid
239  */
241 
242  /**
243  * Creates a new wrapper object and stores a function pointer to a FT_1_UINT16_TO_1_UINT16 function.
244  * @param function The pointer to the conversion function, must be valid
245  */
247 
248  /**
249  * Creates a new wrapper object and stores a function pointer to a FT_1_UINT32_TO_1_UINT8 function.
250  * @param function The pointer to the conversion function, must be valid
251  */
253 
254  /**
255  * Creates a new wrapper object and stores a function pointer to a FT_1_UINT32_TO_1_UINT16 function.
256  * @param function The pointer to the conversion function, must be valid
257  */
259 
260  /**
261  * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_2_UINT8 function.
262  * @param function The pointer to the conversion function, must be valid
263  */
265 
266  /**
267  * Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_3_UINT8 function.
268  * @param function The pointer to the conversion function, must be valid
269  */
271 
272  /**
273  * Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_1_UINT8 function.
274  * @param function The pointer to the conversion function, must be valid
275  */
277 
278  /**
279  * Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_3_UINT8 function.
280  * @param function The pointer to the conversion function, must be valid
281  */
283 
284  /**
285  * Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_1_UINT8_ALPHA function.
286  * @param function The pointer to the conversion function, must be valid
287  */
289 
290  /**
291  * Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_1_UINT8 function.
292  * @param function The pointer to the conversion function, must be valid
293  */
295 
296  /**
297  * Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_3_UINT8 function.
298  * @param function The pointer to the conversion function, must be valid
299  */
301 
302  /**
303  * Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_1_UINT8_ALPHA function.
304  * @param function The pointer to the conversion function, must be valid
305  */
307 
308  /**
309  * Calls the conversion function for a source and target frame.
310  * @param source The source frame, must be valid
311  * @param target The target frame, must be valid
312  * @param conversionFlag The conversion flag to be used
313  * @param options Optional parameters that can be provided to the wrapped conversion function, must be `nullptr` to be ignored or be valid and have the expected number of elements for that specific function
314  * @param worker Optional worker object to be used
315  * @return True, if succeeded
316  */
317  bool invoke(const Frame& source, Frame& target, const FrameConverter::ConversionFlag conversionFlag, const void* options, Worker* worker) const;
318 
319  protected:
320 
321  /// The function pointer of the conversion function.
322  const void* function_;
323 
324  /// The type of the conversion function.
326  };
327 
328  public:
329 
330  /**
331  * Definition of a function pointer to a pixel extraction function.
332  * @param frame The frame from which the pixel will be extracted, must be valid
333  * @param x The horizontal pixel location within the frame, with range [0, width - 1]
334  * @param y The vertical pixel location within the frame, with range [0, height - 1]
335  * @param conversionFlag The conversion flag that will be applied, must be valid
336  * @return The pixel color values, a vector for a trivial case; a matrix in case each channel needs to be handled individually
337  */
338  using FunctionPixelValue = std::function<MatrixD(const Frame& frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag)>;
339 
340  public:
341 
342  /**
343  * Tests the conversion of frames with one pixel format to another pixel format for functions supporting padding.
344  * @param sourcePixelFormat The pixel format of the source frame, must be valid
345  * @param targetPixelFormat The pixel format of the target frame, must be valid
346  * @param width The width of the original frame in pixel, with range [1, infinity)
347  * @param height The height of the original frame in pixel, with range [1, infinity)
348  * @param functionWrapper The wrapper around the conversion function to be tested, must be valid
349  * @param conversionFlag The conversion type to be used
350  * @param functionSourcePixelValue The function pointer which to extract one pixel from the source image, must be valid
351  * @param functionTargetPixelValue The function pointer which to extract one pixel from the target image, must be valid
352  * @param transformationMatrix The transformation matrix defining the conversion (an affine transformation)
353  * @param minimalGroundTruthValue The minimal ground truth value for value clamping, with range (-infinity, maximalGroundTruthValue)
354  * @param maximalGroundTruthValue The maximal ground truth value for value clamping, with range (minimalGroundTruthValue, infinity)
355  * @param testDuration Number of seconds for each test, with range (0, infinity)
356  * @param worker The worker object
357  * @param thresholdMaximalErrorToInteger The maximal allowed error between the ground truth integer and the resulting integer value, with range [0, infinity)
358  * @param options Optional parameters that will be provided to the function wrapper when it is invoked, must be `nullptr` to be ignored or be valid and have the expected number of elements for that specific function
359  * @return True, if succeeded
360  */
361  static bool testFrameConversion(const FrameType::PixelFormat& sourcePixelFormat, const FrameType::PixelFormat& targetPixelFormat, const unsigned int width, const unsigned int height, const FunctionWrapper& functionWrapper, const CV::FrameConverter::ConversionFlag conversionFlag, const FunctionPixelValue functionSourcePixelValue, const FunctionPixelValue functionTargetPixelValue, const MatrixD& transformationMatrix, const double minimalGroundTruthValue, const double maximalGroundTruthValue, const double testDuration, Worker& worker, const unsigned int thresholdMaximalErrorToInteger = 3u, const void* options = nullptr);
362 
363  /**
364  * Validates the color space conversion from a source pixel format to a target pixel format.
365  * @param sourceFrame The source frame, must be valid
366  * @param targetFrame The target frame, must be valid
367  * @param functionSourcePixelValue The function pointer which to extract one pixel from the source image, must be valid
368  * @param functionTargetPixelValue The function pointer which to extract one pixel from the target image, must be valid
369  * @param transformationMatrix The transformation matrix defining the conversion (an affine transformation)
370  * @param conversionFlag The conversion flag that has been applied during conversion
371  * @param averageAbsErrorToFloat Resulting average absolute error between the converted result and the ground truth floating point result, with range [0, 256)
372  * @param averageAbsErrorToInteger Resulting average absolute error between the converted result and the ground truth integer result (rounded result), with range [0, 256)
373  * @param maximalAbsErrorToFloat maximal absolute error between the converted result and the ground truth floating point result, with range [0, 256)
374  * @param maximalAbsErrorToInteger Resulting maximal absolute error between the converted result and the ground truth integer result (rounded result), with range [0, 256)
375  * @param minimalGroundTruthValue The minimal ground truth value for value clamping, with range (-infinity, maximalGroundTruthValue)
376  * @param maximalGroundTruthValue The maximal ground truth value for value clamping, with range (minimalGroundTruthValue, infinity)
377  * @param skipPlausibilityCheck True, to skip the plausibility check ensuring that the resulting pixel values are in a plausible value range; False, to apply the plausibility check
378  * @return True, if succeeded
379  */
380  static bool validateConversion(const Frame& sourceFrame, const Frame& targetFrame, const FunctionPixelValue functionSourcePixelValue, const FunctionPixelValue functionTargetPixelValue, const MatrixD& transformationMatrix, const CV::FrameConverter::ConversionFlag conversionFlag, double* averageAbsErrorToFloat, double* averageAbsErrorToInteger, double* maximalAbsErrorToFloat, unsigned int* maximalAbsErrorToInteger, const double minimalGroundTruthValue, const double maximalGroundTruthValue, const bool skipPlausibilityCheck = false);
381 
382  /**
383  * Extracts one pixel from a generic frame (e.g,. with pixel format BGR24, RGB24, YUV24, ...).
384  * @param frame The frame from which the pixel will be extracted, must be valid
385  * @param x The horizontal pixel location within the frame, with range [0, frame.width() - 1]
386  * @param y The vertical pixel location within the frame, with range [0, frame.height() - 1]
387  * @param conversionFlag The conversion flag that will be applied, must be valid
388  * @return The vector holding the frame's color value at the specified location
389  */
390  static MatrixD functionGenericPixel(const Frame& frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag);
391 };
392 
394  alphaValue_(uint8_t(RandomI::random(0u, 255u))),
395  gammaValue_(0.0f)
396 {
397  const std::vector<float> gammaValues = {0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f};
398 
399  gammaValue_ = RandomI::random(gammaValues);
400 }
401 
403 {
404  return alphaValue_;
405 }
406 
408 {
409  return gammaValue_;
410 }
411 
412 } // namespace TestCV
413 
414 } // namespace Test
415 
416 } // namespace Ocean
417 
418 #endif // META_OCEAN_TEST_TESTCV_FRAME_CONVERTER_TEST_UTILITIES_H
This is the base class for all frame converter classes.
Definition: FrameConverter.h:32
ConversionFlag
Definition of individual conversion flags.
Definition: FrameConverter.h:39
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 matrix with arbitrary size.
Definition: Matrix.h:63
This class provides base random functions and several random functions for integer data types.
Definition: RandomI.h:29
static unsigned int random(const unsigned int maxValue)
Returns one random integer value with specified maximum value.
This template class is the base class for all singleton objects.
Definition: Singleton.h:71
This class is a wrapper for function pointers.
Definition: FrameConverterTestUtilities.h:86
const void * function_
The function pointer of the conversion function.
Definition: FrameConverterTestUtilities.h:322
FunctionWrapper(const TwoSourcesOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_1_UINT8 function.
FunctionType
Definition of individual types of conversion functions.
Definition: FrameConverterTestUtilities.h:93
@ FT_2_UINT8_TO_1_UINT8_ALPHA
2-plane uint8 to 1-plane uint8 conversion function.
Definition: FrameConverterTestUtilities.h:119
@ FT_1_UINT8_TO_2_UINT8
1-plane uint8 to 2-plane uint8 conversion function.
Definition: FrameConverterTestUtilities.h:115
@ FT_1_UINT16_TO_1_UINT16
1-plane uint16 to 1-plane uint16 conversion function.
Definition: FrameConverterTestUtilities.h:109
@ FT_1_UINT8_TO_1_UINT8_BLACKLEVEL_WHITEBALANCE_GAMMA
1-plane uint8 to 1-plane uint8 plus constant black level, white balance, and gamma conversion functio...
Definition: FrameConverterTestUtilities.h:105
@ FT_1_UINT8_GAMMA_TO_1_UINT8
1-plane uint8 plus constant gamma to 1-plane uint8 conversion function.
Definition: FrameConverterTestUtilities.h:101
@ FT_1_UINT8_TO_1_UINT16
1-plane uint8 to 1-plane uint16 conversion function.
Definition: FrameConverterTestUtilities.h:99
@ FT_1_UINT8_TO_1_UINT8_ALPHA
1-plane uint8 to 1-plane plus constant alpha uint8 conversion function.
Definition: FrameConverterTestUtilities.h:103
@ FT_1_UINT16_TO_1_UINT8
1-plane uint16 to 1-plane uint8 conversion function.
Definition: FrameConverterTestUtilities.h:107
@ FT_1_UINT32_TO_1_UINT8
1-plane uint32 to 1-plane uint8 conversion function.
Definition: FrameConverterTestUtilities.h:111
@ FT_1_UINT8_TO_1_UINT8
1-plane uint8 to 1-plane uint8 conversion function.
Definition: FrameConverterTestUtilities.h:97
@ FT_3_UINT8_TO_1_UINT8
3-plane uint8 to 1-plane uint8 conversion function.
Definition: FrameConverterTestUtilities.h:125
@ FT_2_UINT8_TO_1_UINT8
2-plane uint8 to 1-plane plus constant alpha uint8 conversion function.
Definition: FrameConverterTestUtilities.h:121
@ FT_2_UINT8_TO_3_UINT8
2-plane uint8 to 3-plane plus constant alpha uint8 conversion function.
Definition: FrameConverterTestUtilities.h:123
@ FT_1_UINT8_TO_3_UINT8
1-plane uint8 to 3-plane uint8 conversion function.
Definition: FrameConverterTestUtilities.h:117
@ FT_1_UINT32_TO_1_UINT16
1-plane uint32 to 1-plane uint16 conversion function.
Definition: FrameConverterTestUtilities.h:113
@ FT_3_UINT8_TO_3_UINT8
3-plane uint8 to 3-plane uint8 conversion function.
Definition: FrameConverterTestUtilities.h:127
void(*)(const TSource *source0, const TSource *source1, const TSource *source2, TTarget *target0, TTarget *target1, TTarget *target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements0, const uint32_t targetPaddingElements1, const uint32_t targetPaddingElements2, Worker *worker) ThreeSourcesThreeTargetConversionFunction
Definition of a function pointer to a conversion function with three source planes and three target p...
Definition: FrameConverterTestUtilities.h:196
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint32_t, uint16_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT32_TO_1_UINT16 function.
FunctionWrapper(const TwoSourcesThreeTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_3_UINT8 function.
FunctionWrapper(const ThreeSourcesThreeTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_3_UINT8 function.
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8 function.
void(*)(const TSource *source, TTarget *target, const unsigned int width, const unsigned int height, const ConversionFlag conversionFlag, const uint16_t blackLevel, const float *whiteBalance, const float gamma, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker *worker) OneSourceOneTargetBlackLevelWhiteBalanceGammaConversionFunction
Definition of a function pointer to a conversion function with one source plane and one target plane ...
Definition: FrameConverterTestUtilities.h:154
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint16_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT16_TO_1_UINT8 function.
void(*)(const TSource *source, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, const TTarget alpha, Worker *worker) OneSourceOneTargetAlphaConversionFunction
Definition of a function pointer to a conversion function with one source plane and one target plane ...
Definition: FrameConverterTestUtilities.h:148
void(*)(const TSource *source0, const TSource *source1, const TSource *source2, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements, const TTarget alpha, Worker *worker) ThreeSourcesOneTargetAlphaConversionFunction
Definition of a function pointer to a conversion function with three source planes and one target pla...
Definition: FrameConverterTestUtilities.h:202
bool invoke(const Frame &source, Frame &target, const FrameConverter::ConversionFlag conversionFlag, const void *options, Worker *worker) const
Calls the conversion function for a source and target frame.
void(*)(const TSource *source, TTarget *target0, TTarget *target1, TTarget *target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, const uint32_t target2PaddingElements, Worker *worker) OneSourceThreeTargetsConversionFunction
Definition of a function pointer to a conversion function with one source plane and three target plan...
Definition: FrameConverterTestUtilities.h:166
void(*)(const TSource *source, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker *worker) OneSourceOneTargetConversionFunction
Definition of a function pointer to a conversion function with one source plane and one target plane.
Definition: FrameConverterTestUtilities.h:136
const FunctionType functionType_
The type of the conversion function.
Definition: FrameConverterTestUtilities.h:325
FunctionWrapper(const OneSourceOneTargetBlackLevelWhiteBalanceGammaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8_BLACKLEVEL_WHIT...
void(*)(const TSource *source, TTarget *target0, TTarget *target1, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t sourcePaddingElements, const uint32_t target0PaddingElements, const uint32_t target1PaddingElements, Worker *worker) OneSourceTwoTargetsConversionFunction
Definition of a function pointer to a conversion function with one source plane and two target planes...
Definition: FrameConverterTestUtilities.h:160
void(*)(const TSource *source0, const TSource *source1, TTarget *target0, TTarget *target1, TTarget *target2, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements0, const uint32_t targetPaddingElements1, const uint32_t targetPaddingElements2, Worker *worker) TwoSourcesThreeTargetConversionFunction
Definition of a function pointer to a conversion function with two source planes and three target pla...
Definition: FrameConverterTestUtilities.h:178
void(*)(const TSource *source0, const TSource *source1, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements, const TTarget alpha, Worker *worker) TwoSourcesOneTargetAlphaConversionFunction
Definition of a function pointer to a conversion function with two source planes and one target plane...
Definition: FrameConverterTestUtilities.h:184
FunctionWrapper(const OneSourceOneTargetAlphaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT8_ALPHA function.
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint16_t, uint16_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT16_TO_1_UINT16 function.
FunctionWrapper(const ThreeSourcesOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_1_UINT8 function.
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint8_t, uint16_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_1_UINT16 function.
FunctionWrapper(const OneSourceTwoTargetsConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_2_UINT8 function.
FunctionWrapper(const OneSourceThreeTargetsConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_TO_3_UINT8 function.
FunctionWrapper(const OneSourceOneTargetConversionFunction< uint32_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT32_TO_1_UINT8 function.
FunctionWrapper(const TwoSourcesOneTargetAlphaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_2_UINT8_TO_1_UINT8_ALPHA function.
FunctionWrapper(const OneSourceGammaOneTargetConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_1_UINT8_GAMMA_TO_1_UINT8 function.
void(*)(const TSource *source0, const TSource *source1, const TSource *source2, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t source2PaddingElements, const uint32_t targetPaddingElements, Worker *worker) ThreeSourcesOneTargetConversionFunction
Definition of a function pointer to a conversion function with three source planes and one target pla...
Definition: FrameConverterTestUtilities.h:190
void(*)(const TSource *source0, const TSource *source1, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const uint32_t source0PaddingElements, const uint32_t source1PaddingElements, const uint32_t targetPaddingElements, Worker *worker) TwoSourcesOneTargetConversionFunction
Definition of a function pointer to a conversion function with two source planes and one target plane...
Definition: FrameConverterTestUtilities.h:172
FunctionWrapper(const ThreeSourcesOneTargetAlphaConversionFunction< uint8_t, uint8_t > function)
Creates a new wrapper object and stores a function pointer to a FT_3_UINT8_TO_1_UINT8_ALPHA function.
void(*)(const TSource *source, TTarget *target, const uint32_t width, const uint32_t height, const ConversionFlag conversionFlag, const float gamma, const uint32_t sourcePaddingElements, const uint32_t targetPaddingElements, Worker *worker) OneSourceGammaOneTargetConversionFunction
Definition of a function pointer to a conversion function with one source plane and one target plane ...
Definition: FrameConverterTestUtilities.h:142
This class is a helper class simply offering random values which are constant during process executio...
Definition: FrameConverterTestUtilities.h:49
ValueProvider()
Protected constructor.
Definition: FrameConverterTestUtilities.h:393
uint8_t alphaValue() const
Returns the random (but constant during process execution) alpha value.
Definition: FrameConverterTestUtilities.h:402
float gammaValue() const
Returns the random (but constant during process execution) gamma value.
Definition: FrameConverterTestUtilities.h:407
float gammaValue_
The gamma value.
Definition: FrameConverterTestUtilities.h:79
uint8_t alphaValue_
The alpha value.
Definition: FrameConverterTestUtilities.h:76
This class implements frame converter test utilities.
Definition: FrameConverterTestUtilities.h:42
std::function< MatrixD(const Frame &frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag)> FunctionPixelValue
Definition of a function pointer to a pixel extraction function.
Definition: FrameConverterTestUtilities.h:338
static MatrixD functionGenericPixel(const Frame &frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag)
Extracts one pixel from a generic frame (e.g,.
static bool testFrameConversion(const FrameType::PixelFormat &sourcePixelFormat, const FrameType::PixelFormat &targetPixelFormat, const unsigned int width, const unsigned int height, const FunctionWrapper &functionWrapper, const CV::FrameConverter::ConversionFlag conversionFlag, const FunctionPixelValue functionSourcePixelValue, const FunctionPixelValue functionTargetPixelValue, const MatrixD &transformationMatrix, const double minimalGroundTruthValue, const double maximalGroundTruthValue, const double testDuration, Worker &worker, const unsigned int thresholdMaximalErrorToInteger=3u, const void *options=nullptr)
Tests the conversion of frames with one pixel format to another pixel format for functions supporting...
static bool validateConversion(const Frame &sourceFrame, const Frame &targetFrame, const FunctionPixelValue functionSourcePixelValue, const FunctionPixelValue functionTargetPixelValue, const MatrixD &transformationMatrix, const CV::FrameConverter::ConversionFlag conversionFlag, double *averageAbsErrorToFloat, double *averageAbsErrorToInteger, double *maximalAbsErrorToFloat, unsigned int *maximalAbsErrorToInteger, const double minimalGroundTruthValue, const double maximalGroundTruthValue, const bool skipPlausibilityCheck=false)
Validates the color space conversion from a source pixel format to a target pixel format.
This class implements a worker able to distribute function calls over different threads.
Definition: Worker.h:33
MatrixT< double > MatrixD
Definition of the MatrixT template class using a double precision float data type.
Definition: Matrix.h:32
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15