ocr

package
v0.0.0-...-d4b7cc8 Latest Latest
Warning

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

Go to latest
Published: Mar 22, 2026 License: Apache-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultORTLibPath string = getDefaultORTLibPath()

DefaultORTLibPath is the default path to the ONNX Runtime shared library (set by init from GOOS).

Functions

This section is empty.

Types

type Config

type Config struct {
	Models         map[string]common.ModelConfig
	EnableBoxMerge bool
	WorkflowType   string // "PaddleOCR" (default) or "GLM-OCR"
}

Config holds all configuration for the Engine.

type Engine

type Engine struct {
	// contains filtered or unexported fields
}

Engine coordinates the detect → classify → recognize pipeline.

func NewEngine

func NewEngine(opts ...Option) *Engine

NewEngine creates an Engine with the given config.

func (*Engine) Close

func (e *Engine) Close() error

Close releases all model resources.

func (*Engine) DecodeImage

func (e *Engine) DecodeImage(data []byte) (image.Image, error)

func (*Engine) DetectBoundingBoxes

func (e *Engine) DetectBoundingBoxes(data []byte) ([]utils.Box, error)

func (*Engine) GetConfig

func (e *Engine) GetConfig(modelName string) common.ModelConfig

func (*Engine) ImageDetectBoundingBoxes

func (e *Engine) ImageDetectBoundingBoxes(img image.Image) ([]utils.Box, error)

func (*Engine) ImageRunOCR

func (e *Engine) ImageRunOCR(img image.Image) ([]Result, error)

func (*Engine) Init

func (e *Engine) Init() error

Init initializes the workflow and knownModels.

func (*Engine) IsReady

func (e *Engine) IsReady() bool

func (*Engine) RegisterWorkflow

func (e *Engine) RegisterWorkflow(name string, factory WorkflowFactory)

func (*Engine) RunOCR

func (e *Engine) RunOCR(data []byte) ([]Result, error)

type Option

type Option func(*Engine)

Option configures an Engine before initialization.

func WithBoxMerge

func WithBoxMerge(boxMerge bool) Option

WithBoxMerge enables or disables box merging.

func WithModelConfig

func WithModelConfig(modelName string, config common.ModelConfig) Option

WithModelConfig sets the model config for the named model.

func WithWorkflowType

func WithWorkflowType(workflowName string) Option

WithWorkflowType sets the workflow type ("PaddleOCR" or "GLM-OCR").

type Result

type Result struct {
	Box      [][2]int `json:"box"` // [[x1,y1],[x2,y2],[x3,y3],[x4,y4]]
	Text     string   `json:"text"`
	Score    float64  `json:"score"`
	Children []Result `json:"children,omitempty"`
}

Result is a single detected text region. When Children is non-empty, this is a merged parent region containing child text lines.

type Workflow

type Workflow struct {
	// contains filtered or unexported fields
}

Workflow holds the three-stage pipeline components.

func NewGLMOCRWorkflow

func NewGLMOCRWorkflow(engineConf *Config, configSrc common.ConfigSource) *Workflow

func NewPaddleOCRWorkflow

func NewPaddleOCRWorkflow(engineConf *Config, configSrc common.ConfigSource) *Workflow

func NewWorkflow

func NewWorkflow(
	detector detect.Detector,
	classifier classify.Classifier,
	recognizer recognize.Recognizer,
	configSrc common.ConfigSource,
) *Workflow

func (*Workflow) Close

func (w *Workflow) Close() error

Close releases all model resources.

func (*Workflow) DetectOnly

func (w *Workflow) DetectOnly(img image.Image) ([]utils.Box, error)

DetectOnly runs only the detection model and returns boxes.

func (*Workflow) Init

func (w *Workflow) Init() error

Init initializes the workflow and knownModels.

func (*Workflow) RunOCR

func (w *Workflow) RunOCR(img image.Image) ([]Result, error)

RunOCR runs the detection -> classify -> recognize pipeline on img.

type WorkflowFactory

type WorkflowFactory func(engineConf *Config, configSrc common.ConfigSource) *Workflow

Directories

Path Synopsis
Package testutil provides shared test helpers for ORT-backed model tests.
Package testutil provides shared test helpers for ORT-backed model tests.

Jump to

Keyboard shortcuts

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