result.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Intel Corporation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef MOVIDIUS_NCS_LIB_RESULT_H
18 #define MOVIDIUS_NCS_LIB_RESULT_H
19 
20 #include <string>
21 #include <memory>
22 #include <vector>
23 
24 namespace movidius_ncs_lib
25 {
26 struct Item
27 {
28  std::string category;
29  float probability;
30 };
31 
32 struct BBox
33 {
34  int x;
35  int y;
36  int width;
37  int height;
38 };
39 
40 struct ItemInBBox
41 {
44 };
45 
46 using Items = std::vector<Item>;
47 using ItemsPtr = std::shared_ptr<Items>;
48 using ItemInBBoxArray = std::vector<ItemInBBox>;
49 using ItemInBBoxArrayPtr = std::shared_ptr<ItemInBBoxArray>;
50 
52 {
54  float time_taken;
55 };
56 
58 {
60  float time_taken;
61 };
62 
63 using ClassificationResultPtr = std::shared_ptr<ClassificationResult>;
64 using DetectionResultPtr = std::shared_ptr<DetectionResult>;
65 
66 
67 class Result
68 {
69 public:
70  using Ptr = std::shared_ptr<Result>;
71  using ConstPtr = std::shared_ptr<Result const>;
72 
73  explicit Result(const std::string& cnn_type);
74  ClassificationResultPtr getClassificationResult();
75  DetectionResultPtr getDetectionResult();
76  void setClassificationResult(Item item);
77  void setClassificationResult(float time);
78  void setDetectionResult(ItemInBBox item);
79  void setDetectionResult(float time);
80  void parseYoloResult(const std::vector<float>& result, const std::vector<std::string> categories,
81  int img_width, int img_height);
82  void parseSSDResult(const std::vector<float>& result, const std::vector<std::string> categories,
83  int img_width, int img_height);
84 
85 private:
86  void NMS(ItemInBBoxArrayPtr objs_in_bboxes);
87  float IOU(ItemInBBox box1, ItemInBBox box2);
88 
91 };
92 } // namespace movidius_ncs_lib
93 
94 #endif // MOVIDIUS_NCS_LIB_RESULT_H
std::shared_ptr< Result > Ptr
Definition: result.h:70
std::vector< Item > Items
Definition: result.h:46
std::shared_ptr< DetectionResult > DetectionResultPtr
Definition: result.h:64
std::vector< ItemInBBox > ItemInBBoxArray
Definition: result.h:48
std::shared_ptr< ItemInBBoxArray > ItemInBBoxArrayPtr
Definition: result.h:49
DetectionResultPtr detection_result
Definition: result.h:90
std::shared_ptr< Result const > ConstPtr
Definition: result.h:71
ItemInBBoxArray items_in_boxes
Definition: result.h:59
std::string category
Definition: result.h:28
std::shared_ptr< Items > ItemsPtr
Definition: result.h:47
ClassificationResultPtr classification_result
Definition: result.h:89
std::shared_ptr< ClassificationResult > ClassificationResultPtr
Definition: result.h:63


movidius_ncs_lib
Author(s): Xiaojun Huang
autogenerated on Mon Jun 10 2019 14:11:23