Ocean
TestPanoramaFrame.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_PANORAMA_FRAME_H
9 #define META_OCEAN_TEST_TESTCV_TESTADVANCED_PANORAMA_FRAME_H
10 
12 
14 
16 
17 namespace Ocean
18 {
19 
20 namespace Test
21 {
22 
23 namespace TestCV
24 {
25 
26 namespace TestAdvanced
27 {
28 
29 /**
30  * This class implements a test for the panorama frame.
31  * @ingroup testcvadvanced
32  */
33 class OCEAN_TEST_CV_ADVANCED_EXPORT TestPanoramaFrame : protected CV::Advanced::PanoramaFrame
34 {
35  public:
36 
37  /**
38  * Tests the panorama frame functions.
39  * @param testDuration Number of seconds for each test, with range (0, infinity)
40  * @param worker The worker object
41  * @return True, if succeeded
42  */
43  static bool test(const double testDuration, Worker& worker);
44 
45  /**
46  * Tests the conversion between frames with different orientations with all possible function parameters.
47  * @param testDuration Number of seconds for each test, with range (0, infinity)
48  * @param worker The worker object
49  * @return True, if succeeded
50  */
51  static bool testCameraFrame2cameraFrame(const double testDuration, Worker& worker);
52 
53  /**
54  * Tests the conversion between frames with different orientations with specific function parameters.
55  * @param performanceWidth The image width that should be used to measure run-time performance, range: [1, infinity)
56  * @param performanceHeight The image height that should be used to measure run-time performance, range: [1, infinity)
57  * @param useApproximation True, will run tests on the approximated version of the test function, otherwise it will the pixel-exact one
58  * @param useSourceMask True, it will run tests with masks for the source images, otherwise it will run them without them
59  * @param numberChannels The number of channels that the source images that are used for testing will have, range: [1, 4]
60  * @param testDuration Number of seconds for each test, with range (0, infinity)
61  * @param worker The worker object
62  * @return True, if succeeded
63  */
64  static bool testCameraFrame2cameraFrame(const unsigned int performanceWidth, const unsigned int performanceHeight, const bool useApproximation, const bool useSourceMask, const unsigned int numberChannels, const double testDuration, Worker& worker);
65 
66  /**
67  * Tests the cameraFrame2panoramaSubFrame function and the reverse operation.
68  * @param testDuration Number of seconds for each test, with range (0, infinity)
69  * @param worker The worker object
70  * @return True, if succeeded
71  */
72  static bool testCameraFrame2panoramaSubFrame(const double testDuration, Worker& worker);
73 
74  /**
75  * Tests the re-creation of a panorama frame.
76  * @param worker Optional Worker object
77  * @return True, if succeeded
78  */
79  static bool testRecreation(Worker& worker);
80 
81  protected:
82 
83  /**
84  * Tests the re-creation of a panorama frame.
85  * @param channels The number of frame channels to be used, with range [1, infinity)
86  * @param approximate True, to apply an approximation using a lookup table
87  * @param worker Optional Worker object
88  * @return True, if succeeded
89  */
90  static bool testRecreation(const unsigned int channels, const bool approximate, Worker& worker);
91 
92  /**
93  * Determines the error between two frames.
94  * @param frameA The first frame to be used, must be valid
95  * @param frameB The second frame to be used, with same frame type as frameA, must be valid
96  * @return The average intensity error
97  */
98  static double averageFrameError(const Frame& frameA, const Frame& frameB);
99 
100  /**
101  * Validates conversion between frames with different orientations for specific function parameters.
102  * @param sourceCamera The camera profile of the given source frame, must be valid,
103  * @param world_R_source The orientation of the given source frame and camera. Must be orthonormal.
104  * @param source The source frame that will be converted, the frame dimension must match with the given source camera profile, must have a single plane with no more than 4 channels (8 bit), must be valid
105  * @param sourceMask An optional mask defining valid and invalid pixels in the source frame, passing an invalid frame indicates that all pixels in the source frame are valid, otherwise it must be of the same size the source frame and have 1 channel (8 bit) and 1 plane
106  * @param targetCamera The camera profile of the resulting target frame
107  * @param world_R_target The orientation of the resulting target frame, must be orthonormal
108  * @param testTarget The target frame that will be validated, the frame dimension must match with the given source camera profile, must have a single plane with no more than 4 channels, must be valid
109  * @param testTargetMask The target mask of the test target frame that will be validated, defines valid and invalid pixels in the target frame, must be of the same size the target frame and have 1 channel (8 bit) and 1 plane
110  * @param maskValue The mask value defining valid pixels in the mask frames, valid values: {0, 255}
111  * @param approximationBinSize The approximated bin size to be used, with range [1, infinity)
112  * @return True, if succeeded
113  */
114  static bool validateCameraFrame2cameraFrame(const PinholeCamera& sourceCamera, const SquareMatrix3& world_R_source, const Frame& source, const Frame& sourceMask, const PinholeCamera& targetCamera, const SquareMatrix3& world_R_target, const Frame& testTarget, const Frame& testTargetMask, const uint8_t maskValue, const unsigned int approximationBinSize);
115 
116 };
117 
118 }
119 
120 }
121 
122 }
123 
124 }
125 
126 #endif // META_OCEAN_TEST_TESTCV_TESTADVANCED_PANORAMA_FRAME_H
This class implements a panorama frame with spherical projection model.
Definition: PanoramaFrame.h:47
This class implements Ocean's image class.
Definition: Frame.h:1760
This class implements a test for the panorama frame.
Definition: TestPanoramaFrame.h:34
static double averageFrameError(const Frame &frameA, const Frame &frameB)
Determines the error between two frames.
static bool testCameraFrame2cameraFrame(const unsigned int performanceWidth, const unsigned int performanceHeight, const bool useApproximation, const bool useSourceMask, const unsigned int numberChannels, const double testDuration, Worker &worker)
Tests the conversion between frames with different orientations with specific function parameters.
static bool testCameraFrame2cameraFrame(const double testDuration, Worker &worker)
Tests the conversion between frames with different orientations with all possible function parameters...
static bool testCameraFrame2panoramaSubFrame(const double testDuration, Worker &worker)
Tests the cameraFrame2panoramaSubFrame function and the reverse operation.
static bool validateCameraFrame2cameraFrame(const PinholeCamera &sourceCamera, const SquareMatrix3 &world_R_source, const Frame &source, const Frame &sourceMask, const PinholeCamera &targetCamera, const SquareMatrix3 &world_R_target, const Frame &testTarget, const Frame &testTargetMask, const uint8_t maskValue, const unsigned int approximationBinSize)
Validates conversion between frames with different orientations for specific function parameters.
static bool testRecreation(Worker &worker)
Tests the re-creation of a panorama frame.
static bool testRecreation(const unsigned int channels, const bool approximate, Worker &worker)
Tests the re-creation of a panorama frame.
static bool test(const double testDuration, Worker &worker)
Tests the panorama frame functions.
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