Ocean
Loading...
Searching...
No Matches
TestFrameConverterRGGB10_Packed.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_RGGB_10_PACKED_H
9#define META_OCEAN_TEST_TESTCV_TEST_FRAME_CONVERTER_RGGB_10_PACKED_H
10
13
14#include "ocean/base/Worker.h"
15
17
18namespace Ocean
19{
20
21namespace Test
22{
23
24namespace TestCV
25{
26
27/**
28 * This class implements a RGGB10_PACKED frame converter test.
29 * @ingroup testcv
30 */
31class OCEAN_TEST_CV_EXPORT TestFrameConverterRGGB10_Packed
32{
33 private:
34
35 /**
36 * Definition of a functor class to access single pixels of an frame with pixel format RGGB10_PACKED
37 */
39 {
40 public:
41
42 /**
43 * Constructor to specify black level, white balance, and gamma
44 * @param blackLevel The black level value that is subtracted from each element of the raw image before any other operation, range: [0, 1024)
45 * @param whiteBalance Pointer to the white balancing scalars of the red, green, and blue channel (in that order), range: [0, infinity), must be valid and have at least 3 elements
46 * @param gamma The gamma value that each pixel will be encoded with, range: [0, infinity), will be ignored if value is < 0
47 */
48 inline PixelFunctorRGGB10_Packed(const uint16_t blackLevel, const double* whiteBalance, const double gamma);
49
50 /**
51 * Extracts one pixel from a RGGB10_PACKED source frame and subtracts the black level and applies white balancing as well as gamma
52 * The signature of this function intentionally matches that of `FrameConverterTestUtilities::FunctionPixelValue`.
53 * @param frame The frame from which the pixel will be extracted, must be valid
54 * @param x The horizontal pixel location within the frame, with range [0, frame.width() - 1]
55 * @param y The vertical pixel location within the frame, with range [0, frame.height() - 1]
56 * @param conversionFlag The conversion flag that will be applied, must be valid
57 * @return The vector holding the frame's color value at the specified location
58 * @sa FrameConverterTestUtilities::FunctionPixelValue
59 */
60 inline MatrixD operator()(const Frame& frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag) const;
61
62 /**
63 * Returns bit element value of a pixel of RGGB10_PACKED frame as a double clamped to [0, 1023]
64 * The lookup can be done for one top row and bottom row outside of the frame, this row is then mirrored back into the frame.
65 * @param frame The frame from which the value will be extracted, must be valid
66 * @param x The horizontal pixel location within the frame, with range [0, frame.width() - 1]
67 * @param y The vertical pixel location within the frame with one additional top and bottom row, with range [-1, frame.height()]
68 * @param blackLevel Optional black level that will be subtracted from the pixel value (with clamping at 0), range: [0, 1024)
69 * @param whiteBalance Optional white balance scalar that will be multiplied with the value of the element, range: [0 infinity)
70 * @return The value of the element as a double, clamped to [0, 1023]
71 */
72 static double elementValue(const Frame& frame, const unsigned int x, const int y, const uint16_t blackLevel = 0u, const double whiteBalance = 1.0);
73
74 /**
75 * Extracts one pixel from a RGGB10_PACKED source frame.
76 * @param frame The frame from which the pixel will be extracted, must be valid
77 * @param x The horizontal pixel location within the frame, with range [0, frame.width() - 1]
78 * @param y The vertical pixel location within the frame, with range [0, frame.height() - 1]
79 * @param conversionFlag The conversion flag that will be applied, must be valid
80 * @return The vector holding the frame's color value at the specified location
81 */
82 static inline MatrixD pixelFunctionRGGB10_Packed(const Frame& frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag);
83
84 /**
85 * Extracts one pixel from a RGGB10_PACKED source frame and subtracts the black level and applies white balancing as well as gamma
86 * @param frame The frame from which the pixel will be extracted, must be valid
87 * @param x The horizontal pixel location within the frame, with range [0, frame.width() - 1]
88 * @param y The vertical pixel location within the frame, with range [0, frame.height() - 1]
89 * @param conversionFlag The conversion flag that will be applied, must be valid
90 * @param blackLevel The black level value that is subtracted from each element of the raw image before any other operation, range: [0, 1024)
91 * @param whiteBalance Pointer to the white balancing scalars of the red, green, and blue channel (in that order), range: [0, infinity), must be valid and have at least 3 elements
92 * @param gamma The gamma value that each pixel will be encoded with, range: [0, infinity)
93 * @return The vector holding the frame's color value at the specified location
94 */
95 static MatrixD pixelFunctionRGGB10_PackedWithBlackLevelWhiteBalanceGamma(const Frame& frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag, const uint16_t blackLevel, const double* whiteBalance, const double gamma);
96
97 protected:
98
99 /// The black level value that is subtracted from each element of the raw image before any other operation, range: [0, 1024)
100 uint16_t blackLevel_ = 0u;
101
102 /// The white balancing scalars of the red, green, and blue channel (in that order), range: [0, infinity), will be ignored channel-wise for values < 0
103 double whiteBalance_[3] = {0.0, 0.0, 0.0};
104
105 /// The gamma value that each pixel will be encoded with, range: [0, infinity)
106 double gamma_ = 0.0;
107 };
108
109 public:
110
111 /**
112 * Tests all RGGB10_PACKED bit frame conversion functions.
113 * @param width The width of the test frame in pixel, with range [1, infinity)
114 * @param height The height of the test frame in pixel, with range [1, infinity)
115 * @param testDuration Number of seconds for each test, with range (0, infinity)
116 * @param worker The worker object
117 * @return True, if succeeded
118 */
119 static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
120
121 /**
122 * Tests the RGGB10_PACKED to BGR24 conversion.
123 * @param width The width of the original frame in pixel, with range [1, infinity)
124 * @param height The height of the original frame in pixel, with range [1, infinity)
125 * @param flag The conversion flag that has been applied during conversion
126 * @param testDuration Number of seconds for each test, with range (0, infinity)
127 * @param worker The worker object
128 * @return True, if succeeded
129 */
130 static bool testRGGB10_PackedToBGR24(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag flag, const double testDuration, Worker& worker);
131
132 /**
133 * Tests the RGGB10_PACKED to RGB24 conversion.
134 * @param width The width of the original frame in pixel, with range [1, infinity)
135 * @param height The height of the original frame in pixel, with range [1, infinity)
136 * @param flag The conversion flag that has been applied during conversion
137 * @param testDuration Number of seconds for each test, with range (0, infinity)
138 * @param worker The worker object
139 * @return True, if succeeded
140 */
141 static bool testRGGB10_PackedToRGB24(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag flag, const double testDuration, Worker& worker);
142
143 /**
144 * Tests the RGGB10_PACKED to RGB48 conversion.
145 * @param width The width of the original frame in pixel, with range [1, infinity)
146 * @param height The height of the original frame in pixel, with range [1, infinity)
147 * @param flag The conversion flag that has been applied during conversion
148 * @param testDuration Number of seconds for each test, with range (0, infinity)
149 * @param worker The worker object
150 * @return True, if succeeded
151 */
152 static bool testRGGB10_PackedToRGB48(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag flag, const double testDuration, Worker& worker);
153
154 /**
155 * Tests the RGGB10_PACKED to RGB24 conversion with black-level subtraction, white balancing, and gamma encoding.
156 * @param randomGenerator The random generator to be used
157 * @param width The width of the original frame in pixel, with range [1, infinity)
158 * @param height The height of the original frame in pixel, with range [1, infinity)
159 * @param flag The conversion flag that has been applied during conversion
160 * @param testDuration Number of seconds for each test, with range (0, infinity)
161 * @param worker The worker object
162 * @return True, if succeeded
163 */
164 static bool testConvertRGGB10_PackedToRGB24BlacklevelWhiteBalanceGammaLUT(RandomGenerator& randomGenerator, const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag flag, const double testDuration, Worker& worker);
165};
166
167inline TestFrameConverterRGGB10_Packed::PixelFunctorRGGB10_Packed::PixelFunctorRGGB10_Packed(const uint16_t blackLevel, const double* whiteBalance, const double gamma) :
168 blackLevel_(blackLevel),
169 whiteBalance_{whiteBalance[0], whiteBalance[1], whiteBalance[2]},
170 gamma_(gamma)
171{
172 ocean_assert(whiteBalance_[0] >= 0.0 && whiteBalance[1] >= 0.0 && whiteBalance_[2] >= 0.0);
173 ocean_assert(gamma_ >= 0.0);
174}
175
176inline MatrixD TestFrameConverterRGGB10_Packed::PixelFunctorRGGB10_Packed::operator()(const Frame& frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag) const
177{
178 return pixelFunctionRGGB10_PackedWithBlackLevelWhiteBalanceGamma(frame, x, y, conversionFlag, blackLevel_, whiteBalance_, gamma_);
179}
180
181
183{
184 constexpr uint16_t blackLevel = 0u;
185 constexpr double whiteBalance[3] = {1.0, 1.0, 1.0};
186 constexpr double gamma = 1.0;
187
188 return pixelFunctionRGGB10_PackedWithBlackLevelWhiteBalanceGamma(frame, x, y, conversionFlag, blackLevel, whiteBalance, gamma);
189}
190
191}
192
193}
194
195}
196
197#endif // META_OCEAN_TEST_TESTCV_TEST_FRAME_CONVERTER_RGGB_10_PACKED_H
ConversionFlag
Definition of individual conversion flags.
Definition FrameConverter.h:39
This class implements Ocean's image class.
Definition Frame.h:1808
This class implements a matrix with arbitrary size.
Definition Matrix.h:63
This class implements a generator for random numbers.
Definition RandomGenerator.h:42
Definition of a functor class to access single pixels of an frame with pixel format RGGB10_PACKED.
Definition TestFrameConverterRGGB10_Packed.h:39
static double elementValue(const Frame &frame, const unsigned int x, const int y, const uint16_t blackLevel=0u, const double whiteBalance=1.0)
Returns bit element value of a pixel of RGGB10_PACKED frame as a double clamped to [0,...
static MatrixD pixelFunctionRGGB10_PackedWithBlackLevelWhiteBalanceGamma(const Frame &frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag, const uint16_t blackLevel, const double *whiteBalance, const double gamma)
Extracts one pixel from a RGGB10_PACKED source frame and subtracts the black level and applies white ...
double whiteBalance_[3]
The white balancing scalars of the red, green, and blue channel (in that order), range: [0,...
Definition TestFrameConverterRGGB10_Packed.h:103
PixelFunctorRGGB10_Packed(const uint16_t blackLevel, const double *whiteBalance, const double gamma)
Constructor to specify black level, white balance, and gamma.
Definition TestFrameConverterRGGB10_Packed.h:167
MatrixD operator()(const Frame &frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag) const
Extracts one pixel from a RGGB10_PACKED source frame and subtracts the black level and applies white ...
Definition TestFrameConverterRGGB10_Packed.h:176
double gamma_
The gamma value that each pixel will be encoded with, range: [0, infinity)
Definition TestFrameConverterRGGB10_Packed.h:106
static MatrixD pixelFunctionRGGB10_Packed(const Frame &frame, const unsigned int x, const unsigned int y, const CV::FrameConverter::ConversionFlag conversionFlag)
Extracts one pixel from a RGGB10_PACKED source frame.
Definition TestFrameConverterRGGB10_Packed.h:182
This class implements a RGGB10_PACKED frame converter test.
Definition TestFrameConverterRGGB10_Packed.h:32
static bool testRGGB10_PackedToRGB48(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag flag, const double testDuration, Worker &worker)
Tests the RGGB10_PACKED to RGB48 conversion.
static bool testConvertRGGB10_PackedToRGB24BlacklevelWhiteBalanceGammaLUT(RandomGenerator &randomGenerator, const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag flag, const double testDuration, Worker &worker)
Tests the RGGB10_PACKED to RGB24 conversion with black-level subtraction, white balancing,...
static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests all RGGB10_PACKED bit frame conversion functions.
static bool testRGGB10_PackedToRGB24(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag flag, const double testDuration, Worker &worker)
Tests the RGGB10_PACKED to RGB24 conversion.
static bool testRGGB10_PackedToBGR24(const unsigned int width, const unsigned int height, const CV::FrameConverter::ConversionFlag flag, const double testDuration, Worker &worker)
Tests the RGGB10_PACKED to BGR24 conversion.
This class implements a worker able to distribute function calls over different threads.
Definition Worker.h:33
The namespace covering the entire Ocean framework.
Definition Accessor.h:15