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