image_annotator.proto 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967
  1. // Copyright 2019 Google LLC.
  2. //
  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
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  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.
  14. //
  15. syntax = "proto3";
  16. package google.cloud.vision.v1p4beta1;
  17. import "google/api/annotations.proto";
  18. import "google/api/client.proto";
  19. import "google/api/field_behavior.proto";
  20. import "google/cloud/vision/v1p4beta1/face.proto";
  21. import "google/cloud/vision/v1p4beta1/geometry.proto";
  22. import "google/cloud/vision/v1p4beta1/product_search.proto";
  23. import "google/cloud/vision/v1p4beta1/text_annotation.proto";
  24. import "google/cloud/vision/v1p4beta1/web_detection.proto";
  25. import "google/longrunning/operations.proto";
  26. import "google/protobuf/timestamp.proto";
  27. import "google/rpc/status.proto";
  28. import "google/type/color.proto";
  29. import "google/type/latlng.proto";
  30. option cc_enable_arenas = true;
  31. option go_package = "google.golang.org/genproto/googleapis/cloud/vision/v1p4beta1;vision";
  32. option java_multiple_files = true;
  33. option java_outer_classname = "ImageAnnotatorProto";
  34. option java_package = "com.google.cloud.vision.v1p4beta1";
  35. option objc_class_prefix = "GCVN";
  36. // Service that performs Google Cloud Vision API detection tasks over client
  37. // images, such as face, landmark, logo, label, and text detection. The
  38. // ImageAnnotator service returns detected entities from the images.
  39. service ImageAnnotator {
  40. option (google.api.default_host) = "vision.googleapis.com";
  41. option (google.api.oauth_scopes) =
  42. "https://www.googleapis.com/auth/cloud-platform,"
  43. "https://www.googleapis.com/auth/cloud-vision";
  44. // Run image detection and annotation for a batch of images.
  45. rpc BatchAnnotateImages(BatchAnnotateImagesRequest)
  46. returns (BatchAnnotateImagesResponse) {
  47. option (google.api.http) = {
  48. post: "/v1p4beta1/images:annotate"
  49. body: "*"
  50. };
  51. option (google.api.method_signature) = "requests";
  52. }
  53. // Service that performs image detection and annotation for a batch of files.
  54. // Now only "application/pdf", "image/tiff" and "image/gif" are supported.
  55. //
  56. // This service will extract at most 5 (customers can specify which 5 in
  57. // AnnotateFileRequest.pages) frames (gif) or pages (pdf or tiff) from each
  58. // file provided and perform detection and annotation for each image
  59. // extracted.
  60. rpc BatchAnnotateFiles(BatchAnnotateFilesRequest)
  61. returns (BatchAnnotateFilesResponse) {
  62. option (google.api.http) = {
  63. post: "/v1p4beta1/files:annotate"
  64. body: "*"
  65. };
  66. option (google.api.method_signature) = "requests";
  67. }
  68. // Run asynchronous image detection and annotation for a list of images.
  69. //
  70. // Progress and results can be retrieved through the
  71. // `google.longrunning.Operations` interface.
  72. // `Operation.metadata` contains `OperationMetadata` (metadata).
  73. // `Operation.response` contains `AsyncBatchAnnotateImagesResponse` (results).
  74. //
  75. // This service will write image annotation outputs to json files in customer
  76. // GCS bucket, each json file containing BatchAnnotateImagesResponse proto.
  77. rpc AsyncBatchAnnotateImages(AsyncBatchAnnotateImagesRequest)
  78. returns (google.longrunning.Operation) {
  79. option (google.api.http) = {
  80. post: "/v1p4beta1/images:asyncBatchAnnotate"
  81. body: "*"
  82. };
  83. option (google.api.method_signature) = "requests,output_config";
  84. option (google.longrunning.operation_info) = {
  85. response_type: "AsyncBatchAnnotateImagesResponse"
  86. metadata_type: "OperationMetadata"
  87. };
  88. }
  89. // Run asynchronous image detection and annotation for a list of generic
  90. // files, such as PDF files, which may contain multiple pages and multiple
  91. // images per page. Progress and results can be retrieved through the
  92. // `google.longrunning.Operations` interface.
  93. // `Operation.metadata` contains `OperationMetadata` (metadata).
  94. // `Operation.response` contains `AsyncBatchAnnotateFilesResponse` (results).
  95. rpc AsyncBatchAnnotateFiles(AsyncBatchAnnotateFilesRequest)
  96. returns (google.longrunning.Operation) {
  97. option (google.api.http) = {
  98. post: "/v1p4beta1/files:asyncBatchAnnotate"
  99. body: "*"
  100. };
  101. option (google.api.method_signature) = "requests";
  102. option (google.longrunning.operation_info) = {
  103. response_type: "AsyncBatchAnnotateFilesResponse"
  104. metadata_type: "OperationMetadata"
  105. };
  106. }
  107. }
  108. // The type of Google Cloud Vision API detection to perform, and the maximum
  109. // number of results to return for that type. Multiple `Feature` objects can
  110. // be specified in the `features` list.
  111. message Feature {
  112. // Type of Google Cloud Vision API feature to be extracted.
  113. enum Type {
  114. // Unspecified feature type.
  115. TYPE_UNSPECIFIED = 0;
  116. // Run face detection.
  117. FACE_DETECTION = 1;
  118. // Run landmark detection.
  119. LANDMARK_DETECTION = 2;
  120. // Run logo detection.
  121. LOGO_DETECTION = 3;
  122. // Run label detection.
  123. LABEL_DETECTION = 4;
  124. // Run text detection / optical character recognition (OCR). Text detection
  125. // is optimized for areas of text within a larger image; if the image is
  126. // a document, use `DOCUMENT_TEXT_DETECTION` instead.
  127. TEXT_DETECTION = 5;
  128. // Run dense text document OCR. Takes precedence when both
  129. // `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` are present.
  130. DOCUMENT_TEXT_DETECTION = 11;
  131. // Run Safe Search to detect potentially unsafe
  132. // or undesirable content.
  133. SAFE_SEARCH_DETECTION = 6;
  134. // Compute a set of image properties, such as the
  135. // image's dominant colors.
  136. IMAGE_PROPERTIES = 7;
  137. // Run crop hints.
  138. CROP_HINTS = 9;
  139. // Run web detection.
  140. WEB_DETECTION = 10;
  141. // Run Product Search.
  142. PRODUCT_SEARCH = 12;
  143. // Run localizer for object detection.
  144. OBJECT_LOCALIZATION = 19;
  145. }
  146. // The feature type.
  147. Type type = 1;
  148. // Maximum number of results of this type. Does not apply to
  149. // `TEXT_DETECTION`, `DOCUMENT_TEXT_DETECTION`, or `CROP_HINTS`.
  150. int32 max_results = 2;
  151. // Model to use for the feature.
  152. // Supported values: "builtin/stable" (the default if unset) and
  153. // "builtin/latest". `DOCUMENT_TEXT_DETECTION` and `TEXT_DETECTION` also
  154. // support "builtin/weekly" for the bleeding edge release updated weekly.
  155. string model = 3;
  156. }
  157. // External image source (Google Cloud Storage or web URL image location).
  158. message ImageSource {
  159. // **Use `image_uri` instead.**
  160. //
  161. // The Google Cloud Storage URI of the form
  162. // `gs://bucket_name/object_name`. Object versioning is not supported. See
  163. // [Google Cloud Storage Request
  164. // URIs](https://cloud.google.com/storage/docs/reference-uris) for more info.
  165. string gcs_image_uri = 1;
  166. // The URI of the source image. Can be either:
  167. //
  168. // 1. A Google Cloud Storage URI of the form
  169. // `gs://bucket_name/object_name`. Object versioning is not supported. See
  170. // [Google Cloud Storage Request
  171. // URIs](https://cloud.google.com/storage/docs/reference-uris) for more
  172. // info.
  173. //
  174. // 2. A publicly-accessible image HTTP/HTTPS URL. When fetching images from
  175. // HTTP/HTTPS URLs, Google cannot guarantee that the request will be
  176. // completed. Your request may fail if the specified host denies the
  177. // request (e.g. due to request throttling or DOS prevention), or if Google
  178. // throttles requests to the site for abuse prevention. You should not
  179. // depend on externally-hosted images for production applications.
  180. //
  181. // When both `gcs_image_uri` and `image_uri` are specified, `image_uri` takes
  182. // precedence.
  183. string image_uri = 2;
  184. }
  185. // Client image to perform Google Cloud Vision API tasks over.
  186. message Image {
  187. // Image content, represented as a stream of bytes.
  188. // Note: As with all `bytes` fields, protobuffers use a pure binary
  189. // representation, whereas JSON representations use base64.
  190. bytes content = 1;
  191. // Google Cloud Storage image location, or publicly-accessible image
  192. // URL. If both `content` and `source` are provided for an image, `content`
  193. // takes precedence and is used to perform the image annotation request.
  194. ImageSource source = 2;
  195. }
  196. // A bucketized representation of likelihood, which is intended to give clients
  197. // highly stable results across model upgrades.
  198. enum Likelihood {
  199. // Unknown likelihood.
  200. UNKNOWN = 0;
  201. // It is very unlikely.
  202. VERY_UNLIKELY = 1;
  203. // It is unlikely.
  204. UNLIKELY = 2;
  205. // It is possible.
  206. POSSIBLE = 3;
  207. // It is likely.
  208. LIKELY = 4;
  209. // It is very likely.
  210. VERY_LIKELY = 5;
  211. }
  212. // A face annotation object contains the results of face detection.
  213. message FaceAnnotation {
  214. // A face-specific landmark (for example, a face feature).
  215. message Landmark {
  216. // Face landmark (feature) type.
  217. // Left and right are defined from the vantage of the viewer of the image
  218. // without considering mirror projections typical of photos. So, `LEFT_EYE`,
  219. // typically, is the person's right eye.
  220. enum Type {
  221. // Unknown face landmark detected. Should not be filled.
  222. UNKNOWN_LANDMARK = 0;
  223. // Left eye.
  224. LEFT_EYE = 1;
  225. // Right eye.
  226. RIGHT_EYE = 2;
  227. // Left of left eyebrow.
  228. LEFT_OF_LEFT_EYEBROW = 3;
  229. // Right of left eyebrow.
  230. RIGHT_OF_LEFT_EYEBROW = 4;
  231. // Left of right eyebrow.
  232. LEFT_OF_RIGHT_EYEBROW = 5;
  233. // Right of right eyebrow.
  234. RIGHT_OF_RIGHT_EYEBROW = 6;
  235. // Midpoint between eyes.
  236. MIDPOINT_BETWEEN_EYES = 7;
  237. // Nose tip.
  238. NOSE_TIP = 8;
  239. // Upper lip.
  240. UPPER_LIP = 9;
  241. // Lower lip.
  242. LOWER_LIP = 10;
  243. // Mouth left.
  244. MOUTH_LEFT = 11;
  245. // Mouth right.
  246. MOUTH_RIGHT = 12;
  247. // Mouth center.
  248. MOUTH_CENTER = 13;
  249. // Nose, bottom right.
  250. NOSE_BOTTOM_RIGHT = 14;
  251. // Nose, bottom left.
  252. NOSE_BOTTOM_LEFT = 15;
  253. // Nose, bottom center.
  254. NOSE_BOTTOM_CENTER = 16;
  255. // Left eye, top boundary.
  256. LEFT_EYE_TOP_BOUNDARY = 17;
  257. // Left eye, right corner.
  258. LEFT_EYE_RIGHT_CORNER = 18;
  259. // Left eye, bottom boundary.
  260. LEFT_EYE_BOTTOM_BOUNDARY = 19;
  261. // Left eye, left corner.
  262. LEFT_EYE_LEFT_CORNER = 20;
  263. // Right eye, top boundary.
  264. RIGHT_EYE_TOP_BOUNDARY = 21;
  265. // Right eye, right corner.
  266. RIGHT_EYE_RIGHT_CORNER = 22;
  267. // Right eye, bottom boundary.
  268. RIGHT_EYE_BOTTOM_BOUNDARY = 23;
  269. // Right eye, left corner.
  270. RIGHT_EYE_LEFT_CORNER = 24;
  271. // Left eyebrow, upper midpoint.
  272. LEFT_EYEBROW_UPPER_MIDPOINT = 25;
  273. // Right eyebrow, upper midpoint.
  274. RIGHT_EYEBROW_UPPER_MIDPOINT = 26;
  275. // Left ear tragion.
  276. LEFT_EAR_TRAGION = 27;
  277. // Right ear tragion.
  278. RIGHT_EAR_TRAGION = 28;
  279. // Left eye pupil.
  280. LEFT_EYE_PUPIL = 29;
  281. // Right eye pupil.
  282. RIGHT_EYE_PUPIL = 30;
  283. // Forehead glabella.
  284. FOREHEAD_GLABELLA = 31;
  285. // Chin gnathion.
  286. CHIN_GNATHION = 32;
  287. // Chin left gonion.
  288. CHIN_LEFT_GONION = 33;
  289. // Chin right gonion.
  290. CHIN_RIGHT_GONION = 34;
  291. }
  292. // Face landmark type.
  293. Type type = 3;
  294. // Face landmark position.
  295. Position position = 4;
  296. }
  297. // The bounding polygon around the face. The coordinates of the bounding box
  298. // are in the original image's scale.
  299. // The bounding box is computed to "frame" the face in accordance with human
  300. // expectations. It is based on the landmarker results.
  301. // Note that one or more x and/or y coordinates may not be generated in the
  302. // `BoundingPoly` (the polygon will be unbounded) if only a partial face
  303. // appears in the image to be annotated.
  304. 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;
  312. // Detected face landmarks.
  313. repeated Landmark landmarks = 3;
  314. // Roll angle, which indicates the amount of clockwise/anti-clockwise rotation
  315. // of the face relative to the image vertical about the axis perpendicular to
  316. // the face. Range [-180,180].
  317. float roll_angle = 4;
  318. // Yaw angle, which indicates the leftward/rightward angle that the face is
  319. // pointing relative to the vertical plane perpendicular to the image. Range
  320. // [-180,180].
  321. float pan_angle = 5;
  322. // Pitch angle, which indicates the upwards/downwards angle that the face is
  323. // pointing relative to the image's horizontal plane. Range [-180,180].
  324. float tilt_angle = 6;
  325. // Detection confidence. Range [0, 1].
  326. float detection_confidence = 7;
  327. // Face landmarking confidence. Range [0, 1].
  328. float landmarking_confidence = 8;
  329. // Joy likelihood.
  330. Likelihood joy_likelihood = 9;
  331. // Sorrow likelihood.
  332. Likelihood sorrow_likelihood = 10;
  333. // Anger likelihood.
  334. Likelihood anger_likelihood = 11;
  335. // Surprise likelihood.
  336. Likelihood surprise_likelihood = 12;
  337. // Under-exposed likelihood.
  338. Likelihood under_exposed_likelihood = 13;
  339. // Blurred likelihood.
  340. Likelihood blurred_likelihood = 14;
  341. // Headwear likelihood.
  342. Likelihood headwear_likelihood = 15;
  343. // Additional recognition information. Only computed if
  344. // image_context.face_recognition_params is provided, **and** a match is found
  345. // to a [Celebrity][google.cloud.vision.v1p4beta1.Celebrity] in the input
  346. // [CelebritySet][google.cloud.vision.v1p4beta1.CelebritySet]. This field is
  347. // sorted in order of decreasing confidence values.
  348. repeated FaceRecognitionResult recognition_result = 16;
  349. }
  350. // Detected entity location information.
  351. message LocationInfo {
  352. // lat/long location coordinates.
  353. google.type.LatLng lat_lng = 1;
  354. }
  355. // A `Property` consists of a user-supplied name/value pair.
  356. message Property {
  357. // Name of the property.
  358. string name = 1;
  359. // Value of the property.
  360. string value = 2;
  361. // Value of numeric properties.
  362. uint64 uint64_value = 3;
  363. }
  364. // Set of detected entity features.
  365. message EntityAnnotation {
  366. // Opaque entity ID. Some IDs may be available in
  367. // [Google Knowledge Graph Search
  368. // API](https://developers.google.com/knowledge-graph/).
  369. string mid = 1;
  370. // The language code for the locale in which the entity textual
  371. // `description` is expressed.
  372. string locale = 2;
  373. // Entity textual description, expressed in its `locale` language.
  374. string description = 3;
  375. // Overall score of the result. Range [0, 1].
  376. float score = 4;
  377. // **Deprecated. Use `score` instead.**
  378. // The accuracy of the entity detection in an image.
  379. // For example, for an image in which the "Eiffel Tower" entity is detected,
  380. // this field represents the confidence that there is a tower in the query
  381. // image. Range [0, 1].
  382. float confidence = 5 [deprecated = true];
  383. // The relevancy of the ICA (Image Content Annotation) label to the
  384. // image. For example, the relevancy of "tower" is likely higher to an image
  385. // containing the detected "Eiffel Tower" than to an image containing a
  386. // detected distant towering building, even though the confidence that
  387. // there is a tower in each image may be the same. Range [0, 1].
  388. float topicality = 6;
  389. // Image region to which this entity belongs. Not produced
  390. // for `LABEL_DETECTION` features.
  391. BoundingPoly bounding_poly = 7;
  392. // The location information for the detected entity. Multiple
  393. // `LocationInfo` elements can be present because one location may
  394. // indicate the location of the scene in the image, and another location
  395. // may indicate the location of the place where the image was taken.
  396. // Location information is usually present for landmarks.
  397. repeated LocationInfo locations = 8;
  398. // Some entities may have optional user-supplied `Property` (name/value)
  399. // fields, such a score or string that qualifies the entity.
  400. repeated Property properties = 9;
  401. }
  402. // Set of detected objects with bounding boxes.
  403. message LocalizedObjectAnnotation {
  404. // Object ID that should align with EntityAnnotation mid.
  405. string mid = 1;
  406. // The BCP-47 language code, such as "en-US" or "sr-Latn". For more
  407. // information, see
  408. // http://www.unicode.org/reports/tr35/#Unicode_locale_identifier.
  409. string language_code = 2;
  410. // Object name, expressed in its `language_code` language.
  411. string name = 3;
  412. // Score of the result. Range [0, 1].
  413. float score = 4;
  414. // Image region to which this object belongs. This must be populated.
  415. BoundingPoly bounding_poly = 5;
  416. }
  417. // Set of features pertaining to the image, computed by computer vision
  418. // methods over safe-search verticals (for example, adult, spoof, medical,
  419. // violence).
  420. message SafeSearchAnnotation {
  421. // Represents the adult content likelihood for the image. Adult content may
  422. // contain elements such as nudity, pornographic images or cartoons, or
  423. // sexual activities.
  424. Likelihood adult = 1;
  425. // Spoof likelihood. The likelihood that an modification
  426. // was made to the image's canonical version to make it appear
  427. // funny or offensive.
  428. Likelihood spoof = 2;
  429. // Likelihood that this is a medical image.
  430. Likelihood medical = 3;
  431. // Likelihood that this image contains violent content.
  432. Likelihood violence = 4;
  433. // Likelihood that the request image contains racy content. Racy content may
  434. // include (but is not limited to) skimpy or sheer clothing, strategically
  435. // covered nudity, lewd or provocative poses, or close-ups of sensitive
  436. // body areas.
  437. Likelihood racy = 9;
  438. }
  439. // Rectangle determined by min and max `LatLng` pairs.
  440. message LatLongRect {
  441. // Min lat/long pair.
  442. google.type.LatLng min_lat_lng = 1;
  443. // Max lat/long pair.
  444. google.type.LatLng max_lat_lng = 2;
  445. }
  446. // Color information consists of RGB channels, score, and the fraction of
  447. // the image that the color occupies in the image.
  448. message ColorInfo {
  449. // RGB components of the color.
  450. google.type.Color color = 1;
  451. // Image-specific score for this color. Value in range [0, 1].
  452. float score = 2;
  453. // The fraction of pixels the color occupies in the image.
  454. // Value in range [0, 1].
  455. float pixel_fraction = 3;
  456. }
  457. // Set of dominant colors and their corresponding scores.
  458. message DominantColorsAnnotation {
  459. // RGB color values with their score and pixel fraction.
  460. repeated ColorInfo colors = 1;
  461. }
  462. // Stores image properties, such as dominant colors.
  463. message ImageProperties {
  464. // If present, dominant colors completed successfully.
  465. DominantColorsAnnotation dominant_colors = 1;
  466. }
  467. // Single crop hint that is used to generate a new crop when serving an image.
  468. message CropHint {
  469. // The bounding polygon for the crop region. The coordinates of the bounding
  470. // box are in the original image's scale.
  471. BoundingPoly bounding_poly = 1;
  472. // Confidence of this being a salient region. Range [0, 1].
  473. float confidence = 2;
  474. // Fraction of importance of this salient region with respect to the original
  475. // image.
  476. float importance_fraction = 3;
  477. }
  478. // Set of crop hints that are used to generate new crops when serving images.
  479. message CropHintsAnnotation {
  480. // Crop hint results.
  481. repeated CropHint crop_hints = 1;
  482. }
  483. // Parameters for crop hints annotation request.
  484. message CropHintsParams {
  485. // Aspect ratios in floats, representing the ratio of the width to the height
  486. // of the image. For example, if the desired aspect ratio is 4/3, the
  487. // corresponding float value should be 1.33333. If not specified, the
  488. // best possible crop is returned. The number of provided aspect ratios is
  489. // limited to a maximum of 16; any aspect ratios provided after the 16th are
  490. // ignored.
  491. repeated float aspect_ratios = 1;
  492. }
  493. // Parameters for web detection request.
  494. message WebDetectionParams {
  495. // Whether to include results derived from the geo information in the image.
  496. bool include_geo_results = 2;
  497. }
  498. // Parameters for text detections. This is used to control TEXT_DETECTION and
  499. // DOCUMENT_TEXT_DETECTION features.
  500. message TextDetectionParams {
  501. // By default, Cloud Vision API only includes confidence score for
  502. // DOCUMENT_TEXT_DETECTION result. Set the flag to true to include confidence
  503. // score for TEXT_DETECTION as well.
  504. bool enable_text_detection_confidence_score = 9;
  505. // A list of advanced OCR options to fine-tune OCR behavior.
  506. repeated string advanced_ocr_options = 11;
  507. }
  508. // Image context and/or feature-specific parameters.
  509. message ImageContext {
  510. // Not used.
  511. LatLongRect lat_long_rect = 1;
  512. // List of languages to use for TEXT_DETECTION. In most cases, an empty value
  513. // yields the best results since it enables automatic language detection. For
  514. // languages based on the Latin alphabet, setting `language_hints` is not
  515. // needed. In rare cases, when the language of the text in the image is known,
  516. // setting a hint will help get better results (although it will be a
  517. // significant hindrance if the hint is wrong). Text detection returns an
  518. // error if one or more of the specified languages is not one of the
  519. // [supported languages](https://cloud.google.com/vision/docs/languages).
  520. repeated string language_hints = 2;
  521. // Parameters for crop hints annotation request.
  522. CropHintsParams crop_hints_params = 4;
  523. // Parameters for face recognition.
  524. FaceRecognitionParams face_recognition_params = 10;
  525. // Parameters for product search.
  526. ProductSearchParams product_search_params = 5;
  527. // Parameters for web detection.
  528. WebDetectionParams web_detection_params = 6;
  529. // Parameters for text detection and document text detection.
  530. TextDetectionParams text_detection_params = 12;
  531. }
  532. // Request for performing Google Cloud Vision API tasks over a user-provided
  533. // image, with user-requested features, and with context information.
  534. message AnnotateImageRequest {
  535. // The image to be processed.
  536. Image image = 1;
  537. // Requested features.
  538. repeated Feature features = 2;
  539. // Additional context that may accompany the image.
  540. ImageContext image_context = 3;
  541. }
  542. // If an image was produced from a file (e.g. a PDF), this message gives
  543. // information about the source of that image.
  544. message ImageAnnotationContext {
  545. // The URI of the file used to produce the image.
  546. string uri = 1;
  547. // If the file was a PDF or TIFF, this field gives the page number within
  548. // the file used to produce the image.
  549. int32 page_number = 2;
  550. }
  551. // Response to an image annotation request.
  552. message AnnotateImageResponse {
  553. // If present, face detection has completed successfully.
  554. repeated FaceAnnotation face_annotations = 1;
  555. // If present, landmark detection has completed successfully.
  556. repeated EntityAnnotation landmark_annotations = 2;
  557. // If present, logo detection has completed successfully.
  558. repeated EntityAnnotation logo_annotations = 3;
  559. // If present, label detection has completed successfully.
  560. repeated EntityAnnotation label_annotations = 4;
  561. // If present, localized object detection has completed successfully.
  562. // This will be sorted descending by confidence score.
  563. repeated LocalizedObjectAnnotation localized_object_annotations = 22;
  564. // If present, text (OCR) detection has completed successfully.
  565. repeated EntityAnnotation text_annotations = 5;
  566. // If present, text (OCR) detection or document (OCR) text detection has
  567. // completed successfully.
  568. // This annotation provides the structural hierarchy for the OCR detected
  569. // text.
  570. TextAnnotation full_text_annotation = 12;
  571. // If present, safe-search annotation has completed successfully.
  572. SafeSearchAnnotation safe_search_annotation = 6;
  573. // If present, image properties were extracted successfully.
  574. ImageProperties image_properties_annotation = 8;
  575. // If present, crop hints have completed successfully.
  576. CropHintsAnnotation crop_hints_annotation = 11;
  577. // If present, web detection has completed successfully.
  578. WebDetection web_detection = 13;
  579. // If present, product search has completed successfully.
  580. ProductSearchResults product_search_results = 14;
  581. // If set, represents the error message for the operation.
  582. // Note that filled-in image annotations are guaranteed to be
  583. // correct, even when `error` is set.
  584. google.rpc.Status error = 9;
  585. // If present, contextual information is needed to understand where this image
  586. // comes from.
  587. ImageAnnotationContext context = 21;
  588. }
  589. // Multiple image annotation requests are batched into a single service call.
  590. message BatchAnnotateImagesRequest {
  591. // Required. Individual image annotation requests for this batch.
  592. repeated AnnotateImageRequest requests = 1 [(google.api.field_behavior) = REQUIRED];
  593. }
  594. // Response to a batch image annotation request.
  595. message BatchAnnotateImagesResponse {
  596. // Individual responses to image annotation requests within the batch.
  597. repeated AnnotateImageResponse responses = 1;
  598. }
  599. // A request to annotate one single file, e.g. a PDF, TIFF or GIF file.
  600. message AnnotateFileRequest {
  601. // Required. Information about the input file.
  602. InputConfig input_config = 1;
  603. // Required. Requested features.
  604. repeated Feature features = 2;
  605. // Additional context that may accompany the image(s) in the file.
  606. ImageContext image_context = 3;
  607. // Pages of the file to perform image annotation.
  608. //
  609. // Pages starts from 1, we assume the first page of the file is page 1.
  610. // At most 5 pages are supported per request. Pages can be negative.
  611. //
  612. // Page 1 means the first page.
  613. // Page 2 means the second page.
  614. // Page -1 means the last page.
  615. // Page -2 means the second to the last page.
  616. //
  617. // If the file is GIF instead of PDF or TIFF, page refers to GIF frames.
  618. //
  619. // If this field is empty, by default the service performs image annotation
  620. // for the first 5 pages of the file.
  621. repeated int32 pages = 4;
  622. }
  623. // Response to a single file annotation request. A file may contain one or more
  624. // images, which individually have their own responses.
  625. message AnnotateFileResponse {
  626. // Information about the file for which this response is generated.
  627. InputConfig input_config = 1;
  628. // Individual responses to images found within the file. This field will be
  629. // empty if the `error` field is set.
  630. repeated AnnotateImageResponse responses = 2;
  631. // This field gives the total number of pages in the file.
  632. int32 total_pages = 3;
  633. // If set, represents the error message for the failed request. The
  634. // `responses` field will not be set in this case.
  635. google.rpc.Status error = 4;
  636. }
  637. // A list of requests to annotate files using the BatchAnnotateFiles API.
  638. message BatchAnnotateFilesRequest {
  639. // Required. The list of file annotation requests. Right now we support only
  640. // one AnnotateFileRequest in BatchAnnotateFilesRequest.
  641. repeated AnnotateFileRequest requests = 1
  642. [(google.api.field_behavior) = REQUIRED];
  643. }
  644. // A list of file annotation responses.
  645. message BatchAnnotateFilesResponse {
  646. // The list of file annotation responses, each response corresponding to each
  647. // AnnotateFileRequest in BatchAnnotateFilesRequest.
  648. repeated AnnotateFileResponse responses = 1;
  649. }
  650. // An offline file annotation request.
  651. message AsyncAnnotateFileRequest {
  652. // Required. Information about the input file.
  653. InputConfig input_config = 1;
  654. // Required. Requested features.
  655. repeated Feature features = 2;
  656. // Additional context that may accompany the image(s) in the file.
  657. ImageContext image_context = 3;
  658. // Required. The desired output location and metadata (e.g. format).
  659. OutputConfig output_config = 4;
  660. }
  661. // The response for a single offline file annotation request.
  662. message AsyncAnnotateFileResponse {
  663. // The output location and metadata from AsyncAnnotateFileRequest.
  664. OutputConfig output_config = 1;
  665. }
  666. // Request for async image annotation for a list of images.
  667. message AsyncBatchAnnotateImagesRequest {
  668. // Required. Individual image annotation requests for this batch.
  669. repeated AnnotateImageRequest requests = 1
  670. [(google.api.field_behavior) = REQUIRED];
  671. // Required. The desired output location and metadata (e.g. format).
  672. OutputConfig output_config = 2 [(google.api.field_behavior) = REQUIRED];
  673. }
  674. // Response to an async batch image annotation request.
  675. message AsyncBatchAnnotateImagesResponse {
  676. // The output location and metadata from AsyncBatchAnnotateImagesRequest.
  677. OutputConfig output_config = 1;
  678. }
  679. // Multiple async file annotation requests are batched into a single service
  680. // call.
  681. message AsyncBatchAnnotateFilesRequest {
  682. // Required. Individual async file annotation requests for this batch.
  683. repeated AsyncAnnotateFileRequest requests = 1
  684. [(google.api.field_behavior) = REQUIRED];
  685. }
  686. // Response to an async batch file annotation request.
  687. message AsyncBatchAnnotateFilesResponse {
  688. // The list of file annotation responses, one for each request in
  689. // AsyncBatchAnnotateFilesRequest.
  690. repeated AsyncAnnotateFileResponse responses = 1;
  691. }
  692. // The desired input location and metadata.
  693. message InputConfig {
  694. // The Google Cloud Storage location to read the input from.
  695. GcsSource gcs_source = 1;
  696. // File content, represented as a stream of bytes.
  697. // Note: As with all `bytes` fields, protobuffers use a pure binary
  698. // representation, whereas JSON representations use base64.
  699. //
  700. // Currently, this field only works for BatchAnnotateFiles requests. It does
  701. // not work for AsyncBatchAnnotateFiles requests.
  702. bytes content = 3;
  703. // The type of the file. Currently only "application/pdf", "image/tiff" and
  704. // "image/gif" are supported. Wildcards are not supported.
  705. string mime_type = 2;
  706. }
  707. // The desired output location and metadata.
  708. message OutputConfig {
  709. // The Google Cloud Storage location to write the output(s) to.
  710. GcsDestination gcs_destination = 1;
  711. // The max number of response protos to put into each output JSON file on
  712. // Google Cloud Storage.
  713. // The valid range is [1, 100]. If not specified, the default value is 20.
  714. //
  715. // For example, for one pdf file with 100 pages, 100 response protos will
  716. // be generated. If `batch_size` = 20, then 5 json files each
  717. // containing 20 response protos will be written under the prefix
  718. // `gcs_destination`.`uri`.
  719. //
  720. // Currently, batch_size only applies to GcsDestination, with potential future
  721. // support for other output configurations.
  722. int32 batch_size = 2;
  723. }
  724. // The Google Cloud Storage location where the input will be read from.
  725. message GcsSource {
  726. // Google Cloud Storage URI for the input file. This must only be a
  727. // Google Cloud Storage object. Wildcards are not currently supported.
  728. string uri = 1;
  729. }
  730. // The Google Cloud Storage location where the output will be written to.
  731. message GcsDestination {
  732. // Google Cloud Storage URI prefix where the results will be stored. Results
  733. // will be in JSON format and preceded by its corresponding input URI prefix.
  734. // This field can either represent a gcs file prefix or gcs directory. In
  735. // either case, the uri should be unique because in order to get all of the
  736. // output files, you will need to do a wildcard gcs search on the uri prefix
  737. // you provide.
  738. //
  739. // Examples:
  740. //
  741. // * File Prefix: gs://bucket-name/here/filenameprefix The output files
  742. // will be created in gs://bucket-name/here/ and the names of the
  743. // output files will begin with "filenameprefix".
  744. //
  745. // * Directory Prefix: gs://bucket-name/some/location/ The output files
  746. // will be created in gs://bucket-name/some/location/ and the names of the
  747. // output files could be anything because there was no filename prefix
  748. // specified.
  749. //
  750. // If multiple outputs, each response is still AnnotateFileResponse, each of
  751. // which contains some subset of the full list of AnnotateImageResponse.
  752. // Multiple outputs can happen if, for example, the output JSON is too large
  753. // and overflows into multiple sharded files.
  754. string uri = 1;
  755. }
  756. // Contains metadata for the BatchAnnotateImages operation.
  757. message OperationMetadata {
  758. // Batch operation states.
  759. enum State {
  760. // Invalid.
  761. STATE_UNSPECIFIED = 0;
  762. // Request is received.
  763. CREATED = 1;
  764. // Request is actively being processed.
  765. RUNNING = 2;
  766. // The batch processing is done.
  767. DONE = 3;
  768. // The batch processing was cancelled.
  769. CANCELLED = 4;
  770. }
  771. // Current state of the batch operation.
  772. State state = 1;
  773. // The time when the batch request was received.
  774. google.protobuf.Timestamp create_time = 5;
  775. // The time when the operation result was last updated.
  776. google.protobuf.Timestamp update_time = 6;
  777. }