Ocean
TestFrameConverter.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_CONVERTER_H
9 #define META_OCEAN_TEST_TESTCV_TEST_FRAME_CONVERTER_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 a frame converter test for the function of the basic frame converter.
39  * @ingroup testcv
40  */
41 class OCEAN_TEST_CV_EXPORT TestFrameConverter : 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 all frame converter functions.
344  * @param testDuration Number of seconds for each test, with range (0, infinity)
345  * @param worker The worker object to distribute the computation
346  * @return True, if all tests succeeded
347  */
348  static bool test(const double testDuration, Worker& worker);
349 
350  /**
351  * Tests the comfort convert function for a Frame.
352  * @param testDuration Number of seconds for each test, with range (0, infinity)
353  * @return True, if succeeded
354  */
355  static bool testComfortConvert(const double testDuration);
356 
357  /**
358  * Tests the comfort convert and copy function for a Frame.
359  * @param testDuration Number of seconds for each test, with range (0, infinity)
360  * @return True, if succeeded
361  */
362  static bool testComfortConvertAndCopy(const double testDuration);
363 
364  /**
365  * Tests the comfort change function for a Frame.
366  * @param testDuration Number of seconds for each test, with range (0, infinity)
367  * @return True, if succeeded
368  */
369  static bool testComfortChange(const double testDuration);
370 
371  /**
372  * Tests the cast function.
373  * @param testDuration Number of seconds for each test, with range (0, infinity)
374  * @return True, if succeeded
375  */
376  static bool testCast(const double testDuration);
377 
378  /**
379  * Tests the normalized cast function.
380  * @param testDuration Number of seconds for each test, with range (0, infinity)
381  * @return True, if succeeded
382  */
383  static bool testNormalizedCast(const double testDuration);
384 
385  /**
386  * Tests the sub frame function.
387  * @param testDuration Number of seconds for each test, with range (0, infinity)
388  * @return True, if succeeded
389  */
390  static bool testSubFrame(const double testDuration);
391 
392  /**
393  * Tests the sub frame function.
394  * @param testDuration Number of seconds for each test, with range (0, infinity)
395  * @return True, if succeeded
396  */
397  static bool testSubFrameMask(const double testDuration);
398 
399  /**
400  * Tests the patch creator.
401  * @param testDuration Number of seconds for each test, with range (0, infinity)
402  * @return True, if succeeded
403  */
404  static bool testPatchFrame(const double testDuration);
405 
406  /**
407  * Tests the patch creator with mirrored border.
408  * @param testDuration Number of seconds for each test, with range (0, infinity)
409  * @return True, if succeeded
410  */
411  static bool testPatchFrameMirroredBorder(const double testDuration);
412 
413  /**
414  * Test the 1-row-based converter for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of channel 2 and 3, with 6 bit precision.
415  * @param testDuration Number of seconds for each test, with range (0, infinity)
416  * @return True, if the test was successful, otherwise false
417  */
419 
420  /**
421  * Test the 1-row-based converter for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of channel 2 and 3, with 10 bit precision.
422  * @param testDuration Number of seconds for each test, with range (0, infinity)
423  * @return True, if the test was successful, otherwise false
424  */
426 
427  /**
428  * Test the 2-row-based converter for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of channel 2 and 3, with 10 bit precision.
429  * @param testDuration Number of seconds for each test, with range (0, infinity)
430  * @return True, if the test was successful, otherwise false
431  */
433 
434  /**
435  * Test the 2-row-based converter for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of channel 2 and 3, with 10 bit precision.
436  * @param testDuration Number of seconds for each test, with range (0, infinity)
437  * @return True, if the test was successful, otherwise false
438  */
440 
441  /**
442  * Test the 2-row-based converter for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of channel 2 and 3, with 7 bit precision.
443  * @param testDuration Number of seconds for each test, with range (0, infinity)
444  * @return True, if the test was successful, otherwise false
445  */
447 
448  /**
449  * Test the 2-row-based converter for pixel formats with 3 channels, 3 planes and a 2x2 downsampling of channel 2 and 3, with 7 bit precision.
450  * @param testDuration Number of seconds for each test, with range (0, infinity)
451  * @return True, if the test was successful, otherwise false
452  */
454 
455  /**
456  * Test the 1-row-based mapper for pixel formats with 3 planes and 1 channel to 1 plane and 3 channels.
457  * @param testDuration Number of seconds for each test, with range (0, infinity)
458  * @return True, if the test was successful, otherwise false
459  */
461 
462  /**
463  * Test the 1-row-based mapper for pixel formats with 3 channels, 1 planes and a 2x1 downsampling of channel 2 and 3.
464  * @param testDuration Number of seconds for each test, with range (0, infinity)
465  * @return True, if the test was successful, otherwise false
466  */
468 
469  /**
470  * Test the 1-row-based mapper for pixel formats with 3 channels, 1 planes and a 2x1 downsampling of channel 1 and 3.
471  * @param testDuration Number of seconds for each test, with range (0, infinity)
472  * @return True, if the test was successful, otherwise false
473  */
475 
476  /**
477  * Test the 1-row-based mapper for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of channel 2 and 3.
478  * @param testDuration Number of seconds for each test, with range (0, infinity)
479  * @return True, if the test was successful, otherwise false
480  */
482 
483  /**
484  * Test the 2-row-based mapper for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of channel 2 and 3.
485  * @param testDuration Number of seconds for each test, with range (0, infinity)
486  * @return True, if the test was successful, otherwise false
487  */
489 
490  /**
491  * Test the 1-row-based converter for pixel formats with 3 channels, 3 planes and a 2x2 downsampling of channel 2 and 3.
492  * @param testDuration Number of seconds for each test, with range (0, infinity)
493  * @return True, if the test was successful, otherwise false
494  */
496 
497  /**
498  * Test the 2-row-based converter for pixel formats with 3 channels, 3 planes and a 2x2 downsampling of channel 2 and 3.
499  * @param testDuration Number of seconds for each test, with range (0, infinity)
500  * @return True, if the test was successful, otherwise false
501  */
503 
504  /**
505  * Test the 2-row-based converter for pixel formats with 3 channels, 3 planes and a 2x2 downsampling of channel 2 and 3 adding a new target channel.
506  * @param testDuration Number of seconds for each test, with range (0, infinity)
507  * @return True, if the test was successful, otherwise false
508  */
510 
511  /**
512  * Test the 2-row-based converter for pixel formats with 3 channels, 3 planes and a 2x2 downsampling of channel 2 and 3.
513  * @param testDuration Number of seconds for each test, with range (0, infinity)
514  * @return True, if the test was successful, otherwise false
515  */
517 
518  /**
519  * Test the 1-row-based mapper for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of channel 2 and 3.
520  * @param testDuration Number of seconds for each test, with range (0, infinity)
521  * @return True, if the test was successful, otherwise false
522  */
524 
525  /**
526  * Test the 2-row-based mapper for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of channel 2 and 3.
527  * @param testDuration Number of seconds for each test, with range (0, infinity)
528  * @return True, if the test was successful, otherwise false
529  */
531 
532  /**
533  * Test the 1-row-based convert 3-plane to zipped 3-channel function, with 6 bit precision.
534  * @param testDuration Number of seconds for each test, with range (0, infinity)
535  * @return True, if the test was successful, otherwise false
536  */
538 
539  /**
540  * Test the 1-row-based convert zipped 3-channel with 2x1 downsampling to 3-channel function, with 10 bit precision.
541  * @param testDuration Number of seconds for each test, with range (0, infinity)
542  * @return True, if the test was successful, otherwise false
543  */
545 
546  /**
547  * Test the 1-row-based convert zipped 3-channel with 2x1 downsampling to 3-channel function, with 10 bit precision.
548  * @param testDuration Number of seconds for each test, with range (0, infinity)
549  * @return True, if the test was successful, otherwise false
550  */
552 
553  /**
554  * Tests the conversion of frames with one pixel format to another pixel format for functions supporting padding.
555  * @param sourcePixelFormat The pixel format of the source frame, must be valid
556  * @param targetPixelFormat The pixel format of the target frame, must be valid
557  * @param width The width of the original frame in pixel, with range [1, infinity)
558  * @param height The height of the original frame in pixel, with range [1, infinity)
559  * @param functionWrapper The wrapper around the conversion function to be tested, must be valid
560  * @param conversionFlag The conversion type to be used
561  * @param functionSourcePixelValue The function pointer which to extract one pixel from the source image, must be valid
562  * @param functionTargetPixelValue The function pointer which to extract one pixel from the target image, must be valid
563  * @param transformationMatrix The transformation matrix defining the conversion (an affine transformation)
564  * @param minimalGroundTruthValue The minimal ground truth value for value clamping, with range (-infinity, maximalGroundTruthValue)
565  * @param maximalGroundTruthValue The maximal ground truth value for value clamping, with range (minimalGroundTruthValue, infinity)
566  * @param testDuration Number of seconds for each test, with range (0, infinity)
567  * @param worker The worker object
568  * @param thresholdMaximalErrorToInteger The maximal allowed error between the ground truth integer and the resulting integer value, with range [0, infinity)
569  * @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
570  * @return True, if succeeded
571  */
572  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);
573 
574  /**
575  * Tests the color space conversion matrices.
576  * @param testDuration Number of seconds for each test, with range (0, infinity)
577  * @return True, if succeeded
578  */
579  static bool testConversionMatrices(const double testDuration);
580 
581  /**
582  * Validates the color space conversion from a source pixel format to a target pixel format.
583  * @param sourceFrame The source frame, must be valid
584  * @param targetFrame The target frame, must be valid
585  * @param functionSourcePixelValue The function pointer which to extract one pixel from the source image, must be valid
586  * @param functionTargetPixelValue The function pointer which to extract one pixel from the target image, must be valid
587  * @param transformationMatrix The transformation matrix defining the conversion (an affine transformation)
588  * @param conversionFlag The conversion flag that has been applied during conversion
589  * @param averageAbsErrorToFloat Resulting average absolute error between the converted result and the ground truth floating point result, with range [0, 256)
590  * @param averageAbsErrorToInteger Resulting average absolute error between the converted result and the ground truth integer result (rounded result), with range [0, 256)
591  * @param maximalAbsErrorToFloat maximal absolute error between the converted result and the ground truth floating point result, with range [0, 256)
592  * @param maximalAbsErrorToInteger Resulting maximal absolute error between the converted result and the ground truth integer result (rounded result), with range [0, 256)
593  * @param minimalGroundTruthValue The minimal ground truth value for value clamping, with range (-infinity, maximalGroundTruthValue)
594  * @param maximalGroundTruthValue The maximal ground truth value for value clamping, with range (minimalGroundTruthValue, infinity)
595  * @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
596  * @return True, if succeeded
597  */
598  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);
599 
600  /**
601  * Extracts one pixel from a generic frame (e.g,. with pixel format BGR24, RGB24, YUV24, ...).
602  * @param frame The frame from which the pixel will be extracted, must be valid
603  * @param x The horizontal pixel location within the frame, with range [0, frame.width() - 1]
604  * @param y The vertical pixel location within the frame, with range [0, frame.height() - 1]
605  * @param conversionFlag The conversion flag that will be applied, must be valid
606  * @return The vector holding the frame's color value at the specified location
607  */
608  static MatrixD functionGenericPixel(const Frame& frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag);
609 
610  protected:
611 
612  /**
613  * Tests the sub frame function.
614  * @param testDuration Number of seconds for each test, with range (0, infinity)
615  * @return True, if succeeded
616  * @tparam T The data type of the elements to be used
617  */
618  template <typename T>
619  static bool testSubFrame(const double testDuration);
620 
621  /**
622  * Tests the cast function for from 'unsigned char' to a specified data type.
623  * @param width The width of the frame to be tested, with range [1, infinity)
624  * @param height The height of the frame to be tested, with range [1, infinity)
625  * @param channels The number of channels the frame has, with range [1, infinity)
626  * @return True, if succeeded
627  * @tparam T The data type of the target frame
628  */
629  template <typename T>
630  static bool testCast(const unsigned int width, const unsigned int height, const unsigned int channels);
631 
632  /**
633  * Tests the cast function for from 'unsigned char' to a specified data type.
634  * @param width The width of the frame to be tested, with range [1, infinity)
635  * @param height The height of the frame to be tested, with range [1, infinity)
636  * @param channels The number of channels the frame has, with range [1, infinity)
637  * @param normalization The normalization parameter that is applied
638  * @param offset The offset that is added to all values
639  * @return True, if succeeded
640  * @tparam T The data type of the target frame
641  */
642  template <typename T>
643  static bool testNormalizedCast(const unsigned int width, const unsigned int height, const unsigned int channels, const T normalization, const T offset);
644 
645  /**
646  * Tests the patch creator.
647  * @param testDuration Number of seconds for each test, with range (0, infinity)
648  * @return True, if succeeded
649  * @tparam T The element type to be used
650  */
651  template <typename T>
652  static bool testPatchFrame(const double testDuration);
653 
654  /**
655  * Tests the patch creator with mirrored border.
656  * @param testDuration Number of seconds for each test, with range (0, infinity)
657  * @return True, if succeeded
658  * @tparam T The element type to be used
659  * @tparam tChannels The number of frame channels, with range [1, infinity)
660  */
661  template <typename T, unsigned int tChannels>
662  static bool testPatchFrameMirroredBorder(const double testDuration);
663 
664  /**
665  * Validates the sub-frame function.
666  * @param channels Number of data channels of both frames, with range [1, infinity)
667  * @param source The source frame from which the image content has been copied, must be valid
668  * @param sourceWidth Width of the source frame in pixel, with range [1, infinity)
669  * @param sourceHeight Height of the source frame in pixel, with range [1, infinity)
670  * @param target The target frame to which the image content has been copied, must be valid
671  * @param targetWidth Width of the target frame in pixel, with range [1, infinity)
672  * @param targetHeight Height of the target frame in pixel, with range [1, infinity)
673  * @param sourceLeft Horizontal start position of the sub-frame within the source frame, with range [0, sourceWidth - 1]
674  * @param sourceTop Vertical start position of the sub-frame within the source frame, with range [0, sourceHeight - 1]
675  * @param targetLeft Horizontal start position of the sub-frame within the target frame, with range [0, targetWidth - 1]
676  * @param targetTop Vertical start position of the sub-frame within the target frame, with range [0, targetHeight - 1]
677  * @param width The width of the sub-frame in pixel, with range [1, min(sourceWidth - sourceLeft, targetWidth - targetLeft)]
678  * @param height The height of the sub-frame in pixel, with range [1, min(sourceHeight - sourceTop, targetHeight - targetTop)]
679  * @param sourcePaddingElements Optional number of padding elements at the end of each source row, with range [0, infinity)
680  * @param targetPaddingElements Optional number of padding elements at the end of each target row, with range [0, infinity)
681  * @return True, if succeeded
682  * @tparam T The data type of each element
683  */
684  template <typename T>
685  static bool validateSubFrame(const unsigned int channels, const T* source, const unsigned int sourceWidth, const unsigned int sourceHeight, const T* target, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements);
686 
687  /**
688  * Validates the sub-frame function supporting a mask.
689  * @param channels Number of data channels of both frames, with range [1, infinity)
690  * @param source The source frame from which the image content has been copied, must be valid
691  * @param sourceWidth Width of the source frame in pixel, with range [1, infinity)
692  * @param sourceHeight Height of the source frame in pixel, with range [1, infinity)
693  * @param originalTarget The copy of the target frame BEFORE the image content has been copied to it, must be valid
694  * @param target The target frame to which the image content has been copied, must be valid
695  * @param targetWidth Width of the target frame in pixel, with range [1, infinity)
696  * @param targetHeight Height of the target frame in pixel, with range [1, infinity)
697  * @param mask The binary mask that is used to indicate which source pixels to copy to the target frame, must be valid, have one channel, and have the same size as the source frame
698  * @param sourceLeft Horizontal start position of the sub-frame within the source frame, with range [0, sourceWidth - 1]
699  * @param sourceTop Vertical start position of the sub-frame within the source frame, with range [0, sourceHeight - 1]
700  * @param targetLeft Horizontal start position of the sub-frame within the target frame, with range [0, targetWidth - 1]
701  * @param targetTop Vertical start position of the sub-frame within the target frame, with range [0, targetHeight - 1]
702  * @param subFrameWidth Width of the sub-frame in pixel, with range [1, min(sourceWidth - sourceLeft, targetWidth - targetLeft)]
703  * @param subFrameHeight Height of the sub-frame in pixel, with range [1, min(sourceHeight - sourceTop, targetHeight - targetTop)]
704  * @param sourcePaddingElements Optional number of padding elements at the end of each source row, with range [0, infinity)
705  * @param targetPaddingElements Optional number of padding elements at the end of each target row, with range [0, infinity)
706  * @param maskPaddingElements Optional number of padding elements at the end of each source mask row, with range [0, infinity)
707  * @param maskValue Optional value which indicates which pixel value should be interpreted as the foreground (and copied)
708  * @return True, if succeeded
709  * @tparam T The data type of each element
710  */
711  template <typename T>
712  static bool validateSubFrameMask(const unsigned int channels, const T* source, const unsigned int sourceWidth, const unsigned int sourceHeight, const T* originalTarget, const T* target, const unsigned int targetWidth, const unsigned int targetHeight, const uint8_t* mask, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int subFrameWidth, const unsigned int subFrameHeight, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements, const unsigned int maskPaddingElements, const uint8_t maskValue);
713 };
714 
716  alphaValue_(uint8_t(RandomI::random(0u, 255u))),
717  gammaValue_(0.0f)
718 {
719  const std::vector<float> gammaValues = {0.4f, 0.5f, 0.6f, 0.7f, 0.8f, 0.9f, 1.0f};
720 
721  gammaValue_ = RandomI::random(gammaValues);
722 }
723 
725 {
726  return alphaValue_;
727 }
728 
730 {
731  return gammaValue_;
732 }
733 
734 } // namespace TestCV
735 
736 } // namespace Test
737 
738 } // namespace Ocean
739 
740 #endif // META_OCEAN_TEST_TESTCV_TEST_FRAME_CONVERTER_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:1760
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: TestFrameConverter.h:86
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: TestFrameConverter.h:93
@ FT_1_UINT8_TO_1_UINT16
1-plane uint8 to 1-plane uint16 conversion function.
Definition: TestFrameConverter.h:99
@ FT_2_UINT8_TO_1_UINT8
2-plane uint8 to 1-plane plus constant alpha uint8 conversion function.
Definition: TestFrameConverter.h:121
@ FT_1_UINT8_TO_3_UINT8
1-plane uint8 to 3-plane uint8 conversion function.
Definition: TestFrameConverter.h:117
@ FT_1_UINT8_GAMMA_TO_1_UINT8
1-plane uint8 plus constant gamma to 1-plane uint8 conversion function.
Definition: TestFrameConverter.h:101
@ FT_1_UINT8_TO_1_UINT8_ALPHA
1-plane uint8 to 1-plane plus constant alpha uint8 conversion function.
Definition: TestFrameConverter.h:103
@ FT_2_UINT8_TO_3_UINT8
2-plane uint8 to 3-plane plus constant alpha uint8 conversion function.
Definition: TestFrameConverter.h:123
@ FT_1_UINT8_TO_1_UINT8
1-plane uint8 to 1-plane uint8 conversion function.
Definition: TestFrameConverter.h:97
@ FT_1_UINT16_TO_1_UINT8
1-plane uint16 to 1-plane uint8 conversion function.
Definition: TestFrameConverter.h:107
@ FT_1_UINT32_TO_1_UINT16
1-plane uint32 to 1-plane uint16 conversion function.
Definition: TestFrameConverter.h:113
@ FT_1_UINT8_TO_2_UINT8
1-plane uint8 to 2-plane uint8 conversion function.
Definition: TestFrameConverter.h:115
@ FT_1_UINT16_TO_1_UINT16
1-plane uint16 to 1-plane uint16 conversion function.
Definition: TestFrameConverter.h:109
@ FT_3_UINT8_TO_1_UINT8
3-plane uint8 to 1-plane uint8 conversion function.
Definition: TestFrameConverter.h:125
@ FT_2_UINT8_TO_1_UINT8_ALPHA
2-plane uint8 to 1-plane uint8 conversion function.
Definition: TestFrameConverter.h:119
@ FT_1_UINT32_TO_1_UINT8
1-plane uint32 to 1-plane uint8 conversion function.
Definition: TestFrameConverter.h:111
@ FT_3_UINT8_TO_3_UINT8
3-plane uint8 to 3-plane uint8 conversion function.
Definition: TestFrameConverter.h:127
@ 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: TestFrameConverter.h:105
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.
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: TestFrameConverter.h:172
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.
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: TestFrameConverter.h:178
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: TestFrameConverter.h:142
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.
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: TestFrameConverter.h:190
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: TestFrameConverter.h:166
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 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: TestFrameConverter.h:154
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 *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: TestFrameConverter.h:148
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 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 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 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.
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: TestFrameConverter.h:184
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 *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: TestFrameConverter.h:136
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 *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: TestFrameConverter.h:202
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 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.
const void * function_
The function pointer of the conversion function.
Definition: TestFrameConverter.h:322
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 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.
const FunctionType functionType_
The type of the conversion function.
Definition: TestFrameConverter.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: TestFrameConverter.h:160
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: TestFrameConverter.h:196
This class is a helper class simply offering random values which are constant during process executio...
Definition: TestFrameConverter.h:49
float gammaValue_
The gamma value.
Definition: TestFrameConverter.h:79
float gammaValue() const
Returns the random (but constant during process execution) gamma value.
Definition: TestFrameConverter.h:729
uint8_t alphaValue_
The alpha value.
Definition: TestFrameConverter.h:76
uint8_t alphaValue() const
Returns the random (but constant during process execution) alpha value.
Definition: TestFrameConverter.h:724
ValueProvider()
Protected constructor.
Definition: TestFrameConverter.h:715
This class implements a frame converter test for the function of the basic frame converter.
Definition: TestFrameConverter.h:42
static bool testConvertOneRow_3Planes1Channel_To_1Plane3Channels_8BitPerChannel_Precision6Bit(const double testDuration)
Test the 1-row-based convert 3-plane to zipped 3-channel function, with 6 bit precision.
static bool testMapOneRow_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const double testDuration)
Test the 1-row-based mapper for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of cha...
static bool testConvertTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const double testDuration)
Test the 2-row-based converter for pixel formats with 3 channels, 3 planes and a 2x2 downsampling of ...
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 testPatchFrame(const double testDuration)
Tests the patch creator.
static bool testCast(const unsigned int width, const unsigned int height, const unsigned int channels)
Tests the cast function for from 'unsigned char' to a specified data type.
static bool testNormalizedCast(const double testDuration)
Tests the normalized cast function.
static bool testMapOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1BackIsDownsampled_To_1Plane3Channels_8BitPerChannel(const double testDuration)
Test the 1-row-based mapper for pixel formats with 3 channels, 1 planes and a 2x1 downsampling of cha...
static bool testSubFrame(const double testDuration)
Tests the sub frame function.
static bool testMapOneRow_3Plane1Channel_To_1Plane3Channels_8BitPerChannel(const double testDuration)
Test the 1-row-based mapper for pixel formats with 3 planes and 1 channel to 1 plane and 3 channels.
static bool testMapOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const double testDuration)
Test the 1-row-based mapper for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of cha...
static bool testConvertOneRow_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const double testDuration)
Test the 1-row-based converter for pixel formats with 3 channels, 3 planes and a 2x2 downsampling of ...
static bool testComfortChange(const double testDuration)
Tests the comfort change function for a Frame.
static bool testPatchFrame(const double testDuration)
Tests the patch creator.
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.
static bool test(const double testDuration, Worker &worker)
Tests all frame converter functions.
static bool testPatchFrameMirroredBorder(const double testDuration)
Tests the patch creator with mirrored border.
static bool testConversionMatrices(const double testDuration)
Tests the color space conversion matrices.
static bool testConvertOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1BackIsDownsampled_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const double testDuration)
Test the 1-row-based convert zipped 3-channel with 2x1 downsampling to 3-channel function,...
static bool testConvertTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit(const double testDuration)
Test the 2-row-based converter for pixel formats with 3 channels, 3 planes and a 2x2 downsampling of ...
static bool testConvertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const double testDuration)
Test the 1-row-based converter for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of ...
static bool testConvertOneRow_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit(const double testDuration)
Test the 1-row-based converter for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of ...
static bool testMapTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const double testDuration)
Test the 2-row-based mapper for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of cha...
static bool testMapTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel(const double testDuration)
Test the 2-row-based mapper for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of cha...
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: TestFrameConverter.h:338
static bool testComfortConvert(const double testDuration)
Tests the comfort convert function for a Frame.
static bool testNormalizedCast(const unsigned int width, const unsigned int height, const unsigned int channels, const T normalization, const T offset)
Tests the cast function for from 'unsigned char' to a specified data type.
static bool testConvertTwoRows_1Plane1ChannelAnd2Planes1ChannelDownsampled2x2_To_1Plane4Channels_8BitPerChannel_Precision6Bit(const double testDuration)
Test the 2-row-based converter for pixel formats with 3 channels, 3 planes and a 2x2 downsampling of ...
static bool testSubFrame(const double testDuration)
Tests the sub frame function.
static bool testComfortConvertAndCopy(const double testDuration)
Tests the comfort convert and copy function for a Frame.
static bool testConvertOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1FrontIsDownsampled_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const double testDuration)
Test the 1-row-based convert zipped 3-channel with 2x1 downsampling to 3-channel function,...
static bool testConvertTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision6Bit(const double testDuration)
Test the 2-row-based converter for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of ...
static bool testPatchFrameMirroredBorder(const double testDuration)
Tests the patch creator with mirrored border.
static bool testMapOneRow_1Plane3ChannelsWith2ChannelsDownsampled2x1FrontIsDownsampled_To_1Plane3Channels_8BitPerChannel(const double testDuration)
Test the 1-row-based mapper for pixel formats with 3 channels, 1 planes and a 2x1 downsampling of cha...
static bool testConvertTwoRows_1Plane3Channels_To_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_8BitPerChannel_Precision7Bit(const double testDuration)
Test the 2-row-based converter for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of ...
static bool testConvertTwoRows_1Plane1ChannelAnd1Plane2ChannelsDownsampled2x2_To_1Plane3Channels_8BitPerChannel_Precision10Bit(const double testDuration)
Test the 2-row-based converter for pixel formats with 3 channels, 2 planes and a 2x2 downsampling of ...
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 testSubFrameMask(const double testDuration)
Tests the sub frame function.
static bool testCast(const double testDuration)
Tests the cast function.
static bool validateSubFrame(const unsigned int channels, const T *source, const unsigned int sourceWidth, const unsigned int sourceHeight, const T *target, const unsigned int targetWidth, const unsigned int targetHeight, const unsigned int sourceLeft, const unsigned int sourceTop, const unsigned int targetLeft, const unsigned int targetTop, const unsigned int width, const unsigned int height, const unsigned int sourcePaddingElements, const unsigned int targetPaddingElements)
Validates the sub-frame function.
static bool testConvertTwoRows_1Plane3Channels_To_1Plane1ChannelAnd2Planes1ChannelsDownsampled2x2_8BitPerChannel_Precision7Bit(const double testDuration)
Test the 2-row-based converter for pixel formats with 3 channels, 3 planes and a 2x2 downsampling of ...
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