ocr

command
v0.0.0-...-bc30745 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2019 License: Apache-2.0 Imports: 3 Imported by: 0

README

Instanlation

go get github.com/sqeven/go-ai/vision/ocr

Usage

  • 创建client
const (
	// This Api Key and Api Secret is just for example,
	// you should get your own first.
	APIKEY    = "MDNsII2jkUtbF729GQOZt7FS"
	APISECRET = "0vWCVCLsbWHMSH1wjvxaDq4VmvCZM2O9"
)

client := ocr.NewOCRClient(APIKEY, APISECRET)

  • 通用文字识别

rs, err := client.GeneralRecognizeBasic(
    ocr.MustFromFile("ocr.jpg"),
    ocr.DetectDirection(),       //是否检测图像朝向,默认不检测
    ocr.DetectLanguage(),        //是否检测语言,默认不检测。
    ocr.LanguageType("CHN_ENG"), //识别语言类型,默认为CHN_ENG。
    ocr.WithProbability(),       //是否返回识别结果中每一行的置信度
)
if err != nil {
    panic(err)
}

fmt.Println(rs.ToString())

  • 通用文字识别(高精度版)
resp, err := client.GeneralRecognizeEnhanced(
		ocr.MustFromFile("ocr.jpg"),
		ocr.DetectDirection(),
		ocr.DetectLanguage(),
		ocr.LanguageType("CHN_ENG"),
	)
	if err != nil {
		panic(err)
	}
	fmt.Println(resp.ToString())

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

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