ocr

package
v0.0.0-...-7540414 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BAIDU_TOKEN_URL          = "https://aip.baidubce.com/oauth/2.0/token?grant_type=client_credentials&client_id=%s&client_secret=%s"
	BAIDU_OCR_URL            = "https://aip.baidubce.com/rest/2.0/ocr/v1/%s"
	BAIDU_idcardUrl          = "https://aip.baidubce.com/rest/2.0/ocr/v1/idcard"
	BAIDU_bankcardUrl        = "https://aip.baidubce.com/rest/2.0/ocr/v1/bankcard"
	BAIDU_generalUrl         = "https://aip.baidubce.com/rest/2.0/ocr/v1/general"
	BAIDU_basicGeneralUrl    = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic"
	BAIDU_webImageUrl        = "https://aip.baidubce.com/rest/2.0/ocr/v1/webimage"
	BAIDU_enhancedGeneralUrl = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_enhanced"
	BAIDU_drivingLicenseUrl  = "https://aip.baidubce.com/rest/2.0/ocr/v1/driving_license"
	BAIDU_vehicleLicenseUrl  = "https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_license"
	BAIDU_tableRequestUrl    = "https://aip.baidubce.com/rest/2.0/solution/v1/form_ocr/request"
	BAIDU_tableResultUrl     = "https://aip.baidubce.com/rest/2.0/solution/v1/form_ocr/get_request_result"
	BAIDU_licensePlateUrl    = "https://aip.baidubce.com/rest/2.0/ocr/v1/license_plate"
	BAIDU_accurateUrl        = "https://aip.baidubce.com/rest/2.0/ocr/v1/accurate"
	BAIDU_basicAccurateUrl   = "https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic"
	BAIDU_receiptUrl         = "https://aip.baidubce.com/rest/2.0/ocr/v1/receipt"
	BAIDU_businessLicenseUrl = "https://aip.baidubce.com/rest/2.0/ocr/v1/business_license"
	MAX_SIZE                 = 4 * 1024 * 1024
)

Variables

View Source
var (
	IMAGE_FORMATS = []string{"JPEG", "BMP", "PNG"}
)

Functions

This section is empty.

Types

type BaiduAccessToken

type BaiduAccessToken struct {
	BaiduErrorMessage
	Expires       int64  `json:"expires_in"` //过期时间,单位秒。一般为1个月)
	Scope         string `json:"scope"`
	SessionKey    string `json:"session_key"`
	SessionSecret string `json:"session_secret"`
	AccessToken   string `json:"access_token"` //要获取的Access Token;
	RefreshToken  string `json:"refresh_token"`
}

type BaiduErrorMessage

type BaiduErrorMessage struct {
	Code string `json:"error"`
	Msg  string `json:"error_description"`
}

type BaiduOcr

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

func (*BaiduOcr) Init

func (this *BaiduOcr) Init(sdk *BaiduSdk)

func (*BaiduOcr) LoadImageToByte

func (this *BaiduOcr) LoadImageToByte(path string) ([]byte, error)

从文件中加载图片内容,对于不符合的格式,和大小进行检查

func (*BaiduOcr) RecognizedBankCard

func (this *BaiduOcr) RecognizedBankCard(card *BaseImageQuery) BankCardResult

识别银行卡

func (*BaiduOcr) RecognizedBusiness

func (this *BaiduOcr) RecognizedBusiness(card *BaseImageQuery) BusinessLicenseResult

识别营业执照

func (*BaiduOcr) RecognizedCarNo

func (this *BaiduOcr) RecognizedCarNo(card *CarNoQuery) CarNoResult

识别车牌号码

func (*BaiduOcr) RecognizedIdCard

func (this *BaiduOcr) RecognizedIdCard(card *IdCardQuery) IdCardResult

识别身份证

type BaiduSdk

type BaiduSdk struct {
	AppId     string
	AppKey    string
	AppSecret string
	Token     *BaiduAccessToken
}

func (*BaiduSdk) Call

func (this *BaiduSdk) Call(theUrl string, p baiduQuery, result interface{})

type BankCard

type BankCard struct {
	CardNo   string //银行卡卡号
	CardType int32  //银行卡类型,0:不能识别; 1: 借记卡; 2: 信用卡
	BankName string //银行名,不能识别时为空
}

type BankCardResult

type BankCardResult struct {
	Result BankCard `json:"result"`
	// contains filtered or unexported fields
}

银行卡识别结果

type BaseImageQuery

type BaseImageQuery struct {
	Image []byte
}

type BusinessLicenseResult

type BusinessLicenseResult struct {
	Result map[string]RecognizeItem `json:"words_result"`     //识别结果
	Count  int32                    `json:"words_result_num"` // 识别结果数,表示words_result的元素个数
	// contains filtered or unexported fields
}

营业执照

type CarNo

type CarNo struct {
	Color  string `json:"color"`  //车牌颜色
	Number string `json:"number"` //车牌号码
}

type CarNoMutiResult

type CarNoMutiResult struct {
	Result []CarNo `json:"words_result"`
	// contains filtered or unexported fields
}

type CarNoQuery

type CarNoQuery struct {
	Image []byte
	Multi bool //是否是多张一起检测
}

车牌识别

type CarNoResult

type CarNoResult struct {
	Result CarNo `json:"words_result"`
	Array  []CarNo
	// contains filtered or unexported fields
}

type IdCardQuery

type IdCardQuery struct {
	Detect bool //true、false	是否检测图像朝向,默认不检测
	Front  bool //true 表示front身份证正面;back:身份证背面
	Image  []byte
	Risk   bool //是否开启身份证风险检测
}

type IdCardResult

type IdCardResult struct {
	Direction int32  `json:"direction"`    //图像方向,当detect_direction=true时存在。-1:未定义,0:正向,1: 逆时针90度,2:逆时针180度,3:逆时针270度
	Status    string `json:"image_status"` //normal-识别正常reversed_side-未摆正身份证non_idcard-上传的图片中不包含身份证blurred-身份证模糊over_exposure-身份证关键字段反光或过曝unknown-未知状态
	Risk      string `json:"idcard_type"`  //则返回该字段识别身份证类型: normal-正常身份证;copy-复印件;temporary-临时身份证;screen-翻拍;unknow-其他未知情况
	EditTool  string `json:"edit_tool"`    //如果检测身份证被编辑过,该字段指定编辑软件名称,如:Adobe Photoshop CC 2014 (Macintosh),如果没有被编辑过则返回值无此参数

	Result map[string]RecognizeItem `json:"words_result"`     //识别结果
	Count  int32                    `json:"words_result_num"` // 识别结果数,表示words_result的元素个数
	// contains filtered or unexported fields
}

身份证识别结果

type Image_location

type Image_location struct {
	Left   int64 `json:"left"`
	Top    int64 `json:"top"`
	Width  int64 `json:"width"`
	Height int64 `json:"height"`
}

type Parameter

type Parameter map[string]string

func BuildParameter

func BuildParameter() Parameter

type RecognizeItem

type RecognizeItem struct {
	Location Image_location `json:"location"`

	Text string `json:"words"`
}

Jump to

Keyboard shortcuts

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