61 : _input_output(nullptr), _min_distance(0.0f)
74 _input_output = input_output;
75 _min_distance = min_distance;
77 IKernel::configure(
Window());
88 const size_t num_candidates = _input_output->
num_values();
89 size_t num_detections = 0;
92 std::sort(_input_output->
buffer(), _input_output->
buffer() + num_candidates, compare_detection_window);
94 const float min_distance_pow2 = _min_distance * _min_distance;
97 for(
size_t i = 0; i < num_candidates; ++i)
99 if(0.0f != _input_output->
at(i).score)
102 cur.
x = _input_output->
at(i).x;
103 cur.
y = _input_output->
at(i).y;
104 cur.
width = _input_output->
at(i).width;
105 cur.
height = _input_output->
at(i).height;
107 cur.
score = _input_output->
at(i).score;
110 _input_output->
at(num_detections) = cur;
114 const float xc = cur.
x + cur.
width * 0.5f;
115 const float yc = cur.
y + cur.
height * 0.5f;
117 for(
size_t k = i + 1; k < (num_candidates) && (cur.
idx_class == _input_output->
at(k).idx_class); ++k)
119 const float xn = _input_output->
at(k).x + _input_output->
at(k).width * 0.5f;
120 const float yn = _input_output->
at(k).y + _input_output->
at(k).height * 0.5f;
122 const float dx = std::fabs(xn - xc);
123 const float dy = std::fabs(yn - yc);
125 if(dx < _min_distance && dy < _min_distance)
127 const float d = dx * dx + dy * dy;
129 if(d < min_distance_pow2)
132 _input_output->
at(k).score = 0.0f;
139 _input_output->
resize(num_detections);
const Window & window() const
The maximum window the kernel can be executed on.
uint16_t x
Top-left x coordinate.
float score
Confidence value for the detection window.
void resize(size_t num)
Resizes the array to contain "num" elements.
#define ARM_COMPUTE_ERROR_ON(cond)
If the condition is true then an error message is printed and an exception thrown.
Copyright (c) 2017-2021 Arm Limited.
void run(const Window &window, const ThreadInfo &info) override
Execute the kernel on the passed window.
bool is_parallelisable() const override
Indicates whether or not the kernel is parallelisable.
#define ARM_COMPUTE_UNUSED(...)
To avoid unused variables warnings.
virtual T * buffer() const =0
Pointer to the first element of the array.
size_t num_values() const
Number of values currently stored in the array.
#define ARM_COMPUTE_ERROR_ON_MISMATCHING_WINDOWS(f, w)
uint16_t width
Width of the detection window.
void configure(IDetectionWindowArray *input_output, float min_distance)
Initialise the kernel's input, output and the euclidean minimum distance.
#define ARM_COMPUTE_ERROR_ON_UNCONFIGURED_KERNEL(k)
uint16_t idx_class
Index of the class.
CPPDetectionWindowNonMaximaSuppressionKernel()
Default constructor.
uint16_t height
Height of the detection window.
ScaleKernelInfo info(interpolation_policy, default_border_mode, PixelValue(), sampling_policy, false)
Information about executing thread and CPU.
Detection window used for the object detection.
uint16_t y
Top-left y coordinate.
Describe a multidimensional execution window.
virtual T & at(size_t index) const
Reference to the element of the array located at the given index.