DaoAI World C++ SDK INDUSTRIAL 2025.3.0
Loading...
Searching...
No Matches
prediction.h
Go to the documentation of this file.
1// Copyright (c) 2024, DaoAI Robotics. All rights reserved.
2// Version: 2025.3.0
3
4#pragma once
5#include <unordered_map>
6#include "common.h"
7#include "config.h"
8namespace DaoAI
9{
10 namespace DeepLearning
11 {
13 {
14 public:
15
16#ifndef BUILD_INFERENCE_CLIENT
20 virtual std::string toJSONString() { return ""; }
21
25 DAOAI_API virtual std::string toAnnotationJSONString();
26#endif // !BUILD_INFERENCE_CLIENT
27
28
29 int image_width = 0;
30 int image_height = 0;
31 };
32
33
34 namespace Vision
35 {
37 {
38 public:
40#ifndef BUILD_INFERENCE_CLIENT
41 DAOAI_API std::string toJSONString() override;
42 DAOAI_API std::string toAnnotationJSONString() override;
43#else
44 DAOAI_API ObjectDetectionResult(const std::string& json_result);
45#endif // !BUILD_INFERENCE_CLIENT
46
47 size_t num_detections = 0;
48 std::vector<Box> boxes;
49 std::vector<double> confidences;
50 std::vector<int> class_ids;
51 std::vector<std::string> class_labels;
52 std::string decision = "";
53 };
54
60
62 {
63 public:
65#ifndef BUILD_INFERENCE_CLIENT
66 DAOAI_API std::string toJSONString() override;
67 DAOAI_API std::string toAnnotationJSONString() override;
68#else
69 DAOAI_API InstanceSegmentationResult(const std::string& json_result);
70#endif // !BUILD_INFERENCE_CLIENT
71
72 size_t num_detections = 0;
73 std::vector<Box> boxes;
74 std::vector<Mask> masks;
75 std::vector<double> confidences;
76 std::vector<int> class_ids;
77 std::vector<std::string> class_labels;
78 };
79
81 {
82 public:
84#ifndef BUILD_INFERENCE_CLIENT
85 DAOAI_API std::string toJSONString() override;
86 DAOAI_API std::string toAnnotationJSONString() override;
87#else
88 DAOAI_API KeypointDetectionResult(const std::string& json_result);
89#endif // !BUILD_INFERENCE_CLIENT
90
91 size_t num_detections = 0;
92 std::vector<Box> boxes;
93 std::vector<Mask> masks;
94 std::vector<std::vector<Point>> keypoints;
95 std::vector<double> confidences;
96 std::vector<int> class_ids;
97 std::vector<std::string> class_labels;
98 };
99
101 {
102 public:
104#ifndef BUILD_INFERENCE_CLIENT
105 DAOAI_API std::string toJSONString() override;
106 DAOAI_API std::string toAnnotationJSONString() override;
107#else
108 DAOAI_API MultilabelDetectionResult(const std::string& json_result);
109#endif // !BUILD_INFERENCE_CLIENT
110
111 std::vector<std::unordered_map<std::string, double>> attributes;
112 };
113
114 class OCRResult final : public Prediction
115 {
116 public:
118#ifndef BUILD_INFERENCE_CLIENT
119 DAOAI_API std::string toJSONString() override;
120 DAOAI_API std::string toAnnotationJSONString() override;
121#else
122 DAOAI_API OCRResult(const std::string& json_result);
123#endif // !BUILD_INFERENCE_CLIENT
124
125 size_t num_detections = 0;
126 std::vector<Polygon> boxes;
127 std::vector<double> confidences;
128 std::vector<std::string> texts;
129 };
130 class ClassificationResult final : public Prediction
131 {
132 public:
134#ifndef BUILD_INFERENCE_CLIENT
135 DAOAI_API std::string toJSONString() override;
136 DAOAI_API std::string toAnnotationJSONString() override;
137#else
138 DAOAI_API ClassificationResult(const std::string& json_result);
139#endif // !BUILD_INFERENCE_CLIENT
140
141 struct Flag
142 {
143 double confidence = -1;
144 std::string label = "";
145 };
146
147 std::vector<Flag> flags;
148 bool multilabel = false;
149 };
150
151 class ImageEmbedding final : public Prediction
152 {
153 public:
155 DAOAI_API ImageEmbedding(const std::vector<float>& data, const std::vector<size_t>& shape, const int& image_height, const int& image_width);
156#ifndef BUILD_INFERENCE_CLIENT
157 DAOAI_API std::string toJSONString() override;
158#endif // !BUILD_INFERENCE_CLIENT
159 std::vector<float> data;
160 std::vector<size_t> shape;
161 };
162
164 {
165 public:
167#ifndef BUILD_INFERENCE_CLIENT
168 DAOAI_API std::string toJSONString() override;
169 DAOAI_API std::string toAnnotationJSONString() override;
170#endif // !BUILD_INFERENCE_CLIENT
171
173 double confidence = -1;
174 };
175
177 {
178 public:
180#ifndef BUILD_INFERENCE_CLIENT
181 DAOAI_API std::string toJSONString() override;
182 DAOAI_API std::string toAnnotationJSONString() override;
183#else
184 DAOAI_API SupervisedDefectSegmentationResult(const std::string& json_result);
185#endif // !BUILD_INFERENCE_CLIENT
186
187
188 std::unordered_map<std::string, Mask> masks;
189 std::unordered_map<std::string, bool> classes;
191 std::string decision;
192 };
193
194#ifdef INDUSTRIAL
196 {
197 public:
199#ifndef BUILD_INFERENCE_CLIENT
201 DAOAI_API std::string toAnnotationJSONString() override;
202 DAOAI_API std::string toJSONString() override;
203#else
204 DAOAI_API PositioningResult(const std::string& json_result);
205#endif // !BUILD_INFERENCE_CLIENT
206
207 double angle = 0;
209 std::string decision;
210 };
211
213 {
214 public:
216#ifndef BUILD_INFERENCE_CLIENT
218#else
219 DAOAI_API PresenceCheckingResult(const std::string& json_result);
220#endif // !BUILD_INFERENCE_CLIENT
221 };
222
224 {
225 public:
226 struct Region
227 {
228 Region(const std::string& label, const double& ai_deviation_score, const bool& defect, const double* bbox) : label(label), ai_deviation_score(ai_deviation_score), defect(defect), bbox{ bbox[0], bbox[1], bbox[2], bbox[3] } {}
229 std::string label = "";
231 bool defect = false;
232 double bbox[4];
233 };
234
236#ifndef BUILD_INFERENCE_CLIENT
237 DAOAI_API std::string toJSONString() override;
238 DAOAI_API std::string toAnnotationJSONString() override;
239#else
240 DAOAI_API UnsupervisedDefectSegmentationResult(const std::string& json_result);
241#endif // !BUILD_INFERENCE_CLIENT
242
246 bool defect = false;
247 std::vector<Region> region_defects;
248 };
249#endif // INDUSTRIAL
250 }
251 }
252}
#define DAOAI_API
Definition API_EXPORT.h:13
Definition common.h:269
Definition common.h:31
Definition prediction.h:13
virtual DAOAI_API std::string toAnnotationJSONString()
virtual std::string toJSONString()
Definition prediction.h:20
int image_width
Definition prediction.h:29
int image_height
Definition prediction.h:30
DAOAI_API std::string toAnnotationJSONString() override
DAOAI_API std::string toJSONString() override
double confidence
Definition prediction.h:173
DAOAI_API std::string toJSONString() override
bool multilabel
Definition prediction.h:148
std::vector< Flag > flags
Definition prediction.h:147
DAOAI_API std::string toAnnotationJSONString() override
std::vector< float > data
Definition prediction.h:159
DAOAI_API ImageEmbedding(const std::vector< float > &data, const std::vector< size_t > &shape, const int &image_height, const int &image_width)
std::vector< size_t > shape
Definition prediction.h:160
DAOAI_API std::string toJSONString() override
DAOAI_API std::string toAnnotationJSONString() override
std::vector< Mask > masks
Definition prediction.h:74
std::vector< int > class_ids
Definition prediction.h:76
std::vector< std::string > class_labels
Definition prediction.h:77
std::vector< double > confidences
Definition prediction.h:75
std::vector< Box > boxes
Definition prediction.h:73
std::vector< Mask > masks
Definition prediction.h:93
std::vector< double > confidences
Definition prediction.h:95
std::vector< Box > boxes
Definition prediction.h:92
DAOAI_API std::string toJSONString() override
size_t num_detections
Definition prediction.h:91
std::vector< std::string > class_labels
Definition prediction.h:97
std::vector< int > class_ids
Definition prediction.h:96
DAOAI_API std::string toAnnotationJSONString() override
std::vector< std::vector< Point > > keypoints
Definition prediction.h:94
std::vector< std::unordered_map< std::string, double > > attributes
Definition prediction.h:111
DAOAI_API std::string toAnnotationJSONString() override
Definition prediction.h:115
size_t num_detections
Definition prediction.h:125
DAOAI_API std::string toJSONString() override
std::vector< Polygon > boxes
Definition prediction.h:126
std::vector< std::string > texts
Definition prediction.h:128
DAOAI_API std::string toAnnotationJSONString() override
std::vector< double > confidences
Definition prediction.h:127
std::vector< std::string > class_labels
Definition prediction.h:51
std::vector< Box > boxes
Definition prediction.h:48
std::vector< double > confidences
Definition prediction.h:49
std::string decision
Definition prediction.h:52
std::vector< int > class_ids
Definition prediction.h:50
size_t num_detections
Definition prediction.h:47
DAOAI_API std::string toAnnotationJSONString() override
DAOAI_API std::string toJSONString() override
double angle
Definition prediction.h:207
std::string decision
Definition prediction.h:209
Point center
Definition prediction.h:208
DAOAI_API std::string toAnnotationJSONString() override
PositioningResult(const KeypointDetectionResult &keypoint_result)
DAOAI_API std::string toJSONString() override
PresenceCheckingResult(const ObjectDetectionResult &object_result)
std::unordered_map< std::string, bool > classes
Definition prediction.h:189
std::unordered_map< std::string, Mask > masks
Definition prediction.h:188
std::vector< Region > region_defects
Definition prediction.h:247
Definition common.h:14
std::string label
Definition prediction.h:144
Region(const std::string &label, const double &ai_deviation_score, const bool &defect, const double *bbox)
Definition prediction.h:228