ocr

package module
v0.0.0-...-e567a2b Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 13, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

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

func ProcessImage(ctx context.Context, event GCSEvent) error

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL