DaoAI World C++ SDK INDUSTRIAL 2024.8.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: 0.0.0
3
4#pragma once
5#include "common.h"
6#include <unordered_map>
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
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
56 {
57 public:
59#ifndef BUILD_INFERENCE_CLIENT
60 DAOAI_API std::string toJSONString() override;
61 DAOAI_API std::string toAnnotationJSONString() override;
62#else
63 DAOAI_API InstanceSegmentationResult(const std::string& json_result);
64#endif // !BUILD_INFERENCE_CLIENT
65
66 size_t num_detections = 0;
67 std::vector<Box> boxes;
68 std::vector<Mask> masks;
69 std::vector<double> confidences;
70 std::vector<int> class_ids;
71 std::vector<std::string> class_labels;
72 };
73
75 {
76 public:
78#ifndef BUILD_INFERENCE_CLIENT
79 DAOAI_API std::string toJSONString() override;
80 DAOAI_API std::string toAnnotationJSONString() override;
81#else
82 DAOAI_API KeypointDetectionResult(const std::string& json_result);
83#endif // !BUILD_INFERENCE_CLIENT
84
85 size_t num_detections = 0;
86 std::vector<Box> boxes;
87 std::vector<Mask> masks;
88 std::vector<std::vector<Point>> keypoints;
89 std::vector<double> confidences;
90 std::vector<int> class_ids;
91 std::vector<std::string> class_labels;
92 };
93
94
95
96 class OCRResult final : public Prediction
97 {
98 public:
100#ifndef BUILD_INFERENCE_CLIENT
101 DAOAI_API std::string toJSONString() override;
102 DAOAI_API std::string toAnnotationJSONString() override;
103#else
104 DAOAI_API OCRResult(const std::string& json_result);
105#endif // !BUILD_INFERENCE_CLIENT
106
107 size_t num_detections = 0;
108 std::vector<Polygon> boxes;
109 std::vector<double> confidences;
110 std::vector<std::string> texts;
111 };
112 class ClassificationResult final : public Prediction
113 {
114 public:
116#ifndef BUILD_INFERENCE_CLIENT
117 DAOAI_API std::string toJSONString() override;
118 DAOAI_API std::string toAnnotationJSONString() override;
119#else
120 DAOAI_API ClassificationResult(const std::string& json_result);
121#endif // !BUILD_INFERENCE_CLIENT
122
123 struct Flag
124 {
125 double confidence = -1;
126 std::string label = "";
127 };
128
129 std::vector<Flag> flags;
130 bool multilabel = false;
131 };
132
133 class ImageEmbedding final : public Prediction
134 {
135 public:
137 DAOAI_API ImageEmbedding(const std::vector<float>& data, const std::vector<size_t>& shape, const int& image_height, const int& image_width);
138#ifndef BUILD_INFERENCE_CLIENT
139 DAOAI_API std::string toJSONString() override;
140#endif // !BUILD_INFERENCE_CLIENT
141 std::vector<float> data;
142 std::vector<size_t> shape;
143 };
144
146 {
147 public:
149#ifndef BUILD_INFERENCE_CLIENT
150 DAOAI_API std::string toJSONString() override;
151 DAOAI_API std::string toAnnotationJSONString() override;
152#endif // !BUILD_INFERENCE_CLIENT
153
155 double confidence = -1;
156 };
157
159 {
160 public:
162#ifndef BUILD_INFERENCE_CLIENT
163 DAOAI_API std::string toJSONString() override;
164 DAOAI_API std::string toAnnotationJSONString() override;
165#else
166 DAOAI_API SupervisedDefectSegmentationResult(const std::string& json_result);
167#endif // !BUILD_INFERENCE_CLIENT
168
169
170 std::unordered_map<std::string, Mask> masks;
171 std::vector<float> pixel_scores;
172 std::string decision;
173 };
174
175#ifdef INDUSTRIAL
177 {
178 public:
180#ifndef BUILD_INFERENCE_CLIENT
182 DAOAI_API std::string toAnnotationJSONString() override;
183 DAOAI_API std::string toJSONString() override;
184#else
185 DAOAI_API PositioningResult(const std::string& json_result);
186#endif // !BUILD_INFERENCE_CLIENT
187
188 double angle = 0;
190 std::string decision;
191 };
192
194 {
195 public:
197#ifndef BUILD_INFERENCE_CLIENT
199#else
200 DAOAI_API PresenceCheckingResult(const std::string& json_result);
201#endif // !BUILD_INFERENCE_CLIENT
202 };
203
204#ifndef BUILD_INFERENCE_CLIENT
206 {
207 public:
208 struct Region
209 {
210 Region(const std::string& label, const double& confidence, const bool& defect, const double* bbox) : label(label), confidence(confidence), defect(defect), bbox{ bbox[0], bbox[1], bbox[2], bbox[3] } {}
211 std::string label = "";
212 double confidence = -1;
213 bool defect = false;
214 double bbox[4];
215 };
216
222
225
227 DAOAI_API std::string toJSONString();
229 DAOAI_API UnsupervisedDefectSegmentationResult(const std::string& json_result);
230
232 double confidence = -1;
233 bool defect = false;
234 std::vector<Region> region_defects;
235 int image_width = -1;
236 int image_height = -1;
237 };
238#endif // !BUILD_INFERENCE_CLIENT
239#endif // INDUSTRIAL
240 }
241 }
242}
#define DAOAI_API
Definition API_EXPORT.h:13
Definition common.h:186
Definition common.h:266
Definition common.h:28
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:155
DAOAI_API std::string toJSONString() override
bool multilabel
Definition prediction.h:130
std::vector< Flag > flags
Definition prediction.h:129
DAOAI_API std::string toAnnotationJSONString() override
std::vector< float > data
Definition prediction.h:141
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:142
DAOAI_API std::string toJSONString() override
DAOAI_API std::string toAnnotationJSONString() override
std::vector< Mask > masks
Definition prediction.h:68
std::vector< int > class_ids
Definition prediction.h:70
std::vector< std::string > class_labels
Definition prediction.h:71
std::vector< double > confidences
Definition prediction.h:69
std::vector< Box > boxes
Definition prediction.h:67
std::vector< Mask > masks
Definition prediction.h:87
std::vector< double > confidences
Definition prediction.h:89
std::vector< Box > boxes
Definition prediction.h:86
DAOAI_API std::string toJSONString() override
size_t num_detections
Definition prediction.h:85
std::vector< std::string > class_labels
Definition prediction.h:91
std::vector< int > class_ids
Definition prediction.h:90
DAOAI_API std::string toAnnotationJSONString() override
std::vector< std::vector< Point > > keypoints
Definition prediction.h:88
Definition prediction.h:97
size_t num_detections
Definition prediction.h:107
DAOAI_API std::string toJSONString() override
std::vector< Polygon > boxes
Definition prediction.h:108
std::vector< std::string > texts
Definition prediction.h:110
DAOAI_API std::string toAnnotationJSONString() override
std::vector< double > confidences
Definition prediction.h:109
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:188
std::string decision
Definition prediction.h:190
Point center
Definition prediction.h:189
DAOAI_API std::string toAnnotationJSONString() override
PositioningResult(const KeypointDetectionResult &keypoint_result)
DAOAI_API std::string toJSONString() override
PresenceCheckingResult(const ObjectDetectionResult &object_result)
std::vector< float > pixel_scores
Definition prediction.h:171
std::unordered_map< std::string, Mask > masks
Definition prediction.h:170
std::vector< Region > region_defects
Definition prediction.h:234
UnsupervisedDefectSegmentationResult(Image &&mask, const std::vector< Region > &region_defects, const double &confidence, const bool &defect, const int &image_height, const int &image_width)
Definition prediction.h:223
UnsupervisedDefectSegmentationResult(const std::vector< Region > &region_defects, const int &image_height, const int &image_width)
Definition prediction.h:226
UnsupervisedDefectSegmentationResult(double confidence, bool defect, int image_height, int image_width)
Definition prediction.h:218
DAOAI_API UnsupervisedDefectSegmentationResult(const std::string &json_result)
UnsupervisedDefectSegmentationResult(Image &&mask, double confidence, bool defect, int image_height, int image_width)
Definition prediction.h:220
Definition common.h:14
std::string label
Definition prediction.h:126
Region(const std::string &label, const double &confidence, const bool &defect, const double *bbox)
Definition prediction.h:210