Documentation ¶
Overview ¶
Package ocr contains Go samples for creating OCR (Optical Character Recognition) Cloud functions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ProcessImage ¶
ProcessImage is executed when a file is uploaded to the Cloud Storage bucket you created for uploading images. It runs detectText, which processes the image for text.
func SaveResult ¶
func SaveResult(ctx context.Context, event PubSubMessage) error
SaveResult is executed when a message is published to the Cloud Pub/Sub topic specified by the RESULT_TOPIC environment vairable, and saves the data packet to a file in GCS.
func TranslateText ¶
func TranslateText(ctx context.Context, event PubSubMessage) error
TranslateText is executed when a message is published to the Cloud Pub/Sub topic specified by the TRANSLATE_TOPIC environment variable, and translates the text using the Google Translate API.
Types ¶
type GCSEvent ¶
type GCSEvent struct { Bucket string `json:"bucket"` Name string `json:"name"` Metageneration string `json:"metageneration"` ResourceState string `json:"resourceState"` TimeCreated time.Time `json:"timeCreated"` Updated time.Time `json:"updated"` }
GCSEvent is the payload of a GCS event.
type PubSubMessage ¶
type PubSubMessage struct {
Data []byte `json:"data"`
}
PubSubMessage is the payload of a Pub/Sub event. See the documentation for more details: https://cloud.google.com/pubsub/docs/reference/rest/v1/PubsubMessage