Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Config ¶
type Config struct {
// 必填参数
OnnxRuntimeLibPath string // onnxruntime.dll (或 .so, .dylib) 的路径
DetModelPath string // det.onnx (检测模型) 的路径
RecModelPath string // rec.onnx (识别模型) 的路径
DictPath string // dict.txt (字典) 的路径
// 可选参数
UseCuda bool // (可选) 是否启用 CUDA
NumThreads int // (可选) ONNX 线程数, 默认由CPU核心数决定
DetMaxSideLen int // (可选) 检测模型预处理的最长边, 默认 960
DetOutsideExpandPix int // (可选) 检测框外扩像素, 默认 10
RecHeight int // (可选) 识别模型预处理的高度, 默认 48
RecModelNumClasses int64 // (可选) 识别模型类别数, 默认 18385
HeatmapThreshold float32 // (可选) 检测热力图阈值, 默认 0.3
}
Config OCR 引擎的开放配置
type Engine ¶
type Engine interface {
// RunDetect 图像文字区域检测
RunDetect(img image.Image) ([][4]int, error)
// RunRecognize 识别图像中指定区域的文字
RunRecognize(img image.Image, box [4]int) (RecResult, error)
// RunOCR 对图像执行检测和识别
RunOCR(img image.Image) ([]RecResult, error)
// Destroy 释放所有引擎相关的资源
Destroy()
}
Engine 定义了 OCR 引擎必须实现的通用接口
type PaddleOcrEngine ¶
type PaddleOcrEngine struct {
// contains filtered or unexported fields
}
PaddleOcrEngine 是 PaddleOCR 引擎的主结构体
func NewPaddleOcrEngine ¶
func NewPaddleOcrEngine(cfg Config) (*PaddleOcrEngine, error)
NewPaddleOcrEngine 用于初始化 ONNX Runtime、加载模型和字典。
func (*PaddleOcrEngine) RunDetect ¶
func (e *PaddleOcrEngine) RunDetect(img image.Image) ([][4]int, error)
RunDetect 图像文字区域检测
func (*PaddleOcrEngine) RunOCR ¶
func (e *PaddleOcrEngine) RunOCR(img image.Image) ([]RecResult, error)
RunOCR 对图像执行检测和识别 核心优化:并发执行识别
func (*PaddleOcrEngine) RunRecognize ¶
RunRecognize 识别图像中指定区域的文字
Click to show internal directories.
Click to hide internal directories.



