An open API service indexing awesome lists of open source software.

https://github.com/lahsivjar/gcloud-ocr

Sample OCR code to use with GCS and Cloud Functions
https://github.com/lahsivjar/gcloud-ocr

cloud-functions gcloud gcs golang-examples iap pubsub

Last synced: 8 months ago
JSON representation

Sample OCR code to use with GCS and Cloud Functions

Awesome Lists containing this project

README

          

# OCR using GCS and Cloud Functions

Sample code to use google functions with vision API and google cloud storage. The result is dumped into elasticsearch which is running on K8s cluster exposed via IAP.

## Pipeline

![OCR flow](ocr-flow.jpg)

## Pre setup

- Create pub/sub topic with name `image-file-type`
- Create pub/sub topic with name `pdf-file-type`
- Create pub/sub topic with name `es-upload`
- Copy env.yaml.sample to env.yaml and update required values

```
WARNING: The env.yaml file has service account credentials which should be stored as a secret but it is out of scope for this PoC to do so. To learn more about it see [this](https://cloud.google.com/solutions/secrets-management/).
```

## Deployment
```
gcloud functions deploy DispatchWithFileType \
--runtime go111 \
--trigger-resource \
--trigger-event google.storage.object.finalize
```

```
gcloud functions deploy DetectTextsFromImage \
--runtime go111 \
--trigger-topic image-file-types
```

```
gcloud functions deploy UploadTextsToES \
--runtime go111 \
--trigger-topic es-upload \
--env-vars-file env.yaml
```