English|中文
A simple wrapper for hiroi-sora/PaddleOCR-json implemented in Go language.
-
Download the program from PaddleOCR-json releases and decompress it.
-
install paddleocr
go get github.com/doraemonkeys/paddleocr
package main
import (
"fmt"
"github.com/doraemonkeys/paddleocr"
)
func main() {
p, err := paddleocr.NewPpocr("path/to/PaddleOCR-json.exe",
paddleocr.OcrArgs{})
if err != nil {
panic(err)
}
defer p.Close()
result, err := p.OcrFileAndParse(`path/to/image.png`)
if err != nil {
panic(err)
}
if result.Code != paddleocr.CodeSuccess {
fmt.Println("orc failed:", result.Msg)
return
}
fmt.Println(result.Data)
}