Ocean
Loading...
Searching...
No Matches
TestShapeDetector.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_SHAPE_DETECTOR_H
9#define META_OCEAN_TEST_TESTCV_TESTDETECTOR_TEST_SHAPE_DETECTOR_H
10
12
13#include "ocean/base/Frame.h"
14
16
18
19namespace Ocean
20{
21
22namespace Test
23{
24
25namespace TestCV
26{
27
28namespace TestDetector
29{
30
31/**
32 * This class implements tests for the Shape detector.
33 * @ingroup testcvdetector
34 */
36{
37 protected:
38
42
46
47 public:
48
49 /**
50 * Definition of indivdual response types.
51 */
52 enum ResponseType : uint32_t
53 {
54 /// The response is composed of the horizontal and vertical response.
55 RT_HORIZONTAL_AND_VERTICAL = 0u,
56 /// The response is just based on the horizontal response.
57 RT_HORIZONTAL = 1u,
58 /// The response is just based on the vertical response.
59 RT_VERTICAL = 2u,
60 };
61
62 /**
63 * Definition of individual response visualization types.
64 */
65 enum ResponseVisualization : uint32_t
66 {
67 /// The response values are visualized with linear normalization.
68 RV_LINEAR = 0u,
69 /// The response values are visualized with a logarithmic normalization.
70 RV_LOGARITHMIC = 1u
71 };
72
73 /**
74 * This class provides the ground truth implementation of the gradient-based T-detector.
75 */
76 class OCEAN_TEST_CV_DETECTOR_EXPORT GradientBasedDetector
77 {
78 public:
79
80 /**
81 * Definition of individual stategies to determine edge response.
82 */
83 enum EdgeResponseStrategy : uint32_t
84 {
85 /// The edge gradient (vertical and horizontal) is determined between the edge pixel and the direct neighboring pixel.
86 ERS_GRADIENT_TO_NEIGHBOR = 0u,
87 /// The edge gradient (vertical and horizontal) is determine between the edge pixel and the center pixel.
88 ERS_GRADIENT_TO_CENTER = 1u
89 };
90
91 /**
92 * Definition of individual stategies to handle a minimal edge response.
93 */
95 {
96 /// The minimal response is ignored.
97 MRS_IGNORE = 0u,
98 /// The minimal response is checked separately across the horizontal and vertical edge responses.
99 MRS_SEPARATE_HORIZONTAL_VERTICAL = 1u,
100 /// The minimal response is checked separately across opposite edges.
101 MRS_SEPARATE_OPPOSITE_SIDE = 2u
102 };
103
104 /**
105 * Definition of individual penalty usages.
106 */
107 enum PenaltyUsage : uint32_t
108 {
109 /// The penalty is subtracted from the edge response.
110 PU_SUBTRACT = 0u,
111 /// The penalty is used to normalize the edge response (by division).
112 PU_DIVISION = 1u
113 };
114
115 public:
116
117 /**
118 * Detects shapes in a given image.
119 * @param yFrame The frame in which the shapes will be detected, must be valid
120 * @param threshold The minimal threshold for a detected shape, with range (0, infinity)
121 * @param responseMultiplicationFactor An explicit post-processing multiplicatio factor for detector responses, with range (0, infinity)
122 * @param lShapes The resulting detected L-shapes
123 * @param tShapes The resulting detected T-shapes
124 * @param xShapes The resulting detected X-shapes
125 * @param sign The sign of the shape to be detected, -1 for shapes with dark edges and bright environment, 1 for shapes with bright edges and dark environment
126 * @param shapeWidth The width of the shapes, in pixel, with range [shapeBottomBand * 2 + shapeStepSize, infinity), must be odd
127 * @param shapeHeight The height of the shapes, in pixel, with range [shapeBottomBand + shapeStepSize, infinity)
128 * @param shapeStepSize The step size of the shapes, in pixel, with range [1, infinity), must be odd
129 * @param shapeTopBand The top band size of the shapes, in pixel, with range [1, infinity)
130 * @param shapeBottomBand The bottom band size of the shapes, in pixel, with range [1, infinity)
131 * @param responseType The response type to be used for shape detection
132 * @param penaltyFactor The multiplication factor for the penalty value, with range (0, infinity)
133 * @param minimalEdgeResponse The minimal edge response the detector must create to accept the response as candidate, with range [0, infinity)
134 * @param nonMaximumSupressionRadius The radius which is applied during non-maximum-suppression, with range [1, infinity)
135 * @param edgeResponseStrategy The response strategy for edges which will be applied
136 * @param minimalResponseStrategy The strategy for minimal responses to be applied
137 * @param penaltyUsage The penalty mode to be applied
138 * @param fResponseTopDown Optional resulting detector response image for the top-down detector (not rotated)
139 * @param fResponseBottomUp Optional resulting detector response image for the bottom-up detector (rotated by 180 degree)
140 */
141 static void detectShapes(const Frame& yFrame, const double threshold, const double responseMultiplicationFactor, LShapes& lShapes, TShapes& tShapes, XShapes& xShapes, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double penaltyFactor, const unsigned int minimalEdgeResponse, const double nonMaximumSupressionRadius, const EdgeResponseStrategy edgeResponseStrategy, const MinimalResponseStrategy minimalResponseStrategy, const PenaltyUsage penaltyUsage, Frame* fResponseTopDown = nullptr, Frame* fResponseBottomUp = nullptr);
142
143 /**
144 * Determines the gradient-based T-shape detector response.
145 * @param yFrame The frame in which the detector will be applied, must have pixel format FORMAT_Y8
146 * @param x The horizontal position of the T-shape within the frame, with range [0, yFrame.width())
147 * @param y The vertical position of the T-shape wihtin the frame, with range [0, yFrame.height())
148 * @param sign The sign of the shape to be detected, -1 for shapes with dark edges and bright environment, 1 for shapes with bright edges and dark environment
149 * @param shapeWidth The width of the shapes, in pixel, with range [shapeBottomBand * 2 + shapeStepSize, infinity), must be odd
150 * @param shapeHeight The height of the shapes, in pixel, with range [shapeBottomBand + shapeStepSize, infinity)
151 * @param shapeStepSize The step size of the shapes, in pixel, with range [1, infinity), must be odd
152 * @param shapeTopBand The top band size of the shapes, in pixel, with range [1, infinity)
153 * @param shapeBottomBand The bottom band size of the shapes, in pixel, with range [1, infinity)
154 * @param responseType The response type to be used for shape detection
155 * @param penaltyFactor The multiplication factor for the penalty value, with range (0, infinity)
156 * @param minimalEdgeResponse The minimal edge response the detector must create to accept the response as candidate, with range [0, infinity)
157 * @param edgeResponseStrategy The response strategy for edges which will be applied
158 * @param minimalResponseStrategy The strategy for minimal responses to be applied
159 * @param penaltyUsage The penalty mode to be applied
160 * @return The reponse of the T-shape detector
161 */
162 static double tShapeDetectorResponse(const Frame& yFrame, const unsigned int x, const unsigned int y, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double penaltyFactor, const unsigned int minimalEdgeResponse, const EdgeResponseStrategy edgeResponseStrategy, const MinimalResponseStrategy minimalResponseStrategy, const PenaltyUsage penaltyUsage);
163 };
164
165 /**
166 * This class provides the ground truth implementation of the variance-based T-detector.
167 */
168 class OCEAN_TEST_CV_DETECTOR_EXPORT VarianceBasedDetector
169 {
170 public:
171
172 /**
173 * Definition of individual stategies to determine the gradient response.
174 */
176 {
177 /// The foreground response is based on the maximum absolute difference.
178 GRS_MAX_ABSOLUTE_DIFFERENCE = 0u,
179 /// The foreground response is based on the sum of absolute differences.
180 GRS_SUM_ABSOLUTE_DIFFERENCES = 1u,
181 };
182
183 /**
184 * Definition of individual band strategies.
185 */
186 enum BandStrategy : uint32_t
187 {
188 /// The band variance is determined based on a joining all band blocks.
189 BS_JOINED = 0u,
190 /// The band variance is determined based on the average variance of all band blocks.
191 BS_SEPARATE_AVERAGE = 1u,
192 /// The band variance is determined based on the maximum variance of all band blocks.
193 BS_SEPARATE_MAX = 2u,
194 /// The band variance is not used.
195 BS_SKIP = 3u
196 };
197
198 /**
199 * Definition of individual threshold strategies.
200 */
201 enum ThresholdStrategy : uint32_t
202 {
203 /// The threshold value is used as defined.
204 TS_VALUE = 0u,
205 /// The threshold is based on 65% of the sorted top 100 shapes.
206 TS_BASED_ON_TOP_100_65 = 1u,
207 /// The threshold is based on 55% of the sorted top 75 shapes.
208 TS_BASED_ON_TOP_75_55 = 2u,
209 };
210
211 public:
212
213 /**
214 * Detects shapes in a given image.
215 * @param yFrame The frame in which the shapes will be detected, must be valid
216 * @param threshold The minimal threshold for a detected shape, with range (0, infinity)
217 * @param responseMultiplicationFactor An explicit post-processing multiplicatio factor for detector responses, with range (0, infinity)
218 * @param lShapes The resulting detected L-shapes
219 * @param tShapes The resulting detected T-shapes
220 * @param xShapes The resulting detected X-shapes
221 * @param shapeWidth The width of the shapes, in pixel, with range [shapeBottomBand * 2 + shapeStepSize, infinity), must be odd
222 * @param shapeHeight The height of the shapes, in pixel, with range [shapeBottomBand + shapeStepSize, infinity)
223 * @param shapeStepSize The step size of the shapes, in pixel, with range [1, infinity), must be odd
224 * @param shapeTopBand The top band size of the shapes, in pixel, with range [1, infinity)
225 * @param shapeBottomBand The bottom band size of the shapes, in pixel, with range [1, infinity)
226 * @param responseType The response type to be used for shape detection
227 * @param minimalGradient The minimal gradient which is necessary to accept a response, with range [0, 256)
228 * @param varianceFactor The multiplication factor for the variance, with range (0, infinity)
229 * @param minimalVariance The minimal variance value used as lower boundary, with range (0, infinity)
230 * @param maximalRatio The maximal ratio between horizontal and vertical responses to accept a response, with range [1, infinity)
231 * @param nonMaximumSupressionRadius The radius which is applied during non-maximum-suppression, with range [1, infinity)
232 * @param thresholdStrategy The strategy for thresholding the shapes
233 * @param gradientResponseStrategy The strategy for gradient responses to be applied
234 * @param bandStrategy The strategy how to determine the variances for the bands
235 * @param fResponseTopDown Optional resulting detector response image for the top-down detector (not rotated)
236 * @param fResponseBottomUp Optional resulting detector response image for the bottom-up detector (rotated by 180 degree)
237 */
238 static void detectShapes(const Frame& yFrame, const double threshold, const double responseMultiplicationFactor, LShapes& lShapes, TShapes& tShapes, XShapes& xShapes, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double varianceFactor, const double minimalVariance, const double maximalRatio, const double nonMaximumSupressionRadius, const ThresholdStrategy thresholdStrategy, const GradientResponseStrategy gradientResponseStrategy, const BandStrategy bandStrategy, Frame* fResponseTopDown = nullptr, Frame* fResponseBottomUp = nullptr);
239
240 /**
241 * Determines the gradient-based T-shape detector response.
242 * @param linedIntegral The lined integral image of the original yFrame, must be valid
243 * @param linedIntegralSquared The lined integral squared image of the original yFrame, must be valid
244 * @param width The width of the original yFrame, in pixel, with range [1, infinity)
245 * @param height The height of the original yFrame, in pixel, with range [1, infinity)
246 * @param x The horizontal location for which the T-shape response will be determined, in pixel, with range [0, width - 1]
247 * @param y The vertical location for which the T-shape response will be determined, in pixel, with range [0, height - 1]
248 * @param shapeWidth The width of the shapes, in pixel, with range [shapeBottomBand * 2 + shapeStepSize, infinity), must be odd
249 * @param shapeHeight The height of the shapes, in pixel, with range [shapeBottomBand + shapeStepSize, infinity)
250 * @param shapeStepSize The step size of the shapes, in pixel, with range [1, infinity), must be odd
251 * @param shapeTopBand The top band size of the shapes, in pixel, with range [1, infinity)
252 * @param shapeBottomBand The bottom band size of the shapes, in pixel, with range [1, infinity)
253 * @param responseType The response type to be used for shape detection
254 * @param minimalGradient The minimal gradient which is necessary to accept a response, with range [0, 256)
255 * @param varianceFactor The multiplication factor for the variance, with range (0, infinity)
256 * @param minimalVariance The minimal variance value used as lower boundary, with range (0, infinity)
257 * @param maximalRatio The maximal ratio between horizontal and vertical responses to accept a response, with range [1, infinity)
258 * @param gradientResponseStrategy The strategy for gradient responses to be applied
259 * @param bandStrategy The strategy how to determine the variances for the bands
260 */
261 static double tShapeDetectorResponse(const uint32_t* linedIntegral, const uint64_t* linedIntegralSquared, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double varianceFactor, const double minimalVariance, const double maximalRatio, const GradientResponseStrategy gradientResponseStrategy, const BandStrategy bandStrategy);
262 };
263
264 /**
265 * This class provides the ground truth implementation of the gradient&variance-based T-detector.
266 * The shape detector has the following geometry:
267 * <pre>
268 * T-shape width
269 * <--------------------------------------->
270 *
271 * --------------------------------------- ^
272 * | | | top band
273 * | | V
274 * ^ |#######################################| ^
275 * | | | |
276 * | | X | | shapeStepSize
277 * | | | |
278 * | |################ ################| V
279 * T-shape | | # # | ^
280 * height | | # # | | bottom band
281 * | -------- # # -------- V
282 * | | # # |
283 * | | # # |
284 * | | # # |
285 * | | # # |
286 * | | # # |
287 * | | # # |
288 * | | # # |
289 * | | # # |
290 * V ---------------------
291 *
292 * X: position of the T-shape
293 * #: edges of the T-shape
294 * </pre>
295 */
296 class OCEAN_TEST_CV_DETECTOR_EXPORT GradientVarianceBasedDetector
297 {
298 public:
299
300 /**
301 * Definition of individual band strategies.
302 */
303 enum BandStrategy : uint32_t
304 {
305 /// The band variance is not used.
306 BS_SKIP = 0u,
307 /// The band variance is divided.
309 /// The band variance is divided and subtracted.
311 /// Last (exclusive) band strategy value.
312 BS_END
313 };
314
315 /**
316 * Definition of individual optimization strategies.
317 */
318 enum OptimizationStrategy : uint32_t
319 {
320 /// No optimization.
321 OS_NONE = 0u,
322 /// Applying symmetric responses to allow response recycling, top and bottom band need to be identical, four horizontal response (two top and bottom blocks), vertical blocks have same height.
324 /// Applying symmetric responses to allow response recycling, top and bottom band need to be identical, four horizontal response (two top and bottom blocks), vertical blocks have different height.
326 /// Applying symmetric responses to allow response recycling, top and bottom band need to be identical, two horizontal repsonse (one top and one bottom block), vertical blocks have same height.
328 /// Applying symmetric responses to allow response recycling, top and bottom band need to be identical, two horizontal repsonse (one top and one bottom block), vertical blocks have different height.
330 /// Last (exclusive) optimization strategy value.
331 OS_END
332 };
333
334 public:
335
336 /**
337 * Detects standard shapes in a given image.
338 * @param yFrame The frame in which the shapes will be detected, must be valid
339 * @param threshold The minimal threshold for a detected shape, with range (0, infinity)
340 * @param responseMultiplicationFactor An explicit post-processing multiplication factor for detector responses, with range (0, infinity)
341 * @param lShapes The resulting detected L-shapes
342 * @param tShapes The resulting detected T-shapes
343 * @param xShapes The resulting detected X-shapes
344 * @param sign The sign of the shape to be detected, -1 for shapes with dark edges and bright environment, 1 for shapes with bright edges and dark environment, 0 to accept shapes with both signs
345 * @param shapeWidth The width of the shapes, in pixel, with range [shapeBottomBand * 2 + shapeStepSize, infinity), must be odd
346 * @param shapeHeight The height of the shapes, in pixel, with range [shapeBottomBand + shapeStepSize, infinity)
347 * @param shapeStepSize The step size of the shapes, in pixel, with range [1, infinity), must be odd
348 * @param shapeTopBand The top band size of the shapes, in pixel, with range [1, infinity)
349 * @param shapeBottomBand The bottom band size of the shapes, in pixel, with range [1, infinity)
350 * @param responseType The response type to be used for shape detection
351 * @param minimalGradient The minimal gradient which is necessary to accept a response, with range [0, 256)
352 * @param maximalResponseRatio The maximal ratio between horizontal and vertical responses to accept a response, with range [1, infinity)
353 * @param bandStrategy The band strategy to be applied
354 * @param optimizationStrategy The optimization strategy to be applied
355 * @param nonMaximumSupressionRadius The radius which is applied during non-maximum-suppression, with range [1, infinity)
356 * @param fResponseTopDown Optional resulting detector response image for the top-down detector (not rotated)
357 * @param fResponseBottomUp Optional resulting detector response image for the bottom-up detector (rotated by 180 degree)
358 */
359 static void detectShapes(const Frame& yFrame, const double threshold, const double responseMultiplicationFactor, LShapes& lShapes, TShapes& tShapes, XShapes& xShapes, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double maximalResponseRatio, const BandStrategy bandStrategy, const OptimizationStrategy optimizationStrategy, const double nonMaximumSupressionRadius, Frame* fResponseTopDown = nullptr, Frame* fResponseBottomUp = nullptr);
360
361 /**
362 * Detects modified shapes in a given image.
363 * The modified shapes do not have a bar-edge roof, but a step-edge roof.
364 * @param yFrame The frame in which the shapes will be detected, must be valid
365 * @param threshold The minimal threshold for a detected shape, with range (0, infinity)
366 * @param responseMultiplicationFactor An explicit post-processing multiplication factor for detector responses, with range (0, infinity)
367 * @param lShapes The resulting detected L-shapes
368 * @param tShapes The resulting detected T-shapes
369 * @param xShapes The resulting detected X-shapes
370 * @param sign The sign of the shape to be detected, -1 for shapes with dark edges and bright environment, 1 for shapes with bright edges and dark environment, 0 to accept shapes with both signs
371 * @param shapeWidth The width of the shapes, in pixel, with range [shapeBottomBand * 2 + shapeStepSize, infinity), must be odd
372 * @param shapeHeight The height of the shapes, in pixel, with range [shapeBottomBand + shapeStepSize, infinity)
373 * @param shapeStepSize The step size of the shapes, in pixel, with range [1, infinity), must be odd
374 * @param shapeTopBand The top band size of the shapes, in pixel, with range [1, infinity)
375 * @param shapeBottomBand The bottom band size of the shapes, in pixel, with range [1, infinity)
376 * @param responseType The response type to be used for shape detection
377 * @param minimalGradient The minimal gradient which is necessary to accept a response, with range [0, 256)
378 * @param maximalResponseRatio The maximal ratio between horizontal and vertical responses to accept a response, with range [1, infinity)
379 * @param bandStrategy The band strategy to be applied
380 * @param nonMaximumSupressionRadius The radius which is applied during non-maximum-suppression, with range [1, infinity)
381 * @param fResponseTopDown Optional resulting detector response image for the top-down detector (not rotated)
382 * @param fResponseBottomUp Optional resulting detector response image for the bottom-up detector (rotated by 180 degree)
383 */
384 static void detectShapesModified(const Frame& yFrame, const double threshold, const double responseMultiplicationFactor, LShapes& lShapes, TShapes& tShapes, XShapes& xShapes, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double maximalResponseRatio, const BandStrategy bandStrategy, const double nonMaximumSupressionRadius, Frame* fResponseTopDown = nullptr, Frame* fResponseBottomUp = nullptr);
385
386 /**
387 * Determines the gradient&variance-based T-shape detector response.
388 * @param linedIntegral The lined integral image of the original yFrame, must be valid
389 * @param linedIntegralSquared The lined integral squared image of the original yFrame, must be valid
390 * @param width The width of the original yFrame, in pixel, with range [1, infinity)
391 * @param height The height of the original yFrame, in pixel, with range [1, infinity)
392 * @param x The horizontal location for which the T-shape response will be determined, in pixel, with range [0, width - 1]
393 * @param y The vertical location for which the T-shape response will be determined, in pixel, with range [0, height - 1]
394 * @param sign The sign of the shape to be detected, -1 for shapes with dark edges and bright environment, 1 for shapes with bright edges and dark environment, 0 to accept shapes with both signs
395 * @param shapeWidth The width of the shapes, in pixel, with range [shapeBottomBand * 2 + shapeStepSize, infinity), must be odd
396 * @param shapeHeight The height of the shapes, in pixel, with range [shapeBottomBand + shapeStepSize, infinity)
397 * @param shapeStepSize The step size of the shapes, in pixel, with range [1, infinity), must be odd
398 * @param shapeTopBand The top band size of the shapes, in pixel, with range [1, infinity)
399 * @param shapeBottomBand The bottom band size of the shapes, in pixel, with range [1, infinity)
400 * @param responseType The response type to be used for shape detection
401 * @param minimalGradient The minimal gradient which is necessary to accept a response, with range [0, 256)
402 * @param maximalResponseRatio The maximal ratio between horizontal and vertical responses to accept a response, with range [1, infinity)
403 * @param bandStrategy The band strategy to be applied
404 * @param optimizationStrategy The optimization strategy to be applied
405 * @param horizontalResponse Optional resulting horizontal response
406 * @param verticalResponse Optional vertical horizontal response
407 */
408 static double tShapeDetectorResponse(const uint32_t* linedIntegral, const uint64_t* linedIntegralSquared, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double maximalResponseRatio, const BandStrategy bandStrategy, const OptimizationStrategy optimizationStrategy, double* horizontalResponse = nullptr, double* verticalResponse = nullptr);
409
410 /**
411 * Determines the gradient&variance-based T-shape detector response.
412 * The modified T-shapes do not have a bar-edge roof, but a step-edge roof.
413 * @param linedIntegral The lined integral image of the original yFrame, must be valid
414 * @param linedIntegralSquared The lined integral squared image of the original yFrame, must be valid
415 * @param width The width of the original yFrame, in pixel, with range [1, infinity)
416 * @param height The height of the original yFrame, in pixel, with range [1, infinity)
417 * @param x The horizontal location for which the T-shape response will be determined, in pixel, with range [0, width - 1]
418 * @param y The vertical location for which the T-shape response will be determined, in pixel, with range [0, height - 1]
419 * @param sign The sign of the shape to be detected, -1 for shapes with dark edges and bright environment, 1 for shapes with bright edges and dark environment, 0 to accept shapes with both signs
420 * @param shapeWidth The width of the shapes, in pixel, with range [shapeBottomBand * 2 + shapeStepSize, infinity), must be odd
421 * @param shapeHeight The height of the shapes, in pixel, with range [shapeBottomBand + shapeStepSize, infinity)
422 * @param shapeStepSize The step size of the shapes, in pixel, with range [1, infinity), must be odd
423 * @param shapeTopBand The top band size of the shapes, in pixel, with range [1, infinity)
424 * @param shapeBottomBand The bottom band size of the shapes, in pixel, with range [1, infinity)
425 * @param responseType The response type to be used for shape detection
426 * @param minimalGradient The minimal gradient which is necessary to accept a response, with range [0, 256)
427 * @param maximalResponseRatio The maximal ratio between horizontal and vertical responses to accept a response, with range [1, infinity)
428 * @param bandStrategy The band strategy to be applied
429 * @param horizontalResponse Optional resulting horizontal response
430 * @param verticalResponse Optional vertical horizontal response
431 */
432 static double tShapeDetectorResponseModified(const uint32_t* linedIntegral, const uint64_t* linedIntegralSquared, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double maximalResponseRatio, const BandStrategy bandStrategy, double* horizontalResponse = nullptr, double* verticalResponse = nullptr);
433 };
434
435 public:
436
437 /**
438 * Tests the shape detector functions.
439 * @param testDuration Number of seconds for each test, with range (0, infinity)
440 * @param selector The test selector to filter tests
441 * @return True, if succeeded
442 */
443 static bool test(const double testDuration, const TestSelector& selector);
444
445 /**
446 * Test the gradient-based T-shape detector.
447 * @param testDuration The duration in seconds for which this test will be run, with range (0, infinity)
448 * @return True, if succeeded
449 */
450 static bool testGradientBasedTShapeDetector(const double testDuration);
451
452 /**
453 * Test the horizontal response of the gradient&variance-based T-shape detector.
454 * @param testDuration The duration in seconds for which this test will be run, with range (0, infinity)
455 * @return True, if succeeded
456 */
457 static bool testGradientVarianceBasedTShapeDetectorHorizontalResponse(const double testDuration);
458
459 /**
460 * Test the vertical response of the gradient&variance-based T-shape detector.
461 * @param testDuration The duration in seconds for which this test will be run, with range (0, infinity)
462 * @return True, if succeeded
463 */
464 static bool testGradientVarianceBasedTShapeDetectorVerticalResponse(const double testDuration);
465
466 /**
467 * Test the gradient&variance-based T-shape detector.
468 * @param testDuration The duration in seconds for which this test will be run, with range (0, infinity)
469 * @return True, if succeeded
470 */
471 static bool testGradientVarianceBasedTShapeDetector(const double testDuration);
472
473 protected:
474
475 /**
476 * Compares two T-shapes and returns whether the left shape has a higher score.
477 * @param left The left T-shape to compare
478 * @param right The right T-shape to compare
479 * @return True, if so
480 */
481 static inline bool compareTshapes(const TShape& left, const TShape& right);
482};
483
484inline bool TestShapeDetector::compareTshapes(const TShape& left, const TShape& right)
485{
486 return left.score() > right.score();
487}
488
489} // namespace TestDetector
490
491} // namespace TestCV
492
493} // namespce Test
494
495} // namespace Ocean
496
497#endif // META_OCEAN_TEST_TESTCV_TESTDETECTOR_TEST_SHAPE_DETECTOR_H
This class implements an L-shape element like a corner of a rectangle.
Definition ShapeDetector.h:175
This class implements a shape detector based on gradients and variance.
Definition ShapeDetector.h:503
This class implements a T-shape element like a junction connecting two lines, with one line having th...
Definition ShapeDetector.h:249
Scalar score() const
Returns the sore of this shape.
Definition ShapeDetector.h:1081
This class implements a X-shape element like a crossing of two lines, with both lines not crossing ne...
Definition ShapeDetector.h:302
std::vector< TShape > TShapes
Definition of a vector holding T-shape objects.
Definition ShapeDetector.h:374
std::vector< LShape > LShapes
Definition of a vector holding L-shape objects.
Definition ShapeDetector.h:369
std::vector< XShape > XShapes
Definition of a vector holding X-shape objects.
Definition ShapeDetector.h:379
This class implements Ocean's image class.
Definition Frame.h:1879
This class provides the ground truth implementation of the gradient-based T-detector.
Definition TestShapeDetector.h:77
MinimalResponseStrategy
Definition of individual stategies to handle a minimal edge response.
Definition TestShapeDetector.h:95
PenaltyUsage
Definition of individual penalty usages.
Definition TestShapeDetector.h:108
static void detectShapes(const Frame &yFrame, const double threshold, const double responseMultiplicationFactor, LShapes &lShapes, TShapes &tShapes, XShapes &xShapes, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double penaltyFactor, const unsigned int minimalEdgeResponse, const double nonMaximumSupressionRadius, const EdgeResponseStrategy edgeResponseStrategy, const MinimalResponseStrategy minimalResponseStrategy, const PenaltyUsage penaltyUsage, Frame *fResponseTopDown=nullptr, Frame *fResponseBottomUp=nullptr)
Detects shapes in a given image.
static double tShapeDetectorResponse(const Frame &yFrame, const unsigned int x, const unsigned int y, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double penaltyFactor, const unsigned int minimalEdgeResponse, const EdgeResponseStrategy edgeResponseStrategy, const MinimalResponseStrategy minimalResponseStrategy, const PenaltyUsage penaltyUsage)
Determines the gradient-based T-shape detector response.
EdgeResponseStrategy
Definition of individual stategies to determine edge response.
Definition TestShapeDetector.h:84
This class provides the ground truth implementation of the gradient&variance-based T-detector.
Definition TestShapeDetector.h:297
static void detectShapesModified(const Frame &yFrame, const double threshold, const double responseMultiplicationFactor, LShapes &lShapes, TShapes &tShapes, XShapes &xShapes, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double maximalResponseRatio, const BandStrategy bandStrategy, const double nonMaximumSupressionRadius, Frame *fResponseTopDown=nullptr, Frame *fResponseBottomUp=nullptr)
Detects modified shapes in a given image.
static void detectShapes(const Frame &yFrame, const double threshold, const double responseMultiplicationFactor, LShapes &lShapes, TShapes &tShapes, XShapes &xShapes, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double maximalResponseRatio, const BandStrategy bandStrategy, const OptimizationStrategy optimizationStrategy, const double nonMaximumSupressionRadius, Frame *fResponseTopDown=nullptr, Frame *fResponseBottomUp=nullptr)
Detects standard shapes in a given image.
BandStrategy
Definition of individual band strategies.
Definition TestShapeDetector.h:304
@ BS_SUBTRACT_AND_DIVIDE
The band variance is divided and subtracted.
Definition TestShapeDetector.h:310
@ BS_DIVIDE
The band variance is divided.
Definition TestShapeDetector.h:308
static double tShapeDetectorResponse(const uint32_t *linedIntegral, const uint64_t *linedIntegralSquared, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double maximalResponseRatio, const BandStrategy bandStrategy, const OptimizationStrategy optimizationStrategy, double *horizontalResponse=nullptr, double *verticalResponse=nullptr)
Determines the gradient&variance-based T-shape detector response.
static double tShapeDetectorResponseModified(const uint32_t *linedIntegral, const uint64_t *linedIntegralSquared, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const int sign, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double maximalResponseRatio, const BandStrategy bandStrategy, double *horizontalResponse=nullptr, double *verticalResponse=nullptr)
Determines the gradient&variance-based T-shape detector response.
OptimizationStrategy
Definition of individual optimization strategies.
Definition TestShapeDetector.h:319
@ OS_SYMMETRIC_RESPONSES_FOUR_HORIZONTAL_DIFFERENT_VERTICAL
Applying symmetric responses to allow response recycling, top and bottom band need to be identical,...
Definition TestShapeDetector.h:325
@ OS_SYMMETRIC_RESPONSES_TWO_HORIZONTAL_DIFFERENT_VERTICAL
Applying symmetric responses to allow response recycling, top and bottom band need to be identical,...
Definition TestShapeDetector.h:329
@ OS_SYMMETRIC_RESPONSES_TWO_HORIZONTAL_SAME_VERTICAL
Applying symmetric responses to allow response recycling, top and bottom band need to be identical,...
Definition TestShapeDetector.h:327
@ OS_SYMMETRIC_RESPONSES_FOUR_HORIZONTAL_SAME_VERTICAL
Applying symmetric responses to allow response recycling, top and bottom band need to be identical,...
Definition TestShapeDetector.h:323
This class provides the ground truth implementation of the variance-based T-detector.
Definition TestShapeDetector.h:169
GradientResponseStrategy
Definition of individual stategies to determine the gradient response.
Definition TestShapeDetector.h:176
ThresholdStrategy
Definition of individual threshold strategies.
Definition TestShapeDetector.h:202
static void detectShapes(const Frame &yFrame, const double threshold, const double responseMultiplicationFactor, LShapes &lShapes, TShapes &tShapes, XShapes &xShapes, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double varianceFactor, const double minimalVariance, const double maximalRatio, const double nonMaximumSupressionRadius, const ThresholdStrategy thresholdStrategy, const GradientResponseStrategy gradientResponseStrategy, const BandStrategy bandStrategy, Frame *fResponseTopDown=nullptr, Frame *fResponseBottomUp=nullptr)
Detects shapes in a given image.
static double tShapeDetectorResponse(const uint32_t *linedIntegral, const uint64_t *linedIntegralSquared, const unsigned int width, const unsigned int height, const unsigned int x, const unsigned int y, const unsigned int shapeWidth, const unsigned int shapeHeight, const unsigned int shapeStepSize, const unsigned int shapeTopBand, const unsigned int shapeBottomBand, const ResponseType responseType, const double minimalGradient, const double varianceFactor, const double minimalVariance, const double maximalRatio, const GradientResponseStrategy gradientResponseStrategy, const BandStrategy bandStrategy)
Determines the gradient-based T-shape detector response.
BandStrategy
Definition of individual band strategies.
Definition TestShapeDetector.h:187
This class implements tests for the Shape detector.
Definition TestShapeDetector.h:36
static bool testGradientVarianceBasedTShapeDetectorHorizontalResponse(const double testDuration)
Test the horizontal response of the gradient&variance-based T-shape detector.
static bool testGradientBasedTShapeDetector(const double testDuration)
Test the gradient-based T-shape detector.
CV::Detector::ShapeDetector::XShapes XShapes
Definition TestShapeDetector.h:45
ResponseVisualization
Definition of individual response visualization types.
Definition TestShapeDetector.h:66
ResponseType
Definition of indivdual response types.
Definition TestShapeDetector.h:53
static bool testGradientVarianceBasedTShapeDetectorVerticalResponse(const double testDuration)
Test the vertical response of the gradient&variance-based T-shape detector.
static bool test(const double testDuration, const TestSelector &selector)
Tests the shape detector functions.
CV::Detector::ShapeDetector::LShapes LShapes
Definition TestShapeDetector.h:43
static bool compareTshapes(const TShape &left, const TShape &right)
Compares two T-shapes and returns whether the left shape has a higher score.
Definition TestShapeDetector.h:484
CV::Detector::ShapeDetector::TShapes TShapes
Definition TestShapeDetector.h:44
static bool testGradientVarianceBasedTShapeDetector(const double testDuration)
Test the gradient&variance-based T-shape detector.
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