Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/philiptang/aliyun-id-ocr

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/philiptang/aliyun-id-ocr

  • v0.0.0-20170715145302-89b14bc96a57
  • Source
  • Go
  • Socket score

Version published
Created
Source

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
    strings

▼ constants
   +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 : []aliDetail

▼ functions
   -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

FAQs

Package last updated on 15 Jul 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc