The Vision API can run offline (asynchronous) detection services and
annotation of a large batch of image files using any Vision
feature type. For example, you
can specify one or multiple Vision API features (such as
TEXT_DETECTION
, LABEL_DETECTION
,
and LANDMARK_DETECTION
) for a single batch of images.
Output from an offline batch request is written to a JSON file created in the specified Cloud Storage bucket.
Limitations
The Vision API accepts up to 2,000 image files. A larger batch of image files will return an error.
Currently supported feature types
Functietype | |
---|---|
CROP_HINTS |
Voorgestelde hoekpunten bepalen voor een bijsnijdgebied in een afbeelding. |
DOCUMENT_TEXT_DETECTION |
OCR uitvoeren op afbeeldingen met veel tekst, zoals documenten (pdf/tiff), en afbeeldingen met handgeschreven tekst.
TEXT_DETECTION kan worden gebruikt voor afbeeldingen met weinig tekst.
Heeft voorrang als zowel DOCUMENT_TEXT_DETECTION als TEXT_DETECTION aanwezig zijn.
|
FACE_DETECTION |
Gezichten in de afbeelding detecteren. |
IMAGE_PROPERTIES |
Een set afbeeldingseigenschappen berekenen, zoals de dominante kleuren van de afbeelding. |
LABEL_DETECTION |
Labels toevoegen op basis van de inhoud van de afbeelding. |
LANDMARK_DETECTION |
Geografische herkenningspunten in de afbeelding detecteren. |
LOGO_DETECTION |
Bedrijfslogo's in de afbeelding detecteren. |
OBJECT_LOCALIZATION |
Meerdere objecten in een afbeelding detecteren en extraheren. |
SAFE_SEARCH_DETECTION |
SafeSearch uitvoeren om mogelijk onveilige of ongewenste content te detecteren. |
TEXT_DETECTION |
Optical Character Recognition (OCR) uitvoeren op tekst in de afbeelding.
Tekstdetectie is geoptimaliseerd voor gedeelten met weinig tekst in een grotere afbeelding.
Als de afbeelding een document (pdf/tiff) is, veel tekst bevat of handgeschreven tekst bevat, gebruikt u in plaats daarvan DOCUMENT_TEXT_DETECTION .
|
WEB_DETECTION |
Interessegebieden zoals nieuws, gebeurtenissen of beroemdheden in de afbeelding detecteren en vergelijkbare afbeeldingen op het web zoeken met de kracht van Google Afbeeldingen. |
Sample code
Use the following code samples to run offline annotation services on a batch of image files in Cloud Storage.
Java
Before trying this sample, follow the Java setup instructions in the Vision API Quickstart Using Client Libraries. For more information, see the Vision API Java API reference documentation.
Node.js
Before trying this sample, follow the Node.js setup instructions in the Vision Quickstart Using Client Libraries. For more information, see the Vision Node.js API reference documentation.
Python
Before trying this sample, follow the Python setup instructions in the Vision Quickstart Using Client Libraries. For more information, see the Vision Python API reference documentation.
Ruby
Before trying this sample, follow the Ruby setup instructions in the Vision Quickstart Using Client Libraries. For more information, see the Vision Ruby API reference documentation.
Response
A successful request returns response JSON files in the Cloud Storage
bucket you indicated in the code sample. The number of responses per JSON file
is dictated by batch_size
in the code sample.
The returned response is similar to regular Vision API feature responses, depending on which features you request for an image.
The following responses
show LABEL_DETECTION
and TEXT_DETECTION
annotations for image1.png
,
IMAGE_PROPERTIES
annotations for image2.jpg
, and OBJECT_LOCALIZATION
annotations for image3.jpg
.
The response also contain a context
field showing
the file's URI.
offline_batch_output/output-1-to-2.json
{ "responses": [ { "labelAnnotations": [ { "mid": "/m/07s6nbt", "description": "Text", "score": 0.93413997, "topicality": 0.93413997 }, { "mid": "/m/0dwx7", "description": "Logo", "score": 0.8733531, "topicality": 0.8733531 }, ... { "mid": "/m/03bxgrp", "description": "Company", "score": 0.5682425, "topicality": 0.5682425 } ], "textAnnotations": [ { "locale": "en", "description": "Google\n", "boundingPoly": { "vertices": [ { "x": 72, "y": 40 }, { "x": 613, "y": 40 }, { "x": 613, "y": 233 }, { "x": 72, "y": 233 } ] } }, ... ], "blockType": "TEXT" } ] } ], "text": "Google\n" }, "context": { "uri": "gs://cloud-samples-data/vision/document_understanding/image1.png" } }, { "imagePropertiesAnnotation": { "dominantColors": { "colors": [ { "color": { "red": 229, "green": 230, "blue": 238 }, "score": 0.2744754, "pixelFraction": 0.075339235 }, ... { "color": { "red": 86, "green": 87, "blue": 95 }, "score": 0.025770646, "pixelFraction": 0.13109145 } ] } }, "cropHintsAnnotation": { "cropHints": [ { "boundingPoly": { "vertices": [ {}, { "x": 1599 }, { "x": 1599, "y": 1199 }, { "y": 1199 } ] }, "confidence": 0.79999995, "importanceFraction": 1 } ] }, "context": { "uri": "gs://cloud-samples-data/vision/document_understanding/image2.jpg" } } ] }
offline_batch_output/output-3-to-3.json
{ "responses": [ { "context": { "uri": "gs://cloud-samples-data/vision/document_understanding/image3.jpg" }, "localizedObjectAnnotations": [ { "mid": "/m/0bt9lr", "name": "Dog", "score": 0.9669734, "boundingPoly": { "normalizedVertices": [ { "x": 0.6035543, "y": 0.1357359 }, { "x": 0.98546547, "y": 0.1357359 }, { "x": 0.98546547, "y": 0.98426414 }, { "x": 0.6035543, "y": 0.98426414 } ] } }, ... { "mid": "/m/0jbk", "name": "Animal", "score": 0.58003056, "boundingPoly": { "normalizedVertices": [ { "x": 0.014534635, "y": 0.1357359 }, { "x": 0.37197515, "y": 0.1357359 }, { "x": 0.37197515, "y": 0.98426414 }, { "x": 0.014534635, "y": 0.98426414 } ] } } ] } ] }