AugmentedGesture=function(){AugmentedGesture.hasUserMedia||alert("Panic: no UserMedia");console.assert(AugmentedGesture.hasUserMedia,"no usermedia available");this._video=this._videoCtor();this._frameCount=0;var a=document.createElement("canvas");this._canvas=a;a.width=this._video.width/4;a.height=this._video.height/4;this._pointerR={x:a.width/2,y:a.height/2};this._pointerL={x:a.width/2,y:a.height/2}};AugmentedGesture.prototype.destroy=function(){this.stop()}; AugmentedGesture.hasUserMedia=navigator.webkitGetUserMedia?!0:!1; AugmentedGesture.MicroeventMixin=function(a){a.bind=function(a,c){void 0===this._events&&(this._events={});this._events[a]=this._events[a]||[];this._events[a].push(c);return c};a.unbind=function(a,c){void 0===this._events&&(this._events={});!1!==a in this._events&&this._events[a].splice(this._events[a].indexOf(c),1)};a.trigger=function(a){void 0===this._events&&(this._events={});if(void 0!==this._events[a])for(var c=this._events[a].slice(),b=0;b=h?c[b]:0});var j=ImgProc.getMaxHistogram(g);d.disp.VHist&&ImgProc.displayHorizontalHistogram(a, g);g=ImgProc.computeVerticalHistogram(e,function(a,b){return 0!==a[b+1]?!0:!1});ImgProc.windowedAverageHistogram(g,d.smooth.vWidth);h=d.colorFilter.minHist.v;ImgProc.filterHistogram(g,function(a,b,c){c[b]=c[b]>=h?c[b]:0});e=ImgProc.getMaxHistogram(g);d.disp.HHist&&ImgProc.displayVerticalHistogram(a,g);return{h:j,v:e}}var c=this._opts,b=this._canvas,i=b.getContext("2d");this._frameCount++;if(0===this._frameCount%c.general.video.frameRate&&this._video.readyState===this._video.HAVE_ENOUGH_DATA){this._statsUpdate(); b.width!=c.general.video.w&&(b.width=c.general.video.w);b.height!=c.general.video.h&&(b.height=c.general.video.h);var j=b.width,k=b.height;i.drawImage(this._video,0,0,b.width,b.height);var h=i.getImageData(0,0,b.width,b.height);ImgProc.fliph(h);var l=function(b){var f=c.pointers[b],e=a(h,b);f.disp.HLine&&ImgProc.hline(h,e.h.idx,0,255,0);f.disp.VLine&&ImgProc.vline(h,e.v.idx,0,255,0);if(e.h.max===0||e.v.max===0){if(this._pointersPos[b]!==null){this._pointersPos[b]=null;this.trigger("mouseup."+b)}}else{if(!this._pointersPos[b]){this._pointersPos[b]= {x:e.h.idx/j,y:e.v.idx/k};this.trigger("mousedown."+b,this._pointersPos[b]);this.trigger("click."+b,this._pointersPos[b])}var d=this._pointersPos[b],g=d.x,i=d.y;d.x=d.x+(e.h.idx/j-d.x)*f.pointer.coordSmoothH;d.y=d.y+(e.v.idx/k-d.y)*f.pointer.coordSmoothV;if(f.pointer.display){f=f.pointer.crossColor;ImgProc.vline(h,Math.floor(d.x*j),f.r,f.g,f.b);ImgProc.hline(h,Math.floor(d.y*k),f.r,f.g,f.b)}(g!==d.x||i!==d.y)&&this.trigger("mousemove."+b,d)}}.bind(this);Object.keys(this._pointersPos).forEach(function(a){l(a)}); i.putImageData(h,0,0)}};