Ocean
Loading...
Searching...
No Matches
TestOpenImageLibraries.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_OPEN_IMAGE_LIBRARIES_H
9#define META_OCEAN_TEST_TESTMEDIA_TEST_OPEN_IMAGE_LIBRARIES_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 OpenImageLibraries media library.
26 * @ingroup testmedia
27 */
28class OCEAN_TEST_MEDIA_EXPORT TestOpenImageLibraries
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#ifdef OCEAN_MEDIA_OIL_SUPPORT_JPG
40
41 /**
42 * Tests the read and write functions for JPEG images.
43 * @param testDuration The number of seconds for each test
44 * @return True, if succeeded
45 */
46 static bool testJpgImageEncodeDecode(const double testDuration);
47
48#endif // OCEAN_MEDIA_OIL_SUPPORT_JPG
49
50#ifdef OCEAN_MEDIA_OIL_SUPPORT_PNG
51
52 /**
53 * Tests the read and write functions for PNG images.
54 * @param testDuration The number of seconds for each test
55 * @return True, if succeeded
56 */
57 static bool testPngImageEncodeDecode(const double testDuration);
58
59#endif // OCEAN_MEDIA_OIL_SUPPORT_PNG
60
61#ifdef OCEAN_MEDIA_OIL_SUPPORT_TIF
62
63 /**
64 * Tests the read and write functions for TIF images.
65 * @param testDuration The number of seconds for each test
66 * @return True, if succeeded
67 */
68 static bool testTifImageEncodeDecode(const double testDuration);
69
70#endif // OCEAN_MEDIA_OIL_SUPPORT_TIF
71
72#ifdef OCEAN_MEDIA_OIL_SUPPORT_WEBP
73
74 /**
75 * Tests the read and write functions for WEBP images.
76 * @param testDuration The number of seconds for each test
77 * @return True, if succeeded
78 */
79 static bool testWebpImageEncodeDecode(const double testDuration);
80
81#endif // OCEAN_MEDIA_OIL_SUPPORT_WEBP
82
83 /**
84 * Tests the read and write functions for any image.
85 * @param testDuration The number of seconds for each test
86 * @return True, if succeeded
87 */
88 static bool testAnyImageEncodeDecode(const double testDuration);
89
90#ifdef OCEAN_MEDIA_OIL_SUPPORT_JPG
91
92 /**
93 * Tests the read and write functions for JPEG images.
94 * @param width The width of the frame to be tested, with range [1, infinity)
95 * @param height The height of the frame to be tested, with range [1, infinity)
96 * @param pixelFormat The pixel format of the frame to be tested, must be valid
97 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
98 * @param testDuration The number of seconds for each test
99 * @return True, if succeeded
100 */
101 static bool testJpgImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
102
103 /**
104 * Applies a stress test for the JPEG decoder.
105 * @return True, if succeeded
106 */
108
109#endif // OCEAN_MEDIA_OIL_SUPPORT_JPG
110
111#ifdef OCEAN_MEDIA_OIL_SUPPORT_PNG
112
113 /**
114 * Tests the read and write functions for PNG images.
115 * @param width The width of the frame to be tested, with range [1, infinity)
116 * @param height The height of the frame to be tested, with range [1, infinity)
117 * @param pixelFormat The pixel format of the frame to be tested, must be valid
118 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
119 * @param testDuration The number of seconds for each test
120 * @return True, if succeeded
121 */
122 static bool testPngImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
123
124 /**
125 * Applies a stress test for the PNG decoder.
126 * @return True, if succeeded
127 */
129
130#endif // OCEAN_MEDIA_OIL_SUPPORT_PNG
131
132#ifdef OCEAN_MEDIA_OIL_SUPPORT_TIF
133
134 /**
135 * Tests the read and write functions for TIFF images.
136 * @param width The width of the frame to be tested, with range [1, infinity)
137 * @param height The height of the frame to be tested, with range [1, infinity)
138 * @param pixelFormat The pixel format of the frame to be tested, must be valid
139 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
140 * @param testDuration The number of seconds for each test
141 * @return True, if succeeded
142 */
143 static bool testTifImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
144
145 /**
146 * Applies a stress test for the TIFF decoder.
147 * @return True, if succeeded
148 */
150
151#endif // OCEAN_MEDIA_OIL_SUPPORT_TIF
152
153#ifdef OCEAN_MEDIA_OIL_SUPPORT_GIF
154
155 /**
156 * Applies a stress test for the GIF decoder.
157 * @return True, if succeeded
158 */
160
161#endif // OCEAN_MEDIA_OIL_SUPPORT_GIF
162
163#ifdef OCEAN_MEDIA_OIL_SUPPORT_WEBP
164
165 /**
166 * Tests the read and write functions for WEBP images.
167 * @param width The width of the frame to be tested, with range [1, infinity)
168 * @param height The height of the frame to be tested, with range [1, infinity)
169 * @param pixelFormat The pixel format of the frame to be tested, must be valid
170 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
171 * @param testDuration The number of seconds for each test
172 * @return True, if succeeded
173 */
174 static bool testWebpImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
175
176 /**
177 * Applies a stress test for the WEBP decoder.
178 * @return True, if succeeded
179 */
181
182#endif // OCEAN_MEDIA_OIL_SUPPORT_WEBP
183
184 /**
185 * Tests the ImageBufferRecorder and ImageBuffer functionality of the media library.
186 * @param frameType The frame type to be used for testing, must be valid
187 * @param imageType The file extension of the image to be created (e.g. jpg, png, bmp, or tif), must be defined
188 * @param maximalAverageDifference The maximal average difference between two frames so that they still count as similar, with range [0, infinity), 0 for lossless compress, >0 for lossy compression
189 * @return True, if succeeded
190 */
191 static bool testBufferImageRecorder(const FrameType& frameType, const std::string& imageType, const double maximalAverageDifference);
192
193 /**
194 * Applies a stress test for any decoder.
195 * @return True, if succeeded
196 */
197 static bool testDecodeStressTest();
198
199 protected:
200
201 /**
202 * Determines the minimal, the average and the maximal distance between corresponding pixel values (channel-wise) for two frames.
203 * @param firstFrame The first frame for which the similarity will be determined, must be valid
204 * @param secondFrame The second frame for which the similarity will be determined, with identical frame type as 'firstFrame' must be valid
205 * @param minDifference Resulting minimal value difference, with range [0, infinity)
206 * @param aveDifference Resulting average value difference, with range [minDifference, maxDifference]
207 * @param maxDifference Resulting maximal value difference, with range [aveDifference, infinity)
208 * @return True, if succeeded
209 */
210 static bool determineSimilarity(const Frame& firstFrame, const Frame& secondFrame, double& minDifference, double& aveDifference, double& maxDifference);
211
212 /**
213 * Determines the minimal, the average and the maximal distance between corresponding pixel values (channel-wise) for two frames.
214 * @param firstFrame The image data of the first frame for which the similarity will be determined, must be valid
215 * @param secondFrame The image data of the second frame for which the similarity will be determined, must be valid
216 * @param width The width of the frames in pixel, with range [1, infinity)
217 * @param height The height of the frames in pixel, with range [1, infinity)
218 * @param channels The number of frame channels, with range [1, infinity)
219 * @param firstFramePaddingElements The number of padding elements at the end of each first image row, in elements, with range [0, infinity)
220 * @param secondFramePaddingElements The number of padding elements at the end of each second image row, in elements, with range [0, infinity)
221 * @param minDifference Resulting minimal value difference, with range [0, infinity)
222 * @param aveDifference Resulting average value difference, with range [minDifference, maxDifference]
223 * @param maxDifference Resulting maximal value difference, with range [aveDifference, infinity)
224 */
225 template <typename T>
226 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);
227};
228
229}
230
231}
232
233}
234
235#endif // META_OCEAN_TEST_TESTMEDIA_TEST_OPEN_IMAGE_LIBRARIES_H
This class implements Ocean's image class.
Definition Frame.h:1808
Definition of a frame type composed by the frame dimension, pixel format and pixel origin.
Definition Frame.h:30
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 OpenImageLibraries media library.
Definition TestOpenImageLibraries.h:29
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 testAnyImageEncodeDecode(const double testDuration)
Tests the read and write functions for any image.
static bool testPngDecodeStressTest()
Applies a stress test for the PNG decoder.
static bool testJpgImageEncodeDecode(const double testDuration)
Tests the read and write functions for JPEG images.
static bool testWebpDecodeStressTest()
Applies a stress test for the WEBP decoder.
static bool test(const double testDuration)
Invokes all tests that are defined.
static bool testTifImageEncodeDecode(const double testDuration)
Tests the read and write functions for TIF images.
static bool testWebpImageEncodeDecode(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 WEBP images.
static bool testTifImageEncodeDecode(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 TIFF images.
static bool testPngImageEncodeDecode(const double testDuration)
Tests the read and write functions for PNG images.
static bool testDecodeStressTest()
Applies a stress test for any decoder.
static bool testGifDecodeStressTest()
Applies a stress test for the GIF decoder.
static bool testTifDecodeStressTest()
Applies a stress test for the TIFF decoder.
static bool testWebpImageEncodeDecode(const double testDuration)
Tests the read and write functions for WEBP images.
static bool testPngImageEncodeDecode(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 PNG images.
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 testJpgDecodeStressTest()
Applies a stress test for the JPEG decoder.
static bool testBufferImageRecorder(const FrameType &frameType, const std::string &imageType, const double maximalAverageDifference)
Tests the ImageBufferRecorder and ImageBuffer functionality of the media library.
static bool testJpgImageEncodeDecode(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 JPEG images.
The namespace covering the entire Ocean framework.
Definition Accessor.h:15