Documentation ¶
Index ¶
- Constants
- Variables
- type BaiduAccessToken
- type BaiduErrorMessage
- type BaiduOcr
- func (this *BaiduOcr) Init(sdk *BaiduSdk)
- func (this *BaiduOcr) LoadImageToByte(path string) ([]byte, error)
- func (this *BaiduOcr) RecognizedBankCard(card *BaseImageQuery) BankCardResult
- func (this *BaiduOcr) RecognizedBusiness(card *BaseImageQuery) BusinessLicenseResult
- func (this *BaiduOcr) RecognizedCarNo(card *CarNoQuery) CarNoResult
- func (this *BaiduOcr) RecognizedIdCard(card *IdCardQuery) IdCardResult
- type BaiduSdk
- type BankCard
- type BankCardResult
- type BaseImageQuery
- type BusinessLicenseResult
- type CarNo
- type CarNoMutiResult
- type CarNoQuery
- type CarNoResult
- type IdCardQuery
- type IdCardResult
- type Image_location
- type Parameter
- type RecognizeItem
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 BaiduOcr ¶
type BaiduOcr struct {
// contains filtered or unexported fields
}
func (*BaiduOcr) LoadImageToByte ¶
从文件中加载图片内容,对于不符合的格式,和大小进行检查
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 }
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 CarNoMutiResult ¶
type CarNoMutiResult struct { Result []CarNo `json:"words_result"` // contains filtered or unexported fields }
type CarNoResult ¶
type IdCardQuery ¶
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 Parameter ¶
func BuildParameter ¶
func BuildParameter() Parameter
type RecognizeItem ¶
type RecognizeItem struct { Location Image_location `json:"location"` Text string `json:"words"` }
Click to show internal directories.
Click to hide internal directories.