Mobile Scan ID for obtaining identity card information.

Source: Internet
Author: User

Mobile scan ID for ID card information (front-end section)
Recently made a scan of the identity of the function of the following several steps

1: Use h5+ to call the phone camera

if (window.plus) {Playcamera ();} else{Document.addeventlistener ("Plusready", Playcamera (), false);

Call camera to take pictures:

Playcamera:function () {var _self=ext.getcmp ("Add_client_view");   var CMR = Plus.camera.getCamera ();   var res = Cmr.supportedimageresolutions[0];var FMT = cmr.supportedimageformats[0];cmr.captureimage (path) {_ Self. Getbase64code (path);},function (Error) {alert ("Capture image failed:" + error.message);}   ,

2: Convert acquired images to base64 format data

There are 2 ways to convert base64 format photos here:
(1): Use H5 FileReader according to the picture Road to convert to Base64 format picture;

Convert the picture to Base64 format   img2dataurl:function (path) {   Plus.io.resolveLocalFileSystemURL (path, function (entry) {        entry.file (function (file) {        debugger            var reader = new Plus.io.FileReader ();            Reader.onload = function (e) {            imgbase64=e.target.result;                Console.log ("* * * *" +e.target.result);            };            Reader.readasdataurl (file)        ,},function (e) {           ext.toast ("Read and write exception:" + E.message)        ,})   },

  

(2): Use bitmap native Picture object provided by h5+
Please see here Http://www.html5plus.org/doc/zh_cn/nativeobj.html#plus.nativeObj.Bitmap the concrete method;
With detailed instructions

Getbase64code:function (path) {   var bitmap = new Plus.nativeObj.Bitmap ("xxx");   Load bitmap picture from local to convert picture to base64 format        bitmap.load (Path,function () {            var base4=bitmap.tobase64data ();            var datastr=base4.split (', ', 3);//intercept the useless prefix            var imgbase64 = [];            if (datastr.length>1)            {               imgbase64.push (datastr[1]);            } else            {               imgbase64.push (datastr[0]);            }            Console.log (imgbase64);            var traceno=utils.gentrn ();//serial number//Then send Ajax request        },function (e) {            console.log (' Load picture failed: ' +json.stringify (e) );        });   },

  

(3) Call Ali identity card Scan information interface, obtain identity card information;

Mobile Scan ID for obtaining identity card information.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.