ocrlite

package module
v0.0.0-...-7703435 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2023 License: MIT Imports: 3 Imported by: 0

README

go-chineseocr-lite

文字识别过程:

图像输入 -> 预处理 -> 文本检测 -> 文本识别 -> 输出结果

  1. DBNet(Differentiable Binarization Network)
  2. Angle Network - 文字方向检测
  3. CRNN-LSTM(Convolutional Recurrent Neural Network - Long Short Term Memory) - 文字识别

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Predictor

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

func New

func New(isOutputConsole, isOutputPartImg, isOutputResultImg bool) *Predictor

func (*Predictor) Close

func (p *Predictor) Close()

func (*Predictor) DetectFileImage

func (p *Predictor) DetectFileImage(imgDir, imgName string, padding, maxSideLen int, boxScoreThresh, boxThresh, unClipRatio float32, doAngle, mostAngle bool) string

DetectFileImage 识别文件图片

imgPath 目标图片路径,可以相对路径也可以绝对路径。
imgName 图片的文件名
padding 图像预处理,在图片外周添加白边,用于提升识别率,文字框没有正确框住所有文字时,增加此值。
maxSideLen 按图片最长边的长度,此值为0代表不缩放,例:1024,如果图片长边大于1024则把图像整体缩小到1024再进行图像分割计算,如果图片长边小于1024则不缩放,如果图片长边小于32,则缩放到32。
boxScoreThresh 文字框置信度阈值,文字框没有正确框住所有文字时,减小此值。
boxThresh
unClipRatio 单个文字框大小倍率,越大时单个文字框越大。此项与图片的大小相关,越大的图片此值应该越大。
doAngle 启用文字方向检测,只有图片倒置的情况下(旋转90~270度的图片),才需要启用文字方向检测。
mostAngle

func (*Predictor) DetectMemoryImage

func (p *Predictor) DetectMemoryImage(imgBuffer []byte, padding, maxSideLen int, boxScoreThresh, boxThresh, unClipRatio float32, doAngle, mostAngle bool) string

DetectMemoryImage 识别内存图片

func (*Predictor) InitModels

func (p *Predictor) InitModels(detPath, clsPath, recPath, keysPath string) bool

InitModels 初始化模型

detPath dbNet模型文件名(含扩展名)
clsPath angleNet模型文件名(含扩展名)
recPath crnnNet模型文件名(含扩展名)
keysPath keys.txt文件名(含扩展名)

func (*Predictor) SetNumThread

func (p *Predictor) SetNumThread(numOfThread int)

SetNumThread 设置工作线程数

Directories

Path Synopsis
examples
detect_file command
detect_memory command

Jump to

Keyboard shortcuts

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