forked from Azure/azure-sdk-for-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.go
534 lines (484 loc) · 22.6 KB
/
models.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
package computervision
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License. See License.txt in the project root for license information.
//
// Code generated by Microsoft (R) AutoRest Code Generator.
// Changes may cause incorrect behavior and will be lost if the code is regenerated.
import (
"encoding/json"
"github.com/Azure/go-autorest/autorest"
"io"
)
// The package's fully qualified name.
const fqdn = "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/v3.0/computervision"
// AdultInfo an object describing whether the image contains adult-oriented content and/or is racy.
type AdultInfo struct {
// IsAdultContent - A value indicating if the image contains adult-oriented content.
IsAdultContent *bool `json:"isAdultContent,omitempty"`
// IsRacyContent - A value indicating if the image is racy.
IsRacyContent *bool `json:"isRacyContent,omitempty"`
// IsGoryContent - A value indicating if the image is gory.
IsGoryContent *bool `json:"isGoryContent,omitempty"`
// AdultScore - Score from 0 to 1 that indicates how much the content is considered adult-oriented within the image.
AdultScore *float64 `json:"adultScore,omitempty"`
// RacyScore - Score from 0 to 1 that indicates how suggestive is the image.
RacyScore *float64 `json:"racyScore,omitempty"`
// GoreScore - Score from 0 to 1 that indicates how gory is the image.
GoreScore *float64 `json:"goreScore,omitempty"`
}
// AnalyzeResults analyze batch operation result.
type AnalyzeResults struct {
// Version - Version of schema used for this result.
Version *string `json:"version,omitempty"`
// ReadResults - Text extracted from the input.
ReadResults *[]ReadResult `json:"readResults,omitempty"`
}
// AreaOfInterestResult result of AreaOfInterest operation.
type AreaOfInterestResult struct {
autorest.Response `json:"-"`
// AreaOfInterest - READ-ONLY; A bounding box for an area of interest inside an image.
AreaOfInterest *BoundingRect `json:"areaOfInterest,omitempty"`
// RequestID - Id of the REST API request.
RequestID *string `json:"requestId,omitempty"`
Metadata *ImageMetadata `json:"metadata,omitempty"`
}
// MarshalJSON is the custom marshaler for AreaOfInterestResult.
func (aoir AreaOfInterestResult) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if aoir.RequestID != nil {
objectMap["requestId"] = aoir.RequestID
}
if aoir.Metadata != nil {
objectMap["metadata"] = aoir.Metadata
}
return json.Marshal(objectMap)
}
// BoundingRect a bounding box for an area inside an image.
type BoundingRect struct {
// X - X-coordinate of the top left point of the area, in pixels.
X *int32 `json:"x,omitempty"`
// Y - Y-coordinate of the top left point of the area, in pixels.
Y *int32 `json:"y,omitempty"`
// W - Width measured from the top-left point of the area, in pixels.
W *int32 `json:"w,omitempty"`
// H - Height measured from the top-left point of the area, in pixels.
H *int32 `json:"h,omitempty"`
}
// Category an object describing identified category.
type Category struct {
// Name - Name of the category.
Name *string `json:"name,omitempty"`
// Score - Scoring of the category.
Score *float64 `json:"score,omitempty"`
// Detail - Details of the identified category.
Detail *CategoryDetail `json:"detail,omitempty"`
}
// CategoryDetail an object describing additional category details.
type CategoryDetail struct {
// Celebrities - An array of celebrities if any identified.
Celebrities *[]CelebritiesModel `json:"celebrities,omitempty"`
// Landmarks - An array of landmarks if any identified.
Landmarks *[]LandmarksModel `json:"landmarks,omitempty"`
}
// CelebritiesModel an object describing possible celebrity identification.
type CelebritiesModel struct {
// Name - Name of the celebrity.
Name *string `json:"name,omitempty"`
// Confidence - Confidence level for the celebrity recognition as a value ranging from 0 to 1.
Confidence *float64 `json:"confidence,omitempty"`
// FaceRectangle - Location of the identified face in the image.
FaceRectangle *FaceRectangle `json:"faceRectangle,omitempty"`
}
// CelebrityResults result of domain-specific classifications for the domain of celebrities.
type CelebrityResults struct {
// Celebrities - List of celebrities recognized in the image.
Celebrities *[]CelebritiesModel `json:"celebrities,omitempty"`
// RequestID - Id of the REST API request.
RequestID *string `json:"requestId,omitempty"`
Metadata *ImageMetadata `json:"metadata,omitempty"`
}
// ColorInfo an object providing additional metadata describing color attributes.
type ColorInfo struct {
// DominantColorForeground - Possible dominant foreground color.
DominantColorForeground *string `json:"dominantColorForeground,omitempty"`
// DominantColorBackground - Possible dominant background color.
DominantColorBackground *string `json:"dominantColorBackground,omitempty"`
// DominantColors - An array of possible dominant colors.
DominantColors *[]string `json:"dominantColors,omitempty"`
// AccentColor - Possible accent color.
AccentColor *string `json:"accentColor,omitempty"`
// IsBWImg - A value indicating if the image is black and white.
IsBWImg *bool `json:"isBWImg,omitempty"`
}
// DetectedBrand a brand detected in an image.
type DetectedBrand struct {
// Name - READ-ONLY; Label for the brand.
Name *string `json:"name,omitempty"`
// Confidence - READ-ONLY; Confidence score of having observed the brand in the image, as a value ranging from 0 to 1.
Confidence *float64 `json:"confidence,omitempty"`
// Rectangle - READ-ONLY; Approximate location of the detected brand.
Rectangle *BoundingRect `json:"rectangle,omitempty"`
}
// MarshalJSON is the custom marshaler for DetectedBrand.
func (db DetectedBrand) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// DetectedObject an object detected in an image.
type DetectedObject struct {
// Rectangle - READ-ONLY; Approximate location of the detected object.
Rectangle *BoundingRect `json:"rectangle,omitempty"`
// Object - Label for the object.
Object *string `json:"object,omitempty"`
// Confidence - Confidence score of having observed the object in the image, as a value ranging from 0 to 1.
Confidence *float64 `json:"confidence,omitempty"`
// Parent - The parent object, from a taxonomy perspective.
// The parent object is a more generic form of this object. For example, a 'bulldog' would have a parent of 'dog'.
Parent *ObjectHierarchy `json:"parent,omitempty"`
}
// MarshalJSON is the custom marshaler for DetectedObject.
func (do DetectedObject) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if do.Object != nil {
objectMap["object"] = do.Object
}
if do.Confidence != nil {
objectMap["confidence"] = do.Confidence
}
if do.Parent != nil {
objectMap["parent"] = do.Parent
}
return json.Marshal(objectMap)
}
// DetectResult result of a DetectImage call.
type DetectResult struct {
autorest.Response `json:"-"`
// Objects - READ-ONLY; An array of detected objects.
Objects *[]DetectedObject `json:"objects,omitempty"`
// RequestID - Id of the REST API request.
RequestID *string `json:"requestId,omitempty"`
Metadata *ImageMetadata `json:"metadata,omitempty"`
}
// MarshalJSON is the custom marshaler for DetectResult.
func (dr DetectResult) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if dr.RequestID != nil {
objectMap["requestId"] = dr.RequestID
}
if dr.Metadata != nil {
objectMap["metadata"] = dr.Metadata
}
return json.Marshal(objectMap)
}
// DomainModelResults result of image analysis using a specific domain model including additional metadata.
type DomainModelResults struct {
autorest.Response `json:"-"`
// Result - Model-specific response.
Result interface{} `json:"result,omitempty"`
// RequestID - Id of the REST API request.
RequestID *string `json:"requestId,omitempty"`
Metadata *ImageMetadata `json:"metadata,omitempty"`
}
// Error details about the API request error.
type Error struct {
// Code - The error code.
Code interface{} `json:"code,omitempty"`
// Message - A message explaining the error reported by the service.
Message *string `json:"message,omitempty"`
// RequestID - A unique request identifier.
RequestID *string `json:"requestId,omitempty"`
}
// FaceDescription an object describing a face identified in the image.
type FaceDescription struct {
// Age - Possible age of the face.
Age *int32 `json:"age,omitempty"`
// Gender - Possible gender of the face. Possible values include: 'Male', 'Female'
Gender Gender `json:"gender,omitempty"`
// FaceRectangle - Rectangle in the image containing the identified face.
FaceRectangle *FaceRectangle `json:"faceRectangle,omitempty"`
}
// FaceRectangle an object describing face rectangle.
type FaceRectangle struct {
// Left - X-coordinate of the top left point of the face, in pixels.
Left *int32 `json:"left,omitempty"`
// Top - Y-coordinate of the top left point of the face, in pixels.
Top *int32 `json:"top,omitempty"`
// Width - Width measured from the top-left point of the face, in pixels.
Width *int32 `json:"width,omitempty"`
// Height - Height measured from the top-left point of the face, in pixels.
Height *int32 `json:"height,omitempty"`
}
// ImageAnalysis result of AnalyzeImage operation.
type ImageAnalysis struct {
autorest.Response `json:"-"`
// Categories - An array indicating identified categories.
Categories *[]Category `json:"categories,omitempty"`
// Adult - An object describing whether the image contains adult-oriented content and/or is racy.
Adult *AdultInfo `json:"adult,omitempty"`
// Color - An object providing additional metadata describing color attributes.
Color *ColorInfo `json:"color,omitempty"`
// ImageType - An object providing possible image types and matching confidence levels.
ImageType *ImageType `json:"imageType,omitempty"`
// Tags - A list of tags with confidence level.
Tags *[]ImageTag `json:"tags,omitempty"`
// Description - A collection of content tags, along with a list of captions sorted by confidence level, and image metadata.
Description *ImageDescriptionDetails `json:"description,omitempty"`
// Faces - An array of possible faces within the image.
Faces *[]FaceDescription `json:"faces,omitempty"`
// Objects - Array of objects describing what was detected in the image.
Objects *[]DetectedObject `json:"objects,omitempty"`
// Brands - Array of brands detected in the image.
Brands *[]DetectedBrand `json:"brands,omitempty"`
// RequestID - Id of the REST API request.
RequestID *string `json:"requestId,omitempty"`
Metadata *ImageMetadata `json:"metadata,omitempty"`
}
// ImageCaption an image caption, i.e. a brief description of what the image depicts.
type ImageCaption struct {
// Text - The text of the caption.
Text *string `json:"text,omitempty"`
// Confidence - The level of confidence the service has in the caption.
Confidence *float64 `json:"confidence,omitempty"`
}
// ImageDescription a collection of content tags, along with a list of captions sorted by confidence level,
// and image metadata.
type ImageDescription struct {
autorest.Response `json:"-"`
// ImageDescriptionDetails - A collection of content tags, along with a list of captions sorted by confidence level, and image metadata.
*ImageDescriptionDetails `json:"description,omitempty"`
// RequestID - Id of the REST API request.
RequestID *string `json:"requestId,omitempty"`
Metadata *ImageMetadata `json:"metadata,omitempty"`
}
// MarshalJSON is the custom marshaler for ImageDescription.
func (ID ImageDescription) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
if ID.ImageDescriptionDetails != nil {
objectMap["description"] = ID.ImageDescriptionDetails
}
if ID.RequestID != nil {
objectMap["requestId"] = ID.RequestID
}
if ID.Metadata != nil {
objectMap["metadata"] = ID.Metadata
}
return json.Marshal(objectMap)
}
// UnmarshalJSON is the custom unmarshaler for ImageDescription struct.
func (ID *ImageDescription) UnmarshalJSON(body []byte) error {
var m map[string]*json.RawMessage
err := json.Unmarshal(body, &m)
if err != nil {
return err
}
for k, v := range m {
switch k {
case "description":
if v != nil {
var imageDescriptionDetails ImageDescriptionDetails
err = json.Unmarshal(*v, &imageDescriptionDetails)
if err != nil {
return err
}
ID.ImageDescriptionDetails = &imageDescriptionDetails
}
case "requestId":
if v != nil {
var requestID string
err = json.Unmarshal(*v, &requestID)
if err != nil {
return err
}
ID.RequestID = &requestID
}
case "metadata":
if v != nil {
var metadata ImageMetadata
err = json.Unmarshal(*v, &metadata)
if err != nil {
return err
}
ID.Metadata = &metadata
}
}
}
return nil
}
// ImageDescriptionDetails a collection of content tags, along with a list of captions sorted by confidence
// level, and image metadata.
type ImageDescriptionDetails struct {
// Tags - A collection of image tags.
Tags *[]string `json:"tags,omitempty"`
// Captions - A list of captions, sorted by confidence level.
Captions *[]ImageCaption `json:"captions,omitempty"`
}
// ImageMetadata image metadata.
type ImageMetadata struct {
// Width - Image width, in pixels.
Width *int32 `json:"width,omitempty"`
// Height - Image height, in pixels.
Height *int32 `json:"height,omitempty"`
// Format - Image format.
Format *string `json:"format,omitempty"`
}
// ImageTag an entity observation in the image, along with the confidence score.
type ImageTag struct {
// Name - Name of the entity.
Name *string `json:"name,omitempty"`
// Confidence - The level of confidence that the entity was observed.
Confidence *float64 `json:"confidence,omitempty"`
// Hint - Optional hint/details for this tag.
Hint *string `json:"hint,omitempty"`
}
// ImageType an object providing possible image types and matching confidence levels.
type ImageType struct {
// ClipArtType - Confidence level that the image is a clip art.
ClipArtType *int32 `json:"clipArtType,omitempty"`
// LineDrawingType - Confidence level that the image is a line drawing.
LineDrawingType *int32 `json:"lineDrawingType,omitempty"`
}
// ImageURL ...
type ImageURL struct {
// URL - Publicly reachable URL of an image.
URL *string `json:"url,omitempty"`
}
// LandmarkResults result of domain-specific classifications for the domain of landmarks.
type LandmarkResults struct {
// Landmarks - List of landmarks recognized in the image.
Landmarks *[]LandmarksModel `json:"landmarks,omitempty"`
// RequestID - Id of the REST API request.
RequestID *string `json:"requestId,omitempty"`
Metadata *ImageMetadata `json:"metadata,omitempty"`
}
// LandmarksModel a landmark recognized in the image.
type LandmarksModel struct {
// Name - Name of the landmark.
Name *string `json:"name,omitempty"`
// Confidence - Confidence level for the landmark recognition as a value ranging from 0 to 1.
Confidence *float64 `json:"confidence,omitempty"`
}
// Line an object representing a recognized text line.
type Line struct {
// Language - The BCP-47 language code of the recognized text line. Only provided where the language of the line differs from the page's.
Language *string `json:"language,omitempty"`
// BoundingBox - Bounding box of a recognized line.
BoundingBox *[]float64 `json:"boundingBox,omitempty"`
// Text - The text content of the line.
Text *string `json:"text,omitempty"`
// Words - List of words in the text line.
Words *[]Word `json:"words,omitempty"`
}
// ListModelsResult result of the List Domain Models operation.
type ListModelsResult struct {
autorest.Response `json:"-"`
// ModelsProperty - READ-ONLY; An array of supported models.
ModelsProperty *[]ModelDescription `json:"models,omitempty"`
}
// MarshalJSON is the custom marshaler for ListModelsResult.
func (lmr ListModelsResult) MarshalJSON() ([]byte, error) {
objectMap := make(map[string]interface{})
return json.Marshal(objectMap)
}
// ModelDescription an object describing supported model by name and categories.
type ModelDescription struct {
// Name - The name of the model.
Name *string `json:"name,omitempty"`
// Categories - Categories of the model.
Categories *[]string `json:"categories,omitempty"`
}
// ObjectHierarchy an object detected inside an image.
type ObjectHierarchy struct {
// Object - Label for the object.
Object *string `json:"object,omitempty"`
// Confidence - Confidence score of having observed the object in the image, as a value ranging from 0 to 1.
Confidence *float64 `json:"confidence,omitempty"`
// Parent - The parent object, from a taxonomy perspective.
// The parent object is a more generic form of this object. For example, a 'bulldog' would have a parent of 'dog'.
Parent *ObjectHierarchy `json:"parent,omitempty"`
}
// OcrLine an object describing a single recognized line of text.
type OcrLine struct {
// BoundingBox - Bounding box of a recognized line. The four integers represent the x-coordinate of the left edge, the y-coordinate of the top edge, width, and height of the bounding box, in the coordinate system of the input image, after it has been rotated around its center according to the detected text angle (see textAngle property), with the origin at the top-left corner, and the y-axis pointing down.
BoundingBox *string `json:"boundingBox,omitempty"`
// Words - An array of objects, where each object represents a recognized word.
Words *[]OcrWord `json:"words,omitempty"`
}
// OcrRegion a region consists of multiple lines (e.g. a column of text in a multi-column document).
type OcrRegion struct {
// BoundingBox - Bounding box of a recognized region. The four integers represent the x-coordinate of the left edge, the y-coordinate of the top edge, width, and height of the bounding box, in the coordinate system of the input image, after it has been rotated around its center according to the detected text angle (see textAngle property), with the origin at the top-left corner, and the y-axis pointing down.
BoundingBox *string `json:"boundingBox,omitempty"`
// Lines - An array of recognized lines of text.
Lines *[]OcrLine `json:"lines,omitempty"`
}
// OcrResult ...
type OcrResult struct {
autorest.Response `json:"-"`
// Language - The BCP-47 language code of the text in the image.
Language *string `json:"language,omitempty"`
// TextAngle - The angle, in radians, of the detected text with respect to the closest horizontal or vertical direction. After rotating the input image clockwise by this angle, the recognized text lines become horizontal or vertical. In combination with the orientation property it can be used to overlay recognition results correctly on the original image, by rotating either the original image or recognition results by a suitable angle around the center of the original image. If the angle cannot be confidently detected, this property is not present. If the image contains text at different angles, only part of the text will be recognized correctly.
TextAngle *float64 `json:"textAngle,omitempty"`
// Orientation - Orientation of the text recognized in the image, if requested. The value (up, down, left, or right) refers to the direction that the top of the recognized text is facing, after the image has been rotated around its center according to the detected text angle (see textAngle property).
// If detection of the orientation was not requested, or no text is detected, the value is 'NotDetected'.
Orientation *string `json:"orientation,omitempty"`
// Regions - An array of objects, where each object represents a region of recognized text.
Regions *[]OcrRegion `json:"regions,omitempty"`
}
// OcrWord information on a recognized word.
type OcrWord struct {
// BoundingBox - Bounding box of a recognized word. The four integers represent the x-coordinate of the left edge, the y-coordinate of the top edge, width, and height of the bounding box, in the coordinate system of the input image, after it has been rotated around its center according to the detected text angle (see textAngle property), with the origin at the top-left corner, and the y-axis pointing down.
BoundingBox *string `json:"boundingBox,omitempty"`
// Text - String value of a recognized word.
Text *string `json:"text,omitempty"`
}
// ReadCloser ...
type ReadCloser struct {
autorest.Response `json:"-"`
Value *io.ReadCloser `json:"value,omitempty"`
}
// ReadOperationResult OCR result of the read operation.
type ReadOperationResult struct {
autorest.Response `json:"-"`
// Status - Status of the read operation. Possible values include: 'NotStarted', 'Running', 'Failed', 'Succeeded'
Status OperationStatusCodes `json:"status,omitempty"`
// CreatedDateTime - Get UTC date time the batch operation was submitted.
CreatedDateTime *string `json:"createdDateTime,omitempty"`
// LastUpdatedDateTime - Get last updated UTC date time of this batch operation.
LastUpdatedDateTime *string `json:"lastUpdatedDateTime,omitempty"`
// AnalyzeResult - Analyze batch operation result.
AnalyzeResult *AnalyzeResults `json:"analyzeResult,omitempty"`
}
// ReadResult text extracted from a page in the input document.
type ReadResult struct {
// Page - The 1-based page number of the recognition result.
Page *int32 `json:"page,omitempty"`
// Language - The BCP-47 language code of the recognized text page.
Language *string `json:"language,omitempty"`
// Angle - The orientation of the image in degrees in the clockwise direction. Range between [-180, 180).
Angle *float64 `json:"angle,omitempty"`
// Width - The width of the image in pixels or the PDF in inches.
Width *float64 `json:"width,omitempty"`
// Height - The height of the image in pixels or the PDF in inches.
Height *float64 `json:"height,omitempty"`
// Unit - The unit used in the Width, Height and BoundingBox. For images, the unit is 'pixel'. For PDF, the unit is 'inch'. Possible values include: 'Pixel', 'Inch'
Unit TextRecognitionResultDimensionUnit `json:"unit,omitempty"`
// Lines - A list of recognized text lines.
Lines *[]Line `json:"lines,omitempty"`
}
// TagResult the results of a image tag operation, including any tags and image metadata.
type TagResult struct {
autorest.Response `json:"-"`
// Tags - A list of tags with confidence level.
Tags *[]ImageTag `json:"tags,omitempty"`
// RequestID - Id of the REST API request.
RequestID *string `json:"requestId,omitempty"`
Metadata *ImageMetadata `json:"metadata,omitempty"`
}
// Word an object representing a recognized word.
type Word struct {
// BoundingBox - Bounding box of a recognized word.
BoundingBox *[]float64 `json:"boundingBox,omitempty"`
// Text - The text content of the word.
Text *string `json:"text,omitempty"`
// Confidence - Qualitative confidence measure.
Confidence *float64 `json:"confidence,omitempty"`
}