Ocean
TestWhitePointDetector.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_TESTADVANCED_TEST_WHITE_POINT_DETECTOR_H
9 #define META_OCEAN_TEST_TESTCV_TESTADVANCED_TEST_WHITE_POINT_DETECTOR_H
10 
12 
13 #include "ocean/math/Vector3.h"
14 
15 namespace Ocean
16 {
17 
18 namespace Test
19 {
20 
21 namespace TestCV
22 {
23 
24 namespace TestAdvanced
25 {
26 
27 /**
28  * This class implements a white point detection test.
29  * @ingroup testcvadvanced
30  */
31 class OCEAN_TEST_CV_ADVANCED_EXPORT TestWhitePointDetector
32 {
33  public:
34 
35  /**
36  * Tests white point detection and correction functions.
37  * @param width The width of the test frame in pixel, with range [1, infinity)
38  * @param height The height of the test frame in pixel, with range [1, infinity)
39  * @param testDuration Number of seconds for each test, with range (0, infinity)
40  * @param worker The worker instance to distribute the computational load
41  * @return True, if succeeded
42  */
43  static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker& worker);
44 
45  private:
46 
47  /**
48  * Tests the histogram-based white point detection and correction functions.
49  * @param frame Test frame for white point detection, with RGB pixel format, must be valid
50  * @param whitePoint White point to use for generating the test data
51  * @param testDuration Number of seconds for each test, with range (0, infinity)
52  * @param worker The worker instance to distribute the computational load
53  * @return True, if succeeded
54  */
55  static bool testWhitepointDetectorHistogram(const Frame& frame, const VectorF3& whitePoint, const double testDuration, Worker& worker);
56 
57  /**
58  * Tests the gray points-based white point detection and correction functions.
59  * @param frame Test frame for white point detection, with RGB pixel format, must be valid
60  * @param whitePoint White point to use for generating the test data
61  * @param testDuration Number of seconds for each test, with range (0, infinity)
62  * @param worker The worker instance to distribute the computational load
63  * @return True, if succeeded
64  */
65  static bool testWhitepointDetectorGrayPoints(const Frame& frame, const VectorF3& whitePoint, const double testDuration, Worker& worker);
66 
67  /**
68  * Validates the specified detected white point by comparing it with a ground truth white point
69  * @param idealWhitePoint Ground truth white point
70  * @param detectedWhitePoint Detected white point that is compared with the ground truth
71  * @return True, if both white points are equal; otherwise, false is returned.
72  */
73  static bool validateWhitePoint(const VectorF3& idealWhitePoint, const VectorF3& detectedWhitePoint);
74 
75  /**
76  * Validates a white point corrected frame by comparing its frame data with ground truth frame data
77  * @param idealFrame Ground truth frame, with RGB pixel format, must be valid
78  * @param correctedFrame white point corrected frame
79  * @return True, if the frame data of the both frames are (almost) equal; otherwise, false is returned.
80  */
81  static bool validateWhitePointFrame(const Frame& idealFrame, const Frame& correctedFrame);
82 
83  /**
84  * Fills the specified frame with random pixels.
85  * @param frame The frame that is modified, must be valid
86  * @param randomAmount Amount of randomness, with range [0, 1]
87  */
88  static void randomizeWhitePointFrame(Frame& frame, const float randomAmount = 0.5f);
89 };
90 
91 }
92 
93 }
94 
95 }
96 
97 }
98 
99 #endif // OCEAN_TEST_TESTCV_TESTADVANCED_TEST_WHITE_POINT_DETECTOR_H
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements a white point detection test.
Definition: TestWhitePointDetector.h:32
static void randomizeWhitePointFrame(Frame &frame, const float randomAmount=0.5f)
Fills the specified frame with random pixels.
static bool testWhitepointDetectorGrayPoints(const Frame &frame, const VectorF3 &whitePoint, const double testDuration, Worker &worker)
Tests the gray points-based white point detection and correction functions.
static bool validateWhitePointFrame(const Frame &idealFrame, const Frame &correctedFrame)
Validates a white point corrected frame by comparing its frame data with ground truth frame data.
static bool validateWhitePoint(const VectorF3 &idealWhitePoint, const VectorF3 &detectedWhitePoint)
Validates the specified detected white point by comparing it with a ground truth white point.
static bool test(const unsigned int width, const unsigned int height, const double testDuration, Worker &worker)
Tests white point detection and correction functions.
static bool testWhitepointDetectorHistogram(const Frame &frame, const VectorF3 &whitePoint, const double testDuration, Worker &worker)
Tests the histogram-based white point detection and correction functions.
This class implements a vector with three elements.
Definition: Vector3.h:97
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