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