ocr

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package ocr provides a wrapper around system commands to facilitate Optical Character Recognition (OCR) via command-line tools like Tesseract. It abstracts command execution and output handling, allowing for easy mocking and testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command interface {
	TextOutput() (string, error)
}

Command is an interface that abstracts functionalities for sending text input to a command and receiving text output. This abstraction aids in executing and processing the output of system commands.

type Ocr

type Ocr interface {
	// TextFromImageFile executes the OCR process on the specified image file and returns the extracted text.
	// It returns any errors encountered during the OCR operation.
	TextFromImageFile(fileName string) (string, error)
}

Ocr interface abstracts the OCR operations. It provides a function to extract text from image files.

func New

func New(options ...Option) (Ocr, error)

New is a constructor function for creating a new ocr instance with optional configurations. It returns an Ocr instance and any error encountered during its creation.

type Option

type Option func(*ocr)

Option is a function type that applies a configuration to an ocr instance. It's used for optional configuration of the OCR process, allowing for flexible customization of the ocr struct's behavior.

func TesseractPath

func TesseractPath(path string) Option

TesseractPath returns an Option that sets the path to the Tesseract executable. This function allows users of the ocr package to specify a custom path for the Tesseract binary, overriding the default path.

Parameters:

path - The file system path to the Tesseract executable.

Returns:

An Option function that, when applied to an ocr instance, sets its binary path.

Jump to

Keyboard shortcuts

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