小程序使用OCR识别身份证

 

 

 

第一步 需要先添加插件 

 

购买页面

https://developers.weixin.qq.com/community/servicemarket/detail/000ce4cec24ca026d37900ed551415

可以选择免费的  收费的自己选择吧

然后需要在自己的小程序上面设置 

1打开设置

2第三方设置

3添加插件 搜索ocr 或者 wx4418e3e031e551be

这个步骤完成之后 就是在页面写代码了

首先在app.json 中添加 这个就是插件的意思 版本可以选择最新版本的 但是我没找到版本号

  "plugins": {
    "ocr-plugin": {
      "version": "3.0.2",
      "provider": "wx4418e3e031e551be"
    }
  },

然后在当前页面的json文件中添加下边的 代码

  "usingComponents": {
    "ocr-navigator": "plugin://ocr-plugin/ocr-navigator"
  },

wxml 页面代码 调用识别的函数 载体为button 

   <ocr-navigator bind:onSuccess="success" certificateType="idCard" opposite="{{false}}">
      <button type="primary">身份证正面识别</button>
    </ocr-navigator>
    <ocr-navigator bind:onSuccess="success" certificateType="idCard" opposite="{{true}}">
      <button type="primary">身份证反面识别</button>
    </ocr-navigator>

js 页面的代码 

  success: function (e) {
    console.log(e)
  }

 直接就可以输出身份证 识别后的信息 

 

  • 0
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
http://blog.csdn.net/xiaoxiao108/article/details/7226120 前些天,12306这个网站挺火的,看到网上出现了各种各样的登陆、订票插件跟程序。虽然没经历过春运,看到网上各种各样的插件跟工具挺有意思的,下载了几个看了看,都挺不错的。印象中有个java版本的订票程序里面有个验证码识别功能,用tesseract-ocr识别验证码的,如果验证码不是很复杂识别效果还可以。 开发环境 vs2008 开发语言C# 使用方法很简单 1.下载tesseract 的.net 类库tessnet2_32.dll ,添加引用。 http://www.pixel-technology.com/freeware/tessnet2/ 2.下载tesseract 相对应的语言包。 http://code.google.com/p/tesseract-ocr/downloads/list 3.调用tesseract 的方法进行识别。 具体代码 1.读取网上的验证码到pictureBox中 //string url = "https://dynamic.12306.cn/otsweb/passCodeAction.do?rand=lrand"; string url = "http://static.baixing.net/pages/mobile.php?c=bcqsFelX+vKQcrnIbhyDYQ==/2.jpg"; HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest; HttpWebResponse response = request.GetResponse() as HttpWebResponse; System.IO.Stream responseStream = response.GetResponseStream(); this.pictureBox1.Image = Image.FromStream(responseStream); 2.OCR类 public class Ocr { public void DumpResult(List result) { foreach (tessnet2.Word word in result) //Console.WriteLine("{0} : {1}", word.Confidence, word.Text); MessageBox.Show(string.Format("{0} : {1}", word.Confidence, word.Text)); } public List DoOCRNormal(Bitmap image, string lang) { tessnet2.Tesseract ocr = new tessnet2.Tesseract(); ocr.Init(null, lang, false); List result = ocr.DoOCR(image, Rectangle.Empty); DumpResult(result); return result; } System.Threading.ManualResetEvent m_event; public void DoOCRMultiThred(Bitmap image, string lang) { tessnet2.Tesseract ocr = new tessnet2.Tesseract(); ocr.Init(null, lang, false); // If the Oc
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值