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