1 // Copyright 2018 Google LLC.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
18 package google.cloud.vision.v1;
20 import "google/api/annotations.proto";
21 import "google/cloud/vision/v1/geometry.proto";
22 import "google/cloud/vision/v1/product_search.proto";
23 import "google/cloud/vision/v1/text_annotation.proto";
24 import "google/cloud/vision/v1/web_detection.proto";
25 import "google/longrunning/operations.proto";
26 import "google/protobuf/field_mask.proto";
27 import "google/protobuf/timestamp.proto";
28 import "google/rpc/status.proto";
29 import "google/type/color.proto";
30 import "google/type/latlng.proto";
32 option cc_enable_arenas = true;
33 option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1;vision";
34 option java_multiple_files = true;
35 option java_outer_classname = "ImageAnnotatorProto";
36 option java_package = "com.google.cloud.vision.v1";
37 option objc_class_prefix = "GCVN";
39 // Service that performs Google Cloud Vision API detection tasks over client
40 // images, such as face, landmark, logo, label, and text detection. The
41 // ImageAnnotator service returns detected entities from the images.
42 service ImageAnnotator {
43 // Run image detection and annotation for a batch of images.
44 rpc BatchAnnotateImages(BatchAnnotateImagesRequest)
45 returns (BatchAnnotateImagesResponse) {
46 option (google.api.http) = {
47 post: "/v1/images:annotate"
52 // Run asynchronous image detection and annotation for a list of generic
53 // files, such as PDF files, which may contain multiple pages and multiple
54 // images per page. Progress and results can be retrieved through the
55 // `google.longrunning.Operations` interface.
56 // `Operation.metadata` contains `OperationMetadata` (metadata).
57 // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
58 rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest)
59 returns (google.longrunning.Operation) {
60 option (google.api.http) = {
61 post: "/v1/files:asyncBatchAnnotate"
67 // The type of Google Cloud Vision API detection to perform, and the maximum
68 // number of results to return for that type. Multiple `Feature` objects can
69 // be specified in the `features` list.
71 // Type of Google Cloud Vision API feature to be extracted.
73 // Unspecified feature type.
76 // Run face detection.
79 // Run landmark detection.
80 LANDMARK_DETECTION = 2;
82 // Run logo detection.
85 // Run label detection.
88 // Run text detection / optical character recognition (OCR). Text detection
89 // is optimized for areas of text within a larger image; if the image is
90 // a document, use `DOCUMENT_TEXT_DETECTION` instead.
93 // Run dense text document OCR. Takes precedence when both
94 // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present.
95 DOCUMENT_TEXT_DETECTION = 11;
97 // Run Safe Search to detect potentially unsafe
98 // or undesirable content.
99 SAFE_SEARCH_DETECTION = 6;
101 // Compute a set of image properties, such as the
102 // image's dominant colors.
103 IMAGE_PROPERTIES = 7;
108 // Run web detection.
111 // Run Product Search.
114 // Run localizer for object detection.
115 OBJECT_LOCALIZATION = 19;
121 // Maximum number of results of this type. Does not apply to
122 // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`.
123 int32 max_results = 2;
125 // Model to use for the feature.
126 // Supported values: "builtin/stable" (the default if unset) and
131 // External image source (Google Cloud Storage or web URL image location).
132 message ImageSource {
133 // **Use `image_uri` instead.**
135 // The Google Cloud Storage URI of the form
136 // `gs://bucket_name/object_name`. Object versioning is not supported. See
137 // [Google Cloud Storage Request
138 // URIs](https://cloud.google.com/storage/docs/reference-uris) for more info.
139 string gcs_image_uri = 1;
141 // The URI of the source image. Can be either:
143 // 1. A Google Cloud Storage URI of the form
144 // `gs://bucket_name/object_name`. Object versioning is not supported. See
145 // [Google Cloud Storage Request
146 // URIs](https://cloud.google.com/storage/docs/reference-uris) for more
149 // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from
150 // HTTP/HTTPS URLs, Google cannot guarantee that the request will be
151 // completed. Your request may fail if the specified host denies the
152 // request (e.g. due to request throttling or DOS prevention), or if Google
153 // throttles requests to the site for abuse prevention. You should not
154 // depend on externally-hosted images for production applications.
156 // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes
158 string image_uri = 2;
161 // Client image to perform Google Cloud Vision API tasks over.
163 // Image content, represented as a stream of bytes.
164 // Note: As with all `bytes` fields, protobuffers use a pure binary
165 // representation, whereas JSON representations use base64.
168 // Google Cloud Storage image location, or publicly-accessible image
169 // URL. If both `content` and `source` are provided for an image, `content`
170 // takes precedence and is used to perform the image annotation request.
171 ImageSource source = 2;
174 // A face annotation object contains the results of face detection.
175 message FaceAnnotation {
176 // A face-specific landmark (for example, a face feature).
178 // Face landmark (feature) type.
179 // Left and right are defined from the vantage of the viewer of the image
180 // without considering mirror projections typical of photos. So, `LEFT_EYE`,
181 // typically, is the person's right eye.
183 // Unknown face landmark detected. Should not be filled.
184 UNKNOWN_LANDMARK = 0;
192 // Left of left eyebrow.
193 LEFT_OF_LEFT_EYEBROW = 3;
195 // Right of left eyebrow.
196 RIGHT_OF_LEFT_EYEBROW = 4;
198 // Left of right eyebrow.
199 LEFT_OF_RIGHT_EYEBROW = 5;
201 // Right of right eyebrow.
202 RIGHT_OF_RIGHT_EYEBROW = 6;
204 // Midpoint between eyes.
205 MIDPOINT_BETWEEN_EYES = 7;
225 // Nose, bottom right.
226 NOSE_BOTTOM_RIGHT = 14;
228 // Nose, bottom left.
229 NOSE_BOTTOM_LEFT = 15;
231 // Nose, bottom center.
232 NOSE_BOTTOM_CENTER = 16;
234 // Left eye, top boundary.
235 LEFT_EYE_TOP_BOUNDARY = 17;
237 // Left eye, right corner.
238 LEFT_EYE_RIGHT_CORNER = 18;
240 // Left eye, bottom boundary.
241 LEFT_EYE_BOTTOM_BOUNDARY = 19;
243 // Left eye, left corner.
244 LEFT_EYE_LEFT_CORNER = 20;
246 // Right eye, top boundary.
247 RIGHT_EYE_TOP_BOUNDARY = 21;
249 // Right eye, right corner.
250 RIGHT_EYE_RIGHT_CORNER = 22;
252 // Right eye, bottom boundary.
253 RIGHT_EYE_BOTTOM_BOUNDARY = 23;
255 // Right eye, left corner.
256 RIGHT_EYE_LEFT_CORNER = 24;
258 // Left eyebrow, upper midpoint.
259 LEFT_EYEBROW_UPPER_MIDPOINT = 25;
261 // Right eyebrow, upper midpoint.
262 RIGHT_EYEBROW_UPPER_MIDPOINT = 26;
265 LEFT_EAR_TRAGION = 27;
267 // Right ear tragion.
268 RIGHT_EAR_TRAGION = 28;
274 RIGHT_EYE_PUPIL = 30;
276 // Forehead glabella.
277 FOREHEAD_GLABELLA = 31;
283 CHIN_LEFT_GONION = 33;
285 // Chin right gonion.
286 CHIN_RIGHT_GONION = 34;
289 // Face landmark type.
292 // Face landmark position.
293 Position position = 4;
296 // The bounding polygon around the face. The coordinates of the bounding box
297 // are in the original image's scale, as returned in `ImageParams`.
298 // The bounding box is computed to "frame" the face in accordance with human
299 // expectations. It is based on the landmarker results.
300 // Note that one or more x and/or y coordinates may not be generated in the
301 // `BoundingPoly` (the polygon will be unbounded) if only a partial face
302 // appears in the image to be annotated.
303 BoundingPoly bounding_poly = 1;
305 // The `fd_bounding_poly` bounding polygon is tighter than the
306 // `boundingPoly`, and encloses only the skin part of the face. Typically, it
307 // is used to eliminate the face from any image analysis that detects the
308 // "amount of skin" visible in an image. It is not based on the
309 // landmarker results, only on the initial face detection, hence
310 // the <code>fd</code> (face detection) prefix.
311 BoundingPoly fd_bounding_poly = 2;
313 // Detected face landmarks.
314 repeated Landmark landmarks = 3;
316 // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation
317 // of the face relative to the image vertical about the axis perpendicular to
318 // the face. Range [-180,180].
319 float roll_angle = 4;
321 // Yaw angle, which indicates the leftward/rightward angle that the face is
322 // pointing relative to the vertical plane perpendicular to the image. Range
326 // Pitch angle, which indicates the upwards/downwards angle that the face is
327 // pointing relative to the image's horizontal plane. Range [-180,180].
328 float tilt_angle = 6;
330 // Detection confidence. Range [0, 1].
331 float detection_confidence = 7;
333 // Face landmarking confidence. Range [0, 1].
334 float landmarking_confidence = 8;
337 Likelihood joy_likelihood = 9;
339 // Sorrow likelihood.
340 Likelihood sorrow_likelihood = 10;
343 Likelihood anger_likelihood = 11;
345 // Surprise likelihood.
346 Likelihood surprise_likelihood = 12;
348 // Under-exposed likelihood.
349 Likelihood under_exposed_likelihood = 13;
351 // Blurred likelihood.
352 Likelihood blurred_likelihood = 14;
354 // Headwear likelihood.
355 Likelihood headwear_likelihood = 15;
358 // Detected entity location information.
359 message LocationInfo {
360 // lat/long location coordinates.
361 google.type.LatLng lat_lng = 1;
364 // A `Property` consists of a user-supplied name/value pair.
366 // Name of the property.
369 // Value of the property.
372 // Value of numeric properties.
373 uint64 uint64_value = 3;
376 // Set of detected entity features.
377 message EntityAnnotation {
378 // Opaque entity ID. Some IDs may be available in
379 // [Google Knowledge Graph Search
380 // API](https://developers.google.com/knowledge-graph/).
383 // The language code for the locale in which the entity textual
384 // `description` is expressed.
387 // Entity textual description, expressed in its `locale` language.
388 string description = 3;
390 // Overall score of the result. Range [0, 1].
393 // **Deprecated. Use `score` instead.**
394 // The accuracy of the entity detection in an image.
395 // For example, for an image in which the "Eiffel Tower" entity is detected,
396 // this field represents the confidence that there is a tower in the query
397 // image. Range [0, 1].
398 float confidence = 5 [deprecated = true];
400 // The relevancy of the ICA (Image Content Annotation) label to the
401 // image. For example, the relevancy of "tower" is likely higher to an image
402 // containing the detected "Eiffel Tower" than to an image containing a
403 // detected distant towering building, even though the confidence that
404 // there is a tower in each image may be the same. Range [0, 1].
405 float topicality = 6;
407 // Image region to which this entity belongs. Not produced
408 // for `LABEL_DETECTION` features.
409 BoundingPoly bounding_poly = 7;
411 // The location information for the detected entity. Multiple
412 // `LocationInfo` elements can be present because one location may
413 // indicate the location of the scene in the image, and another location
414 // may indicate the location of the place where the image was taken.
415 // Location information is usually present for landmarks.
416 repeated LocationInfo locations = 8;
418 // Some entities may have optional user-supplied `Property` (name/value)
419 // fields, such a score or string that qualifies the entity.
420 repeated Property properties = 9;
423 // Set of detected objects with bounding boxes.
424 message LocalizedObjectAnnotation {
425 // Object ID that should align with EntityAnnotation mid.
428 // The BCP-47 language code, such as "en-US" or "sr-Latn". For more
430 // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
431 string language_code = 2;
433 // Object name, expressed in its `language_code` language.
436 // Score of the result. Range [0, 1].
439 // Image region to which this object belongs. This must be populated.
440 BoundingPoly bounding_poly = 5;
443 // Set of features pertaining to the image, computed by computer vision
444 // methods over safe-search verticals (for example, adult, spoof, medical,
446 message SafeSearchAnnotation {
447 // Represents the adult content likelihood for the image. Adult content may
448 // contain elements such as nudity, pornographic images or cartoons, or
449 // sexual activities.
450 Likelihood adult = 1;
452 // Spoof likelihood. The likelihood that an modification
453 // was made to the image's canonical version to make it appear
454 // funny or offensive.
455 Likelihood spoof = 2;
457 // Likelihood that this is a medical image.
458 Likelihood medical = 3;
460 // Likelihood that this image contains violent content.
461 Likelihood violence = 4;
463 // Likelihood that the request image contains racy content. Racy content may
464 // include (but is not limited to) skimpy or sheer clothing, strategically
465 // covered nudity, lewd or provocative poses, or close-ups of sensitive
470 // Rectangle determined by min and max `LatLng` pairs.
471 message LatLongRect {
472 // Min lat/long pair.
473 google.type.LatLng min_lat_lng = 1;
475 // Max lat/long pair.
476 google.type.LatLng max_lat_lng = 2;
479 // Color information consists of RGB channels, score, and the fraction of
480 // the image that the color occupies in the image.
482 // RGB components of the color.
483 google.type.Color color = 1;
485 // Image-specific score for this color. Value in range [0, 1].
488 // The fraction of pixels the color occupies in the image.
489 // Value in range [0, 1].
490 float pixel_fraction = 3;
493 // Set of dominant colors and their corresponding scores.
494 message DominantColorsAnnotation {
495 // RGB color values with their score and pixel fraction.
496 repeated ColorInfo colors = 1;
499 // Stores image properties, such as dominant colors.
500 message ImageProperties {
501 // If present, dominant colors completed successfully.
502 DominantColorsAnnotation dominant_colors = 1;
505 // Single crop hint that is used to generate a new crop when serving an image.
507 // The bounding polygon for the crop region. The coordinates of the bounding
508 // box are in the original image's scale, as returned in `ImageParams`.
509 BoundingPoly bounding_poly = 1;
511 // Confidence of this being a salient region. Range [0, 1].
512 float confidence = 2;
514 // Fraction of importance of this salient region with respect to the original
516 float importance_fraction = 3;
519 // Set of crop hints that are used to generate new crops when serving images.
520 message CropHintsAnnotation {
521 // Crop hint results.
522 repeated CropHint crop_hints = 1;
525 // Parameters for crop hints annotation request.
526 message CropHintsParams {
527 // Aspect ratios in floats, representing the ratio of the width to the height
528 // of the image. For example, if the desired aspect ratio is 4/3, the
529 // corresponding float value should be 1.33333. If not specified, the
530 // best possible crop is returned. The number of provided aspect ratios is
531 // limited to a maximum of 16; any aspect ratios provided after the 16th are
533 repeated float aspect_ratios = 1;
536 // Parameters for web detection request.
537 message WebDetectionParams {
538 // Whether to include results derived from the geo information in the image.
539 bool include_geo_results = 2;
542 // Image context and/or feature-specific parameters.
543 message ImageContext {
545 LatLongRect lat_long_rect = 1;
547 // List of languages to use for TEXT_DETECTION. In most cases, an empty value
548 // yields the best results since it enables automatic language detection. For
549 // languages based on the Latin alphabet, setting `language_hints` is not
550 // needed. In rare cases, when the language of the text in the image is known,
551 // setting a hint will help get better results (although it will be a
552 // significant hindrance if the hint is wrong). Text detection returns an
553 // error if one or more of the specified languages is not one of the
554 // [supported languages](/vision/docs/languages).
555 repeated string language_hints = 2;
557 // Parameters for crop hints annotation request.
558 CropHintsParams crop_hints_params = 4;
560 // Parameters for product search.
561 ProductSearchParams product_search_params = 5;
563 // Parameters for web detection.
564 WebDetectionParams web_detection_params = 6;
567 // Request for performing Google Cloud Vision API tasks over a user-provided
568 // image, with user-requested features.
569 message AnnotateImageRequest {
570 // The image to be processed.
573 // Requested features.
574 repeated Feature features = 2;
576 // Additional context that may accompany the image.
577 ImageContext image_context = 3;
580 // If an image was produced from a file (e.g. a PDF), this message gives
581 // information about the source of that image.
582 message ImageAnnotationContext {
583 // The URI of the file used to produce the image.
586 // If the file was a PDF or TIFF, this field gives the page number within
587 // the file used to produce the image.
588 int32 page_number = 2;
591 // Response to an image annotation request.
592 message AnnotateImageResponse {
593 // If present, face detection has completed successfully.
594 repeated FaceAnnotation face_annotations = 1;
596 // If present, landmark detection has completed successfully.
597 repeated EntityAnnotation landmark_annotations = 2;
599 // If present, logo detection has completed successfully.
600 repeated EntityAnnotation logo_annotations = 3;
602 // If present, label detection has completed successfully.
603 repeated EntityAnnotation label_annotations = 4;
605 // If present, localized object detection has completed successfully.
606 // This will be sorted descending by confidence score.
607 repeated LocalizedObjectAnnotation localized_object_annotations = 22;
609 // If present, text (OCR) detection has completed successfully.
610 repeated EntityAnnotation text_annotations = 5;
612 // If present, text (OCR) detection or document (OCR) text detection has
613 // completed successfully.
614 // This annotation provides the structural hierarchy for the OCR detected
616 TextAnnotation full_text_annotation = 12;
618 // If present, safe-search annotation has completed successfully.
619 SafeSearchAnnotation safe_search_annotation = 6;
621 // If present, image properties were extracted successfully.
622 ImageProperties image_properties_annotation = 8;
624 // If present, crop hints have completed successfully.
625 CropHintsAnnotation crop_hints_annotation = 11;
627 // If present, web detection has completed successfully.
628 WebDetection web_detection = 13;
630 // If present, product search has completed successfully.
631 ProductSearchResults product_search_results = 14;
633 // If set, represents the error message for the operation.
634 // Note that filled-in image annotations are guaranteed to be
635 // correct, even when `error` is set.
636 google.rpc.Status error = 9;
638 // If present, contextual information is needed to understand where this image
640 ImageAnnotationContext context = 21;
643 // Response to a single file annotation request. A file may contain one or more
644 // images, which individually have their own responses.
645 message AnnotateFileResponse {
646 // Information about the file for which this response is generated.
647 InputConfig input_config = 1;
649 // Individual responses to images found within the file.
650 repeated AnnotateImageResponse responses = 2;
653 // Multiple image annotation requests are batched into a single service call.
654 message BatchAnnotateImagesRequest {
655 // Individual image annotation requests for this batch.
656 repeated AnnotateImageRequest requests = 1;
659 // Response to a batch image annotation request.
660 message BatchAnnotateImagesResponse {
661 // Individual responses to image annotation requests within the batch.
662 repeated AnnotateImageResponse responses = 1;
665 // An offline file annotation request.
666 message AsyncAnnotateFileRequest {
667 // Required. Information about the input file.
668 InputConfig input_config = 1;
670 // Required. Requested features.
671 repeated Feature features = 2;
673 // Additional context that may accompany the image(s) in the file.
674 ImageContext image_context = 3;
676 // Required. The desired output location and metadata (e.g. format).
677 OutputConfig output_config = 4;
680 // The response for a single offline file annotation request.
681 message AsyncAnnotateFileResponse {
682 // The output location and metadata from AsyncAnnotateFileRequest.
683 OutputConfig output_config = 1;
686 // Multiple async file annotation requests are batched into a single service
688 message AsyncBatchAnnotateFilesRequest {
689 // Individual async file annotation requests for this batch.
690 repeated AsyncAnnotateFileRequest requests = 1;
693 // Response to an async batch file annotation request.
694 message AsyncBatchAnnotateFilesResponse {
695 // The list of file annotation responses, one for each request in
696 // AsyncBatchAnnotateFilesRequest.
697 repeated AsyncAnnotateFileResponse responses = 1;
700 // The desired input location and metadata.
701 message InputConfig {
702 // The Google Cloud Storage location to read the input from.
703 GcsSource gcs_source = 1;
705 // The type of the file. Currently only "application/pdf" and "image/tiff"
706 // are supported. Wildcards are not supported.
707 string mime_type = 2;
710 // The desired output location and metadata.
711 message OutputConfig {
712 // The Google Cloud Storage location to write the output(s) to.
713 GcsDestination gcs_destination = 1;
715 // The max number of response protos to put into each output JSON file on
716 // Google Cloud Storage.
717 // The valid range is [1, 100]. If not specified, the default value is 20.
719 // For example, for one pdf file with 100 pages, 100 response protos will
720 // be generated. If `batch_size` = 20, then 5 json files each
721 // containing 20 response protos will be written under the prefix
722 // `gcs_destination`.`uri`.
724 // Currently, batch_size only applies to GcsDestination, with potential future
725 // support for other output configurations.
726 int32 batch_size = 2;
729 // The Google Cloud Storage location where the input will be read from.
731 // Google Cloud Storage URI for the input file. This must only be a
732 // Google Cloud Storage object. Wildcards are not currently supported.
736 // The Google Cloud Storage location where the output will be written to.
737 message GcsDestination {
738 // Google Cloud Storage URI where the results will be stored. Results will
739 // be in JSON format and preceded by its corresponding input URI. This field
740 // can either represent a single file, or a prefix for multiple outputs.
741 // Prefixes must end in a `/`.
745 // * File: gs://bucket-name/filename.json
746 // * Prefix: gs://bucket-name/prefix/here/
747 // * File: gs://bucket-name/prefix/here
749 // If multiple outputs, each response is still AnnotateFileResponse, each of
750 // which contains some subset of the full list of AnnotateImageResponse.
751 // Multiple outputs can happen if, for example, the output JSON is too large
752 // and overflows into multiple sharded files.
756 // Contains metadata for the BatchAnnotateImages operation.
757 message OperationMetadata {
758 // Batch operation states.
761 STATE_UNSPECIFIED = 0;
763 // Request is received.
766 // Request is actively being processed.
769 // The batch processing is done.
772 // The batch processing was cancelled.
776 // Current state of the batch operation.
779 // The time when the batch request was received.
780 google.protobuf.Timestamp create_time = 5;
782 // The time when the operation result was last updated.
783 google.protobuf.Timestamp update_time = 6;
786 // A bucketized representation of likelihood, which is intended to give clients
787 // highly stable results across model upgrades.
789 // Unknown likelihood.
792 // It is very unlikely that the image belongs to the specified vertical.
795 // It is unlikely that the image belongs to the specified vertical.
798 // It is possible that the image belongs to the specified vertical.
801 // It is likely that the image belongs to the specified vertical.
804 // It is very likely that the image belongs to the specified vertical.