Éanna Ó Catháin | 919c14e | 2020-09-14 17:36:49 +0100 | [diff] [blame] | 1 | // |
| 2 | // Copyright © 2020 Arm Ltd and Contributors. All rights reserved. |
| 3 | // SPDX-License-Identifier: MIT |
| 4 | // |
| 5 | |
| 6 | #pragma once |
| 7 | |
| 8 | #include "BoundingBox.hpp" |
| 9 | |
| 10 | #include <string> |
| 11 | #include <vector> |
| 12 | |
| 13 | namespace od |
| 14 | { |
| 15 | /** |
| 16 | * An object detection network inference result decoded data representation. |
| 17 | */ |
| 18 | class DetectedObject |
| 19 | { |
| 20 | |
| 21 | public: |
| 22 | DetectedObject(); |
| 23 | |
| 24 | /** |
| 25 | * Creates detection with given parameters. |
| 26 | * |
| 27 | * @param id - class id |
| 28 | * @param label - human readable text class label |
| 29 | * @param boundingBox - rectangular detection coordinates |
| 30 | * @param score - detection score/probability |
| 31 | */ |
| 32 | DetectedObject(unsigned int id, |
| 33 | std::string label, |
| 34 | const BoundingBox& boundingBox, |
| 35 | float score); |
| 36 | |
| 37 | ~DetectedObject() = default; |
| 38 | |
| 39 | /** |
| 40 | * Get class id |
| 41 | * @return id |
| 42 | */ |
| 43 | unsigned int GetId() const; |
| 44 | |
| 45 | /** |
| 46 | * Get human readable text class label |
| 47 | * @return label |
| 48 | */ |
| 49 | const std::string& GetLabel() const; |
| 50 | |
| 51 | /** |
| 52 | * Get rectangular detection coordinates |
| 53 | * @return detection coordinates |
| 54 | */ |
| 55 | const BoundingBox& GetBoundingBox() const; |
| 56 | |
| 57 | /** |
| 58 | * Get detection score |
| 59 | * @return score |
| 60 | */ |
| 61 | float GetScore() const; |
| 62 | |
| 63 | /** |
| 64 | * Set class id |
| 65 | * @param[in] id - class id |
| 66 | */ |
| 67 | void SetId(unsigned int id); |
| 68 | |
| 69 | /** |
| 70 | * Set class label |
| 71 | * @param[in] label - human readable text class label |
| 72 | */ |
| 73 | void SetLabel(const std::string& label); |
| 74 | |
| 75 | /** |
| 76 | * Set detection coordinates |
| 77 | * @param[in] boundingBox detection coordinates |
| 78 | */ |
| 79 | void SetBoundingBox(const BoundingBox& boundingBox); |
| 80 | |
| 81 | /** |
| 82 | * Set detection score |
| 83 | * @param[in] score - detection score |
| 84 | */ |
| 85 | void SetScore(float score); |
| 86 | |
| 87 | private: |
| 88 | unsigned int m_Id; |
| 89 | std::string m_Label; |
| 90 | BoundingBox m_BoundingBox; |
| 91 | float m_Score; |
| 92 | }; |
| 93 | |
| 94 | using DetectedObjects = std::vector<DetectedObject>; |
| 95 | |
| 96 | }// namespace od |