ocr

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 6, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AliyunClient

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

func NewAliyunClient

func NewAliyunClient(c AliyunConf) *AliyunClient

func (*AliyunClient) OCRText

func (a *AliyunClient) OCRText(imgBase64 string) (string, error)

type AliyunConf

type AliyunConf struct {
	AppCode  string `json:"appcode"`
	Endpoint string `json:"endpoint"`
}

type BaiduClient

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

func NewBaiduClient

func NewBaiduClient(conf BaiduConf) *BaiduClient

func (*BaiduClient) OCRText

func (b *BaiduClient) OCRText(imgBase64 string) (string, error)

type BaiduConf

type BaiduConf struct {
	AK       string `json:"ak"`
	SK       string `json:"sk"`
	TokenURL string `json:"token_url"`
	OCRURL   string `json:"ocr_url"`
}

type Client

type Client interface {
	OCRText(imgBase64 string) (string, error)
}

type OcrServiceProvider

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

func (*OcrServiceProvider) Boot

func (i *OcrServiceProvider) Boot()

func (*OcrServiceProvider) Conf added in v1.3.0

func (i *OcrServiceProvider) Conf() map[string]string

func (*OcrServiceProvider) Description added in v1.3.0

func (i *OcrServiceProvider) Description() string

func (*OcrServiceProvider) Register

func (i *OcrServiceProvider) Register()

type Options

type Options struct {
	Provider string      `json:"provider"`
	Baidu    BaiduConf   `json:"baidu"`
	Aliyun   AliyunConf  `json:"aliyun"`
	Tencent  TencentConf `json:"tencent"`
}

type Service

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

func NewService

func NewService(c Client) *Service

func (*Service) OCRText

func (s *Service) OCRText(imgBytes []byte) (string, error)

func (*Service) OCRTextFromFile

func (s *Service) OCRTextFromFile(path string) (string, error)

type TencentClient

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

func NewTencentClient

func NewTencentClient(c TencentConf) *TencentClient

func (*TencentClient) OCRText

func (t *TencentClient) OCRText(imgBase64 string) (string, error)

type TencentConf

type TencentConf struct {
	SecretID  string `json:"secret_id"`
	SecretKey string `json:"secret_key"`
	Region    string `json:"region"`
	Version   string `json:"version"`
}

Jump to

Keyboard shortcuts

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