Ocean
TestLineDetectorULF.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_TESTDETECTOR_TEST_LINE_DETECTOR_ULF_H
9 #define META_OCEAN_TEST_TESTCV_TESTDETECTOR_TEST_LINE_DETECTOR_ULF_H
10 
12 
13 #include "ocean/base/Frame.h"
14 
16 
17 namespace Ocean
18 {
19 
20 namespace Test
21 {
22 
23 namespace TestCV
24 {
25 
26 namespace TestDetector
27 {
28 
29 /**
30  * This class implements line detector tests.
31  * @ingroup testcvdetector
32  */
33 class OCEAN_TEST_CV_DETECTOR_EXPORT TestLineDetectorULF : protected CV::Detector::LineDetectorULF
34 {
35  public:
36 
37  /**
38  * Invokes all test for the line detector.
39  * @param testDuration Number of seconds for each test, with range (0, infinity)
40  * @param worker The worker object
41  * @return True, if succeeded
42  */
43  static bool test(const double testDuration, Worker& worker);
44 
45  /**
46  * Tests the sliding window sum function for single rows calculating the sums of pixel intensities only.
47  * @param testDuration Number of seconds for each test, with range (0, infinity)
48  * @return True, if succeeded
49  */
50  static bool testRowSums(const double testDuration);
51 
52  /**
53  * Tests the sliding window sum functions for single rows calculating the sums of pixel intensities and the sums of squared pixel intensities.
54  * @param testDuration Number of seconds for each test, with range (0, infinity)
55  * @return True, if succeeded
56  */
57  static bool testRowSqrSums(const double testDuration);
58 
59  /**
60  * Tests the mean square residual bar edge detector.
61  * @param testDuration Number of seconds for each test, with range (0, infinity)
62  * @return True, if succeeded
63  */
64  static bool testRMSBarEdgeDetector(const double testDuration);
65 
66  /**
67  * Tests the horizontal RMS Bar edge detector.
68  * @param testDuration Number of seconds for each test, with range (0, infinity)
69  * @return True, if succeeded
70  */
71  static bool testHorizontalRMSBarEdgeDetector(const double testDuration);
72 
73  /**
74  * Tests the mean square residual bar line detector.
75  * @param testDuration Number of seconds for each test, with range (0, infinity)
76  * @return True, if succeeded
77  */
78  static bool testRMSBarLineDetector(const double testDuration);
79 
80  /**
81  * Tests the mean square residual step edge detector.
82  * @param testDuration Number of seconds for each test, with range (0, infinity)
83  * @return True, if succeeded
84  */
85  static bool testRMSStepEdgeDetector(const double testDuration);
86 
87  /**
88  * Tests the horizontal RMS Step edge detector.
89  * @param testDuration Number of seconds for each test, with range (0, infinity)
90  * @return True, if succeeded
91  */
92  static bool testHorizontalRMSStepEdgeDetector(const double testDuration);
93 
94  /**
95  * Tests the mean square residual step line detector.
96  * @param testDuration Number of seconds for each test, with range (0, infinity)
97  * @return True, if succeeded
98  */
99  static bool testRMSStepLineDetector(const double testDuration);
100 
101  /**
102  * Tests the sum difference edge detector.
103  * @param testDuration Number of seconds for each test, with range (0, infinity)
104  * @return True, if succeeded
105  */
106  static bool testSDStepEdgeDetector(const double testDuration);
107 
108  /**
109  * Tests the horizontal SD Step edge detector.
110  * @param testDuration Number of seconds for each test, with range (0, infinity)
111  * @return True, if succeeded
112  */
113  static bool testHorizontalSDStepEdgeDetector(const double testDuration);
114 
115  protected:
116 
117  /**
118  * Tests the horizontal edge detector of a specific detector.
119  * @param edgeDetector The edge detector to be tested, must support a horizontal detection function
120  * @param testDuration Number of seconds for each test, with range (0, infinity)
121  * @return True, if succeeded
122  */
123  static bool testHorizontalEdgeDetector(const EdgeDetector& edgeDetector, const double testDuration);
124 
125  /**
126  * Determines the horizontal RMS-based bar edge response for one pixel with floating point precision.
127  * The response applies non-maximum suppression within a 3-neighborhood.
128  * @param yFrame The 8 bit grayscale frame for which the response will be calculated, must be valid, with dimension [window * 2 + 3, infinity)x[1, infinity)
129  * @param x The horizontal location within the frame, with range [0, width - 1]
130  * @param y The vertical location within the frame, with range [0, height - 1]
131  * @param windowSize The size of the window to be used, in pixel, with range [1, infinity)
132  * @param minimalDelta The minimal intensity delta between average and center pixel, with range [0, 255]
133  * @return The response at the specified location
134  */
135  static double rmsBarEdgeResponse(const Frame& yFrame, const unsigned int x, const unsigned int y, const unsigned int windowSize, const double minimalDelta = 5.0);
136 
137  /**
138  * Determines the horizontal RMS-based step edge response for one pixel with floating point precision.
139  * The response applies non-maximum suppression within a 3-neighborhood.
140  * @param yFrame The 8 bit grayscale frame for which the response will be calculated, must be valid, with dimension [window * 2 + 3, infinity)x[1, infinity)
141  * @param x The horizontal location within the frame, with range [0, width - 1]
142  * @param y The vertical location within the frame, with range [0, height - 1]
143  * @param windowSize The size of the window to be used, in pixel, with range [1, infinity)
144  * @param decisionDelta Optional resulting minimal delta between center response and neighbor response
145  * @return The response at the specified location
146  * @tparam tSeparateResidual True, to apply a separate residual for left and right window; False, to apply a common residual
147  * @tparam tSignedSquaredResponse True, to apply the squared (but signed) response values; False, to determine the non-squared responses
148  */
149  template <bool tSeparateResidual, bool tSignedSquaredResponse>
150  static double rmsStepEdgeResponse(const Frame& yFrame, const unsigned int x, const unsigned int y, const unsigned int windowSize, double* decisionDelta = nullptr);
151 
152  /**
153  * Determines the horizontal RMS-based step edge response for one pixel with floating point precision.
154  * The response does not apply non-maximum suppression within a 3-neighborhood.
155  * @param yFrame The 8 bit grayscale frame for which the response will be calculated, must be valid, with dimension [window * 2 + 3, infinity)x[1, infinity)
156  * @param x The horizontal location within the frame, with range [0, width - 1]
157  * @param y The vertical location within the frame, with range [0, height - 1]
158  * @param windowSize The size of the window to be used, in pixel, with range [1, infinity)
159  * @return The response at the specified location
160  * @tparam tSeparateResidual True, to apply a separate residual for left and right window; False, to apply a common residual
161  */
162  template <bool tSeparateResidual>
163  static double rmsStepEdgeResponseWithoutNonMaximumSuppression(const Frame& yFrame, const unsigned int x, const unsigned int y, const unsigned int windowSize);
164 
165  /**
166  * Determines the horizontal sum difference step edge detector response for a single pixel.
167  * The response applies non-maximum suppression.
168  * @param yFrame The 8 bit grayscale frame for which the response will be calculated, must be valid, with dimension [window * 2 + 3, infinity)x[1, infinity)
169  * @param x The horizontal location within the frame, with range [0, width - 1]
170  * @param y The vertical location within the frame, with range [0, height - 1]
171  * @param stepSize The number of pixels between both windows sums, "should be odd", "should" have range [1, infinity)
172  * @param windowSize The size of the window to be used, in pixel, with range [1, infinity)
173  * @return The response at the specified location
174  */
175  static double sdStepEdgeResponse(const Frame& yFrame, const unsigned int x, const unsigned int y, const unsigned int stepSize, const unsigned int windowSize);
176 
177  /**
178  * Determines the horizontal sum difference step edge detector response for a single pixel.
179  * The response does not apply non-maximum suppression.
180  * @param yFrame The 8 bit grayscale frame for which the response will be calculated, must be valid, with dimension [window * 2 + 3, infinity)x[1, infinity)
181  * @param x The horizontal location within the frame, with range [0, width - 1]
182  * @param y The vertical location within the frame, with range [0, height - 1]
183  * @param stepSize The number of pixels between both windows sums, "should be odd", "should" have range [1, infinity)
184  * @param windowSize The size of the window to be used, in pixel, with range [1, infinity)
185  * @return The response at the specified location
186  */
187  static double sdStepEdgeResponseWithoutNonMaximumSuppression(const Frame& yFrame, const unsigned int x, const unsigned int y, const unsigned int stepSize, const unsigned int windowSize);
188 };
189 
190 }
191 
192 }
193 
194 }
195 
196 }
197 
198 #endif // META_OCEAN_TEST_TESTCV_TESTDETECTOR_TEST_LINE_DETECTOR_ULF_H
This class implements the almost abstract base class for all edge detectors.
Definition: LineDetectorULF.h:81
This class implements a line detector optimized for urban lines (Urban Line Finder).
Definition: LineDetectorULF.h:34
This class implements Ocean's image class.
Definition: Frame.h:1792
This class implements line detector tests.
Definition: TestLineDetectorULF.h:34
static bool testRMSBarLineDetector(const double testDuration)
Tests the mean square residual bar line detector.
static bool testRMSStepLineDetector(const double testDuration)
Tests the mean square residual step line detector.
static bool testHorizontalEdgeDetector(const EdgeDetector &edgeDetector, const double testDuration)
Tests the horizontal edge detector of a specific detector.
static bool testRowSqrSums(const double testDuration)
Tests the sliding window sum functions for single rows calculating the sums of pixel intensities and ...
static bool testHorizontalRMSStepEdgeDetector(const double testDuration)
Tests the horizontal RMS Step edge detector.
static double sdStepEdgeResponseWithoutNonMaximumSuppression(const Frame &yFrame, const unsigned int x, const unsigned int y, const unsigned int stepSize, const unsigned int windowSize)
Determines the horizontal sum difference step edge detector response for a single pixel.
static bool test(const double testDuration, Worker &worker)
Invokes all test for the line detector.
static bool testHorizontalRMSBarEdgeDetector(const double testDuration)
Tests the horizontal RMS Bar edge detector.
static double rmsStepEdgeResponseWithoutNonMaximumSuppression(const Frame &yFrame, const unsigned int x, const unsigned int y, const unsigned int windowSize)
Determines the horizontal RMS-based step edge response for one pixel with floating point precision.
static double sdStepEdgeResponse(const Frame &yFrame, const unsigned int x, const unsigned int y, const unsigned int stepSize, const unsigned int windowSize)
Determines the horizontal sum difference step edge detector response for a single pixel.
static bool testRMSBarEdgeDetector(const double testDuration)
Tests the mean square residual bar edge detector.
static double rmsStepEdgeResponse(const Frame &yFrame, const unsigned int x, const unsigned int y, const unsigned int windowSize, double *decisionDelta=nullptr)
Determines the horizontal RMS-based step edge response for one pixel with floating point precision.
static bool testRMSStepEdgeDetector(const double testDuration)
Tests the mean square residual step edge detector.
static bool testHorizontalSDStepEdgeDetector(const double testDuration)
Tests the horizontal SD Step edge detector.
static bool testRowSums(const double testDuration)
Tests the sliding window sum function for single rows calculating the sums of pixel intensities only.
static double rmsBarEdgeResponse(const Frame &yFrame, const unsigned int x, const unsigned int y, const unsigned int windowSize, const double minimalDelta=5.0)
Determines the horizontal RMS-based bar edge response for one pixel with floating point precision.
static bool testSDStepEdgeDetector(const double testDuration)
Tests the sum difference edge detector.
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