ArmNN
 20.05
NMS.hpp
Go to the documentation of this file.
1 //
2 // Copyright © 2020 Arm Ltd. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 
6 #pragma once
7 
8 #include <ostream>
9 #include <vector>
10 
11 namespace yolov3 {
12 /** Non Maxima Suprresion configuration meta-data */
13 struct NMSConfig {
14  unsigned int num_classes{0}; /**< Number of classes in the detected boxes */
15  unsigned int num_boxes{0}; /**< Number of detected boxes */
16  float confidence_threshold{0.8f}; /**< Inclusion confidence threshold for a box */
17  float iou_threshold{0.8f}; /**< Inclusion threshold for Intersection-Over-Union */
18 };
19 
20 /** Box representation structure */
21 struct Box {
22  float xmin; /**< X-pos position of the low left coordinate */
23  float xmax; /**< X-pos position of the top right coordinate */
24  float ymin; /**< Y-pos position of the low left coordinate */
25  float ymax; /**< Y-pos position of the top right coordinate */
26 };
27 
28 /** Detection structure */
29 struct Detection {
30  Box box; /**< Detection box */
31  float confidence; /**< Confidence of detection */
32  std::vector<float> classes; /**< Probability of classes */
33 };
34 
35 /** Print identified yolo detections
36  *
37  * @param[in, out] os Output stream to print to
38  * @param[in] detections Detections to print
39  */
40 void print_detection(std::ostream& os,
41  const std::vector<Detection>& detections);
42 
43 /** Perform Non-Maxima Supression on a list of given detections
44  *
45  * @param[in] config Configuration metadata for NMS
46  * @param[in] detected_boxes Detected boxes
47  *
48  * @return A vector with the final detections
49  */
50 std::vector<Detection> nms(const NMSConfig& config,
51  const std::vector<float>& detected_boxes);
52 } // namespace yolov3
float confidence
Confidence of detection.
Definition: NMS.hpp:31
float ymin
Y-pos position of the low left coordinate.
Definition: NMS.hpp:24
unsigned int num_boxes
Number of detected boxes.
Definition: NMS.hpp:15
Definition: NMS.cpp:14
float xmin
X-pos position of the low left coordinate.
Definition: NMS.hpp:22
float xmax
X-pos position of the top right coordinate.
Definition: NMS.hpp:23
void print_detection(std::ostream &os, const std::vector< Detection > &detections)
Print identified yolo detections.
Definition: NMS.cpp:83
Detection structure.
Definition: NMS.hpp:29
std::vector< float > classes
Probability of classes.
Definition: NMS.hpp:32
Box box
Detection box.
Definition: NMS.hpp:30
Box representation structure.
Definition: NMS.hpp:21
float ymax
Y-pos position of the top right coordinate.
Definition: NMS.hpp:25
float iou_threshold
Inclusion threshold for Intersection-Over-Union.
Definition: NMS.hpp:17
std::vector< Detection > nms(const NMSConfig &config, const std::vector< float > &detected_boxes)
Perform Non-Maxima Supression on a list of given detections.
Definition: NMS.cpp:100
Non Maxima Suprresion configuration meta-data.
Definition: NMS.hpp:13
float confidence_threshold
Inclusion confidence threshold for a box.
Definition: NMS.hpp:16
unsigned int num_classes
Number of classes in the detected boxes.
Definition: NMS.hpp:14