Ocean
Loading...
Searching...
No Matches
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
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 FrameNorm class.
28 * @ingroup testcv
29 */
30class OCEAN_TEST_CV_EXPORT TestFrameNorm
31{
32 public:
33
34 /**
35 * Starts all tests of the FrameNorm class.
36 * @param testDuration Number of seconds for each test, with range (0, infinity)
37 * @param selector Test selector for filtering sub-tests; default runs all tests
38 * @return True, if succeeded
39 */
40 static bool test(const double testDuration, const TestSelector& selector = TestSelector());
41
42 /**
43 * Tests the function determining the L2 norm.
44 * @param testDuration Number of seconds for each test, with range (0, infinity)
45 * @return True, if succeeded
46 * @tparam T The data type of each element, 'float' or 'double'
47 */
48 template <typename T>
49 static bool testNormL2(const double testDuration);
50
51 protected:
52
53 /**
54 * Calculates the L2 norm for all elements of a given frame (square root of sum of squared elements).
55 * @param frame The frame for which the L2 norm will be calculated, must be valid
56 * @param width The width of the given frame in pixels (in elements as we have a 1 channel frame), with range [1, infinity)
57 * @param height The height of the given frame in pixels, with range [1, infinity)
58 * @param framePaddingElements The number of padding elements at the end of each frame row, in elements, with range [0, infinity)
59 * @return The resulting L2 norm, with range [0, infinity)
60 * @tparam T The data type of each element of the given frame 'float' or 'double'
61 */
62 template <typename T>
63 static double calculateNormL2(const T* frame, const unsigned int width, const unsigned int height, const unsigned int framePaddingElements);
64};
65
66}
67
68}
69
70}
71
72#endif // OCEAN_TEST_TESTCV_TEST_FRAME_NORM_H
This class implements tests for the FrameNorm class.
Definition TestFrameNorm.h:31
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, const TestSelector &selector=TestSelector())
Starts all tests of the FrameNorm class.
static bool testNormL2(const double testDuration)
Tests the function determining the L2 norm.
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