Versions in this module Expand all Collapse all v1 v1.0.1 May 18, 2026 v1.0.0 May 17, 2026 Changes in this version + const DefaultClientTimeout + const DefaultMaxBodyBytes + const DefaultMaxImageBytes + func InitRuntime(sharedLibraryPath string) error + func RuntimeLibraryPath() string + func ShutdownRuntime() error + type CharsetRange struct + func NewCharsetRangeChars(chars []string) *CharsetRange + func NewCharsetRangeLimit(maxIndex int) *CharsetRange + func NewCharsetRangeString(chars string) *CharsetRange + type ClassifyOptions struct + CharsetRange *CharsetRange + ColorFilter *ColorFilterOptions + PNGFix *bool + Probability bool + type ClassifyResult struct + Confidence float64 + Probability *ProbabilityMatrix + Text string + type ColorFilterOptions struct + Colors []string + Ranges []HSVRange + func NewColorFilterColors(colors ...string) *ColorFilterOptions + func NewColorFilterRanges(ranges ...HSVRange) *ColorFilterOptions + type Config struct + CharsetPath string + InputName string + Model Model + ModelPath string + OutputName string + PNGFix bool + SharedLibraryPath string + type DetectionBox struct + ClassID int + Score float64 + X1 int + X2 int + Y1 int + Y2 int + func (b DetectionBox) Rect() []int + type DetectionConfig struct + InputName string + InputSize int + ModelPath string + NMSThreshold float64 + OutputName string + ScoreThreshold float64 + SharedLibraryPath string + type DetectionEngine interface + DetectBytesDetailed func(data []byte) ([]DetectionBox, error) + type DetectionOptions struct + NMSThreshold *float64 + ScoreThreshold *float64 + type Detector struct + func NewDetector(config DetectionConfig) (*Detector, error) + func (d *Detector) Close() error + func (d *Detector) DetectBytes(data []byte) ([][]int, error) + func (d *Detector) DetectBytesDetailed(data []byte) ([]DetectionBox, error) + func (d *Detector) DetectBytesDetailedWithOptions(data []byte, options *DetectionOptions) ([]DetectionBox, error) + func (d *Detector) DetectImageDetailed(img image.Image) ([]DetectionBox, error) + func (d *Detector) DetectImageDetailedWithOptions(img image.Image, options *DetectionOptions) ([]DetectionBox, error) + type HSVRange struct + Lower [3]int + Upper [3]int + func (r *HSVRange) UnmarshalJSON(data []byte) error + type LogFormat string + const LogFormatJSON + const LogFormatText + func ParseLogFormat(value string) (LogFormat, error) + type Model string + const ModelBeta + const ModelCustom + const ModelOld + type OCR struct + func NewOCR(config Config) (*OCR, error) + func (o *OCR) Charset() []string + func (o *OCR) ClassifyBytes(data []byte, options *ClassifyOptions) (string, error) + func (o *OCR) ClassifyBytesDetailed(data []byte, options *ClassifyOptions) (*ClassifyResult, error) + func (o *OCR) ClassifyImage(img image.Image, options *ClassifyOptions) (string, error) + func (o *OCR) ClassifyImageDetailed(img image.Image, options *ClassifyOptions) (*ClassifyResult, error) + func (o *OCR) Close() error + func (o *OCR) Model() Model + type OCRClient struct + func NewOCRClient(baseURL string, options ...OCRClientOption) *OCRClient + func (c *OCRClient) ClassifyBytes(ctx context.Context, image []byte, options *RemoteClassifyOptions) (*RemoteClassifyResult, error) + func (c *OCRClient) DetectBytes(ctx context.Context, image []byte, options *RemoteDetectOptions) (*RemoteDetectResult, error) + func (c *OCRClient) Ready(ctx context.Context) error + func (c *OCRClient) SlideComparisonBytes(ctx context.Context, targetImage []byte, backgroundImage []byte) (*RemoteSlideComparisonResult, error) + func (c *OCRClient) SlideMatchBytes(ctx context.Context, targetImage []byte, backgroundImage []byte, ...) (*RemoteSlideMatchResult, error) + type OCRClientOption func(*OCRClient) + func WithClientMaxImageBytes(n int64) OCRClientOption + func WithClientTimeout(timeout time.Duration) OCRClientOption + func WithHTTPClient(client *http.Client) OCRClientOption + type OCREngine interface + ClassifyBytesDetailed func(data []byte, options *ClassifyOptions) (*ClassifyResult, error) + Model func() Model + type OCRPool struct + func NewOCRPool(config Config, workers int) (*OCRPool, error) + func (p *OCRPool) ClassifyBytesDetailed(data []byte, options *ClassifyOptions) (*ClassifyResult, error) + func (p *OCRPool) Close() error + func (p *OCRPool) Model() Model + func (p *OCRPool) Size() int + type PreprocessOptions struct + ColorFilter *ColorFilterOptions + PNGFix bool + type PreprocessResult struct + Data []float32 + Height int + Width int + func PreprocessOCRBytes(data []byte, options *PreprocessOptions) (*PreprocessResult, error) + func PreprocessOCRImage(img image.Image, options *PreprocessOptions) (*PreprocessResult, error) + func (r *PreprocessResult) GrayImage() (*image.Gray, error) + type ProbabilityMatrix struct + Charsets []string + Confidence float64 + Probability [][]float64 + Text string + type RemoteClassifyOptions struct + CharsetRange any + ColorFilterColors []string + ColorFilterCustomRanges []HSVRange + Confidence bool + PNGFix *bool + Probability bool + type RemoteClassifyResult struct + Confidence float64 + Probability *ProbabilityMatrix + ProcessingTimeMS float64 + RequestID string + Result string + type RemoteDetectOptions struct + Detailed bool + NMSThreshold *float64 + ScoreThreshold *float64 + type RemoteDetectResult struct + Boxes []DetectionBox + ProcessingTimeMS float64 + RequestID string + Result [][]int + type RemoteError struct + Code string + Message string + RequestID string + StatusCode int + func (e *RemoteError) Error() string + type RemoteSlideComparisonResult struct + ProcessingTimeMS float64 + RequestID string + Result SlideResult + type RemoteSlideMatchOptions struct + SimpleTarget bool + type RemoteSlideMatchResult struct + ProcessingTimeMS float64 + RequestID string + Result SlideResult + type Server struct + func NewServer(ocr OCREngine, options ...ServerOption) *Server + func (s *Server) Handler() http.Handler + func (s *Server) Metrics() ServerMetricsSnapshot + type ServerMetricsSnapshot struct + AverageLatencyMS float64 + CompletedRequests uint64 + ErrorRequests uint64 + InFlightRequests int64 + LastRequestAt string + LastRequestLatency float64 + LastRequestStatus int + MaxLatencyMS float64 + StartedAt string + StatusCodes map[string]uint64 + TotalLatencyMS float64 + TotalRequests uint64 + UptimeSeconds float64 + type ServerOption func(*Server) + func WithDetector(detector DetectionEngine) ServerOption + func WithLogFormat(format LogFormat) ServerOption + func WithLogger(logger *log.Logger) ServerOption + func WithMaxBodyBytes(n int64) ServerOption + func WithMaxImageBytes(n int64) ServerOption + type SlideResult struct + Confidence float64 + Target []int + TargetX int + TargetY int + func SlideComparisonBytes(targetData []byte, backgroundData []byte) (*SlideResult, error) + func SlideComparisonImages(target image.Image, background image.Image) (*SlideResult, error) + func SlideMatchBytes(targetData []byte, backgroundData []byte, simpleTarget bool) (*SlideResult, error) + func SlideMatchImages(target image.Image, background image.Image, simpleTarget bool) (*SlideResult, error)