Documentation ¶
Index ¶
- Constants
- func OcrFile(exePath, imagePath string, argsCnf OcrArgs) ([]byte, error)
- type Data
- type OcrArgs
- type Ppocr
- func (p *Ppocr) Close() error
- func (p *Ppocr) Ocr(image []byte) ([]byte, error)
- func (p *Ppocr) OcrAndParse(image []byte) (Result, error)
- func (p *Ppocr) OcrClipboard() ([]byte, error)
- func (p *Ppocr) OcrClipboardAndParse() (Result, error)
- func (p *Ppocr) OcrFile(imagePath string) ([]byte, error)
- func (p *Ppocr) OcrFileAndParse(imagePath string) (Result, error)
- type Result
Constants ¶
const ( ConfigChinese = "models/config_chinese.txt" ConfigChineseCht = "models/config_chinese_cht.txt" ConfigCyrillic = "models/config_cyrillic.txt" ConfigEn = "models/config_en.txt" ConfigFrenchV2 = "models/config_french_v2.txt" ConfigGermanV2 = "models/config_german_v2.txt" ConfigJapan = "models/config_japan.txt" ConfigKorean = "models/config_korean.txt" )
const ( // CodeSuccess indicates that the OCR process was successful. CodeSuccess = 100 // CodeNoText indicates that no text was recognized. CodeNoText = 101 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type OcrArgs ¶
type OcrArgs struct { // 启用cls方向分类,识别方向不是正朝上的图片。默认为false。 Cls *bool `paddleocr:"cls"` // 启用CPU推理加速,关掉可以减少内存占用,但会降低速度。默认为true。 EnableMkldnn *bool `paddleocr:"enable_mkldnn"` // 若图片长边长度大于该值,会被缩小到该值,以提高速度。默认为960。 // 如果对大图/长图的识别率低,可增大 limit_side_len 的值。 // 建议为 32 & 48 的公倍数,如 960, 2880, 4320 LimitSideLen *int32 `paddleocr:"limit_side_len"` // 启用方向分类,必须与cls值相同。 默认为false。 UseAngleCls *bool `paddleocr:"use_angle_cls"` // 指定不同语言的配置文件路径,识别多国语言。 // models 目录中,每一个 config_xxx.txt 是一组语言配置文件(如英文是congfig_en.txt)。 // 只需将这个文件的路径传入 config_path 参数,即可切换为对应的语言。 // // 例如: // paddleocr.OcrArgs{ ConfigPath: paddleocr.ConfigChinese } ConfigPath string `paddleocr:"config_path"` }
type Ppocr ¶
type Ppocr struct {
// contains filtered or unexported fields
}
func NewPpocr ¶
NewPpocr creates a new instance of the Ppocr struct with the provided executable path and OCR arguments. It initializes the OCR process and returns a pointer to the Ppocr instance and any error encountered.
It is the caller's responsibility to close the Ppocr instance when finished.
func (*Ppocr) Close ¶
Close cleanly shuts down the OCR process associated with the Ppocr instance. It releases any resources and terminates the OCR process.
Warning: This method should only be called once.
func (*Ppocr) Ocr ¶
Ocr processes the OCR for a given image represented as a byte slice. It returns the OCR result as bytes and any error encountered.
func (*Ppocr) OcrAndParse ¶
OcrAndParse processes and parses the OCR for a given image represented as a byte slice. It returns the parsed OCR results as a slice of Result structs and any error encountered.
func (*Ppocr) OcrClipboard ¶
OcrClipboard processes the OCR for an image stored in the clipboard. It returns the raw OCR result as bytes and any error encountered.
func (*Ppocr) OcrClipboardAndParse ¶
OcrClipboardAndParse processes the OCR for an image stored in the clipboard and parses the result. It returns the parsed OCR results as a slice of Result structs and any error encountered.
type Result ¶
func OcrFileAndParse ¶
func ParseResult ¶
ParseResult parses the raw OCR result bytes into a slice of Result structs. It returns the parsed results and any error encountered during parsing.