ocr

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2021 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AWSClient

type AWSClient struct {
	CredentialsPath string
}

func (AWSClient) ResultToDetection

func (_ AWSClient) ResultToDetection(result *Result, width, height int) (*Detection, error)

func (AWSClient) Run

func (c AWSClient) Run(image []byte) (*Result, error)

Method required by ocr.Client Returns AWS document text detection Result Reference: https://docs.aws.amazon.com/textract/

type AzureClient

type AzureClient struct {
	CredentialsPath string
}

func (AzureClient) ResultToDetection

func (_ AzureClient) ResultToDetection(result *Result, _, _ int) (*Detection, error)

func (AzureClient) Run

func (c AzureClient) Run(image []byte) (*Result, error)

Method required by ocr.Client Returns Azure document text detection Result Example: https://docs.microsoft.com/en-us/azure/cognitive-services/computer-vision/quickstarts/go-print-text

type AzureReadClient

type AzureReadClient struct {
	CredentialsPath string
}

func (AzureReadClient) ResultToDetection

func (_ AzureReadClient) ResultToDetection(result *Result, _, _ int) (*Detection, error)

func (AzureReadClient) Run

func (c AzureReadClient) Run(image []byte) (*Result, error)

Method required by ocr.Client Returns Azure READ API document text detection Result

type Block

type Block struct {
	Bounds string `json:"xywh"`
	Lines  []Line `json:"lines"`
}

type Bounds

type Bounds struct {
	X int
	Y int
	W int
	H int
}

func DecodeBounds

func DecodeBounds(bounds string) (Bounds, error)

type Client

type Client interface {
	Run(image []byte) (*Result, error)
	// Converts lossless Result format to unified Detection format
	ResultToDetection(result *Result, width, height int) (*Detection, error)
}

type Detection

type Detection struct {
	AlgoID string  `json:"algo"`
	Date   string  `json:"date"`
	Millis uint32  `json:"millis"`
	Blocks []Block `json:"blocks"`
}

func Merge

func Merge(blws []Detection) (*Detection, error)

func (*Detection) Annotate

func (d *Detection) Annotate(src []byte, c color.Color, ab, al, aw bool) ([]byte, error)

func (*Detection) AnnotateLineBoundaries

func (d *Detection) AnnotateLineBoundaries(src []byte, c color.Color) ([]byte, error)

Attempts to find line boundaries and draw them

func (*Detection) CountBLW

func (d *Detection) CountBLW() (int, int, int)

func (*Detection) Flatten

func (d *Detection) Flatten() ([]bWord, error)

func (*Detection) Plaintext

func (d *Detection) Plaintext() string

type GCPClient

type GCPClient struct {
	CredentialsPath string
}

func (GCPClient) ResultToDetection

func (_ GCPClient) ResultToDetection(result *Result, _, _ int) (*Detection, error)

func (GCPClient) Run

func (c GCPClient) Run(file []byte) (*Result, error)

Method required by ocr.Client Returns GCP document text detection Result Reference: https://cloud.google.com/vision/docs/apis

type Line

type Line struct {
	Bounds string `json:"xywh"`
	Words  []Word `json:"words"`
}

type Result

type Result struct {
	Service  string `json:"service"`
	Version  string `json:"version"`
	FullText string `json:"text"`
	Duration int64  `json:"milliseconds"`
	Date     string `json:"date"`
	Raw      []byte `json:"raw"`
}

type Word

type Word struct {
	Bounds string `json:"xywh"`
	Text   string `json:"text"`
}

Jump to

Keyboard shortcuts

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