Ocean
TestFrameNorm.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 OCEAN_TEST_TESTCV_TEST_FRAME_NORM_H
9 #define OCEAN_TEST_TESTCV_TEST_FRAME_NORM_H
10 
12 
13 #include "ocean/base/Worker.h"
14 
15 namespace Ocean
16 {
17 
18 namespace Test
19 {
20 
21 namespace TestCV
22 {
23 
24 /**
25  * This class implements tests for the FrameNorm class.
26  * @ingroup testcv
27  */
28 class OCEAN_TEST_CV_EXPORT TestFrameNorm
29 {
30  public:
31 
32  /**
33  * Starts all tests of the FrameNorm class.
34  * @param testDuration Number of seconds for each test, with range (0, infinity)
35  * @return True, if succeeded
36  */
37  static bool test(const double testDuration);
38 
39  /**
40  * Tests the function determining the L2 norm.
41  * @param testDuration Number of seconds for each test, with range (0, infinity)
42  * @return True, if succeeded
43  * @tparam T The data type of each element, 'float' or 'double'
44  */
45  template <typename T>
46  static bool testNormL2(const double testDuration);
47 
48  protected:
49 
50  /**
51  * Calculates the L2 norm for all elements of a given frame (square root of sum of squared elements).
52  * @param frame The frame for which the L2 norm will be calculated, must be valid
53  * @param width The width of the given frame in pixels (in elements as we have a 1 channel frame), with range [1, infinity)
54  * @param height The height of the given frame in pixels, with range [1, infinity)
55  * @param framePaddingElements The number of padding elements at the end of each frame row, in elements, with range [0, infinity)
56  * @return The resulting L2 norm, with range [0, infinity)
57  * @tparam T The data type of each element of the given frame 'float' or 'double'
58  */
59  template <typename T>
60  static double calculateNormL2(const T* frame, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements);
61 };
62 
63 }
64 
65 }
66 
67 }
68 
69 #endif // OCEAN_TEST_TESTCV_TEST_FRAME_NORM_H
This class implements tests for the FrameNorm class.
Definition: TestFrameNorm.h:29
static double calculateNormL2(const T *frame, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements)
Calculates the L2 norm for all elements of a given frame (square root of sum of squared elements).
static bool test(const double testDuration)
Starts all tests of the FrameNorm class.
static bool testNormL2(const double testDuration)
Tests the function determining the L2 norm.
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15