上次使用QRCode.js可以来生成二维码,但是我没有找到有文档说明可以对存在的二维码进行扫描解析其中的内容。

幸亏查找到了可行的解决方案,而且很好使哦!就是reqrcode.js

地址:https://gitee.com/weijunw/erweima/tree/master

 reqrcode.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
,)),ne
w _a2(
)),n
ew _a2(,
){return new _ae(c-d,b-c,d,m-p
,k-m,p,,d+k);var e=new _ak(this.image,h,b,i-h,c-b,g,this._am);return e.find()};this.createTransform=function(l,h,k,
b,g){)]};_ax._ci=function(a){var
 b=_ax._cj(a);)}}}}function _dl(a,b){this._dv=a;this._dw=b;this.__defineGetter__("_du",function(){return this._dv});this.__defineGetter__("Codewords",function(){return this._dw})}_dl._gn=function(c,h,r)
{}}}}n^=true}if(m!=o.
_dp){){throw"ReedSolomonException Bad error location"}j[h]=_az._bd(j[
h],e[g])}};;k<l;k++){j=_az._bd(this._fa.multiply(h,j),t
his._dd[k])}){return zero}var h=new Array(j+
);return}else{qrcode.canvas_qr
,i.width,i.height);qrcode.width=i.width;qrcode.height=i.height;try{qrcode
.imagedata=h.getImageData(+qrcod
e.imagedata.data[a+;this._aj=b;this.__defineGetter__("
_ei",function(){return this._aj});this.__defineGetter__("Count",function(){return this.count});this.__defineGetter__("X",function(){return this.x});this.__defineGetter__("Y",function(){return this.y});this._ek=function(){this.count++};this._ev=function(f,e,d){if(Math.abs(e-this.y)<=f&&Math.abs(d-this.x)<=f){var g=Math.abs(f-this._aj);return g<=1||g/this._aj<=1}return false}}function _es(a){this._go=a[0];this._gu=a[1];this._gr=a[2];this.__defineGetter__("_gp",function(){return this._go});this.__defineGetter__("_gq",function(){return this._gu});this.__defineGetter__("_gs",function(){return this._gr})}function _cc(){this.image=null;this._cv=[];this._ge=false;this._al=new Array(0,0,0,0,0);this._am=null;this.__defineGetter__("_da",function(){this._al[0]=0;this._al[1]=0;this._al[2]=0;this._al[3]=0;this._al[4]=0;return this._al});this._ao=function(f){var b=0;for(var d=0;d<5;d++){var e=f[d];if(e==0){return false}b+=e}if(b<7){return false}var c=Math.floor((b<<_el)/7);var a=Math.floor(c/2);return Math.abs(c-(f[0]<<_el))<a&&Math.abs(c-(f[1]<<_el))<a&&Math.abs(3*c-(f[2]<<_el))<3*a&&Math.abs(c-(f[3]<<_el))<a&&Math.abs(c-(f[4]<<_el))<a};this._an=function(b,a){return(a-b[4]-b[3])-b[2]/2};this._ap=function(a,j,d,g){var c=this.image;var h=qrcode.height;var b=this._da;var f=a;while(f>=0&&c[j+f*qrcode.width]){b[2]++;f--}if(f<0){return NaN}while(f>=0&&!c[j+f*qrcode.width]&&b[1]<=d){b[1]++;f--}if(f<0||b[1]>d){return NaN}while(f>=0&&c[j+f*qrcode.width]&&b[0]<=d){b[0]++;f--}if(b[0]>d){return NaN}f=a+1;while(f<h&&c[j+f*qrcode.width]){b[2]++;f++}if(f==h){return NaN}while(f<h&&!c[j+f*qrcode.width]&&b[3]<d){b[3]++;f++}if(f==h||b[3]>=d){return NaN}while(f<h&&c[j+f*qrcode.width]&&b[4]<d){b[4]++;f++}if(b[4]>=d){return NaN}var e=b[0]+b[1]+b[2]+b[3]+b[4];if(5*Math.abs(e-g)>=2*g){return NaN}return this._ao(b)?this._an(b,f):NaN};this._ej=function(b,a,e,h){var d=this.image;var i=qrcode.width;var c=this._da;var g=b;while(g>=0&&d[g+a*qrcode.width]){c[2]++;g--}if(g<0){return NaN}while(g>=0&&!d[g+a*qrcode.width]&&c[1]<=e){c[1]++;g--}if(g<0||c[1]>e){r
*c};this._ce=function(e){var o=false;this.image=e;var n=qrcode.height;var k=qrcode.
width;
]+l[}else{return
 ;i<m.length;i++){k[i]=m.charCodeAt(i)}h.push(k);break;case d:var n=this.get8bitByteArray(g);h.push(n);break;case o:var m=this.getKanjiString(g);h.push(m);break}}while(true);return h})};
 
解析实例:

 qrcodeRD.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
 
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>QRCode Reader</title>
    <script src="jquery.min.js"></script>
    <script src="reqrcode.js"></script>
</head>

<body>
    <input type="file" id="newfile">
</body>

<script>
    var newfile = document.getElementById('newfile');
    var getObjectURL = function (file) {
        var url = null;
        if (window.createObjectURL != undefined) {          // basic
          url = window.createObjectURL(file);
        } else if (window.URL != undefined) {               // mozilla(firefox)
        url = window.URL.createObjectURL(file);
        } else if (window.webkitURL != undefined) {         // webkit or chrome
          url = window.webkitURL.createObjectURL(file);
        }
        return url;
    }

newfile.onchange = function () {
        //   console.log(newfile[0]);
        console.log(getObjectURL(this.files[0]));           // newfile[0]是通过input file上传的二维码图片文件
        qrcode.decode(getObjectURL(this.files[0]));
        qrcode.callback = function (imgMsg) {
            alert("二维码解析:" + imgMsg)
        }
    }
</script>

</html>

运行

注意:reqrcode.js格式是不是不好看,但是格式化后就不好使了  ~

二维码解析:使用 JavaScript 库reqrcode.js解析二维码的更多相关文章

  1. 二维码生成:使用 JavaScript 库QRCode.js生成二维码

    QRCode.js:跨浏览器的javascript二维码生成库,支持html5的Canvas画布,没有任何依赖. Github 地址:https://github.com/davidshimjs/qr ...

  2. 使用医学影像开源库cornerstone.js解析Dicom图像显示到HTML中

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. HTML5 Canvas JavaScript库 Fabric.js 使用经验

    首先,表明我的态度:采用 Flash 才是最优方案,不建议使用 HTML 5 的 Canvas 做一些生产/工业级的网页应用. Flash的优势一是浏览器支持好,二是代码成熟稳定.而HTML5 的 C ...

  4. 网页3D效果库Three.js学习[二]-了解照相机

    camera 上篇大致了解了three.js ,并可以创建一个简单的可动的立方体.下来我们着重了解下camera (照相机),照相机其实就是视角,就像你的眼睛.Three.js有两种不同的相机模式:直 ...

  5. 一个用于格式化和处理数字的javascript库----Numeral.js

    npm地址:https://www.npmjs.com/package/numeral 1.转化成百分比: numeral(num).format('0.00%')

  6. 脸部识别JavaScript类库Tracking.js

    作者 王文刚 发布于 2014年8月10日 |   对Web开发者而言,开源的JavaScript库Tracking.js正在使计算机视觉和增强现实技术变得简单, 使用它可以展示效果类似Kinect或 ...

  7. QRCode.js一个生成二维码的javascript库

    前言 最近在开发中遇到一个需求:将后端返回的链接转换成二维码,那么如何来实现呢?我们可以使用QRCode.js来解决这一问题 什么是 QRCode.js? QRCode.js 是一个用于生成二维码的 ...

  8. 你不可错过的二维码生成与解析-java后台与前端js都有

    1.二维码分类   二维条码也有许多不同的码制,就码制的编码原理而言,通常分为三种类型. 线性堆叠式二维码 编码原理: 建立在一维条码基础之上,按需要堆积成两行或多行. 图示: 矩阵式二维码 最常用编 ...

  9. QRCode.js生成二维码

    QRCode的GitHub地址: https://github.com/KeeeX/qrcodejs 该版本解决了主版本(https://github.com/davidshimjs/qrcodejs ...

随机推荐

  1. cacti监控jvm

    jdk环境 java version "1.6.0_37" Java(TM) SE Runtime Environment (build 1.6.0_37-b06) Java Ho ...

  2. WPF样式继承

    场景:样式A和样式B的背景颜色一样,但是文字颜色不一样 <Style x:key="BaseStyle" TargetType="Button"> ...

  3. Linux 下编译出现 undefined reference to `pthread_create'

    这是由于没有链接线程库的原因,只要在编译的时候加入: -lpthread 参数即可. arm-linux-gcc serial.c -o serial -lpthread 查看 ubuntu 版本的命 ...

  4. iis7.5 发布mvc出错的解决办法

    发布mvc,配置iis7.5时,遇到这个错误. xxxx'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b ...

  5. iphone微信 h5页音乐自动播放

    iphone微信 h5页音乐自动播放: // iphone自动播放 document.addEventListener("WeixinJSBridgeReady", functio ...

  6. popupWindow使用timePicker时点击出现闪屏问题的解决办法

    记录一下刚解决的新鲜bug,噔噔噔噔: 首先说明,我并不知道到底是什么原理导致和解决的问题 总之就是,我在使用popupWindow时的弹出方法使用的是popupWindow.showAsDropDo ...

  7. MYSQL查询前30条数据

    , LIMIT 接受一个或两个数字参数. 参数必须是一个整数常量. 如果给定两个参数,第一个参数指定第一个返回记录行的偏移量, 第二个参数指定返回记录行的最大数目. 初始记录行的偏移量是 (而不是 )

  8. mxnet与tensorflow的卷积实现细节比较

    mxnet的卷积 kernel = 3  pad=1边界补充0后,不管stride是否1还是2,imgw = 奇数或者偶数, 都是从图像位置(0,0)开始卷积 tensorlfow的卷积 kernel ...

  9. Aizu_Insertion Sort

    原题链接:https://vjudge.net/problem/Aizu-ALDS1_1_A 题目描述 Write a program of the Insertion Sort algorithm ...

  10. 第三百四十六节,Python分布式爬虫打造搜索引擎Scrapy精讲—Requests请求和Response响应介绍

    第三百四十六节,Python分布式爬虫打造搜索引擎Scrapy精讲—Requests请求和Response响应介绍 Requests请求 Requests请求就是我们在爬虫文件写的Requests() ...