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