xref: /aosp_15_r20/external/armnn/samples/ObjectDetection/include/YoloResultDecoder.hpp (revision 89c4ff92f2867872bb9e2354d150bf0c8c502810)
1 //
2 // Copyright © 2020 Arm Ltd and Contributors. All rights reserved.
3 // SPDX-License-Identifier: MIT
4 //
5 #pragma once
6 
7 #include "Types.hpp"
8 #include "ArmnnNetworkExecutor.hpp"
9 #include "DetectedObject.hpp"
10 #include "IDetectionResultDecoder.hpp"
11 #include "NonMaxSuppression.hpp"
12 
13 namespace od
14 {
15 
16 class YoloResultDecoder : public IDetectionResultDecoder
17 {
18 
19 public:
20     /**
21      * Constructs Yolo V3  inference reuslts decoder.
22      *
23      * @param NMSThreshold non max suppression threshold
24      * @param ClsThreshold class probability threshold
25      * @param ObjectThreshold detected object score threshold
26      */
27     YoloResultDecoder(float NMSThreshold, float ClsThreshold, float ObjectThreshold);
28 
29     DetectedObjects Decode(const common::InferenceResults<float>& results,
30                            const common::Size& outputFrameSize,
31                            const common::Size& resizedFrameSize,
32                            const std::vector <std::string>& labels) override;
33 private:
34     float m_NmsThreshold;
35     float m_ClsThreshold;
36     float m_objectThreshold;
37 
38     unsigned int m_boxElements = 4U;
39     unsigned int m_confidenceElements = 1U;
40     unsigned int m_numClasses = 80U;
41     unsigned int m_numBoxes = 2535U;
42 };
43 }// namespace od