Documentation
¶
Overview ¶
Package ocr is togo's OCR (image→text) plugin. It exposes a swappable Extractor driver, a Go API ocr.Extract(...), and a REST endpoint POST /api/ocr. Drivers register via ocr.RegisterDriver; pick one with OCR_DRIVER.
- "tesseract" (default): real OCR via the local `tesseract` binary.
- "ai": uses the togo `ai` plugin (a multimodal model) — best-effort; see README.
Install: `togo install togo-framework/ocr` (blank-import registers it).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func RegisterDriver ¶
func RegisterDriver(name string, f DriverFactory)
RegisterDriver registers an OCR engine by name (call from a plugin's init()).
Types ¶
type DriverFactory ¶
DriverFactory builds an Extractor from the kernel (env-configured).
type Extractor ¶
type Extractor interface {
Extract(ctx context.Context, image []byte, opts Options) (string, error)
}
Extractor turns image bytes into text.
type Options ¶
type Options struct {
// Lang is a tesseract language code (e.g. "eng", "ara", "eng+ara"). Default "eng".
Lang string `json:"lang,omitempty"`
// Mime hints the image type for the ai driver (e.g. "image/png"). Default png.
Mime string `json:"mime,omitempty"`
}
Options tune an extraction.
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service is the ocr runtime stored on the kernel (k.Get("ocr")).
func FromKernel ¶
FromKernel fetches the ocr service from the kernel container.
Click to show internal directories.
Click to hide internal directories.