Objectives
- Write and deploy several Background Cloud Functions.
- Upload images to Cloud Storage.
- Extract, translate and save text contained in uploaded images.
Visualizing the flow of data
The flow of data in the OCR tutorial application involves several steps:
- An image that contains text in any language is uploaded to Cloud Storage.
- A Cloud Function is triggered, which uses the Vision API to extract the text and detect the source language.
- The text is queued for translation by publishing a message to a Pub/Sub topic. A translation is queued for each target language different from the source language.
- If a target language matches the source language, the translation queue is skipped, and text is sent to the result queue, another Pub/Sub topic.
- A Cloud Function uses the Translation API to translate the text in the translation queue. The translated result is sent to the result queue.
- Another Cloud Function saves the translated text from the result queue to Cloud Storage.
- The results are found in Cloud Storage as
txt
files for each translation.
It may help to visualize the steps: