Ocean
Loading...
Searching...
No Matches
TestFrequencyAnalysis.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_TEST_FREQUENCY_ANALYSIS_H
9#define META_OCEAN_TEST_TESTCV_TEST_FREQUENCY_ANALYSIS_H
10
12
14
15#include "ocean/base/Worker.h"
16
17namespace Ocean
18{
19
20namespace Test
21{
22
23namespace TestCV
24{
25
26/**
27 * This class implements tests for the FrequencyAnalysis class
28 * (FFT-based image2frequencies / frequencies2image).
29 * @ingroup testcv
30 */
31class OCEAN_TEST_CV_EXPORT TestFrequencyAnalysis
32{
33 public:
34
35 /**
36 * Starts all tests of the FrequencyAnalysis class.
37 * @param testDuration Number of seconds for each test, with range (0, infinity)
38 * @param worker Worker object to distribute computational load
39 * @param selector Test selector for filtering sub-tests; default runs all tests
40 * @return True, if succeeded
41 */
42 static bool test(const double testDuration, Worker& worker, const TestSelector& selector = TestSelector());
43
44 /**
45 * Tests image2frequencies / frequencies2image round-trip identity:
46 * applying the FFT followed by the inverse FFT returns (approximately)
47 * the original frame.
48 * @param testDuration Number of seconds for the test, with range (0, infinity)
49 * @param worker Worker object
50 * @return True, if succeeded
51 */
52 static bool testRoundTripIdentity(const double testDuration, Worker& worker);
53
54 /**
55 * Tests that the DC component of the frequency spectrum equals the sum
56 * of all pixel values for that channel (FFT DC == sum invariant).
57 * @param testDuration Number of seconds for the test, with range (0, infinity)
58 * @param worker Worker object
59 * @return True, if succeeded
60 */
61 static bool testDCComponent(const double testDuration, Worker& worker);
62
63 /**
64 * Tests Parseval's theorem for the discrete Fourier transform:
65 * sum(|f(t)|^2) == (1/N) * sum(|F(k)|^2). For real-valued input this
66 * holds per channel.
67 * @param testDuration Number of seconds for the test, with range (0, infinity)
68 * @param worker Worker object
69 * @return True, if succeeded
70 */
71 static bool testParseval(const double testDuration, Worker& worker);
72
73 /**
74 * Tests that magnitudeFrame() returns a valid Y8 frame of the requested
75 * size (basic shape/sanity invariant).
76 * @param testDuration Number of seconds for the test, with range (0, infinity)
77 * @param worker Worker object
78 * @return True, if succeeded
79 */
80 static bool testMagnitudeFrame(const double testDuration, Worker& worker);
81
82 /**
83 * Stress test: large random frames and many channel counts; verifies
84 * worker vs single-thread output equality for image2frequencies.
85 * @param testDuration Number of seconds for the test, with range (0, infinity)
86 * @param worker Worker object
87 * @return True, if succeeded
88 */
89 static bool testWorkerEquivalenceStress(const double testDuration, Worker& worker);
90
91 /**
92 * Stress test: round-trip identity holds for many random parameter
93 * combinations (sizes/pixelFormats/paddings).
94 * @param testDuration Number of seconds for the test, with range (0, infinity)
95 * @param worker Worker object
96 * @return True, if succeeded
97 */
98 static bool testRoundTripStress(const double testDuration, Worker& worker);
99
100 /**
101 * Stress test: a constant-input frame produces a frequency spectrum
102 * with a single non-zero DC component (per channel).
103 * @param testDuration Number of seconds for the test, with range (0, infinity)
104 * @param worker Worker object
105 * @return True, if succeeded
106 */
107 static bool testConstantInputSpectrumStress(const double testDuration, Worker& worker);
108
109 /**
110 * Stress test: source frames with random padding produce identical
111 * frequency output to padding-free frames carrying the same content.
112 * @param testDuration Number of seconds for the test, with range (0, infinity)
113 * @param worker Worker object
114 * @return True, if succeeded
115 */
116 static bool testPaddingInvarianceStress(const double testDuration, Worker& worker);
117};
118
119}
120
121}
122
123}
124
125#endif // META_OCEAN_TEST_TESTCV_TEST_FREQUENCY_ANALYSIS_H
This class implements tests for the FrequencyAnalysis class (FFT-based image2frequencies / frequencie...
Definition TestFrequencyAnalysis.h:32
static bool testConstantInputSpectrumStress(const double testDuration, Worker &worker)
Stress test: a constant-input frame produces a frequency spectrum with a single non-zero DC component...
static bool testRoundTripStress(const double testDuration, Worker &worker)
Stress test: round-trip identity holds for many random parameter combinations (sizes/pixelFormats/pad...
static bool testMagnitudeFrame(const double testDuration, Worker &worker)
Tests that magnitudeFrame() returns a valid Y8 frame of the requested size (basic shape/sanity invari...
static bool testParseval(const double testDuration, Worker &worker)
Tests Parseval's theorem for the discrete Fourier transform: sum(|f(t)|^2) == (1/N) * sum(|F(k)|^2).
static bool testWorkerEquivalenceStress(const double testDuration, Worker &worker)
Stress test: large random frames and many channel counts; verifies worker vs single-thread output equ...
static bool testRoundTripIdentity(const double testDuration, Worker &worker)
Tests image2frequencies / frequencies2image round-trip identity: applying the FFT followed by the inv...
static bool testDCComponent(const double testDuration, Worker &worker)
Tests that the DC component of the frequency spectrum equals the sum of all pixel values for that cha...
static bool testPaddingInvarianceStress(const double testDuration, Worker &worker)
Stress test: source frames with random padding produce identical frequency output to padding-free fra...
static bool test(const double testDuration, Worker &worker, const TestSelector &selector=TestSelector())
Starts all tests of the FrequencyAnalysis class.
This class implements a test selector that parses test function strings and determines which tests sh...
Definition TestSelector.h:51
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