paddle

package
v0.0.0-...-3abab59 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

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核心数决定
	ThreadCount         int     // (可选) 识别 Session 并发数, 默认 1。>1 时创建多个 ONNX Session 实现并行识别
	DetMaxSideLen       int     // (可选) 检测模型预处理的最长边, 默认 960
	DetOutsideExpandPix int     // (可选) 检测框外扩像素, 默认 10
	RecHeight           int     // (可选) 识别模型预处理的高度, 默认 48
	RecModelNumClasses  int64   // (可选) 识别模型类别数, 默认 18385
	HeatmapThreshold    float32 // (可选) 检测热力图阈值, 默认 0.3
}

Config PaddleOCR 引擎的开放配置

type Engine

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

Engine 是 PaddleOCR 引擎的主结构体

func NewEngine

func NewEngine(cfg Config) (*Engine, error)

NewEngine 用于初始化 ONNX Runtime、加载模型和字典。

func (*Engine) Destroy

func (e *Engine) Destroy()

Destroy 释放所有 ONNX 资源

func (*Engine) RunDetect

func (e *Engine) RunDetect(img image.Image) ([][4]int, error)

RunDetect 图像文字区域检测

func (*Engine) RunOCR

func (e *Engine) RunOCR(img image.Image) ([]ocr.RecResult, error)

RunOCR 对图像执行检测和识别 核心优化:Worker-Pool 模式 — 每个 rec session 独占一个 goroutine,按 stride 分摊 boxes

Jump to

Keyboard shortcuts

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