Ocean
Loading...
Searching...
No Matches
TestSpecial.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_TESTMEDIA_TEST_SPECIAL_H
9#define META_OCEAN_TEST_TESTMEDIA_TEST_SPECIAL_H
10
12
14
15#include "ocean/base/Frame.h"
16
17namespace Ocean
18{
19
20namespace Test
21{
22
23namespace TestMedia
24{
25
26/**
27 * This class implements a test for the Special media library.
28 * @ingroup testmedia
29 */
30class OCEAN_TEST_MEDIA_EXPORT TestSpecial
31{
32 public:
33
34 /**
35 * Invokes all tests that are defined.
36 * @param testDuration The number of seconds for each test
37 * @param selector The test selector
38 * @return True, if succeeded
39 */
40 static bool test(const double testDuration, const TestSelector& selector);
41
42 /**
43 * Tests the read and write functions for BMP images.
44 * @param testDuration The number of seconds for each test
45 * @return True, if succeeded
46 */
47 static bool testBmpImageEncodeDecode(const double testDuration);
48
49 /**
50 * Tests the read and write functions for PFM images.
51 * @param testDuration The number of seconds for each test
52 * @return True, if succeeded
53 */
54 static bool testPfmImageEncodeDecode(const double testDuration);
55
56 /**
57 * Tests the read and write functions for NPY images.
58 * @param testDuration The number of seconds for each test
59 * @return True, if succeeded
60 */
61 static bool testNpyImageEncodeDecode(const double testDuration);
62
63 /**
64 * Tests the read and write functions for OCN images.
65 * @param testDuration The number of seconds for each test
66 * @return True, if succeeded
67 */
68 static bool testOcnImageEncodeDecode(const double testDuration);
69 /**
70 * Tests the read and write functions for any image.
71 * @param testDuration The number of seconds for each test
72 * @return True, if succeeded
73 */
74 static bool testAnyImageEncodeDecode(const double testDuration);
75
76 /**
77 * Tests the read and write functions for BMP images.
78 * @param width The width of the frame to be tested, with range [1, infinity)
79 * @param height The height of the frame to be tested, with range [1, infinity)
80 * @param pixelFormat The pixel format of the frame to be tested, must be valid
81 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
82 * @param testDuration The number of seconds for each test
83 * @return True, if succeeded
84 */
85 static bool testBmpImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
86
87 /**
88 * Applies a stress test for the BMP decoder.
89 * @return True, if succeeded
90 */
92
93 /**
94 * Tests the read and write functions for PFM images.
95 * @param width The width of the frame to be tested, with range [1, infinity)
96 * @param height The height of the frame to be tested, with range [1, infinity)
97 * @param pixelFormat The pixel format of the frame to be tested, must be valid
98 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
99 * @param testDuration The number of seconds for each test
100 * @return True, if succeeded
101 */
102 static bool testPfmImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
103
104 /**
105 * Applies a stress test for the PFM decoder.
106 * @return True, if succeeded
107 */
109
110 /**
111 * Tests the read and write functions for NPY images.
112 * @param width The width of the frame to be tested, with range [1, infinity)
113 * @param height The height of the frame to be tested, with range [1, infinity)
114 * @param pixelFormat The pixel format of the frame to be tested, must be valid
115 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
116 * @param testDuration The number of seconds for each test
117 * @return True, if succeeded
118 */
119 static bool testNpyImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
120
121 /**
122 * Applies a stress test for the NPY decoder.
123 * @return True, if succeeded
124 */
126
127 /**
128 * Applies a stress test for the OCN decoder.
129 * @return True, if succeeded
130 */
132
133 /**
134 * Applies a stress test for any decoder.
135 * @return True, if succeeded
136 */
137 static bool testDecodeStressTest();
138
139 protected:
140
141 /**
142 * Determines the minimal, the average and the maximal distance between corresponding pixel values (channel-wise) for two frames.
143 * @param firstFrame The first frame for which the similarity will be determined, must be valid
144 * @param secondFrame The second frame for which the similarity will be determined, with identical frame type as 'firstFrame' must be valid
145 * @param minDifference Resulting minimal value difference, with range [0, infinity)
146 * @param aveDifference Resulting average value difference, with range [minDifference, maxDifference]
147 * @param maxDifference Resulting maximal value difference, with range [aveDifference, infinity)
148 * @return True, if succeeded
149 */
150 static bool determineSimilarity(const Frame& firstFrame, const Frame& secondFrame, double& minDifference, double& aveDifference, double& maxDifference);
151
152 /**
153 * Determines the minimal, the average and the maximal distance between corresponding pixel values (channel-wise) for two frames.
154 * @param firstFrame The image data of the first frame for which the similarity will be determined, must be valid
155 * @param secondFrame The image data of the second frame for which the similarity will be determined, must be valid
156 * @param width The width of the frames in pixel, with range [1, infinity)
157 * @param height The height of the frames in pixel, with range [1, infinity)
158 * @param channels The number of frame channels, with range [1, infinity)
159 * @param firstFramePaddingElements The number of padding elements at the end of each first image row, in elements, with range [0, infinity)
160 * @param secondFramePaddingElements The number of padding elements at the end of each second image row, in elements, with range [0, infinity)
161 * @param minDifference Resulting minimal value difference, with range [0, infinity)
162 * @param aveDifference Resulting average value difference, with range [minDifference, maxDifference]
163 * @param maxDifference Resulting maximal value difference, with range [aveDifference, infinity)
164 */
165 template <typename T>
166 static void determineSimilarity(const T* firstFrame, const T* secondFrame, const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int firstFramePaddingElements, const unsigned int secondFramePaddingElements, double& minDifference, double& aveDifference, double& maxDifference);
167};
168
169}
170
171}
172
173}
174
175#endif // META_OCEAN_TEST_TESTMEDIA_TEST_SPECIAL_H
This class implements Ocean's image class.
Definition Frame.h:1879
PixelFormat
Definition of all pixel formats available in the Ocean framework.
Definition Frame.h:183
PixelOrigin
Defines different types of frame origin positions.
Definition Frame.h:1046
This class implements a test for the Special media library.
Definition TestSpecial.h:31
static bool testBmpImageEncodeDecode(const double testDuration)
Tests the read and write functions for BMP images.
static bool testBmpImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration)
Tests the read and write functions for BMP images.
static bool testOcnImageEncodeDecode(const double testDuration)
Tests the read and write functions for OCN images.
static void determineSimilarity(const T *firstFrame, const T *secondFrame, const unsigned int width, const unsigned int height, const unsigned int channels, const unsigned int firstFramePaddingElements, const unsigned int secondFramePaddingElements, double &minDifference, double &aveDifference, double &maxDifference)
Determines the minimal, the average and the maximal distance between corresponding pixel values (chan...
static bool testDecodeStressTest()
Applies a stress test for any decoder.
static bool testPfmDecodeStressTest()
Applies a stress test for the PFM decoder.
static bool testOcnDecodeStressTest()
Applies a stress test for the OCN decoder.
static bool testNpyDecodeStressTest()
Applies a stress test for the NPY decoder.
static bool testPfmImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration)
Tests the read and write functions for PFM images.
static bool testAnyImageEncodeDecode(const double testDuration)
Tests the read and write functions for any image.
static bool test(const double testDuration, const TestSelector &selector)
Invokes all tests that are defined.
static bool determineSimilarity(const Frame &firstFrame, const Frame &secondFrame, double &minDifference, double &aveDifference, double &maxDifference)
Determines the minimal, the average and the maximal distance between corresponding pixel values (chan...
static bool testPfmImageEncodeDecode(const double testDuration)
Tests the read and write functions for PFM images.
static bool testNpyImageEncodeDecode(const double testDuration)
Tests the read and write functions for NPY images.
static bool testNpyImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration)
Tests the read and write functions for NPY images.
static bool testBmpDecodeStressTest()
Applies a stress test for the BMP decoder.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
The namespace covering the entire Ocean framework.
Definition Accessor.h:15