Ocean
Loading...
Searching...
No Matches
TestImageIO.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_IMAGE_IO_H
9#define META_OCEAN_TEST_TESTMEDIA_TEST_IMAGE_IO_H
10
12
14
15#include "ocean/base/Frame.h"
16
17#ifdef OCEAN_PLATFORM_BUILD_APPLE
18
19namespace Ocean
20{
21
22namespace Test
23{
24
25namespace TestMedia
26{
27
28/**
29 * This class implements a test for the IMageIO media library.
30 * @ingroup testmedia
31 */
32class OCEAN_TEST_MEDIA_EXPORT TestImageIO
33{
34 public:
35
36 /**
37 * Invokes all tests that are defined.
38 * @param testDuration The number of seconds for each test, with range (0, infinity)
39 * @param selector The test selector
40 * @return True, if succeeded
41 */
42 static bool test(const double testDuration, const TestSelector& selector);
43
44 /**
45 * Tests the read and write functions for BMP images.
46 * @param testDuration The number of seconds for each test, with range (0, infinity)
47 * @return True, if succeeded
48 */
49 static bool testBmpImageEncodeDecode(const double testDuration);
50
51 /**
52 * Tests the read and write functions for JPEG images.
53 * @param testDuration The number of seconds for each test, with range (0, infinity)
54 * @return True, if succeeded
55 */
56 static bool testJpgImageEncodeDecode(const double testDuration);
57
58 /**
59 * Tests the read and write functions for HEIC images.
60 * @param testDuration The number of seconds for each test, with range (0, infinity)
61 * @return True, if succeeded
62 */
63 static bool testHeicImageEncodeDecode(const double testDuration);
64
65 /**
66 * Tests the read and write functions for PNG images.
67 * @param testDuration The number of seconds for each test, with range (0, infinity)
68 * @return True, if succeeded
69 */
70 static bool testPngImageEncodeDecode(const double testDuration);
71
72 /**
73 * Tests the read and write functions for PNG images.
74 * @param testDuration The number of seconds for each test, with range (0, infinity)
75 * @return True, if succeeded
76 */
77 static bool testTifImageEncodeDecode(const double testDuration);
78
79 /**
80 * Tests the read and write functions for any image.
81 * @param testDuration The number of seconds for each test, with range (0, infinity)
82 * @return True, if succeeded
83 */
84 static bool testAnyImageEncodeDecode(const double testDuration);
85
86 /**
87 * Tests the encoding and decoding between individual media libraries.
88 * @param testDuration The number of seconds for each test, with range (0, infinity)
89 * @return True, if succeeded
90 */
91 static bool testInterchangeability(const double testDuration);
92
93 /**
94 * Tests the forward and backward conversion between a Frame and a CGImage.
95 * @param testDuration The number of seconds for each test, with range (0, infinity)
96 * @return True, if succeeded
97 */
98 static bool testConversionCGImage(const double testDuration);
99
100 /**
101 * Tests the read and write functions for BMP images.
102 * @param width The width of the frame to be tested, with range [1, infinity)
103 * @param height The height of the frame to be tested, with range [1, infinity)
104 * @param pixelFormat The pixel format of the frame to be tested, must be valid
105 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
106 * @param testDuration The number of seconds for each test, with range (0, infinity)
107 * @return True, if succeeded
108 */
109 static bool testBmpImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
110
111 /**
112 * Tests the read and write functions for JPEG images.
113 * @param width The width of the frame to be tested, with range [1, infinity)
114 * @param height The height of the frame to be tested, with range [1, infinity)
115 * @param pixelFormat The pixel format of the frame to be tested, must be valid
116 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
117 * @param testDuration The number of seconds for each test, with range (0, infinity)
118 * @return True, if succeeded
119 */
120 static bool testJpgImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
121
122 /**
123 * Tests the read and write functions for HEIC images.
124 * @param width The width of the frame to be tested, with range [1, infinity)
125 * @param height The height of the frame to be tested, with range [1, infinity)
126 * @param pixelFormat The pixel format of the frame to be tested, must be valid
127 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
128 * @param testDuration The number of seconds for each test, with range (0, infinity)
129 * @return True, if succeeded
130 */
131 static bool testHeicImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
132
133 /**
134 * Tests the read and write functions for PNG images.
135 * @param width The width of the frame to be tested, with range [1, infinity)
136 * @param height The height of the frame to be tested, with range [1, infinity)
137 * @param pixelFormat The pixel format of the frame to be tested, must be valid
138 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
139 * @param testDuration The number of seconds for each test, with range (0, infinity)
140 * @return True, if succeeded
141 */
142 static bool testPngImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
143
144 /**
145 * Tests the read and write functions for TIFF images.
146 * @param width The width of the frame to be tested, with range [1, infinity)
147 * @param height The height of the frame to be tested, with range [1, infinity)
148 * @param pixelFormat The pixel format of the frame to be tested, must be valid
149 * @param pixelOrigin The pixel origin of the frame to be tested, must be valid
150 * @param testDuration The number of seconds for each test
151 * @return True, if succeeded
152 */
153 static bool testTifImageEncodeDecode(const unsigned int width, const unsigned int height, const FrameType::PixelFormat pixelFormat, const FrameType::PixelOrigin pixelOrigin, const double testDuration);
154
155 /**
156 * Tests the ImageBufferRecorder and ImageBuffer functionality of the media library.
157 * @param frameType The frame type to be used for testing, must be valid
158 * @param imageType The file extension of the image to be created (e.g. jpg, png, bmp, or tif), must be defined
159 * @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
160 * @return True, if succeeded
161 */
162 static bool testBufferImageRecorder(const FrameType& frameType, const std::string& imageType, const double maximalAverageDifference);
163
164 /**
165 * Tests the quality property for a specified image type.
166 * @param imageType The image type for which the test will be executed
167 * @param testDuration The number of seconds for each test, with range (0, infinity)
168 * @return True, if succeeded
169 */
170 static bool testQualityProperty(const std::string& imageType, const double testDuration);
171
172 /**
173 * Tests setting color profile names for a specified image type.
174 * @param imageType The image type for which the test will be executed
175 * @param testDuration The number of seconds for each test, with range (0, infinity)
176 * @return True, if succeeded
177 */
178 static bool testColorProfileNameProperty(const std::string& imageType, const double testDuration);
179
180 protected:
181
182 /**
183 * Determines the minimal, the average and the maximal distance between corresponding pixel values (channel-wise) for two frames.
184 * @param firstFrame The first frame for which the similarity will be determined, must be valid
185 * @param secondFrame The second frame for which the similarity will be determined, with identical frame type as 'firstFrame' must be valid
186 * @param minDifference Resulting minimal value difference, with range [0, infinity)
187 * @param aveDifference Resulting average value difference, with range [minDifference, maxDifference]
188 * @param maxDifference Resulting maximal value difference, with range [aveDifference, infinity)
189 * @return True, if succeeded
190 */
191 static bool determineSimilarity(const Frame& firstFrame, const Frame& secondFrame, double& minDifference, double& aveDifference, double& maxDifference);
192
193 /**
194 * Determines the minimal, the average and the maximal distance between corresponding pixel values (channel-wise) for two frames.
195 * @param firstFrame The image data of the first frame for which the similarity will be determined, must be valid
196 * @param secondFrame The image data of the second frame for which the similarity will be determined, must be valid
197 * @param width The width of the frames in pixel, with range [1, infinity)
198 * @param height The height of the frames in pixel, with range [1, infinity)
199 * @param channels The number of frame channels, with range [1, infinity)
200 * @param firstFramePaddingElements The number of padding elements at the end of each first image row, in elements, with range [0, infinity)
201 * @param secondFramePaddingElements The number of padding elements at the end of each second image row, in elements, with range [0, infinity)
202 * @param minDifference Resulting minimal value difference, with range [0, infinity)
203 * @param aveDifference Resulting average value difference, with range [minDifference, maxDifference]
204 * @param maxDifference Resulting maximal value difference, with range [aveDifference, infinity)
205 */
206 template <typename T>
207 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);
208};
209
210}
211
212}
213
214}
215
216#endif // OCEAN_PLATFORM_BUILD_APPLE
217
218#endif // META_OCEAN_TEST_TESTMEDIA_TEST_IMAGE_IO_H
This class implements Ocean's image class.
Definition Frame.h:1879
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 IMageIO media library.
Definition TestImageIO.h:33
static bool testHeicImageEncodeDecode(const double testDuration)
Tests the read and write functions for HEIC images.
static bool test(const double testDuration, const TestSelector &selector)
Invokes all tests that are defined.
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 testBmpImageEncodeDecode(const double testDuration)
Tests the read and write functions for BMP 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 testConversionCGImage(const double testDuration)
Tests the forward and backward conversion between a Frame and a CGImage.
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 testTifImageEncodeDecode(const double testDuration)
Tests the read and write functions for PNG images.
static bool testHeicImageEncodeDecode(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 HEIC images.
static bool testQualityProperty(const std::string &imageType, const double testDuration)
Tests the quality property for a specified image type.
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 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 testAnyImageEncodeDecode(const double testDuration)
Tests the read and write functions for any image.
static bool testPngImageEncodeDecode(const double testDuration)
Tests the read and write functions for PNG images.
static bool testJpgImageEncodeDecode(const double testDuration)
Tests the read and write functions for JPEG images.
static bool testInterchangeability(const double testDuration)
Tests the encoding and decoding between individual media libraries.
static bool testColorProfileNameProperty(const std::string &imageType, const double testDuration)
Tests setting color profile names for a specified image type.
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 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.
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