Documentation
¶
Index ¶
- Constants
- Variables
- type Backend
- type BackendType
- type Engine
- type EngineOptions
- type NativeBackend
- func (n *NativeBackend) Available() bool
- func (n *NativeBackend) Close() error
- func (n *NativeBackend) HasLanguage(lang string) bool
- func (n *NativeBackend) Name() string
- func (n *NativeBackend) ProcessImage(ctx context.Context, imagePath, lang string) (string, error)
- func (n *NativeBackend) Version() string
- type NativeInfo
- type WASMBackend
Constants ¶
const (
// TessdataURL is the base URL for downloading tessdata files.
TessdataURL = "https://github.com/tesseract-ocr/tessdata_fast/raw/main"
)
Variables ¶
var ErrNativeNotFound = errors.New("native Tesseract not found")
ErrNativeNotFound is returned when native Tesseract is not installed.
Functions ¶
This section is empty.
Types ¶
type Backend ¶
type Backend interface {
Name() string
Available() bool
ProcessImage(ctx context.Context, imagePath, lang string) (string, error)
Close() error
}
Backend defines the interface for OCR backends.
type BackendType ¶
type BackendType int
BackendType represents the type of OCR backend to use.
const ( BackendAuto BackendType = iota // Auto-select best available backend BackendNative // System-installed Tesseract BackendWASM // WASM-based Tesseract (gogosseract) )
func ParseBackendType ¶
func ParseBackendType(s string) BackendType
ParseBackendType converts a string to BackendType.
func (BackendType) String ¶
func (b BackendType) String() string
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine provides OCR capabilities with configurable backend.
func NewEngineWithOptions ¶
func NewEngineWithOptions(opts EngineOptions) (*Engine, error)
NewEngineWithOptions creates a new OCR engine with specified options.
func (*Engine) BackendName ¶
BackendName returns the name of the currently active backend.
func (*Engine) EnsureTessdata ¶
EnsureTessdata ensures the tessdata file for the language exists.
type EngineOptions ¶
type EngineOptions struct {
Lang string
DataDir string
BackendType BackendType
}
EngineOptions contains options for creating an OCR engine.
type NativeBackend ¶
type NativeBackend struct {
// contains filtered or unexported fields
}
NativeBackend implements Backend using system-installed Tesseract.
func NewNativeBackend ¶
func NewNativeBackend(lang, dataDir string) (*NativeBackend, error)
NewNativeBackend creates a new native Tesseract backend.
func (*NativeBackend) Available ¶
func (n *NativeBackend) Available() bool
func (*NativeBackend) Close ¶
func (n *NativeBackend) Close() error
func (*NativeBackend) HasLanguage ¶
func (n *NativeBackend) HasLanguage(lang string) bool
HasLanguage checks if a language is available in the system tessdata.
func (*NativeBackend) Name ¶
func (n *NativeBackend) Name() string
func (*NativeBackend) ProcessImage ¶
func (*NativeBackend) Version ¶
func (n *NativeBackend) Version() string
Version returns the version of the native Tesseract installation.
type NativeInfo ¶
NativeInfo contains information about the native Tesseract installation.
func DetectNativeTesseract ¶
func DetectNativeTesseract() (*NativeInfo, error)
DetectNativeTesseract checks if native Tesseract is installed and returns its info.
type WASMBackend ¶
type WASMBackend struct {
// contains filtered or unexported fields
}
WASMBackend implements Backend using gogosseract (WASM-based Tesseract).
func NewWASMBackend ¶
func NewWASMBackend(lang, dataDir string) (*WASMBackend, error)
NewWASMBackend creates a new WASM-based Tesseract backend.
func (*WASMBackend) Available ¶
func (w *WASMBackend) Available() bool
func (*WASMBackend) Close ¶
func (w *WASMBackend) Close() error
func (*WASMBackend) EnsureTessdata ¶
func (w *WASMBackend) EnsureTessdata(lang string) error
EnsureTessdata ensures the tessdata file for the language exists.
func (*WASMBackend) Name ¶
func (w *WASMBackend) Name() string