Skip to content

PhilipTang/aliyun-id-ocr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

aliyun-id-ocr

阿里云身份证 OCR 介绍

  • 链接地址: 印刷文字识别-身份证识别
  • 调用方式: 上传图片的 base64 编码值
  • 接口速度: 主要取决于图片大小,一般2M以内响应比较及时,超过2M可能会超时,返回 HTTP 状态码 408

使用方法

添加自己的产品密钥

vi idocr.go
// TODO 修改此处,使用配置文件
const APPCODE = "hehe"

类结构

package
    idocr

▼ imports
    crypto/tls
    encoding/base64
    encoding/json
    errors
    fmt
    github.com/golang/glog
    io/ioutil
    net/http
    stringsconstants
   +APPCODE+IDOCR : struct
    [fields]
   +Address : string
   +Birth : string
   +EndDate : string
   +Issue : string
   +Name : string
   +Nationality : string
   +Num : string
   +Sex : string
   +StartDate : string
    [methods]
   +Back(base64img string) : error
   +Face(base64img string) : error
   -formatResult(input string) : aliDataValue, error
   -post(img, face string) : string, error
    [functions]
   +GetIDCard(faceUrl, backUrl string) : IDOCR, error
   -getIDCardOCR(imgFace, imgBack string) : IDOCR, error-aliDataValue : struct
    [fields]
   +RequestId : string
   +Success : bool
    [embedded]
   +IDOCR : IDOCR-aliDetail : struct
    [fields]
   +OutputLabel : string
   +OutputValue : aliOutputValue-aliOutputValue : struct
    [fields]
   +DataValue : string-aliResult : struct
    [fields]
   +Outputs : []aliDetailfunctions
   -getAndBase64(url string) : string, error
   -getIDCardImg(faceUrl, backUrl string) : string, string, error

测试效果

 go test -v                                                                                                                                                                                146=== RUN   TestFace
 --- PASS: TestFace (2.42s)
 === RUN   TestBack
 --- PASS: TestBack (1.02s)
 === RUN   TestGet
 --- PASS: TestGet (2.52s)
 === RUN   TestGetIDCard
 --- PASS: TestGetIDCard (5.87s)
 === RUN   TestFormatResult
 --- PASS: TestFormatResult (0.00s)
 PASS
 ok  	_/Users/philiptang/Code/aliyun-id-ocr	11.855s

详细打印

go test -v -stderrthreshold=INFO

About

基于阿里云接口的身份证OCR工具包

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages