From db6e0e863277e14d7fc8614533b6b9dc8f7fb011 Mon Sep 17 00:00:00 2001 From: Christoph Oberhofer Date: Sun, 31 Jul 2016 15:57:43 +0200 Subject: [PATCH] Added scan-to-input example --- stylesheets/example.css | 95 +- stylesheets/prism.css | 139 +++ v1.0.0-beta.1/examples/js/prism.js | 7 + v1.0.0-beta.1/examples/js/quagga.js | 1 + v1.0.0-beta.1/examples/js/quagga.min.js | 2 +- .../examples/scan-to-input/index.html | 136 +++ v1.0.0-beta.1/examples/scan-to-input/index.js | 81 ++ v1.0.0-beta.1/index.md | 826 ++++++++++++++++++ 8 files changed, 1270 insertions(+), 17 deletions(-) create mode 100644 stylesheets/prism.css create mode 100644 v1.0.0-beta.1/examples/js/prism.js create mode 100644 v1.0.0-beta.1/examples/scan-to-input/index.html create mode 100644 v1.0.0-beta.1/examples/scan-to-input/index.js create mode 100644 v1.0.0-beta.1/index.md diff --git a/stylesheets/example.css b/stylesheets/example.css index 5856460..c64a6d3 100644 --- a/stylesheets/example.css +++ b/stylesheets/example.css @@ -1,20 +1,83 @@ @charset "UTF-8"; -/* usual styles */ -/* LESS - http://lesscss.org style sheet */ -/* Palette color codes */ -/* Palette URL: http://paletton.com/#uid=31g0q0kHZAviRSkrHLOGomVNzac */ -/* Feel free to copy&paste color codes to your application */ -/* MIXINS */ -/* As hex codes */ -/* Main Primary color */ -/* Main Secondary color (1) */ -/* Main Secondary color (2) */ -/* As RGBa codes */ -/* Main Primary color */ -/* Main Secondary color (1) */ -/* Main Secondary color (2) */ -/* Generated by Paletton.com ├é┬® 2002-2014 */ -/* http://paletton.com */ + +.collapsable-source pre { + font-size: small; +} + +.input-field { + display: flex; + align-items: center; + width: 260px; +} + +.input-field label { + flex: 0 0 auto; + padding-right: 0.5rem; +} + +.input-field input { + flex: 1 1 auto; + height: 20px; +} + +.input-field button { + flex: 0 0 auto; + height: 28px; + font-size: 20px; + width: 40px; +} + +.overlay { + overflow: hidden; + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + width: 100%; + background-color: rgba(0, 0, 0, 0.3); +} + +.overlay__content { + top: 50%; + position: absolute; + left: 50%; + transform: translate(-50%, -50%); + width: 90%; + max-height: 90%; +} + +.overlay__close { + position: absolute; + right: 0; + padding: 0.5rem; + width: 2rem; + height: 2rem; + line-height: 2rem; + text-align: center; + background-color: white; + cursor: pointer; + border: 3px solid black; + font-size: 1.5rem; + margin: -1rem; + border-radius: 2rem; + z-index: 100; + box-sizing: content-box; +} + +.overlay__content video { + width: 100%; + height: 100%; +} + +.overlay__content canvas { + position: absolute; + width: 100%; + height: 100%; + left: 0; + top: 0; +} + /* line 1, ../sass/_viewport.scss */ #interactive.viewport { width: 640px; diff --git a/stylesheets/prism.css b/stylesheets/prism.css new file mode 100644 index 0000000..367f3eb --- /dev/null +++ b/stylesheets/prism.css @@ -0,0 +1,139 @@ +/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+jsx */ +/** + * prism.js default theme for JavaScript, CSS and HTML + * Based on dabblet (http://dabblet.com) + * @author Lea Verou + */ + +code[class*="language-"], +pre[class*="language-"] { + color: black; + background: none; + text-shadow: 0 1px white; + font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace; + text-align: left; + white-space: pre; + word-spacing: normal; + word-break: normal; + word-wrap: normal; + line-height: 1.5; + + -moz-tab-size: 4; + -o-tab-size: 4; + tab-size: 4; + + -webkit-hyphens: none; + -moz-hyphens: none; + -ms-hyphens: none; + hyphens: none; +} + +pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection, +code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection { + text-shadow: none; + background: #b3d4fc; +} + +pre[class*="language-"]::selection, pre[class*="language-"] ::selection, +code[class*="language-"]::selection, code[class*="language-"] ::selection { + text-shadow: none; + background: #b3d4fc; +} + +@media print { + code[class*="language-"], + pre[class*="language-"] { + text-shadow: none; + } +} + +/* Code blocks */ +pre[class*="language-"] { + padding: 1em; + margin: .5em 0; + overflow: auto; +} + +:not(pre) > code[class*="language-"], +pre[class*="language-"] { + background: #f5f2f0; +} + +/* Inline code */ +:not(pre) > code[class*="language-"] { + padding: .1em; + border-radius: .3em; + white-space: normal; +} + +.token.comment, +.token.prolog, +.token.doctype, +.token.cdata { + color: slategray; +} + +.token.punctuation { + color: #999; +} + +.namespace { + opacity: .7; +} + +.token.property, +.token.tag, +.token.boolean, +.token.number, +.token.constant, +.token.symbol, +.token.deleted { + color: #905; +} + +.token.selector, +.token.attr-name, +.token.string, +.token.char, +.token.builtin, +.token.inserted { + color: #690; +} + +.token.operator, +.token.entity, +.token.url, +.language-css .token.string, +.style .token.string { + color: #a67f59; + background: hsla(0, 0%, 100%, .5); +} + +.token.atrule, +.token.attr-value, +.token.keyword { + color: #07a; +} + +.token.function { + color: #DD4A68; +} + +.token.regex, +.token.important, +.token.variable { + color: #e90; +} + +.token.important, +.token.bold { + font-weight: bold; +} +.token.italic { + font-style: italic; +} + +.token.entity { + cursor: help; +} + diff --git a/v1.0.0-beta.1/examples/js/prism.js b/v1.0.0-beta.1/examples/js/prism.js new file mode 100644 index 0000000..f9238c4 --- /dev/null +++ b/v1.0.0-beta.1/examples/js/prism.js @@ -0,0 +1,7 @@ +/* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+jsx */ +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(\w+)\b/i,t=0,n=_self.Prism={util:{encode:function(e){return e instanceof a?new a(e.type,n.util.encode(e.content),e.alias):"Array"===n.util.type(e)?e.map(n.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(m instanceof a)){u.lastIndex=0;var y=u.exec(m),v=1;if(!y&&h&&p!=r.length-1){var b=r[p+1].matchedStr||r[p+1],k=m+b;if(p=m.length)continue;var _=y.index+y[0].length,P=m.length+b.length;if(v=3,P>=_){if(r[p+1].greedy)continue;v=2,k=k.slice(0,P)}m=k}if(y){g&&(f=y[1].length);var w=y.index+f,y=y[0].slice(f),_=w+y.length,S=m.slice(0,w),O=m.slice(_),j=[p,v];S&&j.push(S);var A=new a(i,c?n.tokenize(y,c):y,d,y,h);j.push(A),O&&j.push(O),Array.prototype.splice.apply(r,j)}}}}}return r},hooks:{all:{},add:function(e,t){var a=n.hooks.all;a[e]=a[e]||[],a[e].push(t)},run:function(e,t){var a=n.hooks.all[e];if(a&&a.length)for(var r,l=0;r=a[l++];)r(t)}}},a=n.Token=function(e,t,n,a,r){this.type=e,this.content=t,this.alias=n,this.matchedStr=a||null,this.greedy=!!r};if(a.stringify=function(e,t,r){if("string"==typeof e)return e;if("Array"===n.util.type(e))return e.map(function(n){return a.stringify(n,t,e)}).join("");var l={type:e.type,content:a.stringify(e.content,t,r),tag:"span",classes:["token",e.type],attributes:{},language:t,parent:r};if("comment"==l.type&&(l.attributes.spellcheck="true"),e.alias){var i="Array"===n.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(l.classes,i)}n.hooks.run("wrap",l);var o="";for(var s in l.attributes)o+=(o?" ":"")+s+'="'+(l.attributes[s]||"")+'"';return"<"+l.tag+' class="'+l.classes.join(" ")+'" '+o+">"+l.content+""},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var t=JSON.parse(e.data),a=t.language,r=t.code,l=t.immediateClose;_self.postMessage(n.highlight(r,n.languages[a],a)),l&&_self.close()},!1),_self.Prism):_self.Prism;var r=document.currentScript||[].slice.call(document.getElementsByTagName("script")).pop();return r&&(n.filename=r.src,document.addEventListener&&!r.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",n.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); +Prism.languages.markup={comment://,prolog:/<\?[\w\W]+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?(?!\d)[^\s>\/=.$<]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.hooks.add("wrap",function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&/,"&"))}),Prism.languages.xml=Prism.languages.markup,Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup; +Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{rule:/@[\w-]+/}},url:/url\((?:(["'])(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*?(?=\s*\{)/,string:/("|')(\\(?:\r\n|[\w\W])|(?!\1)[^\\\r\n])*\1/,property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,"function":/[-a-z0-9]+(?=\()/i,punctuation:/[(){};:]/},Prism.languages.css.atrule.inside.rest=Prism.util.clone(Prism.languages.css),Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/()[\w\W]*?(?=<\/style>)/i,lookbehind:!0,inside:Prism.languages.css,alias:"language-css"}}),Prism.languages.insertBefore("inside","attr-value",{"style-attr":{pattern:/\s*style=("|').*?\1/i,inside:{"attr-name":{pattern:/^\s*style/i,inside:Prism.languages.markup.tag.inside},punctuation:/^\s*=\s*['"]|['"]\s*$/,"attr-value":{pattern:/.+/i,inside:Prism.languages.css}},alias:"language-css"}},Prism.languages.markup.tag)); +Prism.languages.clike={comment:[{pattern:/(^|[^\\])\/\*[\w\W]*?\*\//,lookbehind:!0},{pattern:/(^|[^\\:])\/\/.*/,lookbehind:!0}],string:{pattern:/(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0},"class-name":{pattern:/((?:\b(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/i,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|throw|catch|finally|null|break|continue)\b/,"boolean":/\b(true|false)\b/,"function":/[a-z0-9_]+(?=\()/i,number:/\b-?(?:0x[\da-f]+|\d*\.?\d+(?:e[+-]?\d+)?)\b/i,operator:/--?|\+\+?|!=?=?|<=?|>=?|==?=?|&&?|\|\|?|\?|\*|\/|~|\^|%/,punctuation:/[{}[\];(),.:]/}; +Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(as|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|export|extends|finally|for|from|function|get|if|implements|import|in|instanceof|interface|let|new|null|of|package|private|protected|public|return|set|static|super|switch|this|throw|try|typeof|var|void|while|with|yield)\b/,number:/\b-?(0x[\dA-Fa-f]+|0b[01]+|0o[0-7]+|\d*\.?\d+([Ee][+-]?\d+)?|NaN|Infinity)\b/,"function":/[_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*(?=\()/i}),Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^\/])\/(?!\/)(\[.+?]|\\.|[^\/\\\r\n])+\/[gimyu]{0,5}(?=\s*($|[\r\n,.;})]))/,lookbehind:!0,greedy:!0}}),Prism.languages.insertBefore("javascript","class-name",{"template-string":{pattern:/`(?:\\\\|\\?[^\\])*?`/,greedy:!0,inside:{interpolation:{pattern:/\$\{[^}]+\}/,inside:{"interpolation-punctuation":{pattern:/^\$\{|\}$/,alias:"punctuation"},rest:Prism.languages.javascript}},string:/[\s\S]+/}}}),Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/()[\w\W]*?(?=<\/script>)/i,lookbehind:!0,inside:Prism.languages.javascript,alias:"language-javascript"}}),Prism.languages.js=Prism.languages.javascript; +!function(a){var e=a.util.clone(a.languages.javascript);a.languages.jsx=a.languages.extend("markup",e),a.languages.jsx.tag.pattern=/<\/?[\w\.:-]+\s*(?:\s+[\w\.:-]+(?:=(?:("|')(\\?[\w\W])*?\1|[^\s'">=]+|(\{[\w\W]*?\})))?\s*)*\/?>/i,a.languages.jsx.tag.inside["attr-value"].pattern=/=[^\{](?:('|")[\w\W]*?(\1)|[^\s>]+)/i;var s=a.util.clone(a.languages.jsx);delete s.punctuation,s=a.languages.insertBefore("jsx","operator",{punctuation:/=(?={)|[{}[\];(),.:]/},{jsx:s}),a.languages.insertBefore("inside","attr-value",{script:{pattern:/=(\{(?:\{[^}]*\}|[^}])+\})/i,inside:s,alias:"language-javascript"}},a.languages.jsx.tag)}(Prism); diff --git a/v1.0.0-beta.1/examples/js/quagga.js b/v1.0.0-beta.1/examples/js/quagga.js index a567423..e9c7bb6 100644 --- a/v1.0.0-beta.1/examples/js/quagga.js +++ b/v1.0.0-beta.1/examples/js/quagga.js @@ -4759,6 +4759,7 @@ return /******/ (function(modules) { // webpackBootstrap }, stop: function stop() { scanner.stop(); + initialized = false; return this; }, toPromise: function toPromise() { diff --git a/v1.0.0-beta.1/examples/js/quagga.min.js b/v1.0.0-beta.1/examples/js/quagga.min.js index 0462cfb..781162b 100644 --- a/v1.0.0-beta.1/examples/js/quagga.min.js +++ b/v1.0.0-beta.1/examples/js/quagga.min.js @@ -1,4 +1,4 @@ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(t.toString())["default"]:"object"==typeof exports?exports.Quagga=t(t.toString())["default"]:e.Quagga=t(t.toString())["default"]}(this,function(e){return function(e){function t(r){if(n[r])return n[r].e;var o=n[r]={e:{},i:r,l:!1};return e[r].call(o.e,o,o.e,t),o.l=!0,o.e}var n={};return t.m=e,t.c=n,t.p="/",t(t.s=220)}([function(e,t,n){var r=Array.isArray;e.e=r},function(e,t,n){"use strict";var r=!0,o={disableLog:function(e){return"boolean"!=typeof e?new Error("Argument type: "+typeof e+". Please use a boolean."):(r=e,e?"adapter.js logging disabled":"adapter.js logging enabled")},log:function(){if("object"==typeof window){if(r)return;"undefined"!=typeof console&&"function"==typeof console.log&&console.log.apply(console,arguments)}},extractVersion:function(e,t,n){var r=e.match(t);return r&&r.length>=n&&parseInt(r[n],10)},detectBrowser:function(){var e={};if(e.browser=null,e.version=null,e.minVersion=null,"undefined"==typeof window||!window.navigator)return e.browser="Not a browser.",e;if(navigator.mozGetUserMedia)e.browser="firefox",e.version=this.extractVersion(navigator.userAgent,/Firefox\/([0-9]+)\./,1),e.minVersion=31;else if(navigator.webkitGetUserMedia)if(window.webkitRTCPeerConnection)e.browser="chrome",e.version=this.extractVersion(navigator.userAgent,/Chrom(e|ium)\/([0-9]+)\./,2),e.minVersion=38;else{if(!navigator.userAgent.match(/Version\/(\d+).(\d+)/))return e.browser="Unsupported webkit-based browser with GUM support but no WebRTC support.",e;e.browser="safari",e.version=this.extractVersion(navigator.userAgent,/AppleWebKit\/([0-9]+)\./,1),e.minVersion=602}else{if(!navigator.mediaDevices||!navigator.userAgent.match(/Edge\/(\d+).(\d+)$/))return e.browser="Not a supported browser.",e;e.browser="edge",e.version=this.extractVersion(navigator.userAgent,/Edge\/(\d+).(\d+)$/,2),e.minVersion=10547}return e.versiona.AVG_CODE_ERROR?null:f}s++,i[s]=1,u=!u}return null},r.prototype._findPattern=function(e,t,n,r,o){var i,a,c,u,s=[],f=this,d=0,l={error:Number.MAX_VALUE,code:-1,start:0,end:0};for(t||(t=f._nextSet(f._row)),void 0===n&&(n=!1),void 0===r&&(r=!0),void 0===o&&(o=f.AVG_CODE_ERROR),i=0;i=0&&n._matchRange(e,t.start,0))return t;r=t.end,t=null}},r.prototype._verifyTrailingWhitespace=function(e){var t,n=this;return t=e.end+(e.end-e.start),t=i.CODE_G_START?(e.code=e.code-i.CODE_G_START,a|=1<<5-r):a|=0<<5-r,t.push(e.code),n.push(e)}if(o=i._calculateFirstDigit(a),null===o)return null;if(t.unshift(o),e=i._findPattern(i.MIDDLE_PATTERN,e.end,!0,!1),null===e)return null;for(n.push(e),r=0;r<6;r++){if(e=i._decodeCode(e.end,i.CODE_G_START),!e)return null;n.push(e),t.push(e.code)}return e},r.prototype._decode=function(){var e,t,n=this,r=[],o=[],i={};if(e=n._findStart(),!e)return null;if(t={code:e.code,start:e.start,end:e.end},o.push(t),t=n._decodePayload(t,r,o),!t)return null;if(t=n._findEnd(t.end,!1),!t)return null;if(o.push(t),!n._checksum(r))return null;if(this.supplements.length>0){var a=this._decodeExtensions(t.end);if(!a)return null;var c=a.decodedCodes[a.decodedCodes.length-1],s={start:c.start+((c.end-c.start)/2|0),end:c.end};if(!n._verifyTrailingWhitespace(s))return null;i={supplement:a,code:r.join("")+a.code}}return u({code:r.join(""),start:e.start,end:t.end,codeset:"",startInfo:e,decodedCodes:o},i)},r.prototype._decodeExtensions=function(e){var t,n,r=this._nextSet(this._row,e),o=this._findPattern(this.EXTENSION_START_PATTERN,r,!1,!1);if(null===o)return null;for(t=0;t=0;t-=2)n+=e[t];for(n*=3,t=e.length-1;t>=0;t-=2)n+=e[t];return n%10===0},r.CONFIG_KEYS={supplements:{type:"arrayOf(string)","default":[],description:"Allowed extensions to be decoded (2 and/or 5)"}},t.a=r},function(e,t,n){function r(e,t){var n=i(e,t);return o(n)?n:void 0}var o=n(129),i=n(160);e.e=r},function(e,t,n){function r(e){if("string"==typeof e||o(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}var o=n(28),i=1/0;e.e=r},function(e,t,n){function r(e){var t=s(e);if(!t&&!c(e))return i(e);var n=a(e),r=!!n,f=n||[],d=f.length;for(var l in e)!o(e,l)||r&&("length"==l||u(l,d))||t&&"constructor"==l||f.push(l);return f}var o=n(59),i=n(131),a=n(67),c=n(26),u=n(22),s=n(40);e.e=r},function(e,t,n){var r=n(135),o=n(153),i=o(function(e,t,n){r(e,t,n)});e.e=i},function(e,t,n){t.a={drawRect:function(e,t,n,r){n.strokeStyle=r.color,n.fillStyle=r.color,n.lineWidth=1,n.beginPath(),n.strokeRect(e.x,e.y,t.x,t.y)},drawPath:function(e,t,n,r){n.strokeStyle=r.color,n.fillStyle=r.color,n.lineWidth=r.lineWidth,n.beginPath(),n.moveTo(e[0][t.x],e[0][t.y]);for(var o=1;on)return Number.MAX_VALUE;c+=u}return c/f},r.prototype._nextSet=function(e,t){var n;for(t=t||0,n=t;n1&&(e[n[r]]=o)},r.prototype._matchTrace=function(e,t){var n,r,o=[],i=this,a=i._nextSet(i._row),c=!i._row[a],u=0,s={error:Number.MAX_VALUE,code:-1,start:0};if(e){for(n=0;n=0;r--)t=Math.floor(Math.random()*r),n=e[r],e[r]=e[t],e[t]=n;return e},toPointList:function(e){var t,n,r=[],o=[];for(t=0;t=t&&o.push(e[r]);return o},maxIndex:function(e){var t,n=0;for(t=0;te[n]&&(n=t);return n},max:function r(e){var t,r=0;for(t=0;tr&&(r=e[t]);return r},sum:function o(e){for(var t=e.length,o=0;t--;)o+=e[t];return o}}},function(e,t,n){function r(e){var t=-1,n=e?e.length:0;for(this.clear();++t-1&&e%1==0&&e-1&&e%1==0&&e<=o}var o=9007199254740991;e.e=r},function(e,t,n){function r(e){return"symbol"==typeof e||o(e)&&c.call(e)==i}var o=n(4),i="[object Symbol]",a=Object.prototype,c=a.toString;e.e=r},function(e,t,n){function r(e,t){var n={x:e,y:t,toVec2:function(){return w.clone([this.x,this.y])},toVec3:function(){return C.clone([this.x,this.y,1])},round:function(){return this.x=this.x>0?Math.floor(this.x+.5):Math.floor(this.x-.5),this.y=this.y>0?Math.floor(this.y+.5):Math.floor(this.y-.5),this}};return n}function o(e,t,n){n||(n=e);for(var r=e.data,o=r.length,i=n.data;o--;)i[o]=r[o]>o]++;return a}function a(e,t){function n(e,t){var n,r=0;for(n=e;n<=t;n++)r+=a[n];return r}function r(e,t){var n,r=0;for(n=e;n<=t;n++)r+=n*a[n];return r}function o(){var o,c,u,s,f,d,l,p=[0],h=(1<u)for(i=s[c],i.score=o,i.item=e[r],u=Number.MAX_VALUE,a=0;at[r]?r++:n++;return o}function g(e,t){function n(e){for(var t=0,n=e[Math.floor(e.length/2)];t0&&(n=Math.abs(e[t]-l)>Math.abs(e[t-1]-l)?e[t-1]:e[t]),l/nu[f-1]/u[f]?{x:n,y:n}:null}var r,o=h(t.x),i=h(t.y),a=Math.max(t.x,t.y),c=v(o,i),u=[8,10,15,20,32,60,80],s={"x-small":5,small:4,medium:3,large:2,"x-large":1},f=s[e]||s.medium,d=u[f],l=Math.floor(a/d);return r=n(c),r||(r=n(h(a)),r||(r=n(h(l*d)))),r}function m(e){var t={value:parseFloat(e),unit:(e.indexOf("%")===e.length-1,"%")};return t}function y(e,t,n){var r={width:e,height:t},o=Object.keys(n).reduce(function(e,t){var o=n[t],i=m(o),a=E[t](i,r);return e[t]=a,e},{});return{sx:o.left,sy:o.top,sw:o.right-o.left,sh:o.bottom-o.top}}var b=n(77),_=n(15);t.f=r,t.c=c,t.d=u,t.e=s,t.i=f,t.j=d,t.g=l,t.a=p,t.b=g,t.h=y;var w={clone:n(12)},C={clone:n(108)},E={top:function(e,t){if("%"===e.unit)return Math.floor(t.height*(e.value/100))},right:function(e,t){if("%"===e.unit)return Math.floor(t.width-t.width*(e.value/100))},bottom:function(e,t){if("%"===e.unit)return Math.floor(t.height-t.height*(e.value/100))},left:function(e,t){if("%"===e.unit)return Math.floor(t.width*(e.value/100))}}},function(e,t,n){function r(e,t,n,r){t?this.data=t:n?(this.data=new n(e.x*e.y),n===Array&&r&&a.a.init(this.data,0)):(this.data=new Uint8Array(e.x*e.y),Uint8Array===Array&&r&&a.a.init(this.data,0)),this.size=e}var o=n(80),i=n(29),a=n(15),c={clone:n(12)};r.prototype.inImageWithBorder=function(e,t){return e.x>=t&&e.y>=t&&e.x0&&(a=m[r-1],a.m00+=1,a.m01+=n,a.m10+=t,a.m11+=t*n,a.m02+=o,a.m20+=t*t);for(i=0;i=0?_:-_)+b,a.theta=(180*p/b+90)%180-90,a.theta<0&&(a.theta+=180),a.rad=p>b?p-b:p,a.vec=c.clone([Math.cos(p),Math.sin(p)]),y.push(a));return y},r.prototype.show=function(e,t){var n,r,o,i,a,c,u;for(t||(t=1),n=e.getContext("2d"),e.width=this.size.x,e.height=this.size.y,r=n.getImageData(0,0,e.width,e.height),o=r.data,i=0,u=0;u360)&&(t=360);for(var r=[0,1,1],o=[0,0,0],a=[255,255,255],c=[0,0,0],u=[],s=e.getContext("2d"),f=s.getImageData(n.x,n.y,this.size.x,this.size.y),d=f.data,l=this.data.length;l--;)r[0]=this.data[l]*t,u=r[0]<=0?a:r[0]>=360?c:i.a.bind()(r,o),d[4*l+0]=u[0],d[4*l+1]=u[1],d[4*l+2]=u[2],d[4*l+3]=255;s.putImageData(f,n.x,n.y)},t.a=r},function(e,t,n){function r(e){var t=-1,n=e?e.length:0;for(this.clear();++t=o},r.prototype._patternToChar=function(e){var t,n=this;for(t=0;tt&&(r=e[n]);return r},r.prototype._toPattern=function(e){for(var t,n,r=e.length,o=0,i=r,a=0,c=this;i>3;){for(o=c._findNextWidth(e,o),i=0,t=0,n=0;no&&(t|=1<0;n++)if(e[n]>o&&(i--,2*e[n]>=a))return-1;return t}}return-1},r.prototype._findStart=function(){var e,t,n,r=this,o=r._nextSet(r._row),i=o,a=[0,0,0,0,0,0,0,0,0],c=0,u=!1;for(e=o;e0&&n(f)?t>1?r(f,t-1,n,a,c):o(c,f):a||(c[c.length]=f)}return c}var o=n(34),i=n(171);e.e=r},function(e,t,n){function r(e,t){t=i(t,e)?[t]:o(t);for(var n=0,r=t.length;null!=e&&nd))return!1;var p=s.get(e);if(p)return p==t;var h=-1,v=!0,g=u&a?new o:void 0;for(s.set(e,t);++h=n&&parseInt(r[n],10)},detectBrowser:function(){var e={};if(e.browser=null,e.version=null,e.minVersion=null,"undefined"==typeof window||!window.navigator)return e.browser="Not a browser.",e;if(navigator.mozGetUserMedia)e.browser="firefox",e.version=this.extractVersion(navigator.userAgent,/Firefox\/([0-9]+)\./,1),e.minVersion=31;else if(navigator.webkitGetUserMedia)if(window.webkitRTCPeerConnection)e.browser="chrome",e.version=this.extractVersion(navigator.userAgent,/Chrom(e|ium)\/([0-9]+)\./,2),e.minVersion=38;else{if(!navigator.userAgent.match(/Version\/(\d+).(\d+)/))return e.browser="Unsupported webkit-based browser with GUM support but no WebRTC support.",e;e.browser="safari",e.version=this.extractVersion(navigator.userAgent,/AppleWebKit\/([0-9]+)\./,1),e.minVersion=602}else{if(!navigator.mediaDevices||!navigator.userAgent.match(/Edge\/(\d+).(\d+)$/))return e.browser="Not a supported browser.",e;e.browser="edge",e.version=this.extractVersion(navigator.userAgent,/Edge\/(\d+).(\d+)$/,2),e.minVersion=10547}return e.versiona.AVG_CODE_ERROR?null:f}s++,i[s]=1,u=!u}return null},r.prototype._findPattern=function(e,t,n,r,o){var i,a,c,u,s=[],f=this,d=0,l={error:Number.MAX_VALUE,code:-1,start:0,end:0};for(t||(t=f._nextSet(f._row)),void 0===n&&(n=!1),void 0===r&&(r=!0),void 0===o&&(o=f.AVG_CODE_ERROR),i=0;i=0&&n._matchRange(e,t.start,0))return t;r=t.end,t=null}},r.prototype._verifyTrailingWhitespace=function(e){var t,n=this;return t=e.end+(e.end-e.start),t=i.CODE_G_START?(e.code=e.code-i.CODE_G_START,a|=1<<5-r):a|=0<<5-r,t.push(e.code),n.push(e)}if(o=i._calculateFirstDigit(a),null===o)return null;if(t.unshift(o),e=i._findPattern(i.MIDDLE_PATTERN,e.end,!0,!1),null===e)return null;for(n.push(e),r=0;r<6;r++){if(e=i._decodeCode(e.end,i.CODE_G_START),!e)return null;n.push(e),t.push(e.code)}return e},r.prototype._decode=function(){var e,t,n=this,r=[],o=[],i={};if(e=n._findStart(),!e)return null;if(t={code:e.code,start:e.start,end:e.end},o.push(t),t=n._decodePayload(t,r,o),!t)return null;if(t=n._findEnd(t.end,!1),!t)return null;if(o.push(t),!n._checksum(r))return null;if(this.supplements.length>0){var a=this._decodeExtensions(t.end);if(!a)return null;var c=a.decodedCodes[a.decodedCodes.length-1],s={start:c.start+((c.end-c.start)/2|0),end:c.end};if(!n._verifyTrailingWhitespace(s))return null;i={supplement:a,code:r.join("")+a.code}}return u({code:r.join(""),start:e.start,end:t.end,codeset:"",startInfo:e,decodedCodes:o},i)},r.prototype._decodeExtensions=function(e){var t,n,r=this._nextSet(this._row,e),o=this._findPattern(this.EXTENSION_START_PATTERN,r,!1,!1);if(null===o)return null;for(t=0;t=0;t-=2)n+=e[t];for(n*=3,t=e.length-1;t>=0;t-=2)n+=e[t];return n%10===0},r.CONFIG_KEYS={supplements:{type:"arrayOf(string)","default":[],description:"Allowed extensions to be decoded (2 and/or 5)"}},t.a=r},function(e,t,n){function r(e,t){var n=i(e,t);return o(n)?n:void 0}var o=n(129),i=n(160);e.e=r},function(e,t,n){function r(e){if("string"==typeof e||o(e))return e;var t=e+"";return"0"==t&&1/e==-i?"-0":t}var o=n(28),i=1/0;e.e=r},function(e,t,n){function r(e){var t=s(e);if(!t&&!c(e))return i(e);var n=a(e),r=!!n,f=n||[],d=f.length;for(var l in e)!o(e,l)||r&&("length"==l||u(l,d))||t&&"constructor"==l||f.push(l);return f}var o=n(59),i=n(131),a=n(67),c=n(26),u=n(22),s=n(40);e.e=r},function(e,t,n){var r=n(135),o=n(153),i=o(function(e,t,n){r(e,t,n)});e.e=i},function(e,t,n){t.a={drawRect:function(e,t,n,r){n.strokeStyle=r.color,n.fillStyle=r.color,n.lineWidth=1,n.beginPath(),n.strokeRect(e.x,e.y,t.x,t.y)},drawPath:function(e,t,n,r){n.strokeStyle=r.color,n.fillStyle=r.color,n.lineWidth=r.lineWidth,n.beginPath(),n.moveTo(e[0][t.x],e[0][t.y]);for(var o=1;on)return Number.MAX_VALUE;c+=u}return c/f},r.prototype._nextSet=function(e,t){var n;for(t=t||0,n=t;n1&&(e[n[r]]=o)},r.prototype._matchTrace=function(e,t){var n,r,o=[],i=this,a=i._nextSet(i._row),c=!i._row[a],u=0,s={error:Number.MAX_VALUE,code:-1,start:0};if(e){for(n=0;n=0;r--)t=Math.floor(Math.random()*r),n=e[r],e[r]=e[t],e[t]=n;return e},toPointList:function(e){var t,n,r=[],o=[];for(t=0;t=t&&o.push(e[r]);return o},maxIndex:function(e){var t,n=0;for(t=0;te[n]&&(n=t);return n},max:function r(e){var t,r=0;for(t=0;tr&&(r=e[t]);return r},sum:function o(e){for(var t=e.length,o=0;t--;)o+=e[t];return o}}},function(e,t,n){function r(e){var t=-1,n=e?e.length:0;for(this.clear();++t-1&&e%1==0&&e-1&&e%1==0&&e<=o}var o=9007199254740991;e.e=r},function(e,t,n){function r(e){return"symbol"==typeof e||o(e)&&c.call(e)==i}var o=n(4),i="[object Symbol]",a=Object.prototype,c=a.toString;e.e=r},function(e,t,n){function r(e,t){var n={x:e,y:t,toVec2:function(){return w.clone([this.x,this.y])},toVec3:function(){return C.clone([this.x,this.y,1])},round:function(){return this.x=this.x>0?Math.floor(this.x+.5):Math.floor(this.x-.5),this.y=this.y>0?Math.floor(this.y+.5):Math.floor(this.y-.5),this}};return n}function o(e,t,n){n||(n=e);for(var r=e.data,o=r.length,i=n.data;o--;)i[o]=r[o]>o]++;return a}function a(e,t){function n(e,t){var n,r=0;for(n=e;n<=t;n++)r+=a[n];return r}function r(e,t){var n,r=0;for(n=e;n<=t;n++)r+=n*a[n];return r}function o(){var o,c,u,s,f,d,l,p=[0],h=(1<u)for(i=s[c],i.score=o,i.item=e[r],u=Number.MAX_VALUE,a=0;at[r]?r++:n++;return o}function g(e,t){function n(e){for(var t=0,n=e[Math.floor(e.length/2)];t0&&(n=Math.abs(e[t]-l)>Math.abs(e[t-1]-l)?e[t-1]:e[t]),l/nu[f-1]/u[f]?{x:n,y:n}:null}var r,o=h(t.x),i=h(t.y),a=Math.max(t.x,t.y),c=v(o,i),u=[8,10,15,20,32,60,80],s={"x-small":5,small:4,medium:3,large:2,"x-large":1},f=s[e]||s.medium,d=u[f],l=Math.floor(a/d);return r=n(c),r||(r=n(h(a)),r||(r=n(h(l*d)))),r}function m(e){var t={value:parseFloat(e),unit:(e.indexOf("%")===e.length-1,"%")};return t}function y(e,t,n){var r={width:e,height:t},o=Object.keys(n).reduce(function(e,t){var o=n[t],i=m(o),a=E[t](i,r);return e[t]=a,e},{});return{sx:o.left,sy:o.top,sw:o.right-o.left,sh:o.bottom-o.top}}var b=n(77),_=n(15);t.f=r,t.c=c,t.d=u,t.e=s,t.i=f,t.j=d,t.g=l,t.a=p,t.b=g,t.h=y;var w={clone:n(12)},C={clone:n(108)},E={top:function(e,t){if("%"===e.unit)return Math.floor(t.height*(e.value/100))},right:function(e,t){if("%"===e.unit)return Math.floor(t.width-t.width*(e.value/100))},bottom:function(e,t){if("%"===e.unit)return Math.floor(t.height-t.height*(e.value/100))},left:function(e,t){if("%"===e.unit)return Math.floor(t.width*(e.value/100))}}},function(e,t,n){function r(e,t,n,r){t?this.data=t:n?(this.data=new n(e.x*e.y),n===Array&&r&&a.a.init(this.data,0)):(this.data=new Uint8Array(e.x*e.y),Uint8Array===Array&&r&&a.a.init(this.data,0)),this.size=e}var o=n(80),i=n(29),a=n(15),c={clone:n(12)};r.prototype.inImageWithBorder=function(e,t){return e.x>=t&&e.y>=t&&e.x0&&(a=m[r-1],a.m00+=1,a.m01+=n,a.m10+=t,a.m11+=t*n,a.m02+=o,a.m20+=t*t);for(i=0;i=0?_:-_)+b,a.theta=(180*p/b+90)%180-90,a.theta<0&&(a.theta+=180),a.rad=p>b?p-b:p,a.vec=c.clone([Math.cos(p),Math.sin(p)]),y.push(a));return y},r.prototype.show=function(e,t){var n,r,o,i,a,c,u;for(t||(t=1),n=e.getContext("2d"),e.width=this.size.x,e.height=this.size.y,r=n.getImageData(0,0,e.width,e.height),o=r.data,i=0,u=0;u360)&&(t=360);for(var r=[0,1,1],o=[0,0,0],a=[255,255,255],c=[0,0,0],u=[],s=e.getContext("2d"),f=s.getImageData(n.x,n.y,this.size.x,this.size.y),d=f.data,l=this.data.length;l--;)r[0]=this.data[l]*t,u=r[0]<=0?a:r[0]>=360?c:i.a.bind()(r,o),d[4*l+0]=u[0],d[4*l+1]=u[1],d[4*l+2]=u[2],d[4*l+3]=255;s.putImageData(f,n.x,n.y)},t.a=r},function(e,t,n){function r(e){var t=-1,n=e?e.length:0;for(this.clear();++t=o},r.prototype._patternToChar=function(e){var t,n=this;for(t=0;tt&&(r=e[n]);return r},r.prototype._toPattern=function(e){for(var t,n,r=e.length,o=0,i=r,a=0,c=this;i>3;){for(o=c._findNextWidth(e,o),i=0,t=0,n=0;no&&(t|=1<0;n++)if(e[n]>o&&(i--,2*e[n]>=a))return-1;return t}}return-1},r.prototype._findStart=function(){var e,t,n,r=this,o=r._nextSet(r._row),i=o,a=[0,0,0,0,0,0,0,0,0],c=0,u=!1;for(e=o;e0&&n(f)?t>1?r(f,t-1,n,a,c):o(c,f):a||(c[c.length]=f)}return c}var o=n(34),i=n(171);e.e=r},function(e,t,n){function r(e,t){t=i(t,e)?[t]:o(t);for(var n=0,r=t.length;null!=e&&nd))return!1;var p=s.get(e);if(p)return p==t;var h=-1,v=!0,g=u&a?new o:void 0;for(s.set(e,t);++ht},getPoints:function(){return a},getCenter:function(){return c}}},createPoint:function(e,t,n){return{rad:e[n],point:e,id:t}}}},function(e,t,n){var r=Object.assign||function(e){for(var t=1;t>>16&65535,r=65535&e,o=t>>>16&65535,i=65535&t;return r*i+(n*i+r*o<<16>>>0)|0}},function(e,t,n){e.e={inputStream:{name:"Live",type:"LiveStream",constraints:{width:640,height:480,facingMode:"environment"},area:{top:"0%",right:"0%",left:"0%",bottom:"0%"},singleChannel:!1},locate:!0,numOfWorkers:4,decoder:{readers:["code_128_reader"]},locator:{halfSample:!0,patchSize:"medium"}}},function(e,t,n){var r=n(84),o=(n(10),n(94)),i=n(5),a=n(48),c=n(95),u=n(93),s=n(101),f=n(98),d=n(96),l=n(97),p=n(100),h=n(99),v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},g={code_128_reader:o.a,ean_reader:i.a,ean_5_reader:l.a,ean_2_reader:d.a,ean_8_reader:f.a,code_39_reader:a.a,code_39_vin_reader:c.a,codabar_reader:u.a,upc_reader:s.a,upc_e_reader:p.a,i2of5_reader:h.a};t.a={create:function(e,t){function n(){}function o(){e.readers.forEach(function(e){var t,n={},r=[];"object"===("undefined"==typeof e?"undefined":v(e))?(t=e.format,n=e.config):"string"==typeof e&&(t=e),n.supplements&&(r=n.supplements.map(function(e){return new g[e]})),p.push(new g[t](n,r))})}function i(){}function a(e,n,r){function o(t){var r={y:t*Math.sin(n),x:t*Math.cos(n)};e[0].y-=r.y,e[0].x-=r.x,e[1].y+=r.y,e[1].x+=r.x}for(o(r);r>1&&(!t.inImageWithBorder(e[0],0)||!t.inImageWithBorder(e[1],0));)r-=Math.ceil(r/2),o(-r);return e}function c(e){return[{x:(e[1][0]-e[0][0])/2+e[0][0],y:(e[1][1]-e[0][1])/2+e[0][1]},{x:(e[3][0]-e[2][0])/2+e[2][0],y:(e[3][1]-e[2][1])/2+e[2][1]}]}function u(e){var n,o=null,i=r.a.getBarcodeLine(t,e[0],e[1]);for(r.a.toBinaryLine(i),n=0;nC?d:C,m.push(d)}var o,i,a,c,u,s,f,d,l=0|t.x,p=0|t.y,h=0|n.x,v=0|n.y,g=Math.abs(v-p)>Math.abs(h-l),m=[],y=e.data,b=e.size.x,_=0,w=255,C=0;for(g&&(s=l,l=p,p=s,s=h,h=v,v=s),l>h&&(s=l,l=h,h=s,s=p,p=v,v=s),o=h-l,i=Math.abs(v-p),a=o/2|0,u=p,c=pd?o.DIR.UP:o.DIR.DOWN,l.push({pos:0,val:f[0]}),a=0;ap&&f[a+1]>.5*d?o.DIR.UP:r,r!==i&&(l.push({pos:a,val:f[a]}),r=i);for(l.push({pos:f.length,val:f[f.length-1]}),c=l[0].pos;cd?0:1;for(a=1;al[a].val?l[a].val+(l[a+1].val-l[a].val)/3*2|0:l[a+1].val+(l[a].val-l[a+1].val)/3|0,c=l[a].pos;cp?0:1;return{line:f,threshold:p}},r.debug={printFrequency:function(e,t){var n,r=t.getContext("2d");for(t.width=e.length,t.height=256,r.beginPath(),r.strokeStyle="blue",n=0;n0?e.videoWidth>0&&e.videoHeight>0?t():window.setTimeout(r,500):n("Unable to play video stream. Is webcam working?"),o--}var o=10;r()})}function o(e,t){return navigator.mediaDevices.getUserMedia(t).then(function(t){return new Promise(function(n){h=t,e.setAttribute("autoplay","true"),e.srcObject=t,e.addEventListener("loadedmetadata",function(){e.play(),n()})})}).then(r.bind(null,e))}function i(e){var t=d.a.bind()(e,["width","height","facingMode","aspectRatio","deviceId"]);return"undefined"!=typeof e.minAspectRatio&&e.minAspectRatio>0&&(t.aspectRatio=e.minAspectRatio,console.log("WARNING: Constraint 'minAspectRatio' is deprecated; Use 'aspectRatio' instead")),"undefined"!=typeof e.facing&&(t.facingMode=e.facing,console.log("WARNING: Constraint 'facing' is deprecated. Use 'facingMode' instead'")),t}function a(e,t){return"string"==typeof t.video.deviceId&&t.video.deviceId.length>0?Promise.resolve(v({},t,{video:v({},s.a.bind()(t.video,"facingMode"))})):e?"undefined"!=typeof MediaStreamTrack&&"undefined"!=typeof MediaStreamTrack.getSources?new Promise(function(n){MediaStreamTrack.getSources(function(r){var o=r.filter(function(t){return"video"===t.kind&&t.facing===e})[0];return n(o?p.a.bind()({},t,{video:{deviceId:o.id}}):t)})}):Promise.resolve(p.a.bind()({},t,{video:{facingMode:e}})):Promise.resolve(t)}function c(e){var t={audio:!1,video:i(e)};return a(t.video.facingMode,t)}var u=n(200),s=u&&u.__esModule?function(){return u["default"]}:function(){return u};Object.defineProperty(s,"a",{get:s});var f=n(75),d=f&&f.__esModule?function(){return f["default"]}:function(){return f};Object.defineProperty(d,"a",{get:d});var l=n(9),p=l&&l.__esModule?function(){return l["default"]}:function(){return l};Object.defineProperty(p,"a",{get:p});var h,v=Object.assign||function(e){for(var t=1;t0?a(e,t,n[0]):void 0}function o(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],r={inputStream:_.a.bind()({type:"ImageStream",sequence:!1,size:800},t),numOfWorkers:1};return _.a.bind()(e,r,{numOfWorkers:"number"==typeof e.numOfWorkers&&e.numOfWorkers>0?1:0},{inputStream:g.a.bind()(y.a.bind()(e.inputStream,["size"]),h.a)},{inputStream:n})}function i(e,t,n){var r=n.src,i=n.mime,a=i.match(/^(video|image)\/(.*)$/i)||[],c=a[1];if("video"===c)return f(e,{src:r},t);if("image"===c)return o(e,{src:r},t);throw new Error('Source with mimetype: "'+c+'" not supported')}function a(e,t,n){var r=w.a.URL.createObjectURL(n);return i(e,t,{src:r,mime:n.type})}function c(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1],n=arguments[2],r=n.match(E.regex)||[],o=r[1];if(o)return i(e,t,{src:n,mime:o});var a=n.match(S.regex);if(a)throw new Error('Source "objectURL": not supported');var c=n.match(T.regex)||[],s=c[2];if(s)return u(e,t,{src:n,ext:s});throw new Error('Source "'+n+'": not recognized')}function u(e,t,n){var r=n.src,i=n.ext;if(i.match(R.regex))return o(e,{src:r},t);if(i.match(O.regex))return f(e,{src:r},t);throw new Error('Source "MediaString": not recognized')}function s(e,t){t.canvas,arguments.length<=2||void 0===arguments[2]?{}:arguments[2];throw new Error('Source "Canvas": not implemented!')}function f(e,t){var n=arguments.length<=2||void 0===arguments[2]?{}:arguments[2];return _.a.bind()({},e,{inputStream:_.a.bind()({type:"VideoStream"},t)},{inputStream:n})}function d(e,t){t.srcObject,arguments.length<=2||void 0===arguments[2]?{}:arguments[2];throw new Error('Source "MediaStream": not implemented!')}function l(e){var t=arguments.length<=1||void 0===arguments[1]?{}:arguments[1];return _.a.bind()({},e,{inputStream:{type:"LiveStream",constraints:{width:640,height:480,facingMode:"environment"}}},{inputStream:t})}var p=n(197),h=p&&p.__esModule?function(){return p["default"]}:function(){return p};Object.defineProperty(h,"a",{get:h});var v=n(201),g=v&&v.__esModule?function(){return v["default"]}:function(){return v};Object.defineProperty(g,"a",{get:g});var m=n(75),y=m&&m.__esModule?function(){return m["default"]}:function(){return m};Object.defineProperty(y,"a",{get:y});var b=n(9),_=b&&b.__esModule?function(){return b["default"]}:function(){return b};Object.defineProperty(_,"a",{get:_});var w=n(78);t.a=r;var C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol?"symbol":typeof e},E={regex:/^\s*data:([a-z]+\/[a-z0-9\-\+]+(;[a-z\-]+\=[a-z0-9\-]+)?)?(;base64)?,[a-z0-9\!\$\&\'\,\(\)\*\+\,\;\=\-\.\_\~\:\@\/\?\%\s]*\s*$/i},S={regex:/^\s*blob:(.*)$/i},T={regex:/^(?:(?:http[s]?|ftp):\/)?\/?(?:(?:[^:\/\s]+)(?:(?:\/\w+)*\/))?([\w\-]+\.([^#?\s]+))(?:.*)?(?:#[\w\-]+)?$/i},R={regex:/(jpe?g|png|gif|tiff)(?:\s+|$)/i},O={regex:/(webm|ogg|mp4|m4v)/i}},function(e,t,n){function r(e,t){e.width!==t.x&&(e.width=t.x),e.height!==t.y&&(e.height=t.y)}var o=n(29),i={};i.create=function(e,t){var n,i={},a=e.getConfig(),c=(o.f.bind()(e.getRealWidth(),e.getRealHeight()),e.getCanvasSize()),u=o.f.bind()(e.getWidth(),e.getHeight()),s=e.getTopRight(),f=s.x,d=s.y,l=null,p=null;return n=t?t:document.createElement("canvas"),n.width=c.x,n.height=c.y,l=n.getContext("2d"),p=new Uint8Array(u.x*u.y),i.attachData=function(e){p=e},i.getData=function(){return p},i.grab=function(){var t,i=a.halfSample,s=e.getFrame();return!!s&&(r(n,c),l.drawImage(s,0,0,c.x,c.y),t=l.getImageData(f,d,u.x,u.y).data,i?o.i.bind()(t,u,p):o.j.bind()(t,p,a),!0)},i.getSize=function(){return u},i},t.a=i},function(e,t,n){function r(e,t){e.onload=function(){t.loaded(this)}}var o={};o.load=function(e,t,n,o,i){var a,c,u,s=new Array(o),f=new Array(s.length);if(i===!1)s[0]=e;else for(a=0;a1?i.size:Math.floor(t/o*i.size):t,r=i.size?t/o>1?Math.floor(o/t*i.size):i.size:o,s.x=n,s.y=r}var n,r,o={},i=null,a=["canrecord","ended"],c={},u={x:0,y:0},s={x:0,y:0};return o.getRealWidth=function(){return e.videoWidth},o.getRealHeight=function(){return e.videoHeight},o.getWidth=function(){return n},o.getHeight=function(){return r},o.setWidth=function(e){n=e},o.setHeight=function(e){r=e},o.setInputStream=function(t){i=t,e.src="undefined"!=typeof t.src?t.src:""},o.ended=function(){return e.ended},o.getConfig=function(){return i},o.setAttribute=function(t,n){e.setAttribute(t,n)},o.pause=function(){e.pause()},o.play=function(){e.play()},o.setCurrentTime=function(t){"LiveStream"!==i.type&&(e.currentTime=t)},o.addEventListener=function(t,n,r){a.indexOf(t)!==-1?(c[t]||(c[t]=[]),c[t].push(n)):e.addEventListener(t,n,r)},o.clearEventHandlers=function(){a.forEach(function(t){var n=c[t];n&&n.length>0&&n.forEach(function(n){e.removeEventListener(t,n)})})},o.trigger=function(e,n){var r,i=c[e];if("canrecord"===e&&t(),i&&i.length>0)for(r=0;r1?a.size:Math.floor(c/u*a.size):c,o=a.size?c/u>1?Math.floor(u/c*a.size):a.size:u,_.x=n,_.y=o,d=!0,s=0,setTimeout(function(){t("canrecord",[])},0)},h,p,a.sequence)}function t(e,t){var n,r=y[e];if(r&&r.length>0)for(n=0;nf&&(f=o.box[r][0]),o.box[r][1]p&&(p=o.box[r][1]);for(a=[[u,s],[f,s],[f,p],[u,p]],c=M.halfSample?2:1,i=l.invert(i,i),r=0;r<4;r++)d.transformMat2(a[r],a[r],i);for(r=0;r<4;r++)d.scale(a[r],a[r],c);return a}function h(){a.c.bind()(C,P),P.zeroBorder()}function v(){var e,t,n,r,o,i,a,s=[];for(e=0;e0&&r[O.data[n]-1]++;return r=r.map(function(e,t){return{val:e,label:t+1}}),r.sort(function(e,t){return t.val-e.val}),o=r.filter(function(e){return e.val>=5})}function m(e,t){var n,r,o,i,a=[],c=[];for(n=0;n=2){for(o=0;of&&u.push(e[o]);if(u.length>=2){for(a=y(u),i=0,o=0;o1&&a.length>=u.length/4*3&&a.length>e.length/4&&(i/=a.length,c={index:t[1]*I.x+t[0],pos:{x:n,y:r},box:[d.clone([n,r]),d.clone([n+S.size.x,r]),d.clone([n+S.size.x,r+S.size.y]),d.clone([n,r+S.size.y])],moments:a,rad:i,vec:d.clone([Math.cos(i),Math.sin(i)])},s.push(c))}}return s}function w(e){function t(){var e;for(e=0;ea&&n(c)):O.data[c]=Number.MAX_VALUE}var r,o,i=0,a=.95,u=0;for(c.a.init(R.data,0),c.a.init(O.data,0),c.a.init(x.data,null),r=0;r0) {length=length - 1|0;images[outImagePtr+length|0]=(images[aImagePtr+length|0]|0) - (images[bImagePtr+length|0]|0)|0;}}function bitwiseOr(aImagePtr, bImagePtr, outImagePtr) {aImagePtr=aImagePtr|0;bImagePtr=bImagePtr|0;outImagePtr=outImagePtr|0;var length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;images[outImagePtr+length|0]=images[aImagePtr+length|0]|0|(images[bImagePtr+length|0]|0)|0;}}function countNonZero(imagePtr) {imagePtr=imagePtr|0;var sum=0,length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;sum=(sum|0)+(images[imagePtr+length|0]|0)|0;}return sum|0;}function init(imagePtr, value) {imagePtr=imagePtr|0;value=value|0;var length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;images[imagePtr+length|0]=value;}}function dilate(inImagePtr, outImagePtr) {inImagePtr=inImagePtr|0;outImagePtr=outImagePtr|0;var v=0,u=0,sum=0,yStart1=0,yStart2=0,xStart1=0,xStart2=0,offset=0;for (v=1; (v|0)<(size - 1|0); v=v+1|0) {offset=offset+size|0;for (u=1; (u|0)<(size - 1|0); u=u+1|0) {yStart1=offset - size|0;yStart2=offset+size|0;xStart1=u - 1|0;xStart2=u+1|0;sum=(images[inImagePtr+yStart1+xStart1|0]|0)+(images[inImagePtr+yStart1+xStart2|0]|0)+(images[inImagePtr+offset+u|0]|0)+(images[inImagePtr+yStart2+xStart1|0]|0)+(images[inImagePtr+yStart2+xStart2|0]|0)|0;if ((sum|0)>(0|0)) {images[outImagePtr+offset+u|0]=1;} else {images[outImagePtr+offset+u|0]=0;}}}return;}function memcpy(srcImagePtr, dstImagePtr) {srcImagePtr=srcImagePtr|0;dstImagePtr=dstImagePtr|0;var length=0;length=imul(size, size)|0;while ((length|0)>0) {length=length - 1|0;images[dstImagePtr+length|0]=images[srcImagePtr+length|0]|0;}}function zeroBorder(imagePtr) {imagePtr=imagePtr|0;var x=0,y=0;for (x=0; (x|0)<(size - 1|0); x=x+1|0) {images[imagePtr+x|0]=0;images[imagePtr+y|0]=0;y=y+size - 1|0;images[imagePtr+y|0]=0;y=y+1|0;}for (x=0; (x|0)<(size|0); x=x+1|0) {images[imagePtr+y|0]=0;y=y+1|0;}}function skeletonize() {var subImagePtr=0,erodedImagePtr=0,tempImagePtr=0,skelImagePtr=0,sum=0,done=0;erodedImagePtr=imul(size, size)|0;tempImagePtr=erodedImagePtr+erodedImagePtr|0;skelImagePtr=tempImagePtr+erodedImagePtr|0;init(skelImagePtr, 0);zeroBorder(subImagePtr);do {erode(subImagePtr, erodedImagePtr);dilate(erodedImagePtr, tempImagePtr);subtract(subImagePtr, tempImagePtr, tempImagePtr);bitwiseOr(skelImagePtr, tempImagePtr, skelImagePtr);memcpy(erodedImagePtr, subImagePtr);sum=countNonZero(subImagePtr)|0;done=(sum|0) == 0|0;} while (!done);}return {skeletonize: skeletonize};} exports["a"]=Skeletonizer; },function(e,t,n){function r(){o.a.call(this),this._counters=[]}var o=n(11),i={ALPHABETH_STRING:{value:"0123456789-$:/.+ABCD"},ALPHABET:{value:[48,49,50,51,52,53,54,55,56,57,45,36,58,47,46,43,65,66,67,68]},CHARACTER_ENCODINGS:{value:[3,6,9,96,18,66,33,36,48,72,12,24,69,81,84,21,26,41,11,14]},START_END:{value:[26,41,11,14]},MIN_ENCODED_CHARS:{value:4},MAX_ACCEPTABLE:{value:2},PADDING:{value:1.5},FORMAT:{value:"codabar",writeable:!1}};r.prototype=Object.create(o.a.prototype,i),r.prototype.constructor=r,r.prototype._decode=function(){var e,t,n,r,o,i=this,a=[];if(this._counters=i._fillCounters(),e=i._findStart(),!e)return null;r=e.startCounter;do{if(n=i._toPattern(r),n<0)return null;if(t=i._patternToChar(n),t<0)return null;if(a.push(t),r+=8,a.length>1&&i._isStartEnd(n))break}while(ri._counters.length?i._counters.length:r,o=e.start+i._sumCounters(e.startCounter,r-8),{code:a.join(""),start:e.start,end:o,startInfo:e,decodedCodes:a}):null},r.prototype._verifyWhitespace=function(e,t){return(e-1<=0||this._counters[e-1]>=this._calculatePatternLength(e)/2)&&(t+8>=this._counters.length||this._counters[t+7]>=this._calculatePatternLength(t)/2)},r.prototype._calculatePatternLength=function(e){var t,n=0;for(t=e;t=0;i--)n=2===(1&i)?u.bar:u.space,r=1===(1&a)?n.wide:n.narrow,r.size+=c._counters[s+i],r.counts++,a>>=1;s+=8}return["space","bar"].forEach(function(e){var t=u[e];t.wide.min=Math.floor((t.narrow.size/t.narrow.counts+t.wide.size/t.wide.counts)/2),t.narrow.max=Math.ceil(t.wide.min),t.wide.max=Math.ceil((t.wide.size*c.MAX_ACCEPTABLE+c.PADDING)/t.wide.counts)}),u},r.prototype._charToPattern=function(e){var t,n=this,r=e.charCodeAt(0);for(t=0;t=0;r--){if(o=0===(1&r)?s.bar:s.space,i=1===(1&c)?o.wide:o.narrow,a=u._counters[f+r],ai.max)return!1;c>>=1}f+=8}return!0},r.prototype._patternToChar=function(e){var t,n=this;for(t=0;ti&&(i=r),rthis._counters.length)return-1;for(t=this._computeAlternatingThreshold(e,a),n=this._computeAlternatingThreshold(e+1,a),r=0;ro&&(u|=c),c>>=1;return u},r.prototype._isStartEnd=function(e){var t;for(t=0;tc.AVG_CODE_ERROR?null:(c.CODE_PATTERN[d.code]&&(d.correction.bar=o(c.CODE_PATTERN[d.code],a,this.MODULE_INDICES.bar),d.correction.space=o(c.CODE_PATTERN[d.code],a,this.MODULE_INDICES.space)),d)}f++,a[f]=1,s=!s}return null},r.prototype._correct=function(e,t){this._correctBars(e,t.bar,this.MODULE_INDICES.bar),this._correctBars(e,t.space,this.MODULE_INDICES.space)},r.prototype._findStart=function(){var e,t,n,r,i,a=[0,0,0,0,0,0],c=this,u=c._nextSet(c._row),s=!1,f=0,d={error:Number.MAX_VALUE,code:-1,start:0,end:0,correction:{bar:1,space:1}};for(e=u;e=this.CODE_G_START&&(r|=1<<1-o),1!=o&&(i=this._nextSet(this._row,n.end),i=this._nextUnset(this._row,i))}return 2!=c.length||parseInt(c.join(""))%4!==r?null:{code:c.join(""),decodedCodes:u,end:n.end}},t.a=r},function(e,t,n){function r(){a.a.call(this)}function o(e){var t;for(t=0;t<10;t++)if(e===u[t])return t;return null}function i(e){var t,n=e.length,r=0;for(t=n-2;t>=0;t-=2)r+=e[t];for(r*=3,t=n-1;t>=0;t-=2)r+=e[t];return r*=3,r%10}var a=n(5),c={FORMAT:{value:"ean_5",writeable:!1}},u=[24,20,18,17,12,6,3,10,9,5];r.prototype=Object.create(a.a.prototype,c),r.prototype.constructor=r,r.prototype.decode=function(e,t){this._row=e;var n,r=0,a=0,c=t,u=this._row.length,s=[],f=[];for(a=0;a<5&&c=this.CODE_G_START&&(r|=1<<4-a),4!=a&&(c=this._nextSet(this._row,n.end),c=this._nextUnset(this._row,c))}return 5!=s.length?null:i(s)!==o(r)?null:{code:s.join(""),decodedCodes:f,end:n.end}},t.a=r},function(e,t,n){function r(e,t){o.a.call(this,e,t)}var o=n(5),i={FORMAT:{value:"ean_8",writeable:!1}};r.prototype=Object.create(o.a.prototype,i),r.prototype.constructor=r,r.prototype._decodePayload=function(e,t,n){var r,o=this;for(r=0;r<4;r++){if(e=o._decodeCode(e.end,o.CODE_G_START),!e)return null;t.push(e.code),n.push(e)}if(e=o._findPattern(o.MIDDLE_PATTERN,e.end,!0,!1),null===e)return null;for(n.push(e),r=0;r<4;r++){if(e=o._decodeCode(e.end,o.CODE_G_START),!e)return null;n.push(e),t.push(e.code)}return e},t.a=r},function(e,t,n){function r(e){e=a.a.bind()(o(),e),c.a.call(this,e),this.barSpaceRatio=[1,1],e.normalizeBarSpaceWidth&&(this.SINGLE_CODE_ERROR=.38,this.AVG_CODE_ERROR=.09)}function o(){var e={};return Object.keys(r.CONFIG_KEYS).forEach(function(t){e[t]=r.CONFIG_KEYS[t]["default"]}),e}var i=n(9),a=i&&i.__esModule?function(){return i["default"]}:function(){return i};Object.defineProperty(a,"a",{get:a});var c=n(11),u=1,s=3,f={START_PATTERN:{value:[u,u,u,u]},STOP_PATTERN:{value:[u,u,s]},CODE_PATTERN:{value:[[u,u,s,s,u],[s,u,u,u,s],[u,s,u,u,s],[s,s,u,u,u],[u,u,s,u,s],[s,u,s,u,u],[u,s,s,u,u],[u,u,u,s,s],[s,u,u,s,u],[u,s,u,s,u]]},SINGLE_CODE_ERROR:{value:.78,writable:!0},AVG_CODE_ERROR:{value:.38,writable:!0},MAX_CORRECTION_FACTOR:{value:5},FORMAT:{value:"i2of5"}};r.prototype=Object.create(c.a.prototype,f),r.prototype.constructor=r,r.prototype._matchPattern=function(e,t){if(this.config.normalizeBarSpaceWidth){var n,r=[0,0],o=[0,0],i=[0,0],a=this.MAX_CORRECTION_FACTOR,u=1/a;for(n=0;n=0&&n._matchRange(e,t.start,0))return t;r=t.end,t=null}},r.prototype._verifyTrailingWhitespace=function(e){var t,n=this;return t=e.end+(e.end-e.start)/2,t=o.CODE_G_START&&(e.code=e.code-o.CODE_G_START,i|=1<<5-r),t.push(e.code),n.push(e)}return o._determineParity(i,t)?e:null},r.prototype._determineParity=function(e,t){var n,r;for(r=0;r0)for(r=0;r0){if(e=B.filter(function(e){return!e.busy})[0],!e)return;I.attachData(e.imageData)}else I.attachData(k.data);I.grab()&&(e?(e.busy=!0,e.worker.postMessage({cmd:"process",imageData:e.imageData},[e.imageData.buffer])):S())}else S()}function R(){var e=null,t=1e3/(0===V.frequency?60:V.frequency||60);F=!1,function n(r){e=e||r,F||(r>=e&&(e+=t,T()),window.requestAnimFrame(n))}(performance.now())}function O(){W&&"LiveStream"===V.inputStream.type?R():T()}function x(e){var t,n={worker:void 0,imageData:new Uint8Array(j.getWidth()*j.getHeight()),busy:!0};t=A(),n.worker=new Worker(t),n.worker.onmessage=function(r){return"initialized"===r.data.event?(URL.revokeObjectURL(t),n.busy=!1,n.imageData=new Uint8Array(r.data.imageData),e(n)):void("processed"===r.data.event?(n.imageData=new Uint8Array(r.data.imageData),n.busy=!1,E(r.data.result,n.imageData)):"error"===r.data.event)},n.worker.postMessage({cmd:"init",size:{x:j.getWidth(),y:j.getHeight()},imageData:n.imageData,config:P(V)},[n.imageData.buffer])}function P(e){return v({},e,{inputStream:v({},e.inputStream,{target:null})})}function D(e){function t(e){self.postMessage({event:"processed",imageData:o.data,result:e},[o.data.buffer])}function n(){self.postMessage({event:"initialized",imageData:o.data},[o.data.buffer])}if(e){var r=e()["default"];if(!r)return void self.postMessage({event:"error",message:"Quagga could not be created"})}var o,i=r._worker.createScanner();self.onmessage=function(e){if("init"===e.data.cmd){var a=e.data.config;a.numOfWorkers=0,o=new r.ImageWrapper({x:e.data.size.x,y:e.data.size.y},new Uint8Array(e.data.imageData)),i.init(a,n,o),i.subscribe("processed",t)}else"process"===e.data.cmd&&(o.data=new Uint8Array(e.data.imageData),i.start())}}function A(){var t,n;return"undefined"!=typeof e&&(n=e),t=new Blob(["("+D.toString()+")("+n+");"],{type:"text/javascript"}),window.URL.createObjectURL(t)}function M(e,t){var n=e-B.length;if(0===n)return t&&t();if(n<0){var r=B.slice(n);return r.forEach(function(e){e.worker.terminate()}),B=B.slice(0,n),t&&t()}for(var o=function(n){B.push(n),B.length>=e&&t&&t()},i=0;i-1}var o=n(126);e.e=r},function(e,t,n){function r(e,t,n){for(var r=-1,o=e?e.length:0;++r=f&&(l=s,p=!1,t=new o(t));e:for(;++d1?n[i-1]:void 0,c=i>2?n[2]:void 0;for(a=e.length>3&&"function"==typeof a?(i--,a):void 0,c&&o(n[0],n[1],c)&&(a=i<3?void 0:a,i=1),t=Object(t);++r-1}var o=n(18);e.e=r},function(e,t,n){function r(e,t){var n=this.__data__,r=o(n,e);return r<0?n.push([e,t]):n[r][1]=t,this}var o=n(18);e.e=r},function(e,t,n){function r(){this.__data__={hash:new o,map:new(a||i),string:new o}}var o=n(110),i=n(16),a=n(50);e.e=r},function(e,t,n){function r(e){return o(this,e)["delete"](e)}var o=n(19);e.e=r},function(e,t,n){function r(e){return o(this,e).get(e)}var o=n(19);e.e=r},function(e,t,n){function r(e){return o(this,e).has(e)}var o=n(19);e.e=r},function(e,t,n){function r(e,t){return o(this,e).set(e,t),this}var o=n(19);e.e=r},function(e,t,n){function r(e){return this.__data__.set(e,o),this}var o="__lodash_hash_undefined__";e.e=r},function(e,t,n){function r(e){return this.__data__.has(e)}e.e=r},function(e,t,n){function r(){this.__data__=new o}var o=n(16);e.e=r},function(e,t,n){function r(e){return this.__data__["delete"](e)}e.e=r},function(e,t,n){function r(e){return this.__data__.get(e)}e.e=r},function(e,t,n){function r(e){return this.__data__.has(e)}e.e=r},function(e,t,n){function r(e,t){var n=this.__data__;return n instanceof o&&n.__data__.length==a&&(n=this.__data__=new i(n.__data__)),n.set(e,t),this}var o=n(16),i=n(31),a=200;e.e=r},function(e,t,n){var r=n(199),o=n(209),i=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(\.|\[\])(?:\4|$))/g,a=/\\(\\)?/g,c=r(function(e){var t=[];return o(e).replace(i,function(e,n,r,o){t.push(r?o.replace(a,"$1"):n||e)}),t});e.e=c},function(e,t,n){function r(e,t,n){var r=null==e?void 0:o(e,t);return void 0===r?n:r}var o=n(57);e.e=r},function(e,t,n){function r(e,t){return null!=e&&i(e,t,o)}var o=n(125),i=n(161);e.e=r},function(e,t,n){function r(e){return e}e.e=r},function(e,t,n){function r(e){if(c(e)&&(a(e)||d(e)||s(e.splice)||i(e)||u(e)))return!e.length;if(f(e)){var t=o(e);if(t==p||t==h)return!e.size}for(var n in e)if(g.call(e,n))return!1;return!(y&&l(e).length)}var o=n(39),i=n(13),a=n(0),c=n(26),u=n(74),s=n(14),f=n(4),d=n(41),l=n(8),p="[object Map]",h="[object Set]",v=Object.prototype,g=v.hasOwnProperty,m=v.propertyIsEnumerable,y=!m.call({valueOf:1},"valueOf");e.e=r},function(e,t,n){function r(e){if(!a(e)||l.call(e)!=c||i(e))return!1;var t=o(e);if(null===t)return!0;var n=f.call(t,"constructor")&&t.constructor;return"function"==typeof n&&n instanceof n&&s.call(n)==d}var o=n(20),i=n(21),a=n(4),c="[object Object]",u=Object.prototype,s=Function.prototype.toString,f=u.hasOwnProperty,d=s.call(Object),l=u.toString;e.e=r},function(e,t,n){function r(e,t){if("function"!=typeof e||t&&"function"!=typeof t)throw new TypeError(i);var n=function(){var r=arguments,o=t?t.apply(this,r):r[0],i=n.cache;if(i.has(o))return i.get(o);var a=e.apply(this,r);return n.cache=i.set(o,a),a};return n.cache=new(r.Cache||o),n}var o=n(31),i="Expected a function";r.Cache=o,e.e=r},function(e,t,n){var r=n(33),o=n(124),i=n(56),a=n(61),c=n(66),u=n(44),s=n(7),f=u(function(e,t){return null==e?{}:(t=r(i(t,1),s),a(e,o(c(e),t)))});e.e=f},function(e,t,n){function r(e,t){return t=o(t),i(e,function(e,n){return!t(e,n)})}var o=n(130),i=n(137);e.e=r},function(e,t,n){function r(e){return a(e)?o(c(e)):i(e)}var o=n(62),i=n(138),a=n(23),c=n(7);e.e=r},function(e,t,n){function r(){return[]}e.e=r},function(e,t,n){function r(){return!1}e.e=r},function(e,t,n){function r(e){if(!e)return 0===e?e:0;if(e=o(e),e===i||e===-i){var t=e<0?-1:1;return t*a}return e===e?e:0}var o=n(207),i=1/0,a=1.7976931348623157e308;e.e=r},function(e,t,n){function r(e){var t=o(e),n=t%1;return t===t?n?t-n:t:0}var o=n(205);e.e=r},function(e,t,n){function r(e){if("number"==typeof e)return e;if(a(e))return c;if(i(e)){var t=o(e.valueOf)?e.valueOf():e;e=i(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=e.replace(u,"");var n=f.test(e);return n||d.test(e)?l(e.slice(2),n?2:8):s.test(e)?c:+e}var o=n(14),i=n(3),a=n(28),c=NaN,u=/^\s+|\s+$/g,s=/^[-+]0x[0-9a-f]+$/i,f=/^0b[01]+$/i,d=/^0o[0-7]+$/i,l=parseInt;e.e=r},function(e,t,n){function r(e){return o(e,i(e))}var o=n(37),i=n(43);e.e=r},function(e,t,n){function r(e){return null==e?"":o(e)}var o=n(140);e.e=r},function(e,t,n){"use strict";var r={};r.generateIdentifier=function(){return Math.random().toString(36).substr(2,10)},r.localCName=r.generateIdentifier(),r.splitLines=function(e){return e.trim().split("\n").map(function(e){return e.trim()})},r.splitSections=function(e){var t=e.split("\nm=");return t.map(function(e,t){return(t>0?"m="+e:e).trim()+"\r\n"})},r.matchPrefix=function(e,t){return r.splitLines(e).filter(function(e){return 0===e.indexOf(t)})},r.parseCandidate=function(e){var t;t=0===e.indexOf("a=candidate:")?e.substring(12).split(" "):e.substring(10).split(" ");for(var n={foundation:t[0],component:t[1],protocol:t[2].toLowerCase(),priority:parseInt(t[3],10),ip:t[4],port:parseInt(t[5],10),type:t[7]},r=8;r-1?(n.attribute=e.substr(t+1,r-t-1),n.value=e.substr(r+1)):n.attribute=e.substr(t+1),n},r.getDtlsParameters=function(e,t){var n=r.splitLines(e);n=n.concat(r.splitLines(t));var o=n.filter(function(e){return 0===e.indexOf("a=fingerprint:")})[0].substr(14),i={role:"auto",fingerprints:[{algorithm:o.split(" ")[0],value:o.split(" ")[1]}]};return i},r.writeDtlsParameters=function(e,t){var n="a=setup:"+t+"\r\n";return e.fingerprints.forEach(function(e){n+="a=fingerprint:"+e.algorithm+" "+e.value+"\r\n"}),n},r.getIceParameters=function(e,t){var n=r.splitLines(e);n=n.concat(r.splitLines(t));var o={usernameFragment:n.filter(function(e){return 0===e.indexOf("a=ice-ufrag:")})[0].substr(12),password:n.filter(function(e){return 0===e.indexOf("a=ice-pwd:")})[0].substr(10)};return o},r.writeIceParameters=function(e){return"a=ice-ufrag:"+e.usernameFragment+"\r\na=ice-pwd:"+e.password+"\r\n"},r.parseRtpParameters=function(e){for(var t={codecs:[],headerExtensions:[],fecMechanisms:[],rtcp:[]},n=r.splitLines(e),o=n[0].split(" "),i=3;i0?"9":"0",n+=" UDP/TLS/RTP/SAVPF ",n+=t.codecs.map(function(e){return void 0!==e.preferredPayloadType?e.preferredPayloadType:e.payloadType}).join(" ")+"\r\n",n+="c=IN IP4 0.0.0.0\r\n",n+="a=rtcp:9 IN IP4 0.0.0.0\r\n",t.codecs.forEach(function(e){n+=r.writeRtpMap(e),n+=r.writeFmtp(e),n+=r.writeRtcpFb(e)}),n+="a=rtcp-mux\r\n"},r.parseRtpEncodingParameters=function(e){var t,n=[],o=r.parseRtpParameters(e),i=o.fecMechanisms.indexOf("RED")!==-1,a=o.fecMechanisms.indexOf("ULPFEC")!==-1,c=r.matchPrefix(e,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute}),u=c.length>0&&c[0].ssrc,s=r.matchPrefix(e,"a=ssrc-group:FID").map(function(e){var t=e.split(" ");return t.shift(),t.map(function(e){return parseInt(e,10)})});s.length>0&&s[0].length>1&&s[0][0]===u&&(t=s[0][1]),o.codecs.forEach(function(e){if("RTX"===e.name.toUpperCase()&&e.parameters.apt){var r={ssrc:u,codecPayloadType:parseInt(e.parameters.apt,10),rtx:{payloadType:e.payloadType,ssrc:t}};n.push(r),i&&(r=JSON.parse(JSON.stringify(r)),r.fec={ssrc:t,mechanism:a?"red+ulpfec":"red"},n.push(r))}}),0===n.length&&u&&n.push({ssrc:u});var f=r.matchPrefix(e,"b=");return f.length&&(0===f[0].indexOf("b=TIAS:")?f=parseInt(f[0].substr(7),10):0===f[0].indexOf("b=AS:")&&(f=parseInt(f[0].substr(5),10)),n.forEach(function(e){e.maxBitrate=f})),n},r.writeSessionBoilerplate=function(){return"v=0\r\no=thisisadapterortc 8169639915646943137 2 IN IP4 127.0.0.1\r\ns=-\r\nt=0 0\r\n"},r.writeMediaSection=function(e,t,n,o){var i=r.writeRtpDescription(e.kind,t);if(i+=r.writeIceParameters(e.iceGatherer.getLocalParameters()),i+=r.writeDtlsParameters(e.dtlsTransport.getLocalParameters(),"offer"===n?"actpass":"active"),i+="a=mid:"+e.mid+"\r\n",i+=e.rtpSender&&e.rtpReceiver?"a=sendrecv\r\n":e.rtpSender?"a=sendonly\r\n":e.rtpReceiver?"a=recvonly\r\n":"a=inactive\r\n",e.rtpSender){var a="msid:"+o.id+" "+e.rtpSender.track.id+"\r\n";i+="a="+a,i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" "+a}return i+="a=ssrc:"+e.sendEncodingParameters[0].ssrc+" cname:"+r.localCName+"\r\n"},r.getDirection=function(e,t){for(var n=r.splitLines(e),o=0;o0&&"function"==typeof e)return o(e,t);var a=function(e){var t={},n=e.result();return n.forEach(function(e){var n={id:e.id,timestamp:e.timestamp,type:e.type};e.names().forEach(function(t){n[t]=e.stat(t)}),t[n.id]=n}),t},c=function(e,t){var n=new Map(Object.keys(e).map(function(t){return[t,e[t]]}));return t=t||e,Object.keys(t).forEach(function(e){n[e]=t[e]}),n};if(arguments.length>=2){var u=function(e){i[1](c(a(e)))};return o.apply(this,[u,arguments[0]])}return new Promise(function(t,n){1===i.length&&"object"==typeof e?o.apply(r,[function(e){t(c(a(e)))},n]):o.apply(r,[function(e){t(c(a(e),e.result()))},n])}).then(t,n)},n},window.RTCPeerConnection.prototype=webkitRTCPeerConnection.prototype,webkitRTCPeerConnection.generateCertificate&&Object.defineProperty(window.RTCPeerConnection,"generateCertificate",{get:function(){return webkitRTCPeerConnection.generateCertificate}}),["createOffer","createAnswer"].forEach(function(e){var t=webkitRTCPeerConnection.prototype[e];webkitRTCPeerConnection.prototype[e]=function(){var e=this;if(arguments.length<1||1===arguments.length&&"object"==typeof arguments[0]){var n=1===arguments.length?arguments[0]:void 0;return new Promise(function(r,o){t.apply(e,[r,o,n])})}return t.apply(this,arguments)}}),o.version<51&&["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=webkitRTCPeerConnection.prototype[e];webkitRTCPeerConnection.prototype[e]=function(){var e=arguments,n=this,r=new Promise(function(r,o){t.apply(n,[e[0],r,o])});return e.length<2?r:r.then(function(){e[1].apply(null,[])},function(t){e.length>=3&&e[2].apply(null,[t])})}});var e=RTCPeerConnection.prototype.addIceCandidate;RTCPeerConnection.prototype.addIceCandidate=function(){return null===arguments[0]?Promise.resolve():e.apply(this,arguments)},["setLocalDescription","setRemoteDescription","addIceCandidate"].forEach(function(e){var t=webkitRTCPeerConnection.prototype[e];webkitRTCPeerConnection.prototype[e]=function(){return arguments[0]=new("addIceCandidate"===e?RTCIceCandidate:RTCSessionDescription)(arguments[0]),t.apply(this,arguments)}})},attachMediaStream:function(e,t){r("DEPRECATED, attachMediaStream will soon be removed."),o.version>=43?e.srcObject=t:"undefined"!=typeof e.src?e.src=URL.createObjectURL(t):r("Error attaching stream to element.")},reattachMediaStream:function(e,t){r("DEPRECATED, reattachMediaStream will soon be removed."),o.version>=43?e.srcObject=t.srcObject:e.src=t.src}};e.e={shimMediaStream:i.shimMediaStream,shimOnTrack:i.shimOnTrack,shimSourceObject:i.shimSourceObject,shimPeerConnection:i.shimPeerConnection,shimGetUserMedia:n(214),attachMediaStream:i.attachMediaStream,reattachMediaStream:i.reattachMediaStream}},function(e,t,n){"use strict";var r=n(1).log;e.e=function(){var e=function(e){if("object"!=typeof e||e.mandatory||e.optional)return e;var t={};return Object.keys(e).forEach(function(n){if("require"!==n&&"advanced"!==n&&"mediaSource"!==n){var r="object"==typeof e[n]?e[n]:{ideal:e[n]};void 0!==r.exact&&"number"==typeof r.exact&&(r.min=r.max=r.exact);var o=function(e,t){return e?e+t.charAt(0).toUpperCase()+t.slice(1):"deviceId"===t?"sourceId":t};if(void 0!==r.ideal){t.optional=t.optional||[];var i={};"number"==typeof r.ideal?(i[o("min",n)]=r.ideal,t.optional.push(i),i={},i[o("max",n)]=r.ideal,t.optional.push(i)):(i[o("",n)]=r.ideal,t.optional.push(i))}void 0!==r.exact&&"number"!=typeof r.exact?(t.mandatory=t.mandatory||{},t.mandatory[o("",n)]=r.exact):["min","max"].forEach(function(e){void 0!==r[e]&&(t.mandatory=t.mandatory||{},t.mandatory[o(e,n)]=r[e])})}}),e.advanced&&(t.optional=(t.optional||[]).concat(e.advanced)),t},t=function(t,n){if(t=JSON.parse(JSON.stringify(t)),t&&t.audio&&(t.audio=e(t.audio)),t&&"object"==typeof t.video){var o=t.video.facingMode;if(o=o&&("object"==typeof o?o:{ideal:o}),o&&("user"===o.exact||"environment"===o.exact||"user"===o.ideal||"environment"===o.ideal)&&(!navigator.mediaDevices.getSupportedConstraints||!navigator.mediaDevices.getSupportedConstraints().facingMode)&&(delete t.video.facingMode,"environment"===o.exact||"environment"===o.ideal))return navigator.mediaDevices.enumerateDevices().then(function(i){i=i.filter(function(e){return"videoinput"===e.kind});var a=i.find(function(e){return e.label.toLowerCase().indexOf("back")!==-1})||i.length&&i[i.length-1];return a&&(t.video.deviceId=o.exact?{exact:a.deviceId}:{ideal:a.deviceId}),t.video=e(t.video),r("chrome: "+JSON.stringify(t)),n(t)});t.video=e(t.video)}return r("chrome: "+JSON.stringify(t)),n(t)},n=function(e){return{name:{PermissionDeniedError:"NotAllowedError",ConstraintNotSatisfiedError:"OverconstrainedError"}[e.name]||e.name,message:e.message,constraint:e.constraintName,toString:function(){return this.name+(this.message&&": ")+this.message}}},o=function(e,r,o){t(e,function(e){navigator.webkitGetUserMedia(e,r,function(e){o(n(e))})})};navigator.getUserMedia=o;var i=function(e){return new Promise(function(t,n){navigator.getUserMedia(e,t,n)})};if(navigator.mediaDevices||(navigator.mediaDevices={getUserMedia:i,enumerateDevices:function(){return new Promise(function(e){var t={audio:"audioinput",video:"videoinput"};return MediaStreamTrack.getSources(function(n){e(n.map(function(e){return{label:e.label,kind:t[e.kind],deviceId:e.id,groupId:""}}))})})}}),navigator.mediaDevices.getUserMedia){var a=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(e){return t(e,function(e){return a(e)["catch"](function(e){return Promise.reject(n(e))})})}}else navigator.mediaDevices.getUserMedia=function(e){return i(e)};"undefined"==typeof navigator.mediaDevices.addEventListener&&(navigator.mediaDevices.addEventListener=function(){r("Dummy mediaDevices.addEventListener called.")}),"undefined"==typeof navigator.mediaDevices.removeEventListener&&(navigator.mediaDevices.removeEventListener=function(){r("Dummy mediaDevices.removeEventListener called.")})}},function(e,t,n){"use strict";var r=n(210),o=n(1).log,i={shimPeerConnection:function(){window.RTCIceGatherer&&(window.RTCIceCandidate||(window.RTCIceCandidate=function(e){return e}),window.RTCSessionDescription||(window.RTCSessionDescription=function(e){return e})),window.RTCPeerConnection=function(e){var t=this,n=document.createDocumentFragment();if(["addEventListener","removeEventListener","dispatchEvent"].forEach(function(e){t[e]=n[e].bind(n)}),this.onicecandidate=null,this.onaddstream=null,this.ontrack=null,this.onremovestream=null,this.onsignalingstatechange=null,this.oniceconnectionstatechange=null,this.onnegotiationneeded=null,this.ondatachannel=null,this.localStreams=[],this.remoteStreams=[],this.getLocalStreams=function(){return t.localStreams},this.getRemoteStreams=function(){return t.remoteStreams},this.localDescription=new RTCSessionDescription({type:"",sdp:""}),this.remoteDescription=new RTCSessionDescription({type:"",sdp:""}),this.signalingState="stable",this.iceConnectionState="new",this.iceGatheringState="new",this.iceOptions={gatherPolicy:"all",iceServers:[]},e&&e.iceTransportPolicy)switch(e.iceTransportPolicy){case"all":case"relay":this.iceOptions.gatherPolicy=e.iceTransportPolicy;break;case"none":throw new TypeError('iceTransportPolicy "none" not supported')}if(this.usingBundle=e&&"max-bundle"===e.bundlePolicy,e&&e.iceServers){var r=JSON.parse(JSON.stringify(e.iceServers));this.iceOptions.iceServers=r.filter(function(e){if(e&&e.urls){var t=e.urls;return"string"==typeof t&&(t=[t]),t=t.filter(function(e){return 0===e.indexOf("turn:")&&e.indexOf("transport=udp")!==-1})[0],!!t}return!1})}this.transceivers=[],this._localIceCandidatesBuffer=[]},window.RTCPeerConnection.prototype._emitBufferedCandidates=function(){var e=this,t=r.splitSections(e.localDescription.sdp);this._localIceCandidatesBuffer.forEach(function(n){var r=!n.candidate||0===Object.keys(n.candidate).length;if(r)for(var o=1;o-1&&(this.localStreams.splice(t,1),this._maybeFireNegotiationNeeded())},window.RTCPeerConnection.prototype.getSenders=function(){return this.transceivers.filter(function(e){return!!e.rtpSender}).map(function(e){return e.rtpSender})},window.RTCPeerConnection.prototype.getReceivers=function(){return this.transceivers.filter(function(e){return!!e.rtpReceiver}).map(function(e){return e.rtpReceiver})},window.RTCPeerConnection.prototype._getCommonCapabilities=function(e,t){var n={codecs:[],headerExtensions:[],fecMechanisms:[]};return e.codecs.forEach(function(e){for(var r=0;r0;t.forEach(function(e,t){var a=o.transceivers[t],c=a.iceGatherer,u=a.iceTransport,s=a.dtlsTransport,f=a.localCapabilities,d=a.remoteCapabilities,l="0"===e.split("\n",1)[0].split(" ",2)[1];if(!l){var p=r.getIceParameters(e,n);if(i){var h=r.matchPrefix(e,"a=candidate:").map(function(e){return r.parseCandidate(e)}).filter(function(e){return"1"===e.component});h.length&&u.setRemoteCandidates(h)}var v=r.getDtlsParameters(e,n);i&&(v.role="server"),o.usingBundle&&0!==t||(u.start(c,p,i?"controlling":"controlled"),s.start(v));var g=o._getCommonCapabilities(f,d);o._transceive(a,g.codecs.length>0,!1)}})}switch(this.localDescription={type:e.type,sdp:e.sdp},e.type){case"offer":this._updateSignalingState("have-local-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+e.type+'"')}var a=arguments.length>1&&"function"==typeof arguments[1];if(a){var c=arguments[1];window.setTimeout(function(){c(),"new"===o.iceGatheringState&&(o.iceGatheringState="gathering"),o._emitBufferedCandidates()},0)}var u=Promise.resolve();return u.then(function(){a||("new"===o.iceGatheringState&&(o.iceGatheringState="gathering"),window.setTimeout(o._emitBufferedCandidates.bind(o),500))}),u},window.RTCPeerConnection.prototype.setRemoteDescription=function(e){var t=this,n=new MediaStream,o=[],i=r.splitSections(e.sdp),a=i.shift(),c=r.matchPrefix(a,"a=ice-lite").length>0; switch(this.usingBundle=r.matchPrefix(a,"a=group:BUNDLE ").length>0,i.forEach(function(i,u){var s,f,d,l,p,h,v,g,m,y,b,_,w=r.splitLines(i),C=w[0].substr(2).split(" "),E=C[0],S="0"===C[1],T=r.getDirection(i,a),R=r.parseRtpParameters(i);S||(b=r.getIceParameters(i,a),_=r.getDtlsParameters(i,a),_.role="client"),g=r.parseRtpEncodingParameters(i);var O=r.matchPrefix(i,"a=mid:");O=O.length?O[0].substr(6):r.generateIdentifier();var x,P=r.matchPrefix(i,"a=ssrc:").map(function(e){return r.parseSsrcMedia(e)}).filter(function(e){return"cname"===e.attribute})[0];P&&(x=P.value);var D=r.matchPrefix(i,"a=end-of-candidates").length>0,A=r.matchPrefix(i,"a=candidate:").map(function(e){return r.parseCandidate(e)}).filter(function(e){return"1"===e.component});if("offer"!==e.type||S)"answer"!==e.type||S||(s=t.transceivers[u],f=s.iceGatherer,d=s.iceTransport,l=s.dtlsTransport,p=s.rtpSender,h=s.rtpReceiver,v=s.sendEncodingParameters,m=s.localCapabilities,t.transceivers[u].recvEncodingParameters=g,t.transceivers[u].remoteCapabilities=R,t.transceivers[u].cname=x,(c||D)&&A.length&&d.setRemoteCandidates(A),t.usingBundle&&0!==u||(d.start(f,b,"controlling"),l.start(_)),t._transceive(s,"sendrecv"===T||"recvonly"===T,"sendrecv"===T||"sendonly"===T),!h||"sendrecv"!==T&&"sendonly"!==T?delete s.rtpReceiver:(y=h.track,o.push([y,h]),n.addTrack(y)));else{var M=t.usingBundle&&u>0?{iceGatherer:t.transceivers[0].iceGatherer,iceTransport:t.transceivers[0].iceTransport,dtlsTransport:t.transceivers[0].dtlsTransport}:t._createIceAndDtlsTransports(O,u);if(D&&M.iceTransport.setRemoteCandidates(A),m=RTCRtpReceiver.getCapabilities(E),v=[{ssrc:1001*(2*u+2)}],h=new RTCRtpReceiver(M.dtlsTransport,E),y=h.track,o.push([y,h]),n.addTrack(y),t.localStreams.length>0&&t.localStreams[0].getTracks().length>=u){var j=t.localStreams[0].getTracks()[u];p=new RTCRtpSender(j,M.dtlsTransport)}t.transceivers[u]={iceGatherer:M.iceGatherer,iceTransport:M.iceTransport,dtlsTransport:M.dtlsTransport,localCapabilities:m,remoteCapabilities:R,rtpSender:p,rtpReceiver:h,kind:E,mid:O,cname:x,sendEncodingParameters:v,recvEncodingParameters:g},t._transceive(t.transceivers[u],!1,"sendrecv"===T||"sendonly"===T)}}),this.remoteDescription={type:e.type,sdp:e.sdp},e.type){case"offer":this._updateSignalingState("have-remote-offer");break;case"answer":this._updateSignalingState("stable");break;default:throw new TypeError('unsupported type "'+e.type+'"')}return n.getTracks().length&&(t.remoteStreams.push(n),window.setTimeout(function(){var e=new Event("addstream");e.stream=n,t.dispatchEvent(e),null!==t.onaddstream&&window.setTimeout(function(){t.onaddstream(e)},0),o.forEach(function(r){var o=r[0],i=r[1],a=new Event("track");a.track=o,a.receiver=i,a.streams=[n],t.dispatchEvent(e),null!==t.ontrack&&window.setTimeout(function(){t.ontrack(a)},0)})},0)),arguments.length>1&&"function"==typeof arguments[1]&&window.setTimeout(arguments[1],0),Promise.resolve()},window.RTCPeerConnection.prototype.close=function(){this.transceivers.forEach(function(e){e.iceTransport&&e.iceTransport.stop(),e.dtlsTransport&&e.dtlsTransport.stop(),e.rtpSender&&e.rtpSender.stop(),e.rtpReceiver&&e.rtpReceiver.stop()}),this._updateSignalingState("closed")},window.RTCPeerConnection.prototype._updateSignalingState=function(e){this.signalingState=e;var t=new Event("signalingstatechange");this.dispatchEvent(t),null!==this.onsignalingstatechange&&this.onsignalingstatechange(t)},window.RTCPeerConnection.prototype._maybeFireNegotiationNeeded=function(){var e=new Event("negotiationneeded");this.dispatchEvent(e),null!==this.onnegotiationneeded&&this.onnegotiationneeded(e)},window.RTCPeerConnection.prototype._updateConnectionState=function(){var e,t=this,n={"new":0,closed:0,connecting:0,checking:0,connected:0,completed:0,failed:0};if(this.transceivers.forEach(function(e){n[e.iceTransport.state]++,n[e.dtlsTransport.state]++}),n.connected+=n.completed,e="new",n.failed>0?e="failed":n.connecting>0||n.checking>0?e="connecting":n.disconnected>0?e="disconnected":n["new"]>0?e="new":(n.connected>0||n.completed>0)&&(e="connected"),e!==t.iceConnectionState){t.iceConnectionState=e;var r=new Event("iceconnectionstatechange");this.dispatchEvent(r),null!==this.oniceconnectionstatechange&&this.oniceconnectionstatechange(r)}},window.RTCPeerConnection.prototype.createOffer=function(){var e=this;if(this._pendingOffer)throw new Error("createOffer called while there is a pending offer.");var t;1===arguments.length&&"function"!=typeof arguments[0]?t=arguments[0]:3===arguments.length&&(t=arguments[2]);var n=[],o=0,i=0;if(this.localStreams.length&&(o=this.localStreams[0].getAudioTracks().length,i=this.localStreams[0].getVideoTracks().length),t){if(t.mandatory||t.optional)throw new TypeError("Legacy mandatory/optional constraints not supported.");void 0!==t.offerToReceiveAudio&&(o=t.offerToReceiveAudio),void 0!==t.offerToReceiveVideo&&(i=t.offerToReceiveVideo)}for(this.localStreams.length&&this.localStreams[0].getTracks().forEach(function(e){n.push({kind:e.kind,track:e,wantReceive:"audio"===e.kind?o>0:i>0}),"audio"===e.kind?o--:"video"===e.kind&&i--});o>0||i>0;)o>0&&(n.push({kind:"audio",wantReceive:!0}),o--),i>0&&(n.push({kind:"video",wantReceive:!0}),i--);var a=r.writeSessionBoilerplate(),c=[];n.forEach(function(t,n){var o,i,a=t.track,u=t.kind,s=r.generateIdentifier(),f=e.usingBundle&&n>0?{iceGatherer:c[0].iceGatherer,iceTransport:c[0].iceTransport,dtlsTransport:c[0].dtlsTransport}:e._createIceAndDtlsTransports(s,n),d=RTCRtpSender.getCapabilities(u),l=[{ssrc:1001*(2*n+1)}];a&&(o=new RTCRtpSender(a,f.dtlsTransport)),t.wantReceive&&(i=new RTCRtpReceiver(f.dtlsTransport,u)),c[n]={iceGatherer:f.iceGatherer,iceTransport:f.iceTransport,dtlsTransport:f.dtlsTransport,localCapabilities:d,remoteCapabilities:null,rtpSender:o,rtpReceiver:i,kind:u,mid:s,sendEncodingParameters:l,recvEncodingParameters:null}}),this.usingBundle&&(a+="a=group:BUNDLE "+c.map(function(e){return e.mid}).join(" ")+"\r\n"),n.forEach(function(t,n){var o=c[n];a+=r.writeMediaSection(o,o.localCapabilities,"offer",e.localStreams[0])}),this._pendingOffer=c;var u=new RTCSessionDescription({type:"offer",sdp:a});return arguments.length&&"function"==typeof arguments[0]&&window.setTimeout(arguments[0],0,u),Promise.resolve(u)},window.RTCPeerConnection.prototype.createAnswer=function(){var e=this,t=r.writeSessionBoilerplate();this.usingBundle&&(t+="a=group:BUNDLE "+this.transceivers.map(function(e){return e.mid}).join(" ")+"\r\n"),this.transceivers.forEach(function(n){var o=e._getCommonCapabilities(n.localCapabilities,n.remoteCapabilities);t+=r.writeMediaSection(n,o,"answer",e.localStreams[0])});var n=new RTCSessionDescription({type:"answer",sdp:t});return arguments.length&&"function"==typeof arguments[0]&&window.setTimeout(arguments[0],0,n),Promise.resolve(n)},window.RTCPeerConnection.prototype.addIceCandidate=function(e){if(null===e)this.transceivers.forEach(function(e){e.iceTransport.addRemoteCandidate({})});else{var t=e.sdpMLineIndex;if(e.sdpMid)for(var n=0;n0?r.parseCandidate(e.candidate):{};if("tcp"===i.protocol&&0===i.port)return;if("1"!==i.component)return;"endOfCandidates"===i.type&&(i={}),o.iceTransport.addRemoteCandidate(i);var a=r.splitSections(this.remoteDescription.sdp);a[t+1]+=(i.type?e.candidate.trim():"a=end-of-candidates")+"\r\n",this.remoteDescription.sdp=a.join("")}}return arguments.length>1&&"function"==typeof arguments[1]&&window.setTimeout(arguments[1],0),Promise.resolve()},window.RTCPeerConnection.prototype.getStats=function(){var e=[];this.transceivers.forEach(function(t){["rtpSender","rtpReceiver","iceGatherer","iceTransport","dtlsTransport"].forEach(function(n){t[n]&&e.push(t[n].getStats())})});var t=arguments.length>1&&"function"==typeof arguments[1]&&arguments[1];return new Promise(function(n){var r=new Map;Promise.all(e).then(function(e){e.forEach(function(e){Object.keys(e).forEach(function(t){r.set(t,e[t]),r[t]=e[t]})}),t&&window.setTimeout(t,0,r),n(r)})})}},attachMediaStream:function(e,t){o("DEPRECATED, attachMediaStream will soon be removed."),e.srcObject=t},reattachMediaStream:function(e,t){o("DEPRECATED, reattachMediaStream will soon be removed."),e.srcObject=t.srcObject}};e.e={shimPeerConnection:i.shimPeerConnection,shimGetUserMedia:n(216),attachMediaStream:i.attachMediaStream,reattachMediaStream:i.reattachMediaStream}},function(e,t,n){"use strict";e.e=function(){var e=function(e){return{name:{PermissionDeniedError:"NotAllowedError"}[e.name]||e.name,message:e.message,constraint:e.constraint,toString:function(){return this.name}}},t=navigator.mediaDevices.getUserMedia.bind(navigator.mediaDevices);navigator.mediaDevices.getUserMedia=function(n){return t(n)["catch"](function(t){return Promise.reject(e(t))})}}},function(e,t,n){"use strict";var r=n(1).log,o=n(1).browserDetails,i={shimOnTrack:function(){"object"!=typeof window||!window.RTCPeerConnection||"ontrack"in window.RTCPeerConnection.prototype||Object.defineProperty(window.RTCPeerConnection.prototype,"ontrack",{get:function(){return this._ontrack},set:function(e){this._ontrack&&(this.removeEventListener("track",this._ontrack),this.removeEventListener("addstream",this._ontrackpoly)),this.addEventListener("track",this._ontrack=e),this.addEventListener("addstream",this._ontrackpoly=function(e){e.stream.getTracks().forEach(function(t){var n=new Event("track");n.track=t,n.receiver={track:t},n.streams=[e.stream],this.dispatchEvent(n)}.bind(this))}.bind(this))}})},shimSourceObject:function(){"object"==typeof window&&(!window.HTMLMediaElement||"srcObject"in window.HTMLMediaElement.prototype||Object.defineProperty(window.HTMLMediaElement.prototype,"srcObject",{get:function(){return this.mozSrcObject},set:function(e){this.mozSrcObject=e}}))},shimPeerConnection:function(){if("object"==typeof window&&(window.RTCPeerConnection||window.mozRTCPeerConnection)){window.RTCPeerConnection||(window.RTCPeerConnection=function(e,t){if(o.version<38&&e&&e.iceServers){for(var n=[],r=0;r +
+

Scan barcode to input-field

+

Click the button next to the input-field + to start scanning an EAN-13 barcode

+
+
+
+ + + +
+
+
+

This example demonstrates the following features: +

    +
  • Access to user's camera
  • +
  • Configuring EAN-Reader
  • +
  • Use custom mount-point (Query-Selector)
  • +
  • Start/Stop scanning based on certain events
  • +
+

+
+

Source

+
+
+                
+var Quagga = window.Quagga;
+var App = {
+    _scanner: null,
+    init: function() {
+        this.attachListeners();
+    },
+    activateScanner: function() {
+        var scanner = this.configureScanner('.overlay__content'),
+            onDetected = function (result) {
+                document.querySelector('input.isbn').value = result.codeResult.code;
+                stop();
+            }.bind(this),
+            stop = function() {
+                scanner.stop();  // should also clear all event-listeners?
+                scanner.removeEventListener('detected', onDetected);
+                this.hideOverlay();
+                this.attachListeners();
+            }.bind(this);
+
+        this.showOverlay(stop);
+        scanner.addEventListener('detected', onDetected).start();
+    },
+    attachListeners: function() {
+        var self = this,
+            button = document.querySelector('.input-field input + button.scan');
+
+        button.addEventListener("click", function onClick(e) {
+            e.preventDefault();
+            button.removeEventListener("click", onClick);
+            self.activateScanner();
+        });
+    },
+    showOverlay: function(cancelCb) {
+        if (!this._overlay) {
+            var content = document.createElement('div'),
+                closeButton = document.createElement('div');
+
+            closeButton.appendChild(document.createTextNode('X'));
+            content.className = 'overlay__content';
+            closeButton.className = 'overlay__close';
+            this._overlay = document.createElement('div');
+            this._overlay.className = 'overlay';
+            this._overlay.appendChild(content);
+            content.appendChild(closeButton);
+            closeButton.addEventListener('click', function closeClick() {
+                closeButton.removeEventListener('click', closeClick);
+                cancelCb();
+            });
+            document.body.appendChild(this._overlay);
+        } else {
+            var closeButton = document.querySelector('.overlay__close');
+            closeButton.addEventListener('click', function closeClick() {
+                closeButton.removeEventListener('click', closeClick);
+                cancelCb();
+            });
+        }
+        this._overlay.style.display = "block";
+    },
+    hideOverlay: function() {
+        if (this._overlay) {
+            this._overlay.style.display = "none";
+        }
+    },
+    configureScanner: function(selector) {
+        if (!this._scanner) {
+            this._scanner = Quagga
+                .decoder({readers: ['ean_reader']})
+                .locator({patchSize: 'medium'})
+                .fromVideo({
+                    target: selector,
+                    constraints: {
+                        width: 800,
+                        height: 600,
+                        facingMode: "environment"
+                    }
+                });
+        }
+        return this._scanner;
+    }
+};
+App.init();
+                
+            
+
+
+
+                
+<form>
+    <div class="input-field">
+        <label for="isbn_input">EAN:</label>
+        <input id="isbn_input" class="isbn" type="text" />
+        <button type="button" class="icon-barcode button scan"> </button>
+    </div>
+</form>
+                
+            
+
+
+
+ + + + diff --git a/v1.0.0-beta.1/examples/scan-to-input/index.js b/v1.0.0-beta.1/examples/scan-to-input/index.js new file mode 100644 index 0000000..09d2d15 --- /dev/null +++ b/v1.0.0-beta.1/examples/scan-to-input/index.js @@ -0,0 +1,81 @@ +var Quagga = window.Quagga; +var App = { + _scanner: null, + init: function() { + this.attachListeners(); + }, + activateScanner: function() { + var scanner = this.configureScanner('.overlay__content'), + onDetected = function (result) { + document.querySelector('input.isbn').value = result.codeResult.code; + stop(); + }.bind(this), + stop = function() { + scanner.stop(); // should also clear all event-listeners? + scanner.removeEventListener('detected', onDetected); + this.hideOverlay(); + this.attachListeners(); + }.bind(this); + + this.showOverlay(stop); + scanner.addEventListener('detected', onDetected).start(); + }, + attachListeners: function() { + var self = this, + button = document.querySelector('.input-field input + button.scan'); + + button.addEventListener("click", function onClick(e) { + e.preventDefault(); + button.removeEventListener("click", onClick); + self.activateScanner(); + }); + }, + showOverlay: function(cancelCb) { + if (!this._overlay) { + var content = document.createElement('div'), + closeButton = document.createElement('div'); + + closeButton.appendChild(document.createTextNode('X')); + content.className = 'overlay__content'; + closeButton.className = 'overlay__close'; + this._overlay = document.createElement('div'); + this._overlay.className = 'overlay'; + this._overlay.appendChild(content); + content.appendChild(closeButton); + closeButton.addEventListener('click', function closeClick() { + closeButton.removeEventListener('click', closeClick); + cancelCb(); + }); + document.body.appendChild(this._overlay); + } else { + var closeButton = document.querySelector('.overlay__close'); + closeButton.addEventListener('click', function closeClick() { + closeButton.removeEventListener('click', closeClick); + cancelCb(); + }); + } + this._overlay.style.display = "block"; + }, + hideOverlay: function() { + if (this._overlay) { + this._overlay.style.display = "none"; + } + }, + configureScanner: function(selector) { + if (!this._scanner) { + this._scanner = Quagga + .decoder({readers: ['ean_reader']}) + .locator({patchSize: 'medium'}) + .fromSource({ + target: selector, + constraints: { + width: 800, + height: 600, + facingMode: "environment" + } + }); + } + return this._scanner; + } +}; +App.init(); diff --git a/v1.0.0-beta.1/index.md b/v1.0.0-beta.1/index.md new file mode 100644 index 0000000..5e387e8 --- /dev/null +++ b/v1.0.0-beta.1/index.md @@ -0,0 +1,826 @@ +--- +layout: default +title: Home +showInMenu: true +--- + +quaggaJS +======== + +- [Changelog](#changelog) (2016-04-24) +- [Browser Support](#browser-support) +- [Installing](#installing) +- [Getting Started](#gettingstarted) +- [API](#api) +- [Configuration](#configobject) + +## What is QuaggaJS? + +QuaggaJS is a barcode-scanner entirely written in JavaScript supporting real- +time localization and decoding of various types of barcodes such as __EAN__, +__CODE 128__, __CODE 39__, __EAN 8__, __UPC-A__, __UPC-C__, __I2of5__ and +__CODABAR__. The library is also capable of using `getUserMedia` to get direct +access to the user's camera stream. Although the code relies on heavy image- +processing even recent smartphones are capable of locating and decoding +barcodes in real-time. + +Try some [examples](https://serratus.github.io/quaggaJS/examples) and check out +the blog post ([How barcode-localization works in QuaggaJS][oberhofer_co_how]) +if you want to dive deeper into this topic. + +![teaser][teaser_left]![teaser][teaser_right] + + +## Yet another barcode library? + +This is not yet another port of the great [zxing][zxing_github] library, but +more of an extension to it. This implementation features a barcode locator which +is capable of finding a barcode-like pattern in an image resulting in an +estimated bounding box including the rotation. Simply speaking, this reader is +invariant to scale and rotation, whereas other libraries require the barcode to +be aligned with the viewport. + + +## Browser Support + +Quagga makes use of many modern Web-APIs which are not implemented by all +browsers yet. There are two modes in which Quagga operates: 1. analyzing static +images and 2. using a camera to decode the images from a live-stream. The latter +requires the presence of the MediaDevices API. You can track the compatibility +of the used Web-APIs for each mode: + +- [Static Images](http://caniuse.com/#feat=webworkers,canvas,typedarrays,bloburls,blobbuilder) +- [Live Stream](http://caniuse.com/#feat=webworkers,canvas,typedarrays,bloburls,blobbuilder,stream) + +### Static Images + +The following APIs need to be implemented in your browser: +- [webworkers](http://caniuse.com/#feat=webworkers) +- [canvas](http://caniuse.com/#feat=canvas) +- [typedarrays](http://caniuse.com/#feat=typedarrays) +- [bloburls](http://caniuse.com/#feat=bloburls) +- [blobbuilder](http://caniuse.com/#feat=blobbuilder) + +### Live Stream + +In addition to the APIs mentioned above: +- [MediaDevices](http://caniuse.com/#feat=stream) + +## Installing + +QuaggaJS can be installed using __npm__, __bower__, or by including it with +the __script__ tag. + +### NPM + +```console +> npm install quagga +``` + +And then import it as dependency in your project: + +```javascript +import Quagga from 'quagga'; // ES6 +const Quagga = require('quagga').default; // Common JS (important: default) +``` + +Currently, the full functionality is only available through the browser. When +using QuaggaJS within __node__, only file-based decoding is available. See the +example for [node_examples](#node-example). + +### Bower + +You can also install QuaggaJS through __bower__: + +```console +> bower install quagga +``` + +### Script-Tag Anno 1998 + +You can simply include `dist/quagga.min.js` in your project and you are ready +to go. The script exposes the library on the global namespace under `Quagga`. + + +## Getting Started + +For starters, have a look at the [examples][github_examples] to get an idea +where to go from here. + + +## Building + +You can build the library yourself by simply cloning the repo and typing: + +```console +> npm install +> npm run build +``` + +This npm script builds a non optimized version `quagga.js` and a minified +version `quagga.min.js` and places both files in the `dist` folder. +Additionally, a `quagga.map` source-map is placed alongside these files. This +file is only valid for the non-uglified version `quagga.js` because the +minified version is altered after compression and does not align with the map +file any more. + +### Node + +The code in the `dist` folder is only targeted to the browser and won't work in +node due to the dependency on the DOM. For the use in node, the `build` command +also creates a `quagga.js` file in the `lib` folder. + +## API + +You can check out the [examples][github_examples] to get an idea of how to +use QuaggaJS. Basically the library exposes the following API: + +### Quagga.init(config, callback) + +This method initializes the library for a given configuration `config` (see +below) and invokes the `callback(err)` when Quagga has finished its +bootstrapping phase. The initialization process also requests for camera +access if real-time detection is configured. In case of an error, the `err` +parameter is set and contains information about the cause. A potential cause +may be the `inputStream.type` is set to `LiveStream`, but the browser does +not support this API, or simply if the user denies the permission to use the +camera. + +If you do not specify a target, QuaggaJS would look for an element that matches +the CSS selector `#interactive.viewport` (for backwards compatibility). +`target` can be a string (CSS selector matching one of your DOM node) or a DOM +node. + +```javascript +Quagga.init({ + inputStream : { + name : "Live", + type : "LiveStream", + target: document.querySelector('#yourElement') // Or '#yourElement' (optional) + }, + decoder : { + readers : ["code_128_reader"] + } + }, function(err) { + if (err) { + console.log(err); + return + } + console.log("Initialization finished. Ready to start"); + Quagga.start(); + }); +``` + +### Quagga.start() + +When the library is initialized, the `start()` method starts the video-stream +and begins locating and decoding the images. + +### Quagga.stop() + +If the decoder is currently running, after calling `stop()` the decoder does not +process any more images. Additionally, if a camera-stream was requested upon +initialization, this operation also disconnects the camera. + +### Quagga.onProcessed(callback) + +This method registers a `callback(data)` function that is called for each frame +after the processing is done. The `data` object contains detailed information +about the success/failure of the operation. The output varies, depending whether +the detection and/or decoding were successful or not. + +### Quagga.onDetected(callback) + +Registers a `callback(data)` function which is triggered whenever a barcode- +pattern has been located and decoded successfully. The passed `data` object +contains information about the decoding process including the detected code +which can be obtained by calling `data.codeResult.code`. + +### Quagga.decodeSingle(config, callback) + +In contrast to the calls described above, this method does not rely on +`getUserMedia` and operates on a single image instead. The provided callback +is the same as in `onDetected` and contains the result `data` object. + +### Quagga.offProcessed(handler) + +In case the `onProcessed` event is no longer relevant, `offProcessed` removes +the given `handler` from the event-queue. + +### Quagga.offDetected(handler) + +In case the `onDetected` event is no longer relevant, `offDetected` removes +the given `handler` from the event-queue. + +## The result object + +The callbacks passed into `onProcessed`, `onDetected` and `decodeSingle` +receive a `data` object upon execution. The `data` object contains the following +information. Depending on the success, some fields may be `undefined` or just +empty. + +```javascript +{ + "codeResult": { + "code": "FANAVF1461710", // the decoded code as a string + "format": "code_128", // or code_39, codabar, ean_13, ean_8, upc_a, upc_e + "start": 355, + "end": 26, + "codeset": 100, + "startInfo": { + "error": 1.0000000000000002, + "code": 104, + "start": 21, + "end": 41 + }, + "decodedCodes": [{ + "code": 104, + "start": 21, + "end": 41 + }, + // stripped for brevity + { + "error": 0.8888888888888893, + "code": 106, + "start": 328, + "end": 350 + }], + "endInfo": { + "error": 0.8888888888888893, + "code": 106, + "start": 328, + "end": 350 + }, + "direction": -1 + }, + "line": [{ + "x": 25.97278706156836, + "y": 360.5616435369468 + }, { + "x": 401.9220519377024, + "y": 70.87524989906444 + }], + "angle": -0.6565217179979483, + "pattern": [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, /* ... */ 1], + "box": [ + [77.4074243622672, 410.9288668804402], + [0.050203235235130705, 310.53619724086366], + [360.15706727788256, 33.05711026051813], + [437.5142884049146, 133.44977990009465] + ], + "boxes": [ + [ + [77.4074243622672, 410.9288668804402], + [0.050203235235130705, 310.53619724086366], + [360.15706727788256, 33.05711026051813], + [437.5142884049146, 133.44977990009465] + ], + [ + [248.90769330706507, 415.2041489551161], + [198.9532321622869, 352.62160512937635], + [339.546160777576, 240.3979259789976], + [389.5006219223542, 302.98046980473737] + ] + ] +} +``` + +## Configuration + +The configuration that ships with QuaggaJS covers the default use-cases and can +be fine-tuned for specific requirements. + +The configuration is managed by the `config` object defining the following +high-level properties: + +```javascript +{ + numOfWorkers: 4, + locate: true, + inputStream: {...}, + frequency: 10, + decoder:{...}, + locator: {...}, + debug: false, +} +``` + +### numOfWorkers + +QuaggaJS supports web-workers out of the box and runs with `4` workers in its +default configuration. The number should align with the number of cores +available in your targeted devices. + +In case you don't know the number upfront, or if the variety of devices is +too big, you can either use `navigator.hardwareConcurrency` (see +[here](https://wiki.whatwg.org/wiki/Navigator_HW_Concurrency)) where available +or make use of [core-estimator](https://github.com/oftn/core-estimator). + +### locate + +One of the main features of QuaggaJS is its ability to locate a barcode in a +given image. The `locate` property controls whether this feature is turned on +(default) or off. + +Why would someone turn this feature off? Localizing a barcode is a +computationally expensive operation and might not work properly on some +devices. Another reason would be the lack of auto-focus producing blurry +images which makes the localization feature very unstable. + +However, even if none of the above apply, there is one more case where it might +be useful to disable `locate`: If the orientation, and/or the approximate +position of the barcode is known, or if you want to guide the user through a +rectangular outline. This can increase performance and robustness at the same +time. + +### inputStream + +The `inputStream` property defines the sources of images/videos within QuaggaJS. + +```javascript +{ + name: "Live", + type: "LiveStream", + constraints: { + width: 640, + height: 480, + facingMode: "environment", + deviceId: "7832475934759384534" + }, + area: { // defines rectangle of the detection/localization area + top: "0%", // top offset + right: "0%", // right offset + left: "0%", // left offset + bottom: "0%" // bottom offset + }, + singleChannel: false // true: only the red color-channel is read +} +``` + +First, the `type` property can be set to three different values: +`ImageStream`, `VideoStream`, or `LiveStream` (default) and should be selected +depending on the use-case. Most probably, the default value is sufficient. + +Second, the `constraint` key defines the physical dimensions of the input image +and additional properties, such as `facingMode` which sets the source of the +user's camera in case of multiple attached devices. Additionally, if required, +the `deviceId` can be set if the selection of the camera is given to the user. +This can be easily achieved via +[MediaDevices.enumerateDevices()][enumerateDevices] + +Thirdly, the `area` prop restricts the decoding area of the image. The values +are given in percentage, similar to the CSS style property when using +`position: absolute`. This `area` is also useful in cases the `locate` property +is set to `false`, defining the rectangle for the user. + +The last key `singleChannel` is only relevant in cases someone wants to debug +erroneous behavior of the decoder. If set to `true` the input image's red +color-channel is read instead of calculating the gray-scale values of the +source's RGB. This is useful in combination with the `ResultCollector` where +the gray-scale representations of the wrongly identified images are saved. + +### frequency + +This top-level property controls the scan-frequency of the video-stream. It's +optional and defines the maximum number of scans per second. This renders +useful for cases where the scan-session is long-running and resources such as +CPU power are of concern. + +### decoder + +QuaggaJS usually runs in a two-stage manner (`locate` is set to `true`) where, +after the barcode is located, the decoding process starts. Decoding is the +process of converting the bars into its true meaning. Most of the configuration +options within the `decoder` are for debugging/visualization purposes only. + +```javascript +{ + readers: [ + 'code_128_reader' + ], + debug: { + drawBoundingBox: false, + showFrequency: false, + drawScanline: false, + showPattern: false + } + multiple: false +} +``` + +The most important property is `readers` which takes an array of types of +barcodes which should be decoded during the session. Possible values are: + +- code_128_reader (default) +- ean_reader +- ean_8_reader +- code_39_reader +- code_39_vin_reader +- codabar_reader +- upc_reader +- upc_e_reader +- i2of5_reader + +Why are not all types activated by default? Simply because one should +explicitly define the set of barcodes for their use-case. More decoders means +more possible clashes, or false-positives. One should take care of the order +the readers are given, since some might return a value even though it is not +the correct type (EAN-13 vs. UPC-A). + +The `multiple` property tells the decoder if it should continue decoding after +finding a valid barcode. If multiple is set to `true`, the results will be +returned as an array of result objects. Each object in the array will have a +`box`, and may have a `codeResult` depending on the success of decoding the +individual box. + +The remaining properties `drawBoundingBox`, `showFrequency`, `drawScanline` and +`showPattern` are mostly of interest during debugging and visualization. + +#### Enabling extended EAN + +The default setting for `ean_reader` is not capable of reading extensions such +as [EAN-2](https://en.wikipedia.org/wiki/EAN_2) or +[EAN-5](https://en.wikipedia.org/wiki/EAN_5). In order to activate those +supplements you have to provide them in the configuration as followed: + +```javascript +decoder: { + readers: [{ + format: "ean_reader", + config: { + supplements: [ + 'ean_5_reader', 'ean_2_reader' + ] + } + }] +} +``` + +Beware that the order of the `supplements` matters in such that the reader stops +decoding when the first supplement was found. So if you are interested in EAN-2 +and EAN-5 extensions, use the order depicted above. + +It's important to mention that, if supplements are supplied, regular EAN-13 +codes cannot be read any more with the same reader. If you want to read EAN-13 +with and without extensions you have to add another `ean_reader` reader to the +configuration. + +### locator + +The `locator` config is only relevant if the `locate` flag is set to `true`. +It controls the behavior of the localization-process and needs to be adjusted +for each specific use-case. The default settings are simply a combination of +values which worked best during development. + +Only two properties are relevant for the use in Quagga (`halfSample` and +`patchSize`) whereas the rest is only needed for development and debugging. + + +```javascript +{ + halfSample: true, + patchSize: "medium", // x-small, small, medium, large, x-large + debug: { + showCanvas: false, + showPatches: false, + showFoundPatches: false, + showSkeleton: false, + showLabels: false, + showPatchLabels: false, + showRemainingPatchLabels: false, + boxFromPatches: { + showTransformed: false, + showTransformedBox: false, + showBB: false + } + } +} +``` + +The `halfSample` flag tells the locator-process whether it should operate on an +image scaled down (half width/height, quarter pixel-count ) or not. Turning +`halfSample` on reduces the processing-time significantly and also helps +finding a barcode pattern due to implicit smoothing. +It should be turned off in cases where the barcode is really small and the full +resolution is needed to find the position. It's recommended to keep it turned +on and use a higher resolution video-image if needed. + +The second property `patchSize` defines the density of the search-grid. The +property accepts strings of the value `x-small`, `small`, `medium`, `large` and +`x-large`. The `patchSize` is proportional to the size of the scanned barcodes. +If you have really large barcodes which can be read close-up, then the use of +`large` or `x-large` is recommended. In cases where the barcode is further away +from the camera lens (lack of auto-focus, or small barcodes) then it's advised +to set the size to `small` or even `x-small`. For the latter it's also +recommended to crank up the resolution in order to find a barcode. + +## Examples + +The following example takes an image `src` as input and prints the result on the +console. The decoder is configured to detect _Code128_ barcodes and enables the +locating-mechanism for more robust results. + +```javascript +Quagga.decodeSingle({ + decoder: { + readers: ["code_128_reader"] // List of active readers + }, + locate: true, // try to locate the barcode in the image + src: '/test/fixtures/code_128/image-001.jpg' // or 'data:image/jpg;base64,' + data +}, function(result){ + if(result.codeResult) { + console.log("result", result.codeResult.code); + } else { + console.log("not detected"); + } +}); +``` + +### Using node + +The following example illustrates the use of QuaggaJS within a node +environment. It's almost identical to the browser version with the difference +that node does not support web-workers out of the box. Therefore the config +property `numOfWorkers` must be explicitly set to `0`. + +```javascript +var Quagga = require('quagga'); + +Quagga.decodeSingle({ + src: "image-abc-123.jpg", + numOfWorkers: 0, // Needs to be 0 when used within node + inputStream: { + size: 800 // restrict input-size to be 800px in width (long-side) + }, + decoder: { + readers: ["code_128_reader"] // List of active readers + }, +}, function(result) { + if(result.codeResult) { + console.log("result", result.codeResult.code); + } else { + console.log("not detected"); + } +}); +``` + +## Tests + +Unit Tests can be run with [Karma][karmaUrl] and written using +[Mocha][mochaUrl], [Chai][chaiUrl] and [SinonJS][sinonUrl]. Coverage reports are +automatically generated in the coverage/ folder. + +```console +> npm install +> npm run test +``` +## Image Debugging + +In case you want to take a deeper dive into the inner workings of Quagga, get to +know the _debugging_ capabilities of the current implementation. The various +flags exposed through the `config` object give you the abilily to visualize +almost every step in the processing. Because of the introduction of the +web-workers, and their restriction not to have access to the DOM, the +configuration must be explicitly set to `config.numOfWorkers = 0` in order to +work. + +## ResultCollector + +Quagga is not perfect by any means and may produce false positives from time +to time. In order to find out which images produced those false positives, +the built-in ``ResultCollector`` will support you and me helping squashing +bugs in the implementation. + +### Creating a ``ResultCollector`` + +You can easily create a new ``ResultCollector`` by calling its ``create`` +method with a configuration. + +```javascript +var resultCollector = Quagga.ResultCollector.create({ + capture: true, // keep track of the image producing this result + capacity: 20, // maximum number of results to store + blacklist: [ // list containing codes which should not be recorded + {code: "3574660239843", format: "ean_13"}], + filter: function(codeResult) { + // only store results which match this constraint + // returns true/false + // e.g.: return codeResult.format === "ean_13"; + return true; + } +}); +``` + +### Using a ``ResultCollector`` + +After creating a ``ResultCollector`` you have to attach it to Quagga by +calling ``Quagga.registerResultCollector(resultCollector)``. + +### Reading results + +After a test/recording session, you can now print the collected results which +do not fit into a certain schema. Calling ``getResults`` on the +``resultCollector`` returns an ``Array`` containing objects with: + +```javascript +{ + codeResult: {}, // same as in onDetected event + frame: "data:image/png;base64,iVBOR..." // dataURL of the gray-scaled image +} +``` + +The ``frame`` property is an internal representation of the image and +therefore only available in gray-scale. The dataURL representation allows +easy saving/rendering of the image. + +### Comparing results + +Now, having the frames available on disk, you can load each single image by +calling ``decodeSingle`` with the same configuration as used during recording +. In order to reproduce the exact same result, you have to make sure to turn +on the ``singleChannel`` flag in the configuration when using ``decodeSingle``. + +## Changelog + +### 2016-04-24 +- Features + - EAN-13 extended codes can now be decoded (See + [\#71](https://github.com/serratus/quaggaJS/issues/71)) + +Take a look at the release-notes ( + [0.11.0](https://github.com/serratus/quaggaJS/releases/tag/v0.11.0)) + +### 2016-04-19 +- Improvements + - Reducing false-positives for Code 128 barcodes ( + addresses [\#104](https://github.com/serratus/quaggaJS/issues/104)) + +### 2016-03-31 +Take a look at the release-notes ( + [0.10.0](https://github.com/serratus/quaggaJS/releases/tag/v0.10.0)) + +### 2016-02-18 + +- Internal Changes + - Restructuring into meaningful folders + - Removing debug-code in production build + + +### 2016-02-15 +Take a look at the release-notes ( + [0.9.0](https://github.com/serratus/quaggaJS/releases/tag/v0.9.0)) + +### 2015-11-22 + +- Fixes + - Fixed inconsistencies for Code 128 decoding (See + [\#76](https://github.com/serratus/quaggaJS/issues/76)) + +### 2015-11-15 + +- Fixes + - Fixed inconsistency in Code 39 decoding + - added inline-source-map to quagga.js file + +### 2015-10-13 +Take a look at the release-notes ([0.8.0] +(https://github.com/serratus/quaggaJS/releases/tag/v0.8.0)) + +- Improvements + - Replaced RequireJS with webpack + +### 2015-09-15 +Take a look at the release-notes ([0.7.0] +(https://github.com/serratus/quaggaJS/releases/tag/v0.7.0)) + +- Features + - Added basic support for running QuaggaJS inside __node__ (see [example] + (#node-example)) + +### 2015-08-29 +- Improvements + - Added support for Internet Explorer (only Edge+ supports `getUserMedia`) + +### 2015-08-13 +- Improvements + - Added `offProcessed` and `offDetected` methods for detaching event- + listeners from the event-queue. + +### 2015-07-29 +- Features + - Added basic support for [ITF][i2of5_wiki] barcodes (`i2of5_reader`) + +### 2015-07-08 +- Improvements + - Parameter tweaking to reduce false-positives significantly (for the + entire EAN and UPC family) + - Fixing bug in parity check for UPC-E codes + - Fixing bug in alignment for EAN-8 codes + +### 2015-07-06 +- Improvements + - Added `err` parameter to [Quagga.init()](#quaggainit) callback + function + +### 2015-06-21 +- Features + - Added ``singleChannel`` configuration to ``inputStream`` (in [config] + (#configobject)) + - Added ``ResultCollector`` functionality (see [ResultCollector] + (#resultcollector)) + +### 2015-06-13 +- Improvements + - Added ``format`` property to ``codeResult`` (in [result](#resultobject)) + +### 2015-06-13 +- Improvements + - Added fixes for ``Code39Reader`` (trailing whitespace was missing) + +### 2015-06-09 +- Features + - Introduced the ``area`` property + - Ability to define a rectangle where localization/decoding should be applied + +### 2015-05-20 +- Improvements + - Making EAN and UPC readers even more restrictive + - Added example using requirejs + +### 2015-05-18 +- Improvements + - Making EAN and UPC readers more restrictive + - Added integration-tests for all barcode-readers + +### 2015-05-09 +- Improvements + - Odd image dimensions no longer cause problems + +### 2015-04-30 +- Features + - Added support for [UPC-A and UPC-E][upc_wiki] barcodes + - Added support for [EAN-8][ean_8_wiki] barcodes +- Improvements + - Added extended configuration to the live-video example + - Releasing resources when calling ``Quagga.stop()`` + +### 2015-04-25 +- Improvements + - Added extended configuration to the file-input example + - Configurable ``patchSize`` for better adjustment to small/medium/large + barcodes + +### 2015-04-16 +- Features + - Added support for [Codabar][codabar_wiki] barcodes + +### 2015-03-16 +- Improvements + - now includes minified version (23.3KB gzipped) + - No need for configuration of script-name any more + +### 2015-03-12 +- Improvements + - removed dependency on async.js + +### 2015-03-04 +- Features + - Added support for [Code 39][code39_wiki] barcodes + +### 2015-01-21 +- Features + - Added support for web-worker (using 4 workers as default, can be changed + through `config.numOfWorkers`) + - Due to the way how web-workers are created, the name of the script file + (`config.scriptName`) should be kept in sync with your actual filename + - Removed canvas-overlay for decoding (boxes & scanline) which can now be + easily implemented using the existing API (see example) +- API Changes +In the course of implementing web-workers some breaking changes were +introduced to the API. + - The `Quagga.init` function no longer receives the callback as part of the + config but rather as a second argument: `Quagga.init(config, cb)` + - The callback to `Quagga.onDetected` now receives an object containing + much more information in addition to the decoded code.(see + [data](#resultobject)) + - Added `Quagga.onProcessed(callback)` which provides a way to get information + for each image processed. The callback receives the same `data` object as + `Quagga.onDetected` does. Depending on the success of the process the `data` + object might not contain any `resultCode` and/or `box` properties. + +[zxing_github]: https://github.com/zxing/zxing +[teaser_left]: https://raw.githubusercontent.com/serratus/quaggaJS/master/doc/img/mobile-located.png +[teaser_right]: https://raw.githubusercontent.com/serratus/quaggaJS/master/doc/img/mobile-detected.png +[caniuse_getusermedia]: http://caniuse.com/#feat=stream +[sinonUrl]: http://sinonjs.org/ +[chaiUrl]: http://chaijs.com/ +[mochaUrl]: https://github.com/mochajs/mocha +[karmaUrl]: http://karma-runner.github.io/ +[code39_wiki]: http://en.wikipedia.org/wiki/Code_39 +[codabar_wiki]: http://en.wikipedia.org/wiki/Codabar +[upc_wiki]: http://en.wikipedia.org/wiki/Universal_Product_Code +[ean_8_wiki]: http://en.wikipedia.org/wiki/EAN-8 +[oberhofer_co_how]: http://www.oberhofer.co/how-barcode-localization-works-in-quaggajs/ +[github_examples]: https://serratus.github.io/quaggaJS/examples +[i2of5_wiki]: https://en.wikipedia.org/wiki/Interleaved_2_of_5 +[enumerateDevices]: https://developer.mozilla.org/en-US/docs/Web/API/MediaDevices/enumerateDevices