-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathJSARToolKit.min.js
1 lines (1 loc) · 157 KB
/
JSARToolKit.min.js
1
if(!window.console){console={log:function(){}}}ASVector=function(b){b=b||0;if(b.length){this.length=b.length;for(var a=0;a<b.length;a++){this[a]=b[a]}}else{this.length=b;for(var a=0;a<b;a++){this[a]=0}}};ASVector.prototype={};ASVector.prototype.set=function(a,b){if(a.length){ASVector.call(this,a)}else{this[a]=b}};if(typeof Float32Array=="undefined"){FloatVector=ASVector;IntVector=ASVector;UintVector=ASVector}else{FloatVector=Float32Array;IntVector=Int32Array;UintVector=Uint32Array}toInt=Math.floor;Object.extend=function(d,c){for(var a in c){try{d[a]=c[a]}catch(b){}}return d};toArray=function(d){var b=new Array(d.length);for(var c=0;c<d.length;c++){b[c]=d[c]}return b};Klass=(function(){var e=function(){if(this.initialize){this.initialize.apply(this,arguments)}};e.ancestors=toArray(arguments);e.prototype={};for(var d=0;d<arguments.length;d++){var b=arguments[d];if(b.prototype){Object.extend(e.prototype,b.prototype)}else{Object.extend(e.prototype,b)}}Object.extend(e,e.prototype);return e});Object.asCopy=function(d){if(typeof d!="object"){return d}else{if(d instanceof FloatVector){var b=new FloatVector(d.length);for(var c=0;c<b.length;c++){b[c]=d[c]}return b}else{if(d instanceof IntVector){var b=new IntVector(d.length);for(var c=0;c<b.length;c++){b[c]=d[c]}return b}else{if(d instanceof UintVector){var b=new UintVector(d.length);for(var c=0;c<b.length;c++){b[c]=d[c]}return b}else{if(d instanceof Array){return d.map(Object.asCopy)}else{var a={};for(var c in d){var b=d[c];if(typeof b=="object"){b=Object.asCopy(b)}a[c]=b}return a}}}}}};ASKlass=(function(e){var g=function(){var c=this.__copyObjects__;for(var a=0;a<c.length;a++){this[c[a]]=Object.asCopy(this[c[a]])}if(this.initialize){this.initialize.apply(this,arguments)}};g.ancestors=toArray(arguments).slice(1);g.prototype={};for(var f=1;f<arguments.length;f++){var b=arguments[f];if(b.prototype){Object.extend(g.prototype,b.prototype)}else{Object.extend(g.prototype,b)}}g.prototype.className=e;g.prototype.initialize=g.prototype[e];g.prototype.__copyObjects__=[];for(var f in g.prototype){var d=g.prototype[f];if(f!="__copyObjects__"){if(typeof d=="object"){g.prototype.__copyObjects__.push(f)}}}Object.extend(g,g.prototype);return g});BitmapData=Klass({initialize:function(e,c,d,b){this.width=e;this.height=c;this.transparent=(d==null?true:d);this.fill=(b==null?4294967295:b);this.data=new UintVector(e*c);for(var a=0;a<this.data.length;a++){this.data[a]=b}this.rect=new Rectangle(0,0,this.width,this.height)},fillRect:function(g,m){var a=this.width;var f=Math.clamp(g.y,0,this.height)*a,i=Math.clamp(g.y+g.height,0,this.height)*a,l=Math.clamp(g.x,0,this.width),b=Math.clamp(g.x+g.width,0,this.width);var e=this.data;for(var k=f;k<i;k+=a){for(var c=l;c<b;c++){e[k+c]=m}}},getPixel32:function(a,b){return this.data[b*this.width+a]},setPixel32:function(a,c,b){return this.data[c*this.width+a]=b},getPixel:function(a,b){return this.data[b*this.width+a]&16777215},setPixel:function(a,c,b){return this.data[c*this.width+a]=b|(this.data[c*this.width+a]&4278190080)},getWidth:function(){return this.width},getHeight:function(){return this.height},copyPixels:function(o,a,f){var e=this.width;var n=o.width;var r=o.data;var k=this.data;var s=Math.clamp(f.y,0,this.height)*e,g=Math.clamp(f.y+a.height,0,this.height)*e,t=Math.clamp(f.x,0,this.width),u=Math.clamp(f.x+a.width,0,this.width);var l=Math.clamp(a.y,0,o.height)*n,b=Math.clamp(a.y+a.height,0,o.height)*n,m=Math.clamp(a.x,0,o.width),p=Math.clamp(a.x+a.width,0,o.width);for(var c=l,i=s;c<b&&i<g;c+=n,i+=e){for(var q=m,v=t;q<p&&v<u;q++,v++){k[i+v]=r[c+q]}}},getColorBoundsRect:function(a,c,b){if(b){return this.getColorBoundsRect_true(a,c)}else{return this.getColorBoundsRect_false(a,c)}},getColorBoundsRect_true:function(p,i){var g=this.width,f=this.height,b=0,a=0;var o=this.width;h=this.height;var k=this.data;var e=0,c=0;minYfor:for(var l=0;l<h;l++){c=l*o-1;for(var n=0;n<o;n++){e=(k[++c]&p)-i;if(!e){g=b=n;f=a=l;break minYfor}}}maxYfor:for(var l=h-1;l>f;l--){c=l*o-1;for(var n=0;n<o;n++){e=(k[++c]&p)-i;if(!e){if(n<g){g=n}if(n>b){b=n}a=l;break maxYfor}}}for(var l=f;l<=a;l++){c=l*o-1;for(var n=0;n<g;n++){e=(k[++c]&p)-i;if(!e){g=n;break}}c=l*o+o;for(var n=o-1;n>b;n--){e=(k[--c]&p)-i;if(!e){b=n;break}}}return new Rectangle(g,f,Math.max(0,b-g),Math.max(0,a-f))},getColorBoundsRect_false:function(o,g){var f=this.width,e=this.height,b=0,a=0;var n=this.width;h=this.height;var i=this.data;minYfor:for(var k=0;k<h;k++){for(var l=0;l<n;l++){var c=(i[k*n+l]&o)-g;if(c){f=b=l;e=a=k;break minYfor}}}maxYfor:for(var k=h-1;k>e;k--){for(var l=0;l<n;l++){var c=(i[k*n+l]&o)-g;if(c){if(l<f){f=l}if(l>b){b=l}a=k;break maxYfor}}}for(var k=e;k<=a;k++){for(var l=0;l<f;l++){var c=(i[k*n+l]&o)-g;if(c){f=l;break}}for(var l=h-1;l>b;l--){var c=(i[k*n+l]&o)-g;if(c){b=l;break}}}return new Rectangle(f,e,Math.max(0,b-f),Math.max(0,a-e))},putImageData:function(a,o,m,p,i){p=Math.clamp(p,0,a.width),i=Math.clamp(i,0,a.height);var c=this.width;var k=this.data;var f=a.data;var m=Math.clamp(m,0,this.height)*c,l=Math.clamp(m+i,0,this.height)*c,o=Math.clamp(o,0,this.width),b=Math.clamp(o+p,0,this.width);for(var n=m,q=0;n<l;n+=c,q+=a.width*4){for(var e=o,g=0;e<b;e++,g+=4){k[n+e]=((f[q+g]<<16)|(f[q+g+1]<<8)|(f[q+g+2])|(f[q+g+3]<<24))}}},drawCanvas:function(c,a,e,b,d){this.putImageData(c.getContext("2d").getImageData(0,0,b,d),a,e,b,d)},drawOnCanvas:function(g){var o=g.getContext("2d");var e=o.getImageData(0,0,this.width,this.height);var a=this.width;var f=this.height*a;var k=this.data;var i=e.data;for(var m=0;m<f;m+=a){for(var n=0;n<a;n++){var b=4*(m+n);var l=k[m+n];i[b]=(l>>16)&255;i[++b]=(l>>8)&255;i[++b]=(l)&255;i[++b]=(l>>24)&255}}o.putImageData(e,0,0)},floodFill:function(p,n,k){var f=0,d=0,c=0,r=0;var e=0;var m=[];var q=this.width,i=this.height;var b=this.width;var g=this.data;e=g[n*b+p];if(e==k||p<0||p>=q||n<0||n>=i){return}m.push([n,p,p,1]);m.push([n+1,p,p,-1]);while(m.length>0){var o=m.pop();n=o[0]+o[3],d=o[1],c=o[2],r=o[3];for(p=d;p>=0&&g[n*b+p]==e;p--){g[n*b+p]=k}if(p<d){f=p+1;if(f<d){m.push([n,f,d-1,-r])}p=d+1;for(;p<q&&g[n*b+p]==e;p++){g[n*b+p]=k}m.push([n,f,p-1,r]);if(p>c+1){m.push([n,c+1,p-1,-r])}}for(p++;p<=c&&g[n*b+p]!=e;p++){null}f=p;while(p<=c){for(;p<q&&g[n*b+p]==e;p++){g[n*b+p]=k}m.push([n,f,p-1,r]);if(p>c+1){m.push([n,c+1,p-1,-r])}for(p++;p<=c&&g[n*b+p]!=e;p++){null}f=p}}}});Rectangle=Klass({initialize:function(a,d,b,c){this.x=a;this.y=d;this.top=d;this.left=a;this.bottom=d+c;this.right=a+b;this.width=b;this.height=c;this.updateCalc()},updateCalc:function(){this.top=this.y;this.left=this.x;this.bottom=this.y+this.height;this.right=this.x+this.width},clone:function(){return new Rectangle(this.x,this.y,this.width,this.height)},inflate:function(b,a){this.x-=b;this.y-=a;this.width+=2*b;this.height+=2*a;this.updateCalc()},isEmpty:function(){return(this.width<=0&&this.height<=0)}});NyARException=Klass(Error,{initialize:function(a){Error.call(this,a)},trap:function(a){throw new NyARException("trap:"+a)},notImplement:function(){throw new NyARException("Not Implement!")}});NyAS3Const_Inherited=Klass({});NyAS3Utils=Klass({assert:function(a,b){if(!a){throw new Error("NyAS3Utils.assert:"+b!=null?b:"")}}});NyARVec=Klass({clm:null,v:null,initialize:function(a){this.v=new FloatVector(a);this.clm=a},getClm:function(){return this.clm},getArray:function(){return this.v}});NyARMat=Klass({m:null,__matrixSelfInv_nos:null,clm:null,row:null,initialize:function(b,a){this.m=new Array(b);for(var d=0;d<b;d++){this.m[d]=new FloatVector(a);for(var c=0;c<a;c++){this.m[d][c]=0}}this.__matrixSelfInv_nos=new FloatVector(b);this.clm=a;this.row=b;return},getClm:function(){return this.clm},getRow:function(){return this.row},getArray:function(){return this.m},matrixSelfInv:function(){var g=this.m;var r=this.row;var f=r-1;var d,q,m;var k,o,c;var e=this.__matrixSelfInv_nos;var a,t,s;switch(r){case 0:throw new NyARException();case 1:g[0][0]=1/g[0][0];return true}var b;for(b=0;b<r;b++){e[b]=b}o=0;for(b=0;b<r;b++){d=g[b];a=0;for(var l=b;l<r;l++){if(a<(t=Math.abs(g[l][0]))){a=t;o=l}}if(a==0){return false}c=e[o];e[o]=e[b];e[b]=c;q=g[o];for(k=0;k<r;k++){s=q[k];q[k]=d[k];d[k]=s}s=d[0];for(k=0;k<f;k++){d[k]=d[k+1]/s}d[k]=1/s;for(l=0;l<r;l++){if(l!=b){m=g[l];s=m[0];for(k=0;k<f;k++){m[k]=m[k+1]-s*d[k]}m[k]=-s*d[k]}}}for(b=0;b<r;b++){for(k=b;k<r;k++){if(e[k]==b){break}}e[k]=e[b];for(l=0;l<r;l++){m=g[l];s=m[k];m[k]=m[b];m[b]=s}}return true}});ArrayUtils=ASKlass("ArrayUtils",{create2dInt:function(a,c){var d=new Array(a);for(var b=0;b<a;b++){d[b]=new IntVector(c)}return d},create2dNumber:function(a,c){var d=new Array(a);for(var b=0;b<a;b++){d[b]=new FloatVector(c)}return d},copyInt:function(f,d,b,a,e){for(var c=0;c<e;c++){b[a+c]=f[d+c]}}});ArrayUtil=ASKlass("ArrayUtil",{createJaggedArray:function(b){var a=new Array(b);var c=toArray(arguments).slice(1);while(b--){a[b]=c.length?this.createJaggedArray.apply(null,c):0}return a},create2d:function(a,b){return this.createJaggedArray(a,b)},create3d:function(c,a,b){return this.createJaggedArray(c,a,b)},copy:function(f,d,b,a,e){for(var c=0;c<e;c++){b[a+c]=f[d+c]}}});FLARException=ASKlass("FLARException",NyARException,{FLARException:function(a){NyARException.initialize.call(this,a||"")},trap:function(a){throw new FLARException("trap:"+a)},notImplement:function(){throw new FLARException("Not Implement!")}});FLARMat=NyARMat;FLARRgbPixelReader_BitmapData=ASKlass("FLARRgbPixelReader_BitmapData",{_ref_bitmap:null,FLARRgbPixelReader_BitmapData:function(a){this._ref_bitmap=a},getPixel:function(b,a,e){var d=this._ref_bitmap.getPixel(b,a);e[0]=(d>>16)&255;e[1]=(d>>8)&255;e[2]=d&255;return},getPixelSet:function(b,a,e,k){var g=this._ref_bitmap;var f;var d;for(d=0;d<e;d++){f=g.getPixel(b[d],a[d]);k[d*3+0]=(f>>16)&255;k[d*3+1]=(f>>8)&255;k[d*3+2]=f&255}},setPixel:function(b,a,c){NyARException.notImplement()},setPixels:function(c,b,d,a){NyARException.notImplement()},switchBuffer:function(a){NyARException.notImplement()}});FLARGrayPixelReader_BitmapData=ASKlass("FLARGrayPixelReader_BitmapData",{_ref_bitmap:null,FLARGrayPixelReader_BitmapData:function(a){this._ref_bitmap=a},getPixel:function(c,a,e,g){NyARException.notImplement();var b=this._ref_bitmap.getWidth();var f=this._ref_bitmap.getBuffer();g[0]=g[1]=g[2]=~f(c+b*a)&255},getPixelSet:function(c,a,f,k){var b=this._ref_bitmap.getWidth();var g=this._ref_bitmap.data;for(var e=0;e<f;e++){k[e]=~g[c[e]+b*a[e]]&255}},setPixel:function(b,a,c){NyARException.notImplement()},setPixels:function(c,b,d,a){NyARException.notImplement()},switchBuffer:function(a){NyARException.notImplement()}});INyARHistogramAnalyzer_Threshold=ASKlass("INyARHistogramAnalyzer_Threshold",{getThreshold:function(a){}});NyARHistogramAnalyzer_SlidePTile=ASKlass("NyARHistogramAnalyzer_SlidePTile",INyARHistogramAnalyzer_Threshold,{_persentage:0,NyARHistogramAnalyzer_SlidePTile:function(a){NyAS3Utils.assert(0<=a&&a<=50);this._persentage=a},getThreshold:function(c){var i=c.length;var f=c.total_of_data;var d=c.data;var a=f*this._persentage/100;var b;var g,e;b=a;for(e=0;e<i-2;e++){b-=d[e];if(b<=0){break}}b=a;for(g=i-1;g>1;g--){b-=d[g];if(b<=0){break}}return(g+e)/2}});INyARPca2d=ASKlass("INyARPca2d",{pca:function(f,c,b,e,d,a){}});NyARPca2d_MatrixPCA_O2=ASKlass("NyARPca2d_MatrixPCA_O2",INyARPca2d,{PCA_EPS:0.000001,PCA_MAX_ITER:100,PCA_VZERO:1e-16,PCA_QRM:function(g,a){var q,r,u,p,n,l;var o;var f,d;var k,i,e,b;f=g.m00;o=g.m01;d=g.m11;k=b=1;i=e=0;var m=0;do{m++;if(m>this.PCA_MAX_ITER){break}q=(f-d)/2;r=o*o;u=Math.sqrt(q*q+r);if(q<0){u=-u}p=f-d+r/(q+u);n=o;if(Math.abs(p)>=Math.abs(n)){if(Math.abs(p)>this.PCA_VZERO){r=-n/p;l=1/Math.sqrt(r*r+1);u=r*l}else{l=1;u=0}}else{r=-p/n;u=1/Math.sqrt(r*r+1);l=r*u}q=f-d;r=(q*u+2*l*o)*u;f-=r;d+=r;o+=u*(l*q-2*u*o);p=k;n=e;k=l*p-u*n;e=u*p+l*n;p=i;n=b;i=l*p-u*n;b=u*p+l*n}while(Math.abs(o)>this.PCA_EPS*(Math.abs(f)+Math.abs(d)));r=f;if(d>r){r=d;d=f;f=r;g.m00=e;g.m01=b;g.m10=k;g.m11=i}else{g.m00=k;g.m01=i;g.m10=e;g.m11=b}a[0]=f;a[1]=d;return},PCA_PCA:function(c,a,g,d,e,q){var f;var p=0;var n=0;for(f=0;f<g;f++){p+=c[f];n+=a[f]}p=p/g;n=n/g;var r=Math.sqrt((g));var b,k,m;b=k=m=0;for(f=0;f<g;f++){var o=(c[f]-p)/r;var l=(a[f]-n)/r;b+=(o*o);m+=(o*l);k+=(l*l)}d.m00=b;d.m01=d.m10=m;d.m11=k;this.PCA_QRM(d,e);if(e[0]<this.PCA_VZERO){e[0]=0;d.m00=0;d.m01=0}if(e[1]<this.PCA_VZERO){e[1]=0;d.m10=0;d.m11=0}q[0]=p;q[1]=n;return},pca:function(g,d,b,f,e,a){this.PCA_PCA(g,d,b,f,e,a);var c=e[0]+e[1];e[0]/=c;e[1]/=c;return}});INyARRgbPixelReader=ASKlass("INyARRgbPixelReader",{getPixel:function(b,a,c){},getPixelSet:function(b,a,c,d){},setPixel:function(b,a,c){},setPixels:function(c,b,d,a){},switchBuffer:function(a){}});NyARRgbPixelReader_INT1D_X8R8G8B8_32=ASKlass("NyARRgbPixelReader_INT1D_X8R8G8B8_32",INyARRgbPixelReader,{_ref_buf:null,_size:null,NyARRgbPixelReader_INT1D_X8R8G8B8_32:function(a,b){this._ref_buf=a;this._size=b},getPixel:function(b,a,d){var c=this._ref_buf[b+a*this._size.w];d[0]=(c>>16)&255;d[1]=(c>>8)&255;d[2]=c&255;return},getPixelSet:function(b,a,g,k){var f=this._size.w;var d=this._ref_buf;for(var e=g-1;e>=0;e--){var c=d[b[e]+a[e]*f];k[e*3+0]=(c>>16)&255;k[e*3+1]=(c>>8)&255;k[e*3+2]=c&255}return},setPixel:function(b,a,c){this._ref_buf[b+a*this._size.w]=((c[0]<<16)&255)|((c[1]<<8)&255)|((c[2])&255)},setPixels:function(c,b,d,a){throw new NyARException()},switchBuffer:function(a){NyAS3Utils.assert(a.length>=this._size.w*this._size.h);this._ref_buf=(a)}});NyARRgbPixelReader_Canvas2D=ASKlass("NyARRgbPixelReader_Canvas2D",INyARRgbPixelReader,{_ref_canvas:null,_data:null,NyARRgbPixelReader_Canvas2D:function(a){this._ref_canvas=a},getData:function(){if(this._ref_canvas.changed||!this._data){var b=this._ref_canvas;var a=b.getContext("2d");this._data=a.getImageData(0,0,b.width,b.height);this._ref_canvas.changed=false}return this._data},getPixel:function(c,a,i){var g=this.getData();var b=g.width;var e=g.height;var f=g.data;i[0]=f[a*b+c];i[1]=f[a*b+c+1];i[2]=f[a*b+c+2];return},getPixelSet:function(k,f,g,a){var b=this.getData();var n=b.width;var e=b.height;var l=b.data;for(var c=0;c<g;c++){var m=f[c]*n*4+k[c]*4;a[c*3+0]=l[m+0];a[c*3+1]=l[m+1];a[c*3+2]=l[m+2]}},setPixel:function(b,a,c){NyARException.notImplement()},setPixels:function(c,b,d,a){NyARException.notImplement()},switchBuffer:function(a){NyARException.notImplement()}});INyARDoubleMatrix=Klass({setValue:function(a){},getValue:function(a){}});NyARDoubleMatrix22=Klass(INyARDoubleMatrix,{m00:0,m01:0,m10:0,m11:0,setValue:function(a){this.m00=a[0];this.m01=a[1];this.m10=a[3];this.m11=a[4];return},getValue:function(a){a[0]=this.m00;a[1]=this.m01;a[3]=this.m10;a[4]=this.m11;return},inverse:function(d){var b,a,e,c;b=d.m00;a=d.m01;e=d.m10;c=d.m11;var f=b*c-a*e;if(f==0){return false}f=1/f;this.m00=c*f;this.m01=-a*f;this.m10=-e*f;this.m11=b*f;return true}});NyARDoubleMatrix33=Klass(INyARDoubleMatrix,{m00:0,m01:0,m02:0,m10:0,m11:0,m12:0,m20:0,m21:0,m22:0,createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARDoubleMatrix33()}return a},setValue:function(a){this.m00=a[0];this.m01=a[1];this.m02=a[2];this.m10=a[3];this.m11=a[4];this.m12=a[5];this.m20=a[6];this.m21=a[7];this.m22=a[8];return},setValue_NyARDoubleMatrix33:function(a){this.m00=a.m00;this.m01=a.m01;this.m02=a.m02;this.m10=a.m10;this.m11=a.m11;this.m12=a.m12;this.m20=a.m20;this.m21=a.m21;this.m22=a.m22;return},getValue:function(a){a[0]=this.m00;a[1]=this.m01;a[2]=this.m02;a[3]=this.m10;a[4]=this.m11;a[5]=this.m12;a[6]=this.m20;a[7]=this.m21;a[8]=this.m22;return},inverse:function(f){var i,g,e,p,o,n,v,u,t;var s,r,q,c,b,a,m,l,k;i=f.m00;g=f.m01;e=f.m02;p=f.m10;o=f.m11;n=f.m12;v=f.m20;u=f.m21;t=f.m22;s=o*t-n*u;r=u*e-t*g;q=g*n-e*o;c=n*v-p*t;b=t*i-v*e;a=e*p-i*n;m=p*u-o*v;l=v*g-u*i;k=i*o-g*p;var d=i*s+p*r+v*q;if(d==0){return false}d=1/d;this.m00=s*d;this.m01=r*d;this.m02=q*d;this.m10=c*d;this.m11=b*d;this.m12=a*d;this.m20=m*d;this.m21=l*d;this.m22=k*d;return true},getZXYAngle:function(b){var a=this.m21;if(a>=1){b.x=Math.PI/2;b.y=0;b.z=Math.atan2(-this.m10,this.m00)}else{if(a<=-1){b.x=-Math.PI/2;b.y=0;b.z=Math.atan2(-this.m10,this.m00)}else{b.x=Math.asin(a);b.z=Math.atan2(-this.m01,this.m11);b.y=Math.atan2(-this.m20,this.m22)}}},setZXYAngle_NyARDoublePoint3d:function(a){this.setZXYAngle_Number(a.x,a.y,a.z);return},setZXYAngle_Number:function(i,g,f){var e=Math.sin(i);var b=Math.cos(i);var d=Math.sin(g);var a=Math.cos(g);var c=Math.sin(f);var k=Math.cos(f);this.m00=k*a-c*e*d;this.m01=-c*b;this.m02=k*d+c*e*a;this.m10=c*a+k*e*d;this.m11=k*b;this.m12=c*d-k*e*a;this.m20=-b*d;this.m21=e;this.m22=a*b;return},transformVertex_NyARDoublePoint3d:function(a,b){transformVertex_double(a.x,a.y,a.z,b);return},transformVertex_double:function(b,a,d,c){c.x=this.m00*b+this.m01*a+this.m02*d;c.y=this.m10*b+this.m11*a+this.m12*d;c.z=this.m20*b+this.m21*a+this.m22*d;return}});NyARDoubleMatrix34=Klass(INyARDoubleMatrix,{m00:0,m01:0,m02:0,m03:0,m10:0,m11:0,m12:0,m13:0,m20:0,m21:0,m22:0,m23:0,setValue:function(a){this.m00=a[0];this.m01=a[1];this.m02=a[2];this.m03=a[3];this.m10=a[4];this.m11=a[5];this.m12=a[6];this.m13=a[7];this.m20=a[8];this.m21=a[9];this.m22=a[10];this.m23=a[11];return},setValue_NyARDoubleMatrix34:function(a){this.m00=a.m00;this.m01=a.m01;this.m02=a.m02;this.m03=a.m03;this.m10=a.m10;this.m11=a.m11;this.m12=a.m12;this.m13=a.m13;this.m20=a.m20;this.m21=a.m21;this.m22=a.m22;this.m23=a.m23;return},getValue:function(a){a[0]=this.m00;a[1]=this.m01;a[2]=this.m02;a[3]=this.m03;a[4]=this.m10;a[5]=this.m11;a[6]=this.m12;a[7]=this.m13;a[8]=this.m20;a[9]=this.m21;a[10]=this.m22;a[11]=this.m23;return}});NyARDoubleMatrix44=Klass(INyARDoubleMatrix,{m00:0,m01:0,m02:0,m03:0,m10:0,m11:0,m12:0,m13:0,m20:0,m21:0,m22:0,m23:0,m30:0,m31:0,m32:0,m33:0,createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARDoubleMatrix44()}return a},setValue:function(a){this.m00=a[0];this.m01=a[1];this.m02=a[2];this.m03=a[3];this.m10=a[4];this.m11=a[5];this.m12=a[6];this.m13=a[7];this.m20=a[8];this.m21=a[9];this.m22=a[10];this.m23=a[11];this.m30=a[12];this.m31=a[13];this.m32=a[14];this.m33=a[15];return},getValue:function(a){a[0]=this.m00;a[1]=this.m01;a[2]=this.m02;a[3]=this.m03;a[4]=this.m10;a[5]=this.m11;a[6]=this.m12;a[7]=this.m13;a[8]=this.m20;a[9]=this.m21;a[10]=this.m22;a[11]=this.m23;a[12]=this.m30;a[13]=this.m31;a[14]=this.m32;a[15]=this.m33;return},inverse:function(H){var p,n,m,l,P,O,N,M,E,C,A,y,s,r,q,o;var f,c,b,a,L,K,J,I,w,v,u,t,k,i,g,d;var G,F,D,B,z,x;p=H.m00;n=H.m01;m=H.m02;l=H.m03;P=H.m10;O=H.m11;N=H.m12;M=H.m13;E=H.m20;C=H.m21;A=H.m22;y=H.m23;s=H.m30;r=H.m31;q=H.m32;o=H.m33;G=A*o-y*q;F=y*r-C*o;D=C*q-A*r;B=y*s-E*o;z=E*q-A*s;x=E*r-C*s;f=O*G+N*F+M*D;L=-(N*B+M*z+P*G);w=M*x-P*F+O*B;k=-(P*D-O*z+N*x);G=q*l-o*m;F=o*n-r*l;D=r*m-q*n;B=o*p-s*l;z=s*m-q*p;x=s*n-r*p;c=-(C*G+A*F+y*D);K=A*B+y*z+E*G;v=-(y*x-E*F+C*B);i=E*D-C*z+A*x;G=m*M-l*N;F=l*O-n*M;D=n*N-m*O;B=l*P-p*M;z=p*N-m*P;x=p*O-n*P;b=r*G+q*F+o*D;J=-(q*B+o*z+s*G);u=o*x-s*F+r*B;g=-(s*D-r*z+q*x);G=N*y-M*A;F=M*C-O*y;D=O*A-N*C;B=M*E-P*y;z=P*A-N*E;x=P*C-O*E;a=-(n*G+m*F+l*D);I=m*B+l*z+p*G;t=-(l*x-p*F+n*B);d=p*D-n*z+m*x;var e=(p*f+P*c+E*b+s*a);if(e==0){return false}e=1/e;this.m00=f*e;this.m01=c*e;this.m02=b*e;this.m03=a*e;this.m10=L*e;this.m11=K*e;this.m12=J*e;this.m13=I*e;this.m20=w*e;this.m21=v*e;this.m22=u*e;this.m23=t*e;this.m30=k*e;this.m31=i*e;this.m32=g*e;this.m33=d*e;return true}});NyARObjectStack=Klass({_items:null,_length:0,initialize:function(a){a=toInt(a);this._items=this.createArray(a);this._length=0;return},createArray:function(a){throw new NyARException()},prePush:function(){if(this._length>=this._items.length){return null}var a=this._items[this._length];this._length++;return a},init:function(a){if(a>=this._items.length){throw new NyARException()}this._length=a},pop:function(){NyAS3Utils.assert(this._length>=1);this._length--;return this._items[this._length]},pops:function(a){NyAS3Utils.assert(this._length>=a);this._length-=a;return},getArray:function(){return this._items},getItem:function(a){return this._items[a]},getLength:function(){return this._length},clear:function(){this._length=0}});NyARIntPointStack=Klass(NyARObjectStack,{initialize:function(a){NyARObjectStack.initialize.call(this,a)},createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARIntPoint2d()}return a}});NyARIntRectStack=Klass({_items:null,_length:null,initialize:function(a){this._items=this.createArray(a);this._length=0;return},createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARIntRect()}return a},prePush:function(){if(this._length>=this._items.length){return null}var a=this._items[this._length];this._length++;return a},init:function(a){if(a>=this._items.length){throw new NyARException()}this._length=a},pop:function(){NyAS3Utils.assert(this._length>=1);this._length--;return this._items[this._length]},pops:function(a){NyAS3Utils.assert(this._length>=a);this._length-=a;return},getArray:function(){return this._items},getItem:function(a){return this._items[a]},getLength:function(){return this._length},clear:function(){this._length=0}});NyARBufferType=Klass((function(){var f=65536;var b=131072;var c=196608;var e=262144;var d=1048576;var a=16711680;return({NULL_ALLZERO:1,USER_DEFINE:a,BYTE1D_R8G8B8_24:f|1,BYTE1D_B8G8R8_24:f|2,BYTE1D_B8G8R8X8_32:f|257,BYTE1D_X8R8G8B8_32:f|258,BYTE1D_R5G6B5_16LE:f|513,BYTE1D_R5G6B5_16BE:f|514,WORD1D_R5G6B5_16LE:c|513,WORD1D_R5G6B5_16BE:c|514,INT2D:b|0,INT2D_GRAY_8:b|1,INT2D_BIN_8:b|2,INT1D:e|0,INT1D_GRAY_8:e|1,INT1D_BIN_8:e|2,INT1D_X8R8G8B8_32:e|258,INT1D_X7H9S8V8_32:e|259,OBJECT_Java:d|256,OBJECT_CS:d|512,OBJECT_AS3:d|768,OBJECT_JS:d|1024,OBJECT_Java_BufferedImage:d|256|1,OBJECT_AS3_BitmapData:d|768|1,OBJECT_JS_Canvas:d|1024|1})})());NyARDoublePoint2d=Klass({x:0,y:0,createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARDoublePoint2d()}return a},initialize:function(){switch(arguments.length){case 0:this.x=0;this.y=0;return;case 1:this.x=args[0].x;this.y=args[0].y;return;break;case 2:this.x=Number(args[0]);this.y=Number(args[1]);return;default:break}throw new NyARException()},setValue_NyARDoublePoint2d:function(a){this.x=a.x;this.y=a.y;return},setValue_NyARIntPoint2d:function(a){this.x=(a.x);this.y=(a.y);return},dist:function(){return Math.sqrt(this.x*this.x+this.y+this.y)},sqNorm:function(){return this.x*this.x+this.y+this.y}});NyARDoublePoint3d=Klass({x:0,y:0,z:0,createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARDoublePoint3d()}return a},setValue:function(a){this.x=a.x;this.y=a.y;this.z=a.z;return},dist:function(b){var a,d,c;a=this.x-b.x;d=this.y-b.y;c=this.z-b.z;return Math.sqrt(a*a+d*d+c*c)}});NyARHistogram=Klass({data:null,length:0,total_of_data:0,initialize:function(a){this.data=new FloatVector(a);this.length=a;this.total_of_data=0},getTotal:function(c,b){NyAS3Utils.assert(c<b&&b<this.length);var a=0;var e=this.data;for(var d=c;d<=b;d++){a+=e[d]}return a},lowCut:function(a){var c=0;for(var b=0;b<a;b++){c+=this.data[b];this.data[b]=0}this.total_of_data-=c},highCut:function(a){var c=0;for(var b=this.length-1;b>=a;b--){c+=this.data[b];this.data[b]=0}this.total_of_data-=c},getMinSample:function(){var d=this.data;var a=this.length-1;var c=d[a];for(var b=this.length-2;b>=0;b--){if(d[b]<c){c=d[b];a=b}}return a},getMinData:function(){return this.data[this.getMinSample()]},getAverage:function(){var b=0;for(var a=this.length-1;a>=0;a--){b+=this.data[a]*a}return toInt(b/this.total_of_data)}});NyARIntPoint2d=Klass({x:0,y:0,createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARIntPoint2d()}return a},copyArray:function(b,c){for(var a=b.length-1;a>=0;a--){c[a].x=b[a].x;c[a].y=b[a].y}return}});NyARIntRect=Klass({x:0,y:0,w:0,h:0});NyARIntSize=Klass({h:0,w:0,initialize:function(){switch(arguments.length){case 0:this.w=0;this.h=0;return;case 1:this.w=arguments[0].w;this.h=arguments[0].h;return;break;case 2:this.w=toInt(arguments[0]);this.h=toInt(arguments[1]);return;break;default:break}throw new NyARException()},isEqualSize_int:function(b,a){if(b==this.w&&a==this.h){return true}return false},isEqualSize_NyARIntSize:function(a){if(a.w==this.w&&a.h==this.h){return true}return false}});NyARLinear=Klass({dx:0,dy:0,c:0,createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARLinear()}return a},copyFrom:function(a){this.dx=a.dx;this.dy=a.dy;this.c=a.c;return},crossPos:function(d,c,b){var a=c.dy*d.dx-d.dy*c.dx;if(a==0){return false}b.x=(c.dx*d.c-d.dx*c.c)/a;b.y=(d.dy*c.c-c.dy*d.c)/a;return true}});IFLdoThFilterImpl=ASKlass("IFLdoThFilterImpl",{doThFilter:function(b,a,d,c){}});FLARRasterFilter_Threshold=ASKlass("FLARRasterFilter_Threshold",{_threshold:0,_do_threshold_impl:null,FLARRasterFilter_Threshold:function(a){},setThreshold:function(a){this._threshold=a},doFilter:function(n,a){NyAS3Utils.assert(n._width==a._width&&n._height==a._height);var e=(a.getBuffer());var m=n.getRgbPixelReader();var g=m.getData().data;var l=e.data;var o=this._threshold*10000;for(var f=0,b=0;f<g.length;f+=4,++b){var k=g[f]*2989+g[f+1]*5866+g[f+2]*1145;var p=(k<=o)?4294967295:4278190080;l[b]=p}if(window.DEBUG){var q=document.getElementById("debugCanvas");e.drawOnCanvas(q)}return}});Point=function(a,b){this.x=a||0;this.y=b||0};doThFilterImpl_BUFFERFORMAT_OBJECT_AS_BitmapData={doThFilter:function(o,a,q){var e=(a.getBuffer());var b=(o.getBuffer());var l=b.data;var n=e.data;for(var g=0;g<l.length;g++){var p=l[g];var m=((p>>16)&255)*0.2989+((p>>8)&255)*0.5866+(p&255)*0.1145;var k=(m<=q);var r=k*4294967295+(1-k)*4278190080;n[j]=r}}};FLARDoublePoint2d=NyARDoublePoint2d;FLARDoublePoint3d=NyARDoublePoint3d;FLARIntSize=NyARIntSize;NyARLabelInfo=ASKlass("NyARLabelInfo",{area:0,clip_r:0,clip_l:0,clip_b:0,clip_t:0,pos_x:0,pos_y:0,NyARLabelInfo:function(){}});NyARLabelInfoStack=ASKlass("NyARLabelInfoStack",{_items:null,_length:0,NyARLabelInfoStack:function(a){this._items=this.createArray(a);this._length=0;return},createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARLabelInfo()}return(a)},sortByArea:function(){var a=this._length;if(a<1){return}var d=Math.floor(a*13/10);var e=this._items;for(;;){var f=0;for(var c=0;c+d<a;c++){if(e[c+d].area>e[c].area){var b=e[c+d];e[c+d]=e[c];e[c]=b;f++}}if(d==1){if(f==0){break}}else{d=Math.floor(d*10/13)}}},prePush:function(){if(this._length>=this._items.length){return null}var a=this._items[this._length];this._length++;return a},init:function(a){if(a>=this._items.length){throw new NyARException()}this._length=a},pop:function(){NyAS3Utils.assert(this._length>=1);this._length--;return this._items[this._length]},pops:function(a){NyAS3Utils.assert(this._length>=a);this._length-=a;return},getArray:function(){return this._items},getItem:function(a){return this._items[a]},getLength:function(){return this._length},clear:function(){this._length=0}});NyARLabelOverlapChecker=ASKlass("NyARLabelOverlapChecker",{_labels:null,_length:0,NyARLabelOverlapChecker:function(a){this._labels=this.createArray(a)},createArray:function(a){return new Array(a)},push:function(a){this._labels[this._length]=a;this._length++},check:function(k){var b=this._labels;var e=toInt(k.pos_x);var g=toInt(k.pos_y);for(var a=this._length-1;a>=0;a--){var c=toInt(b[a].pos_x);var f=toInt(b[a].pos_y);var l=(e-c)*(e-c)+(g-f)*(g-f);if(l<b[a].area/4){return false}}return true},setMaxLabels:function(a){if(a>this._labels.length){this._labels=this.createArray(a)}this._length=0}});NyARLabeling_Rle=ASKlass("NyARLabeling_Rle",{AR_AREA_MAX:100000,AR_AREA_MIN:70,_rlestack:null,_rle1:null,_rle2:null,_max_area:0,_min_area:0,NyARLabeling_Rle:function(b,a){this._rlestack=new RleInfoStack(b*a*2048/(320*240)+32);this._rle1=RleElement.createArray(b/2+1);this._rle2=RleElement.createArray(b/2+1);this.setAreaRange(this.AR_AREA_MAX,this.AR_AREA_MIN);return},setAreaRange:function(a,b){this._max_area=a;this._min_area=b;return},toRLE:function(i,e,m,g,f){var k=0;var l=0,b=1,d=2,c=3;var a=-1;var o=e;var n=e+m-1;while(o<n){if(i[o]!=4294967295){o++;continue}a=(o-e);g[k+l]=a;a++;o++;while(o<n){if(i[o]!=4294967295){g[k+b]=a;k+=c;o++;a=-1;break}else{a++;o++}}}if(i[o]!=4294967295){if(a>=0){g[k+b]=a;k+=c}}else{if(a>=0){g[k+b]=(a+1)}else{g[k+l]=(m-1);g[k+b]=(m)}k+=c}return k/c},addFragment:function(i,n,p,g,c){var m=0,b=1,e=2,d=3;var f=i[n+m];var a=i[n+b];var k=a-f;i[n+e]=p;var o=c.prePush();o.entry_x=f;o.area=k;o.clip_l=f;o.clip_r=a-1;o.clip_t=g;o.clip_b=g;o.pos_x=(k*(2*f+(k-1)))/2;o.pos_y=g*k;return},labeling_NyARBinRaster:function(c,b,d,a){NyAS3Utils.assert(c.isEqualBufferType(NyARBufferType.INT1D_BIN_8));return this.imple_labeling(c,0,b,d,a)},labeling_NyARGrayscaleRaster:function(e,c,b,d,a){NyAS3Utils.assert(e.isEqualBufferType(NyARBufferType.INT1D_GRAY_8));return this.imple_labeling(e,c,b,d,a)},labeling:function(b,a){return this.imple_labeling(b,0,0,b.getHeight(),a)},imple_labeling:function(p,e,s,u,G){var J=this._rlestack;J.clear();var Q=this._rle1;var d=this._rle2;var b=0;var O=0;var a=p.getWidth();var v=(p.getBuffer().data);var n=0;var c=0;var m=0,E=1,L=2,F=3;b=this.toRLE(v,s,a,Q,e);var P;for(P=0;P<b;P++){this.addFragment(Q,P*F,n,s,J);n++;c++}var q=(J.getArray());for(var D=s+1;D<u;D++){O=this.toRLE(v,D*a,a,d,e);var g=0;SCAN_CUR:for(P=0;P<O;P++){var C=-1;SCAN_PREV:while(g<b){if(d[P*F+m]-Q[g*F+E]>0){g++;continue}else{if(Q[g*F+m]-d[P*F+E]>0){this.addFragment(d,P*F,n,D,J);n++;c++;continue SCAN_CUR}}C=Q[g*F+L];var H=q[C];d[P*F+L]=C;var N=d[P*F+m];var I=d[P*F+E];var o=I-N;H.area+=o;H.clip_l=N<H.clip_l?N:H.clip_l;H.clip_r=I>H.clip_r?I-1:H.clip_r;H.clip_b=D;H.pos_x+=(o*(2*N+(o-1)))/2;H.pos_y+=D*o;g++;while(g<b){if(d[P*F+m]-Q[g*F+E]>0){break SCAN_PREV}else{if(Q[g*F+m]-d[P*F+E]>0){g--;continue SCAN_CUR}}var A=Q[g*F+L];var M=q[A];if(C!=A){c--;var f;for(f=g;f<b;f++){if(Q[f*F+L]==A){Q[f*F+L]=C}}for(f=0;f<P;f++){if(d[f*F+L]==A){d[f*F+L]=C}}H.area+=M.area;H.pos_x+=M.pos_x;H.pos_y+=M.pos_y;if(H.clip_t>M.clip_t){H.clip_t=M.clip_t;H.entry_x=M.entry_x}else{if(H.clip_t<M.clip_t){}else{if(H.entry_x>M.entry_x){H.entry_x=M.entry_x}else{}}}if(H.clip_l>M.clip_l){H.clip_l=M.clip_l}else{}if(H.clip_r<M.clip_r){H.clip_r=M.clip_r}else{}M.area=0}g++}g--;break}if(C<0){this.addFragment(d,P*F,n,D,J);n++;c++}}var K=Q;Q=d;b=O;d=K}G.init(c);var x=(G.getArray());var t=this._max_area;var R=this._min_area;var w=0;for(P=n-1;P>=0;P--){var B=q[P].area;if(B<R||B>t){continue}var k=q[P];var z=x[w];z.area=B;z.clip_b=k.clip_b;z.clip_r=k.clip_r;z.clip_t=k.clip_t;z.clip_l=k.clip_l;z.entry_x=k.entry_x;z.pos_x=k.pos_x/k.area;z.pos_y=k.pos_y/k.area;w++}G.pops(c-w);return w}});RleInfo=ASKlass("RleInfo",{entry_x:0,area:0,clip_r:0,clip_l:0,clip_b:0,clip_t:0,pos_x:0,pos_y:0});RleInfoStack=ASKlass("RleInfoStack",NyARObjectStack,{RleInfoStack:function(a){NyARObjectStack.initialize.call(this,a);return},createArray:function(b){var a=new Array(toInt(b));for(var c=0;c<b;c++){a[c]=new RleInfo()}return a}});RleElement=ASKlass("RleElement",{l:0,r:0,fid:0,createArray:function(b){return new IntVector(toInt(b)*3);var a=new Array(toInt(b));for(var c=0;c<b;c++){a[c]=new RleElement()}return a}});NyARRleLabelFragmentInfo=ASKlass("NyARRleLabelFragmentInfo",NyARLabelInfo,{entry_x:0});NyARRleLabelFragmentInfoStack=ASKlass("NyARRleLabelFragmentInfoStack",NyARLabelInfoStack,{NyARRleLabelFragmentInfoStack:function(a){NyARLabelInfoStack.initialize.call(this,a);return},createArray:function(b){var a=new Array(toInt(b));for(var c=0;c<b;c++){a[c]=new NyARRleLabelFragmentInfo()}return(a)}});FLARLabeling=ASKlass("FLARLabeling",{AR_AREA_MAX:100000,AR_AREA_MIN:70,ZERO_POINT:new Point(),ONE_POINT:new Point(1,1),hSearch:null,hLineRect:null,_tmp_bmp:null,areaMax:0,areaMin:0,FLARLabeling:function(b,a){this._tmp_bmp=new BitmapData(b,a,false,0);this.hSearch=new BitmapData(b,1,false,0);this.hLineRect=new Rectangle(0,0,1,1);this.setAreaRange(this.AR_AREA_MAX,this.AR_AREA_MIN);return},setAreaRange:function(a,b){this.areaMax=a;this.areaMin=b},labeling:function(d,c){var k=this._tmp_bmp;k.fillRect(k.rect,0);var m=k.rect.clone();m.inflate(-1,-1);k.copyPixels(d.getBuffer(),m,this.ONE_POINT);var i=k.getColorBoundsRect(16777215,16777215,true);var f=this.hLineRect;f.y=0;f.width=k.width;var l=this.hSearch;var e;var a;var g=0;var n;c.clear();while(!i.isEmpty()){f.y=i.top;l.copyPixels(k,f,this.ZERO_POINT);e=l.getColorBoundsRect(16777215,16777215,true);k.floodFill(e.x,f.y,++g);a=k.getColorBoundsRect(16777215,g,true);n=c.prePush();var b=a.width*a.height;if(b<=this.areaMax&&b>=this.areaMin){n.area=b;n.clip_l=a.left;n.clip_r=a.right-1;n.clip_t=a.top;n.clip_b=a.bottom-1;n.pos_x=(a.left+a.right-1)*0.5;n.pos_y=(a.top+a.bottom-1)*0.5;n.entry_x=this.getTopClipTangentX(k,g,n);if(n.entry_x==-1){return -1}}else{c.pop()}i=k.getColorBoundsRect(16777215,16777215,true)}return c.getLength()},getTopClipTangentX:function(c,f,e){var a;var b=e.clip_r;var d;for(d=e.clip_l;d<=b;d++){a=c.getPixel(d,e.clip_t);if(a>0&&a==f){return d}}return -1}});INyARCameraDistortionFactor=ASKlass("INyARCameraDistortionFactor",{ideal2Observ:function(a,b){},ideal2ObservBatch:function(b,c,a){},observ2Ideal:function(c,a,b){},observ2IdealBatch:function(d,f,c,e,a,b){}});NyARCameraDistortionFactor=ASKlass("NyARCameraDistortionFactor",INyARCameraDistortionFactor,{PD_LOOP:3,_f0:0,_f1:0,_f2:0,_f3:0,copyFrom:function(a){this._f0=a._f0;this._f1=a._f1;this._f2=a._f2;this._f3=a._f3;return},setValue:function(a){this._f0=a[0];this._f1=a[1];this._f2=a[2];this._f3=a[3];return},getValue:function(a){a[0]=this._f0;a[1]=this._f1;a[2]=this._f2;a[3]=this._f3;return},changeScale:function(a){this._f0=this._f0*a;this._f1=this._f1*a;this._f2=this._f2/(a*a);return},ideal2Observ:function(c,f){var a=(c.x-this._f0)*this._f3;var e=(c.y-this._f1)*this._f3;if(a==0&&e==0){f.x=this._f0;f.y=this._f1}else{var b=1-this._f2/100000000*(a*a+e*e);f.x=a*b+this._f0;f.y=e*b+this._f1}return},ideal2ObservBatch:function(m,l,n){var k,g;var b=this._f0;var a=this._f1;var o=this._f3;var e=this._f2/100000000;for(var c=0;c<n;c++){k=(m[c].x-b)*o;g=(m[c].y-a)*o;if(k==0&&g==0){l[c].x=b;l[c].y=a}else{var f=1-e*(k*k+g*g);l[c].x=k*f+b;l[c].y=g*f+a}}return},observ2Ideal:function(f,e,g){var m,l,d,b,n,r,o,s;var c=this._f0;var a=this._f1;r=f-c;o=e-a;d=this._f2/100000000;m=r*r+o*o;b=l=Math.sqrt(m);for(var k=1;;k++){if(l!=0){s=d*m;n=l-((1-s)*l-b)/(1-3*s);r=r*n/l;o=o*n/l}else{r=0;o=0;break}if(k==this.PD_LOOP){break}m=r*r+o*o;l=Math.sqrt(m)}g.x=r/this._f3+c;g.y=o/this._f3+a;return},observ2IdealBatch:function(e,v,k,c,u,t){var s,f,m,d,l,g,b;var a=this._f0;var x=this._f1;var w=this._f3;var n=this._f2/100000000;for(var o=0;o<c;o++){l=e[k+o]-a;g=v[k+o]-x;s=l*l+g*g;m=f=Math.sqrt(s);for(var r=1;;r++){if(f!=0){b=n*s;d=f-((1-b)*f-m)/(1-3*b);l=l*d/f;g=g*d/f}else{l=0;g=0;break}if(r==PD_LOOP){break}s=l*l+g*g;f=Math.sqrt(s)}u[o]=l/w+a;t[o]=g/w+x}return}});NyARObserv2IdealMap=ASKlass("NyARObserv2IdealMap",{_stride:0,_mapx:null,_mapy:null,NyARObserv2IdealMap:function(b,e){var a=new NyARDoublePoint2d();this._mapx=new FloatVector(e.w*e.h);this._mapy=new FloatVector(e.w*e.h);this._stride=e.w;var f=e.h*e.w-1;for(var c=e.h-1;c>=0;c--){for(var d=e.w-1;d>=0;d--){b.observ2Ideal(d,c,a);this._mapx[f]=a.x;this._mapy[f]=a.y;f--}}return},observ2Ideal:function(d,b,c){var a=d+b*this._stride;c.x=this._mapx[a];c.y=this._mapy[a];return},observ2IdealBatch:function(c,n,d,l,m,e,i){var o;var a=i;var k=this._mapx;var g=this._mapy;var b=this._stride;for(var f=0;f<l;f++){o=c[d+f]+n[d+f]*b;m[a]=k[o];e[a]=g[o];a++}return}});NyARPerspectiveProjectionMatrix=ASKlass("NyARPerspectiveProjectionMatrix",NyARDoubleMatrix34,{dot:function(c,a,f,e,d,b){return(c*e+a*d+f*b)},norm:function(e,d,f){return Math.sqrt(e*e+d*d+f*f)},decompMat:function(n,p){var o,w;var y,x,v;var e,d,b,a,m,l,k,i,u,t,s,q;if(this.m23>=0){e=this.m00;d=this.m01;b=this.m02;a=this.m03;m=this.m10;l=this.m11;k=this.m12;i=this.m13;u=this.m20;t=this.m21;s=this.m22;q=this.m23}else{e=-this.m00;d=-this.m01;b=-this.m02;a=-this.m03;m=-this.m10;l=-this.m11;k=-this.m12;i=-this.m13;u=-this.m20;t=-this.m21;s=-this.m22;q=-this.m23}var f=n.getArray();var g=p.getArray();for(o=0;o<3;o++){for(w=0;w<4;w++){f[o][w]=0}}f[2][2]=this.norm(u,t,s);g[2][0]=u/f[2][2];g[2][1]=t/f[2][2];g[2][2]=s/f[2][2];g[2][3]=q/f[2][2];f[1][2]=this.dot(g[2][0],g[2][1],g[2][2],m,l,k);y=m-f[1][2]*g[2][0];x=l-f[1][2]*g[2][1];v=k-f[1][2]*g[2][2];f[1][1]=this.norm(y,x,v);g[1][0]=y/f[1][1];g[1][1]=x/f[1][1];g[1][2]=v/f[1][1];f[0][2]=this.dot(g[2][0],g[2][1],g[2][2],e,d,b);f[0][1]=this.dot(g[1][0],g[1][1],g[1][2],e,d,b);y=e-f[0][1]*g[1][0]-f[0][2]*g[2][0];x=d-f[0][1]*g[1][1]-f[0][2]*g[2][1];v=b-f[0][1]*g[1][2]-f[0][2]*g[2][2];f[0][0]=this.norm(y,x,v);g[0][0]=y/f[0][0];g[0][1]=x/f[0][0];g[0][2]=v/f[0][0];g[1][3]=(i-f[1][2]*g[2][3])/f[1][1];g[0][3]=(a-f[0][1]*g[1][3]-f[0][2]*g[2][3])/f[0][0];for(o=0;o<3;o++){for(w=0;w<3;w++){f[o][w]/=f[2][2]}}return},changeScale:function(a){this.m00=this.m00*a;this.m10=this.m10*a;this.m01=this.m01*a;this.m11=this.m11*a;this.m02=this.m02*a;this.m12=this.m12*a;this.m03=this.m03*a;this.m13=this.m13*a;return},projectionConvert_NyARDoublePoint3d:function(c,b){var a=c.z*this.m22;b.x=(c.x*this.m00+c.y*this.m01+c.z*this.m02)/a;b.y=(c.y*this.m11+c.z*this.m12)/a;return},projectionConvert_Number:function(d,a,e,c){var b=e*this.m22;c.x=(d*this.m00+a*this.m01+e*this.m02)/b;c.y=(a*this.m11+e*this.m12)/b;return}});NyARParam=ASKlass("NyARParam",{_screen_size:new NyARIntSize(),SIZE_OF_PARAM_SET:4+4+(3*4*8)+(4*8),_dist:new NyARCameraDistortionFactor(),_projection_matrix:new NyARPerspectiveProjectionMatrix(),getScreenSize:function(){return this._screen_size},getPerspectiveProjectionMatrix:function(){return this._projection_matrix},getDistortionFactor:function(){return this._dist},copyCameraMatrix:function(e,n,m){var f=new FLARMat(3,4);var c=new FLARMat(3,4);var d=ArrayUtil.createJaggedArray(3,3);var a=ArrayUtil.createJaggedArray(4,4);var k=0;var g=0;var s=this.getScreenSize();var b=s.w;var o=s.h;this.getPerspectiveProjectionMatrix().decompMat(c,f);var l=c.getArray();var r=f.getArray();for(k=0;k<4;k++){l[1][k]=(o-1)*(l[2][k])-l[1][k]}for(k=0;k<3;k++){for(g=0;g<3;g++){d[k][g]=l[k][g]/l[2][2]}}a[0][0]=(2*d[0][0]/(b-1));a[0][1]=(2*d[0][1]/(b-1));a[0][2]=-((2*d[0][2]/(b-1))-1);a[0][3]=0;a[1][0]=0;a[1][1]=-(2*d[1][1]/(o-1));a[1][2]=-((2*d[1][2]/(o-1))-1);a[1][3]=0;a[2][0]=0;a[2][1]=0;a[2][2]=-(m+n)/(n-m);a[2][3]=2*m*n/(n-m);a[3][0]=0;a[3][1]=0;a[3][2]=1;a[3][3]=0;for(k=0;k<4;k++){for(g=0;g<3;g++){e[g*4+k]=a[k][0]*r[0][g]+a[k][1]*r[1][g]+a[k][2]*r[2][g]}e[k+4*3]=a[k][0]*r[0][3]+a[k][1]*r[1][3]+a[k][2]*r[2][3]+a[k][3]}},setValue:function(a,b){this._dist.setValue(a);this._projection_matrix.setValue(b);return},changeScreenSize:function(a,c){var b=a/this._screen_size.w;this._dist.changeScale(b);this._projection_matrix.changeScale(b);this._screen_size.w=a;this._screen_size.h=c;return},loadARParam:function(c){var b=new FloatVector(12);c.endian=Endian.BIG_ENDIAN;this._screen_size.w=c.readInt();this._screen_size.h=c.readInt();var a;for(a=0;a<12;a++){b[a]=c.readDouble()}this._projection_matrix.setValue(b);for(a=0;a<4;a++){b[a]=c.readDouble()}this._dist.setValue(b);return}});FLARParam=ASKlass("FLARParam",NyARParam,{FLARParam:function(b,c){b=b||640;c=c||480;this._screen_size.w=b;this._screen_size.h=c;var d=(b/c)/(4/3);var e=new FloatVector([b/2,1.1*c/2,26.2,1.0127565206658486]);var a=new FloatVector([d*700.9514702992245,0,b/2-0.5,0,0,726.0941816535367,c/2-0.5,0,0,0,1,0]);this.setValue(e,a)}});INyARRaster=ASKlass("INyARRaster",{getWidth:function(){},getHeight:function(){},getSize:function(){},getBuffer:function(){},getBufferType:function(){},isEqualBufferType:function(a){},hasBuffer:function(){},wrapBuffer:function(a){}});NyARRaster_BasicClass=ASKlass("NyARRaster_BasicClass",INyARRaster,{_size:null,_buffer_type:0,NyARRaster_BasicClass:function(){switch(arguments.length){case 1:if(arguments[0]==NyAS3Const_Inherited){}break;case 3:this.overload_NyARRaster_BasicClass(toInt(arguments[0]),toInt(arguments[1]),toInt(arguments[2]));break;default:throw new NyARException()}},overload_NyARRaster_BasicClass:function(c,b,a){this._size=new NyARIntSize(c,b);this._buffer_type=a},getWidth:function(){return this._size.w},getHeight:function(){return this._size.h},getSize:function(){return this._size},getBufferType:function(){return this._buffer_type},isEqualBufferType:function(a){return this._buffer_type==a},getBuffer:function(){throw new NyARException()},hasBuffer:function(){throw new NyARException()},wrapBuffer:function(a){throw new NyARException()}});NyARBinRaster=ASKlass("NyARBinRaster",NyARRaster_BasicClass,{_buf:null,_is_attached_buffer:null,NyARBinRaster:function(){NyARRaster_BasicClass.initialize.call(this,NyAS3Const_Inherited);switch(arguments.length){case 1:if(arguments[0]==NyAS3Const_Inherited){}break;case 2:this.override_NyARBinRaster2(toInt(arguments[0]),toInt(arguments[1]));break;case 3:this.override_NyARBinRaster3(toInt(arguments[0]),toInt(arguments[1]),Boolean(arguments[2]));break;case 4:this.override_NyARBinRaster4(toInt(arguments[0]),toInt(arguments[1]),toInt(arguments[2]),Boolean(arguments[3]));break;default:throw new NyARException()}},override_NyARBinRaster4:function(d,c,a,b){NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,d,c,a);if(!this.initInstance(this._size,a,b)){throw new NyARException()}},override_NyARBinRaster3:function(c,b,a){NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,c,b,NyARBufferType.INT1D_BIN_8);if(!this.initInstance(this._size,NyARBufferType.INT1D_BIN_8,a)){throw new NyARException()}},override_NyARBinRaster2:function(b,a){NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,b,a,NyARBufferType.INT1D_BIN_8);if(!this.initInstance(this._size,NyARBufferType.INT1D_BIN_8,true)){throw new NyARException()}},initInstance:function(c,b,a){switch(b){case NyARBufferType.INT1D_BIN_8:this._buf=a?new IntVector(c.w*c.h):null;break;default:return false}this._is_attached_buffer=a;return true},getBuffer:function(){return this._buf},hasBuffer:function(){return this._buf!=null},wrapBuffer:function(a){NyAS3Utils.assert(!this._is_attached_buffer);this._buf=a}});NyARGrayscaleRaster=ASKlass("NyARGrayscaleRaster",NyARRaster_BasicClass,{_buf:null,_is_attached_buffer:null,NyARGrayscaleRaster:function(){NyARRaster_BasicClass.initialize.call(this,NyAS3Const_Inherited);switch(arguments.length){case 1:if(arguments[0]==NyAS3Const_Inherited){}break;case 2:this.overload_NyARGrayscaleRaster2(toInt(arguments[0]),toInt(arguments[1]));break;case 3:this.overload_NyARGrayscaleRaster3(toInt(arguments[0]),toInt(arguments[1]),Boolean(arguments[2]));break;case 4:this.overload_NyARGrayscaleRaster4(toInt(arguments[0]),toInt(arguments[1]),toInt(arguments[2]),Boolean(arguments[3]));break;default:throw new NyARException()}},overload_NyARGrayscaleRaster2:function(b,a){NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,b,a,NyARBufferType.INT1D_GRAY_8);if(!this.initInstance(this._size,NyARBufferType.INT1D_GRAY_8,true)){throw new NyARException()}},overload_NyARGrayscaleRaster3:function(c,b,a){NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,c,b,NyARBufferType.INT1D_GRAY_8);if(!this.initInstance(this._size,NyARBufferType.INT1D_GRAY_8,a)){throw new NyARException()}},overload_NyARGrayscaleRaster4:function(d,c,a,b){NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,d,c,a);if(!this.initInstance(this._size,a,b)){throw new NyARException()}},initInstance:function(c,b,a){switch(b){case NyARBufferType.INT1D_GRAY_8:this._buf=a?new IntVector(c.w*c.h):null;break;default:return false}this._is_attached_buffer=a;return true},getBuffer:function(){return this._buf},hasBuffer:function(){return this._buf!=null},wrapBuffer:function(a){NyAS3Utils.assert(!this._is_attached_buffer);this._buf=a}});NyARRaster=ASKlass("NyARRaster",NyARRaster_BasicClass,{_buf:null,_buf_type:0,_is_attached_buffer:null,NyARRaster:function(){NyARRaster_BasicClass.initialize.call(this,NyAS3Const_Inherited);switch(arguments.length){case 1:if(arguments[0]==NyAS3Const_Inherited){}break;case 3:this.overload_NyARRaster3(toInt(arguments[0]),toInt(arguments[1]),toInt(arguments[2]));break;case 4:this.overload_NyARRaster4(toInt(arguments[0]),toInt(arguments[1]),toInt(arguments[2]),Boolean(arguments[3]));break;default:throw new NyARException()}},overload_NyARRaster4:function(d,c,a,b){NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,d,c,a);if(!this.initInstance(this._size,a,b)){throw new NyARException()}return},overload_NyARRaster3:function(c,b,a){NyARRaster_BasicClass.overload_NyARRaster_BasicClass.call(this,c,b,a);if(!this.initInstance(this._size,a,true)){throw new NyARException()}return},initInstance:function(c,b,a){switch(b){case NyARBufferType.INT1D_X8R8G8B8_32:this._buf=a?new IntVector(c.w*c.h):null;break;default:return false}this._is_attached_buffer=a;return true},getBuffer:function(){return this._buf},hasBuffer:function(){return this._buf!=null},wrapBuffer:function(a){NyAS3Utils.assert(!this._is_attached_buffer);this._buf=a}});INyARRgbRaster=ASKlass("INyARRgbRaster",INyARRaster,{getRgbPixelReader:function(){}});NyARRgbRaster_BasicClass=ASKlass("NyARRgbRaster_BasicClass",INyARRgbRaster,{_size:null,_buffer_type:0,NyARRgbRaster_BasicClass:function(){switch(arguments.length){case 1:if(arguments[0]==NyAS3Const_Inherited){}break;case 3:this.overload_NyARRgbRaster_BasicClass(toInt(arguments[0]),toInt(arguments[1]),toInt(arguments[2]));break;default:throw new NyARException()}},overload_NyARRgbRaster_BasicClass:function(c,b,a){this._size=new NyARIntSize(c,b);this._buffer_type=a},getWidth:function(){return this._size.w},getHeight:function(){return this._size.h},getSize:function(){return this._size},getBufferType:function(){return this._buffer_type},isEqualBufferType:function(a){return this._buffer_type==a},getRgbPixelReader:function(){throw new NyARException()},getBuffer:function(){throw new NyARException()},hasBuffer:function(){throw new NyARException()},wrapBuffer:function(a){throw new NyARException()}});NyARRgbRaster=ASKlass("NyARRgbRaster",NyARRgbRaster_BasicClass,{_buf:null,_reader:null,_is_attached_buffer:null,NyARRgbRaster:function(){NyARRgbRaster_BasicClass.initialize.call(this,NyAS3Const_Inherited);switch(arguments.length){case 1:if(arguments[0]==NyAS3Const_Inherited){}break;case 3:this.overload_NyARRgbRaster3(toInt(arguments[0]),toInt(arguments[1]),toInt(arguments[2]));break;case 4:this.overload_NyARRgbRaster4(toInt(arguments[0]),toInt(arguments[1]),toInt(arguments[2]),Boolean(arguments[3]));break;default:throw new NyARException()}},overload_NyARRgbRaster4:function(d,c,a,b){NyARRgbRaster_BasicClass.overload_NyARRgbRaster_BasicClass.call(this,d,c,a);if(!this.initInstance(this._size,a,b)){throw new NyARException()}},overload_NyARRgbRaster3:function(c,b,a){NyARRgbRaster_BasicClass.overload_NyARRgbRaster_BasicClass.call(this,c,b,a);if(!this.initInstance(this._size,a,true)){throw new NyARException()}},initInstance:function(c,a,b){switch(a){case NyARBufferType.INT1D_X8R8G8B8_32:this._buf=b?new IntVector(c.w*c.h):null;this._reader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._buf||new IntVector(1),c);break;case NyARBufferType.BYTE1D_B8G8R8X8_32:case NyARBufferType.BYTE1D_R8G8B8_24:default:return false}this._is_attached_buffer=b;return true},getRgbPixelReader:function(){return this._reader},getBuffer:function(){return this._buf},hasBuffer:function(){return this._buf!=null},wrapBuffer:function(a){NyAS3Utils.assert(!this._is_attached_buffer);this._buf=a;this._reader.switchBuffer(a)}});NyARRgbRaster_Canvas2D=ASKlass("NyARRgbRaster_Canvas2D",NyARRgbRaster_BasicClass,{_canvas:null,_rgb_reader:null,NyARRgbRaster_Canvas2D:function(a){NyARRgbRaster_BasicClass.initialize.call(this,a.width,a.height,NyARBufferType.OBJECT_JS_Canvas);this._canvas=a;this._rgb_reader=new NyARRgbPixelReader_Canvas2D(this._canvas)},getRgbPixelReader:function(){return this._rgb_reader},getBuffer:function(){return this._canvas},hasBuffer:function(){return this._bitmapData!=null}});FLARCanvas=function(a,b){var d=document.createElement("canvas");d.width=a;d.height=b;return d};FLARBinRaster=ASKlass("FLARBinRaster",NyARBinRaster,{FLARBinRaster:function(b,a){NyARBinRaster.initialize.call(this,b,a,NyARBufferType.OBJECT_AS3_BitmapData,true);this._gray_reader=new FLARGrayPixelReader_BitmapData(this._buf)},initInstance:function(c,b,a){this._buf=a?new BitmapData(c.w,c.h,0):null;return true},getGrayPixelReader:function(){return this._gray_reader}});FLARRgbRaster_BitmapData=ASKlass("FLARRgbRaster_BitmapData",NyARRgbRaster_BasicClass,{_bitmapData:null,_rgb_reader:null,FLARRgbRaster_BitmapData:function(a){NyARRgbRaster_BasicClass.initialize.call(this,a.width,a.height,NyARBufferType.OBJECT_AS3_BitmapData);this._bitmapData=a;this._rgb_reader=new FLARRgbPixelReader_BitmapData(this._bitmapData)},getRgbPixelReader:function(){return this._rgb_reader},getBuffer:function(){return this._bitmapData},hasBuffer:function(){return this._bitmapData!=null}});NyARMatchPattDeviationBlackWhiteData=ASKlass("NyARMatchPattDeviationBlackWhiteData",{_data:null,_pow:0,_number_of_pixels:0,refData:function(){return this._data},getPow:function(){return this._pow},NyARMatchPattDeviationBlackWhiteData:function(b,a){this._number_of_pixels=a*b;this._data=new IntVector(this._number_of_pixels);return},setRaster:function(e){var d;var k;var l;var m=this._data;var b=(e.getBuffer());var f=this._number_of_pixels;k=0;for(d=f-1;d>=0;d--){l=b[d];k+=((l>>16)&255)+((l>>8)&255)+(l&255)}k=(f*255*3-k)/(3*f);var g=0,c;for(d=f-1;d>=0;d--){l=b[d];c=((255*3-(l&255)-((l>>8)&255)-((l>>16)&255))/3)-k;m[d]=c;g+=c*c}var a=Math.sqrt(g);this._pow=a!=0?a:1e-7;return}});NyARMatchPattDeviationColorData=ASKlass("NyARMatchPattDeviationColorData",{_data:null,_pow:0,_number_of_pixels:0,_optimize_for_mod:0,refData:function(){return this._data},getPow:function(){return this._pow},NyARMatchPattDeviationColorData:function(b,a){this._number_of_pixels=a*b;this._data=new IntVector(this._number_of_pixels*3);this._optimize_for_mod=this._number_of_pixels-(this._number_of_pixels%8);return},setRaster:function(g){NyAS3Utils.assert(g.isEqualBufferType(NyARBufferType.INT1D_X8R8G8B8_32));NyAS3Utils.assert(g.getSize().isEqualSize_NyARIntSize(g.getSize()));var b=(g.getBuffer());var f;var m;var n;var o=this._data;var l=this._number_of_pixels;var c=this._optimize_for_mod;m=0;for(f=l-1;f>=c;f--){n=b[f];m+=((n>>16)&255)+((n>>8)&255)+(n&255)}for(;f>=0;){n=b[f];m+=((n>>16)&255)+((n>>8)&255)+(n&255);f--;n=b[f];m+=((n>>16)&255)+((n>>8)&255)+(n&255);f--;n=b[f];m+=((n>>16)&255)+((n>>8)&255)+(n&255);f--;n=b[f];m+=((n>>16)&255)+((n>>8)&255)+(n&255);f--;n=b[f];m+=((n>>16)&255)+((n>>8)&255)+(n&255);f--;n=b[f];m+=((n>>16)&255)+((n>>8)&255)+(n&255);f--;n=b[f];m+=((n>>16)&255)+((n>>8)&255)+(n&255);f--;n=b[f];m+=((n>>16)&255)+((n>>8)&255)+(n&255);f--}m=l*255*3-m;m=255-(m/(l*3));var k=0,e;var d=l*3-1;for(f=l-1;f>=c;f--){n=b[f];e=(m-(n&255));o[d--]=e;k+=e*e;e=(m-((n>>8)&255));o[d--]=e;k+=e*e;e=(m-((n>>16)&255));o[d--]=e;k+=e*e}for(;f>=0;){n=b[f];f--;e=(m-(n&255));o[d--]=e;k+=e*e;e=(m-((n>>8)&255));o[d--]=e;k+=e*e;e=(m-((n>>16)&255));o[d--]=e;k+=e*e;n=b[f];f--;e=(m-(n&255));o[d--]=e;k+=e*e;e=(m-((n>>8)&255));o[d--]=e;k+=e*e;e=(m-((n>>16)&255));o[d--]=e;k+=e*e;n=b[f];f--;e=(m-(n&255));o[d--]=e;k+=e*e;e=(m-((n>>8)&255));o[d--]=e;k+=e*e;e=(m-((n>>16)&255));o[d--]=e;k+=e*e;n=b[f];f--;e=(m-(n&255));o[d--]=e;k+=e*e;e=(m-((n>>8)&255));o[d--]=e;k+=e*e;e=(m-((n>>16)&255));o[d--]=e;k+=e*e;n=b[f];f--;e=(m-(n&255));o[d--]=e;k+=e*e;e=(m-((n>>8)&255));o[d--]=e;k+=e*e;e=(m-((n>>16)&255));o[d--]=e;k+=e*e;n=b[f];f--;e=(m-(n&255));o[d--]=e;k+=e*e;e=(m-((n>>8)&255));o[d--]=e;k+=e*e;e=(m-((n>>16)&255));o[d--]=e;k+=e*e;n=b[f];f--;e=(m-(n&255));o[d--]=e;k+=e*e;e=(m-((n>>8)&255));o[d--]=e;k+=e*e;e=(m-((n>>16)&255));o[d--]=e;k+=e*e;n=b[f];f--;e=(m-(n&255));o[d--]=e;k+=e*e;e=(m-((n>>8)&255));o[d--]=e;k+=e*e;e=(m-((n>>16)&255));o[d--]=e;k+=e*e}var a=Math.sqrt(k);this._pow=a!=0?a:1e-7;return}});NyARMatchPattResult=ASKlass("NyARMatchPattResult",{DIRECTION_UNKNOWN:-1,confidence:0,direction:0});NyARCode=ASKlass("NyARCode",{_color_pat:new Array(4),_bw_pat:new Array(4),_width:0,_height:0,NyARCode:function(c,b){this._width=c;this._height=b;for(var a=0;a<4;a++){this._color_pat[a]=new NyARMatchPattDeviationColorData(c,b);this._bw_pat[a]=new NyARMatchPattDeviationBlackWhiteData(c,b)}return},getColorData:function(a){return this._color_pat[a]},getBlackWhiteData:function(a){return this._bw_pat[a]},getWidth:function(){return this._width},getHeight:function(){return this._height},loadARPattFromFile:function(a){NyARCodeFileReader.loadFromARToolKitFormFile(a,this);return},setRaster:function(a){NyAS3Utils.assert(a.length!=4);for(var b=0;b<4;b++){this._color_pat[b].setRaster(a[b])}return}});NyARCodeFileReader=ASKlass("NyARCodeFileReader",{loadFromARToolKitFormFile:function(i,f){var e=f.getWidth();var a=f.getHeight();var g=new NyARRaster(e,a,NyARBufferType.INT1D_X8R8G8B8_32);var c=i.match(/\d+/g);var b=(g.getBuffer());for(var d=0;d<4;d++){this.readBlock(c,e,a,b);f.getColorData(d).setRaster(g);f.getBlackWhiteData(d).setRaster(g)}g=null;return},readBlock:function(a,i,d,g){var f=i*d;var b;for(b=0;b<3;b++){for(var c=0;c<f;c++){var e=parseInt(a.shift());if(isNaN(e)){throw new NyARException("syntax error in pattern file.")}g[c]=(g[c]<<8)|((255&toInt(e)))}}for(b=0;b<f;b++){g[b]=((g[b]<<16)&16711680)|(g[b]&65280)|((g[b]>>16)&255)}return}});FLARCode=ASKlass("FLARCode",NyARCode,{markerPercentWidth:50,markerPercentHeight:50,FLARCode:function(d,c,b,a){NyARCode.initialize.call(this,d,c);this.markerPercentWidth=b==null?50:b;this.markerPercentHeight=a==null?50:a},loadARPatt:function(a){NyARCode.loadARPattFromFile.call(this,a);return}});INyARMatchPatt=ASKlass("INyARMatchPatt",{setARCode:function(a){}});NyARMatchPatt_Color_WITHOUT_PCA=ASKlass("NyARMatchPatt_Color_WITHOUT_PCA",INyARMatchPatt,{_code_patt:null,_optimize_for_mod:0,_rgbpixels:0,NyARMatchPatt_Color_WITHOUT_PCA:function(){switch(arguments.length){case 1:var e=arguments[0];var a=e.getWidth();var b=e.getHeight();this._rgbpixels=a*b*3;this._optimize_for_mod=this._rgbpixels-(this._rgbpixels%16);this.setARCode(e);return;break;case 2:var d=toInt(arguments[0]),c=toInt(arguments[1]);this._rgbpixels=c*d*3;this._optimize_for_mod=this._rgbpixels-(this._rgbpixels%16);return;break;default:break}throw new NyARException()},setARCode:function(a){this._code_patt=a;return},evaluate:function(f,k){NyAS3Utils.assert(this._code_patt!=null);var o=f.refData();var l;var n=Number.MIN_VALUE;var m=NyARMatchPattResult.DIRECTION_UNKNOWN;var c=this._optimize_for_mod;for(var d=0;d<4;d++){l=0;var b=this._code_patt.getColorData(d);var g=b.refData();var e;for(e=this._rgbpixels-1;e>=c;e--){l+=o[e]*g[e]}for(;e>=0;){l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--;l+=o[e]*g[e];e--}var a=l/b.getPow();if(a>n){n=a;m=d}}k.direction=m;k.confidence=n/f.getPow();return true}});NyARRasterAnalyzer_Histogram=ASKlass("NyARRasterAnalyzer_Histogram",{_histImpl:null,_vertical_skip:0,NyARRasterAnalyzer_Histogram:function(b,a){if(!this.initInstance(b,a)){throw new NyARException()}},initInstance:function(b,a){switch(b){case NyARBufferType.INT1D_GRAY_8:this._histImpl=new NyARRasterThresholdAnalyzer_Histogram_INT1D_GRAY_8();break;case NyARBufferType.INT1D_X8R8G8B8_32:this._histImpl=new NyARRasterThresholdAnalyzer_Histogram_INT1D_X8R8G8B8_32();break;default:return false}this._vertical_skip=a;return true},setVerticalInterval:function(a){this._vertical_skip=a;return},analyzeRaster:function(d,e){var b=d.getSize();NyAS3Utils.assert(b.w*b.h<1073741824);NyAS3Utils.assert(e.length==256);var c=e.data;for(var a=e.length-1;a>=0;a--){c[a]=0}e.total_of_data=b.w*b.h/this._vertical_skip;return this._histImpl.createHistogram(d,b,c,this._vertical_skip)}});ICreateHistogramImpl=ASKlass("ICreateHistogramImpl",{createHistogram:function(d,b,c,a){}});NyARRasterThresholdAnalyzer_Histogram_INT1D_GRAY_8=ASKlass("NyARRasterThresholdAnalyzer_Histogram_INT1D_GRAY_8",ICreateHistogramImpl,{createHistogram:function(i,e,g,b){NyAS3Utils.assert(i.isEqualBufferType(NyARBufferType.INT1D_GRAY_8));var c=(IntVector)(i.getBuffer());for(var f=e.h-1;f>=0;f-=b){var d=f*e.w;for(var a=e.w-1;a>=0;a--){g[c[d]]++;d++}}return e.w*e.h}});NyARRasterThresholdAnalyzer_Histogram_INT1D_X8R8G8B8_32=ASKlass("NyARRasterThresholdAnalyzer_Histogram_INT1D_X8R8G8B8_32",ICreateHistogramImpl,{createHistogram:function(b,i,c,g){NyAS3Utils.assert(b.isEqualBufferType(NyARBufferType.INT1D_X8R8G8B8_32));var e=(b.getBuffer());for(var d=i.h-1;d>=0;d-=g){var k=d*i.w;for(var f=i.w-1;f>=0;f--){var a=e[k];c[((a&255)+(a&255)+(a&255))/3]++;k++}}return i.w*i.h}});INyARRasterThresholdAnalyzer=ASKlass("INyARRasterThresholdAnalyzer",{analyzeRaster:function(a){}});NyARRasterThresholdAnalyzer_SlidePTile=ASKlass("NyARRasterThresholdAnalyzer_SlidePTile",INyARRasterThresholdAnalyzer,{_raster_analyzer:null,_sptile:null,_histgram:null,NyARRasterThresholdAnalyzer_SlidePTile:function(a,c,b){NyAS3Utils.assert(0<=a&&a<=50);if(!this.initInstance(c,b)){throw new NyARException()}this._sptile=new NyARHistogramAnalyzer_SlidePTile(a);this._histgram=new NyARHistogram(256)},initInstance:function(b,a){this._raster_analyzer=new NyARRasterAnalyzer_Histogram(b,a);return true},setVerticalInterval:function(a){this._raster_analyzer.setVerticalInterval(a);return},analyzeRaster:function(a){this._raster_analyzer.analyzeRaster(a,this._histgram);return this._sptile.getThreshold(this._histgram)}});FLARRasterAnalyzer_Histogram=ASKlass("FLARRasterAnalyzer_Histogram",NyARRasterAnalyzer_Histogram,{FLARRasterAnalyzer_Histogram:function(a){NyARRasterAnalyzer_Histogram.initialize.call(this,NyARBufferType.OBJECT_AS3_BitmapData,a)},initInstance:function(b,a){if(b!=NyARBufferType.OBJECT_AS3_BitmapData){return false}else{this._vertical_skip=a}return true},analyzeRaster:function(d,e){var b=d.getSize();NyAS3Utils.assert(b.w*b.h<1073741824);NyAS3Utils.assert(e.length==256);var c=e.data;for(var a=e.length-1;a>=0;a--){c[a]=0}e.total_of_data=b.w*b.h/this._vertical_skip;return this.createHistgram_AS3_BitmapData(d,b,c,this._vertical_skip)},createHistgram_AS3_BitmapData:function(b,i,c,g){NyAS3Utils.assert(b.isEqualBufferType(NyARBufferType.OBJECT_AS3_BitmapData));var e=(b.getBuffer());for(var d=i.h-1;d>=0;d-=g){var k=d*i.w;for(var f=i.w-1;f>=0;f--){var a=e.getPixel(f,d);c[toInt((((a>>8)&255)+((a>>16)&255)+(a&255))/3)]++;k++}}return i.w*i.h}});FLARRasterThresholdAnalyzer_SlidePTile=ASKlass("FLARRasterThresholdAnalyzer_SlidePTile",NyARRasterThresholdAnalyzer_SlidePTile,{FLARRasterThresholdAnalyzer_SlidePTile:function(a,b){NyARRasterThresholdAnalyzer_SlidePTile.initialize.call(this,a,NyARBufferType.OBJECT_AS3_BitmapData,b)},initInstance:function(b,a){if(b!=NyARBufferType.OBJECT_AS3_BitmapData){return false}this._raster_analyzer=new FLARRasterAnalyzer_Histogram(a);return true}});INyARRasterFilter=ASKlass("INyARRasterFilter",{doFilter:function(b,a){}});INyARRasterFilter_Gs2Bin=ASKlass("INyARRasterFilter_Gs2Bin",{doFilter:function(b,a){}});INyARRasterFilter_Rgb2Gs=ASKlass("INyARRasterFilter_Rgb2Gs",{doFilter:function(b,a){}});INyARRasterFilter_Rgb2Bin=ASKlass("INyARRasterFilter_Rgb2Bin",{doFilter:function(b,a){}});NyARRasterFilter_ARToolkitThreshold=ASKlass("NyARRasterFilter_ARToolkitThreshold",INyARRasterFilter_Rgb2Bin,{_threshold:0,_do_threshold_impl:null,NyARRasterFilter_ARToolkitThreshold:function(b,a){this._threshold=b;switch(a){case NyARBufferType.INT1D_X8R8G8B8_32:this._do_threshold_impl=new doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32();break;default:throw new NyARException()}},setThreshold:function(a){this._threshold=a},doFilter:function(b,a){NyAS3Utils.assert(a.isEqualBufferType(NyARBufferType.INT1D_BIN_8));NyAS3Utils.assert(b.getSize().isEqualSize_NyARIntSize(a.getSize())==true);this._do_threshold_impl.doThFilter(b,a,a.getSize(),this._threshold);return}});IdoThFilterImpl=ASKlass("IdoThFilterImpl",{doThFilter:function(b,a,d,c){}});doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32=ASKlass("doThFilterImpl_BUFFERFORMAT_INT1D_X8R8G8B8_32",IdoThFilterImpl,{doThFilter:function(g,a,l,k){NyAS3Utils.assert(a.isEqualBufferType(NyARBufferType.INT1D_BIN_8));var f=(IntVector)(a.getBuffer());var b=(IntVector)(g.getBuffer());var c=k*3;var i;var m;var e=l.h*l.w;var d=e-(e%8);for(m=e-1;m>=d;m--){i=b[m];f[m]=(((i>>16)&255)+((i>>8)&255)+(i&255))<=c?0:1}for(;m>=0;){i=b[m];f[m]=(((i>>16)&255)+((i>>8)&255)+(i&255))<=c?0:1;m--;i=b[m];f[m]=(((i>>16)&255)+((i>>8)&255)+(i&255))<=c?0:1;m--;i=b[m];f[m]=(((i>>16)&255)+((i>>8)&255)+(i&255))<=c?0:1;m--;i=b[m];f[m]=(((i>>16)&255)+((i>>8)&255)+(i&255))<=c?0:1;m--;i=b[m];f[m]=(((i>>16)&255)+((i>>8)&255)+(i&255))<=c?0:1;m--;i=b[m];f[m]=(((i>>16)&255)+((i>>8)&255)+(i&255))<=c?0:1;m--;i=b[m];f[m]=(((i>>16)&255)+((i>>8)&255)+(i&255))<=c?0:1;m--;i=b[m];f[m]=(((i>>16)&255)+((i>>8)&255)+(i&255))<=c?0:1;m--}}});NyARContourPickup=ASKlass("NyARContourPickup",{_getContour_xdir:new IntVector([0,1,1,1,0,-1,-1,-1,0,1,1,1,0,-1,-1]),_getContour_ydir:new IntVector([-1,-1,0,1,1,1,0,-1,-1,-1,0,1,1,1,0]),getContour_NyARBinRaster:function(a,e,c,b,f,d){return this.impl_getContour(a,0,e,c,b,f,d)},getContour_NyARGrayscaleRaster:function(a,b,f,d,c,g,e){return this.impl_getContour(a,b,f,d,c,g,e)},impl_getContour:function(g,m,f,e,d,b,a){var n=this._getContour_xdir;var t=this._getContour_ydir;var w=g.getBuffer();var u=g.getWidth();var q=g.getHeight();var o=1;b[0]=f;a[0]=e;var s=5;var z=f;var p=e;for(;;){s=(s+5)%8;if(z>=1&&z<u-1&&p>=1&&p<q-1){for(;;){if(w[(p+t[s])*u+(z+n[s])]<=m){break}s++;if(w[(p+t[s])*u+(z+n[s])]<=m){break}s++;if(w[(p+t[s])*u+(z+n[s])]<=m){break}s++;if(w[(p+t[s])*u+(z+n[s])]<=m){break}s++;if(w[(p+t[s])*u+(z+n[s])]<=m){break}s++;if(w[(p+t[s])*u+(z+n[s])]<=m){break}s++;if(w[(p+t[s])*u+(z+n[s])]<=m){break}s++;if(w[(p+t[s])*u+(z+n[s])]<=m){break}throw new NyARException()}}else{var v;for(v=0;v<8;v++){var l=z+n[s];var k=p+t[s];if(l>=0&&l<u&&k>=0&&k<q){if(w[(k)*u+(l)]<=m){break}}s++}if(v==8){throw new NyARException()}}s=s%8;z=z+n[s];p=p+t[s];b[o]=z;a[o]=p;if(z==f&&p==e){o++;break}o++;if(o==d){return o}}return o}});NyARCoord2Linear=ASKlass("NyARCoord2Linear",{_xpos:null,_ypos:null,_pca:null,__getSquareLine_evec:new NyARDoubleMatrix22(),__getSquareLine_mean:new FloatVector(2),__getSquareLine_ev:new FloatVector(2),_dist_factor:null,NyARCoord2Linear:function(b,a){this._dist_factor=new NyARObserv2IdealMap(a,b);this._pca=new NyARPca2d_MatrixPCA_O2();this._xpos=new FloatVector(b.w+b.h);this._ypos=new FloatVector(b.w+b.h);return},coord2Line:function(c,g,a,e,k,i){var b,m,f;var d;if(g>=c){d=(g-c+1)*0.05+0.5;m=Math.floor(c+d);f=Math.floor(g-d)}else{d=((g+k-c+1)%k)*0.05+0.5;m=(Math.floor(c+d))%k;f=(Math.floor(g+k-d))%k}if(m<=f){b=f-m+1;this._dist_factor.observ2IdealBatch(a,e,m,b,this._xpos,this._ypos,0)}else{b=f+1+k-m;this._dist_factor.observ2IdealBatch(a,e,m,k-m,this._xpos,this._ypos,0);this._dist_factor.observ2IdealBatch(a,e,0,f+1,this._xpos,this._ypos,k-m)}if(b<2){return false}var l=this.__getSquareLine_evec;var o=this.__getSquareLine_mean;this._pca.pca(this._xpos,this._ypos,b,l,this.__getSquareLine_ev,o);i.dy=l.m01;i.dx=-l.m00;i.c=-(i.dy*o[0]+i.dx*o[1]);return true}});NyARVertexCounter=ASKlass("NyARVertexCounter",{vertex:new IntVector(10),number_of_vertex:0,thresh:0,x_coord:null,y_coord:null,getVertex:function(c,f,e,b,a,d){this.number_of_vertex=0;this.thresh=d;this.x_coord=c;this.y_coord=f;return this.get_vertex(b,a,e)},get_vertex:function(s,g,n){var f;var l;var q=0;var e=this.x_coord;var r=this.y_coord;var p=r[g]-r[s];var o=e[s]-e[g];var m=e[g]*r[s]-r[g]*e[s];var k=0;if(s<g){for(f=s+1;f<g;f++){l=p*e[f]+o*r[f]+m;if(l*l>k){k=l*l;q=f}}}else{for(f=s+1;f<n;f++){l=p*e[f]+o*r[f]+m;if(l*l>k){k=l*l;q=f}}for(f=0;f<g;f++){l=p*e[f]+o*r[f]+m;if(l*l>k){k=l*l;q=f}}}if(k/(p*p+o*o)>this.thresh){if(!this.get_vertex(s,q,n)){return false}if(this.number_of_vertex>5){return false}this.vertex[this.number_of_vertex]=q;this.number_of_vertex++;if(!this.get_vertex(q,g,n)){return false}}return true}});NyARCoord2SquareVertexIndexes=ASKlass("NyARCoord2SquareVertexIndexes",{VERTEX_FACTOR:1,__getSquareVertex_wv1:new NyARVertexCounter(),__getSquareVertex_wv2:new NyARVertexCounter(),NyARCoord2SquareVertexIndexes:function(){return},getVertexIndexes:function(c,n,f,b,a){var i=this.__getSquareVertex_wv1;var g=this.__getSquareVertex_wv2;var l=this.getFarPoint(c,n,f,0);var e=(l+f)%f;var m=this.getFarPoint(c,n,f,l);var d=(b/0.75)*0.01*this.VERTEX_FACTOR;a[0]=l;if(!i.getVertex(c,n,f,l,m,d)){return false}if(!g.getVertex(c,n,f,m,e,d)){return false}var k;if(i.number_of_vertex==1&&g.number_of_vertex==1){a[1]=i.vertex[0];a[2]=m;a[3]=g.vertex[0]}else{if(i.number_of_vertex>1&&g.number_of_vertex==0){if(m>=l){k=(m-l)/2+l}else{k=((m+f-l)/2+l)%f}if(!i.getVertex(c,n,f,l,k,d)){return false}if(!g.getVertex(c,n,f,k,m,d)){return false}if(i.number_of_vertex==1&&g.number_of_vertex==1){a[1]=i.vertex[0];a[2]=g.vertex[0];a[3]=m}else{return false}}else{if(i.number_of_vertex==0&&g.number_of_vertex>1){if(m<=e){k=(m+e)/2}else{k=((m+f+e)/2)%f}if(!i.getVertex(c,n,f,m,k,d)){return false}if(!g.getVertex(c,n,f,k,e,d)){return false}if(i.number_of_vertex==1&&g.number_of_vertex==1){a[1]=m;a[2]=i.vertex[0];a[3]=g.vertex[0]}else{return false}}else{return false}}}return true},getFarPoint:function(b,a,f,p){var n=b[p];var l=a[p];var g=0;var o,m,k;var e=0;var c;for(c=p+1;c<f;c++){m=b[c]-n;k=a[c]-l;o=m*m+k*k;if(o>g){g=o;e=c}}for(c=0;c<p;c++){m=b[c]-n;k=a[c]-l;o=m*m+k*k;if(o>g){g=o;e=c}}return e}});NyARSquare=ASKlass("NyARSquare",{line:NyARLinear.createArray(4),sqvertex:NyARDoublePoint2d.createArray(4),getCenter2d:function(a){a.x=(this.sqvertex[0].x+this.sqvertex[1].x+this.sqvertex[2].x+this.sqvertex[3].x)/4;a.y=(this.sqvertex[0].y+this.sqvertex[1].y+this.sqvertex[2].y+this.sqvertex[3].y)/4;return}});NyARSquareContourDetector=ASKlass("NyARSquareContourDetector",{detectMarkerCB:function(a,b){NyARException.trap("getRgbPixelReader not implemented.")}});NyARSquareContourDetector_IDetectMarkerCallback=ASKlass("NyARSquareContourDetector_IDetectMarkerCallback",{onSquareDetect:function(a,e,d,c,b){}});RleLabelOverlapChecker=ASKlass("RleLabelOverlapChecker",NyARLabelOverlapChecker,{RleLabelOverlapChecker:function(a){NyARLabelOverlapChecker.initialize.call(this,a)},createArray:function(a){return new Array(a)}});NyARSquareContourDetector_Rle=ASKlass("NyARSquareContourDetector_Rle",NyARSquareContourDetector,{AR_AREA_MAX:100000,AR_AREA_MIN:70,_width:0,_height:0,_labeling:null,_overlap_checker:new RleLabelOverlapChecker(32),_cpickup:new NyARContourPickup(),_stack:null,_coord2vertex:new NyARCoord2SquareVertexIndexes(),_max_coord:0,_xcoord:null,_ycoord:null,NyARSquareContourDetector_Rle:function(b){this._width=b.w;this._height=b.h;this._labeling=new NyARLabeling_Rle(this._width,this._height);this._labeling.setAreaRange(this.AR_AREA_MAX,this.AR_AREA_MIN);this._stack=new NyARRleLabelFragmentInfoStack(b.w*b.h*2048/(320*240)+32);var a=(this._width+this._height)*2;this._max_coord=a;this._xcoord=new IntVector(a);this._ycoord=new IntVector(a);return},__detectMarker_mkvertex:new IntVector(4),detectMarkerCB:function(m,e){var d=this._stack;var s=this._overlap_checker;var r=this._labeling.labeling_NyARBinRaster(m,0,m.getHeight(),d);if(r<1){return}d.sortByArea();var n=(d.getArray());var o=this._width;var l=this._height;var f=this._xcoord;var q=this._ycoord;var k=this._max_coord;var b=this.__detectMarker_mkvertex;s.setMaxLabels(r);for(var g=0;g<r;g++){var a=n[g];var p=a.area;if(a.clip_l==0||a.clip_r==o-1){continue}if(a.clip_t==0||a.clip_b==l-1){continue}if(!s.check(a)){continue}var c=_cpickup.getContour_NyARBinRaster(m,a.entry_x,a.clip_t,k,f,q);if(c==k){continue}if(!this._coord2vertex.getVertexIndexes(f,q,c,p,b)){continue}e.onSquareDetect(this,f,q,c,b);s.push(a)}return}});NyARSquareStack=ASKlass("NyARSquareStack",NyARObjectStack,{NyARSquareStack:function(a){NyARObjectStack.initialize.call(this,a)},createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARSquare()}return(a)}});FLARSquare=NyARSquare;Cxdir=new IntVector([0,1,1,1,0,-1,-1,-1]);Cydir=new IntVector([-1,-1,0,1,1,1,0,-1]);FLContourPickup=ASKlass("FLContourPickup",NyARContourPickup,{FLContourPickup:function(){},getContour_FLARBinRaster:function(g,f,e,d,b,a){var m=this._getContour_xdir;var s=this._getContour_ydir;var v=g.getBuffer();var t=g.getWidth();var p=g.getHeight();var n=1;b[0]=f;a[0]=e;var q=5;var w=f;var o=e;for(;;){q=(q+5)%8;if(w>=1&&w<t-1&&o>=1&&o<p-1){for(;;){if(v.getPixel(w+m[q],o+s[q])>0){break}q++;if(v.getPixel(w+m[q],o+s[q])>0){break}q++;if(v.getPixel(w+m[q],o+s[q])>0){break}q++;if(v.getPixel(w+m[q],o+s[q])>0){break}q++;if(v.getPixel(w+m[q],o+s[q])>0){break}q++;if(v.getPixel(w+m[q],o+s[q])>0){break}q++;if(v.getPixel(w+m[q],o+s[q])>0){break}q++;if(v.getPixel(w+m[q],o+s[q])>0){break}return -1}}else{var u;for(u=0;u<8;u++){var l=w+m[q];var k=o+s[q];if(l>=0&&l<t&&k>=0&&k<p){if(v.getPixel(k,l)>0){break}}q++}if(u==8){return -1}}q=q%8;w=w+m[q];o=o+s[q];b[n]=w;a[n]=o;if(w==f&&o==e){n++;break}n++;if(n==d){return n}}return n}});FLARSquareContourDetector=ASKlass("FLARSquareContourDetector",NyARSquareContourDetector,{AR_AREA_MAX:100000,AR_AREA_MIN:70,_width:0,_height:0,_labeling:null,_overlap_checker:new NyARLabelOverlapChecker(32),_cpickup:new FLContourPickup(),_stack:null,_coord2vertex:new NyARCoord2SquareVertexIndexes(),_max_coord:0,_xcoord:null,_ycoord:null,FLARSquareContourDetector:function(b){this._width=b.w;this._height=b.h;this._labeling=new NyARLabeling_Rle(this._width,this._height);this._stack=new NyARRleLabelFragmentInfoStack(b.w*b.h*2048/(320*240)+32);var a=(this._width+this._height)*2;this._max_coord=a;this._xcoord=new IntVector(a);this._ycoord=new IntVector(a);return},setAreaRange:function(a,b){this._labeling.setAreaRange(a,b)},__detectMarker_mkvertex:new IntVector(4),detectMarkerCB:function(g,s){var t=this._stack;var a=this._overlap_checker;var b=this._labeling.labeling(g,t);if(b<1){return}t.sortByArea();var r=t.getArray();var p=this._width;var e=this._height;var l=this._xcoord;var o=this._ycoord;var u=this._max_coord;var f=this.__detectMarker_mkvertex;a.setMaxLabels(b);for(var q=0;q<b;q++){var d=r[q];var k=d.area;if(d.clip_l==0||d.clip_r==p-1){continue}if(d.clip_t==0||d.clip_b==e-1){continue}if(!a.check(d)){continue}if(window.DEBUG){var c=document.getElementById("debugCanvas").getContext("2d");c.strokeStyle="red";c.strokeRect(d.clip_l,d.clip_t,d.clip_r-d.clip_l,d.clip_b-d.clip_t);c.fillStyle="red";c.fillRect(d.entry_x-1,d.clip_t-1,3,3);c.fillStyle="cyan";c.fillRect(d.pos_x-1,d.pos_y-1,3,3)}var n=this._cpickup.getContour_FLARBinRaster(g,d.entry_x,d.clip_t,u,l,o);if(n==-1){return -1}if(n==u){continue}var m=this._coord2vertex.getVertexIndexes(l,o,n,k,f);if(!m){continue}s.onSquareDetect(this,l,o,n,f);a.push(d)}return}});INyARTransMat=Klass({transMat:function(b,c,a){},transMatContinue:function(a,b,c){}});NyARRectOffset=ASKlass("NyARRectOffset",{vertex:NyARDoublePoint3d.createArray(4),createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARRectOffset()}return a},setSquare:function(c){var b=c/2;var a;a=this.vertex[0];a.x=-b;a.y=b;a.z=0;a=this.vertex[1];a.x=b;a.y=b;a.z=0;a=this.vertex[2];a.x=b;a.y=-b;a.z=0;a=this.vertex[3];a.x=-b;a.y=-b;a.z=0;return}});NyARTransMat=ASKlass("NyARTransMat",INyARTransMat,{_projection_mat_ref:null,_rotmatrix:null,_transsolver:null,_mat_optimize:null,_ref_dist_factor:null,NyARTransMat:function(a){var c=a.getDistortionFactor();var b=a.getPerspectiveProjectionMatrix();this._transsolver=new NyARTransportVectorSolver(b,4);this._rotmatrix=new NyARRotMatrix(b);this._mat_optimize=new NyARPartialDifferentiationOptimize(b);this._ref_dist_factor=c;this._projection_mat_ref=b;this.__transMat_vertex_2d=NyARDoublePoint2d.createArray(4);this.__transMat_vertex_3d=NyARDoublePoint3d.createArray(4);this.__transMat_trans=new NyARDoublePoint3d();this.__rot=new NyARDoubleMatrix33()},makeErrThreshold:function(g){var f,d,e,c;f=g[0].x-g[2].x;d=g[0].y-g[2].y;e=f*f+d*d;f=g[1].x-g[3].x;d=g[1].y-g[3].y;c=f*f+d*d;return(Math.sqrt(e>c?e:c))/200},transMat:function(e,f,d){var c=this.__transMat_trans;var a=this.makeErrThreshold(e.sqvertex);var g=this.__transMat_vertex_2d;var b=this.__transMat_vertex_3d;this._ref_dist_factor.ideal2ObservBatch(e.sqvertex,g,4);this._transsolver.set2dVertex(g,4);this._rotmatrix.initRotBySquare(e.line,e.sqvertex);this._rotmatrix.getPoint3dBatch(f.vertex,b,4);this._transsolver.solveTransportVector(b,c);d.error=this.optimize(this._rotmatrix,c,this._transsolver,f.vertex,g,a);this.updateMatrixValue(this._rotmatrix,c,d);return},transMatContinue:function(l,c,k){var n=this.__transMat_trans;if(!k.has_value){this.transMat(l,c,k);return}var d=this.makeErrThreshold(l.sqvertex);var b=this.__transMat_vertex_2d;var m=this.__transMat_vertex_3d;this._ref_dist_factor.ideal2ObservBatch(l.sqvertex,b,4);this._transsolver.set2dVertex(b,4);this._rotmatrix.initRotByPrevResult(k);this._rotmatrix.getPoint3dBatch(c.vertex,m,4);this._transsolver.solveTransportVector(m,n);var f=this.errRate(this._rotmatrix,n,c.vertex,b,4,m);var a=this.__rot;if(f<k.error+d){a.setValue_NyARDoubleMatrix33(this._rotmatrix);for(var g=0;g<5;g++){this._mat_optimize.modifyMatrix(a,n,c.vertex,b,4);var e=this.errRate(a,n,c.vertex,b,4,m);if(f-e<d/2){break}this._transsolver.solveTransportVector(m,n);this._rotmatrix.setValue_NyARDoubleMatrix33(a);f=e}this.updateMatrixValue(this._rotmatrix,n,k)}else{this._rotmatrix.initRotBySquare(l.line,l.sqvertex);this._rotmatrix.getPoint3dBatch(c.vertex,m,4);this._transsolver.solveTransportVector(m,n);f=this.optimize(this._rotmatrix,n,this._transsolver,c.vertex,b,d);this.updateMatrixValue(this._rotmatrix,n,k)}k.error=f;return},optimize:function(n,k,l,f,d,b){var m=this.__transMat_vertex_3d;var e=this.errRate(n,k,f,d,4,m);var a=this.__rot;a.setValue_NyARDoubleMatrix33(n);for(var g=0;g<5;g++){this._mat_optimize.modifyMatrix(a,k,f,d,4);var c=this.errRate(a,k,f,d,4,m);if(e-c<b){break}l.solveTransportVector(m,k);n.setValue_NyARDoubleMatrix33(a);e=c}return e},errRate:function(w,q,u,p,n,b){var f=this._projection_mat_ref;var a=f.m00;var y=f.m01;var x=f.m02;var k=f.m11;var g=f.m12;var d=0;for(var t=0;t<n;t++){var r,c,s;b[t].x=r=w.m00*u[t].x+w.m01*u[t].y+w.m02*u[t].z;b[t].y=c=w.m10*u[t].x+w.m11*u[t].y+w.m12*u[t].z;b[t].z=s=w.m20*u[t].x+w.m21*u[t].y+w.m22*u[t].z;r+=q.x;c+=q.y;s+=q.z;var e=r*a+c*y+s*x;var v=c*k+s*g;var m=s;var o=p[t].x-e/m;var l=p[t].y-v/m;d+=o*o+l*l}return d/n},updateMatrixValue:function(a,c,b){b.m00=a.m00;b.m01=a.m01;b.m02=a.m02;b.m03=c.x;b.m10=a.m10;b.m11=a.m11;b.m12=a.m12;b.m13=c.y;b.m20=a.m20;b.m21=a.m21;b.m22=a.m22;b.m23=c.z;b.has_value=true;return}});NyARTransMatResult=ASKlass("NyARTransMatResult",NyARDoubleMatrix34,{error:0,has_value:false,getZXYAngle:function(b){var a=this.m21;if(a>=1){b.x=Math.PI/2;b.y=0;b.z=Math.atan2(-this.m10,this.m00)}else{if(a<=-1){b.x=-Math.PI/2;b.y=0;b.z=Math.atan2(-this.m10,this.m00)}else{b.x=Math.asin(a);b.z=Math.atan2(-this.m01,this.m11);b.y=Math.atan2(-this.m20,this.m22)}}},transformVertex_Number:function(b,a,d,c){c.x=this.m00*b+this.m01*a+this.m02*d+this.m03;c.y=this.m10*b+this.m11*a+this.m12*d+this.m13;c.z=this.m20*b+this.m21*a+this.m22*d+this.m23;return},transformVertex_NyARDoublePoint3d:function(a,b){this.transformVertex_Number(a.x,a.y,a.z,b)}});NyARPartialDifferentiationOptimize=ASKlass("NyARPartialDifferentiationOptimize",{_projection_mat_ref:null,NyARPartialDifferentiationOptimize:function(a){this._projection_mat_ref=a;this.__angles_in=TSinCosValue.createArray(3);this.__ang=new NyARDoublePoint3d();this.__sin_table=new FloatVector(4);return},sincos2Rotation_ZXY:function(g,a){var f=g[0].sin_val;var i=g[0].cos_val;var d=g[1].sin_val;var e=g[1].cos_val;var b=g[2].sin_val;var c=g[2].cos_val;a.m00=c*e-b*f*d;a.m01=-b*i;a.m02=c*d+b*f*e;a.m10=b*e+c*f*d;a.m11=c*i;a.m12=b*d-c*f*e;a.m20=-i*d;a.m21=f;a.m22=e*i},rotation2Sincos_ZXY:function(b,g,f){var a,e,d;var c=b.m21;if(c>=1){a=Math.PI/2;e=0;d=Math.atan2(-b.m10,b.m00)}else{if(c<=-1){a=-Math.PI/2;e=0;d=Math.atan2(-b.m10,b.m00)}else{a=Math.asin(c);e=Math.atan2(-b.m20,b.m22);d=Math.atan2(-b.m01,b.m11)}}f.x=a;f.y=e;f.z=d;g[0].sin_val=Math.sin(a);g[0].cos_val=Math.cos(a);g[1].sin_val=Math.sin(e);g[1].cos_val=Math.cos(e);g[2].sin_val=Math.sin(d);g[2].cos_val=Math.cos(d);return},optimizeParamX:function(z,y,af,R,k,r,Q){var P=this._projection_mat_ref;var m=z.sin_val;var x=z.cos_val;var l=y.sin_val;var w=y.cos_val;var t,v,u,s,q,p;t=v=u=s=q=p=0;for(var V=0;V<r;V++){var F,E,D;F=R[V].x;E=R[V].y;D=R[V].z;var I=P.m00;var H=P.m01;var G=P.m02;var o=P.m11;var n=P.m12;var U=(I*(-l*m*F+l*x*D)+H*(w*m*F-w*x*D)+G*(E));var T=(I*(-l*E)+H*((w*E))+G*(-m*F+x*D));var S=(I*(af.x+w*x*F+w*m*D)+H*((af.y+l*x*F+l*m*D))+G*(af.z));var C=(o*(w*m*F-w*x*D)+n*(E));var B=(o*((w*E))+n*(-m*F+x*D));var A=(o*((af.y+l*x*F+l*m*D))+n*(af.z));var ag=(E);var ad=(-m*F+x*D);var ac=af.z;var g=k[V].x;var ae=k[V].y;var ab,aa,Z,Y,X,W;ab=(g*ag-U);aa=(g*ad-T);Z=(g*ac-S);Y=(ae*ag-C);X=(ae*ad-B);W=(ae*ac-A);t+=Y*X+ab*aa;q+=Y*Y+ab*ab;v+=Y*W+ab*Z;s+=X*X+aa*aa;u+=X*W+aa*Z;p+=W*W+Z*Z}t*=2;v*=2;u*=2;return this.getMinimumErrorAngleFromParam(t,v,u,s,q,p,Q)},optimizeParamY:function(z,y,af,R,k,r,Q){var P=this._projection_mat_ref;var m=z.sin_val;var x=z.cos_val;var l=y.sin_val;var w=y.cos_val;var t,v,u,s,q,p;t=v=u=s=q=p=0;for(var V=0;V<r;V++){var F,E,D;F=R[V].x;E=R[V].y;D=R[V].z;var I=P.m00;var H=P.m01;var G=P.m02;var o=P.m11;var n=P.m12;var U=(I*(-l*m*F+w*D)+H*(w*m*F+l*D)+G*(-x*F));var T=(H*(l*F-w*m*D)+I*(w*F+l*m*D)+G*(x*D));var S=(I*(af.x+(-l*x)*E)+H*(af.y+(w*x)*E)+G*(af.z+(m)*E));var C=(o*(w*m*F+l*D)+n*(-x*F));var B=(o*(l*F-w*m*D)+n*(x*D));var A=(o*(af.y+(w*x)*E)+n*(af.z+(m)*E));var ag=(-x*F);var ad=(x*D);var ac=af.z+(m)*E;var g=k[V].x;var ae=k[V].y;var ab,aa,Z,Y,X,W;ab=(g*ag-U);aa=(g*ad-T);Z=(g*ac-S);Y=(ae*ag-C);X=(ae*ad-B);W=(ae*ac-A);t+=Y*X+ab*aa;q+=Y*Y+ab*ab;v+=Y*W+ab*Z;s+=X*X+aa*aa;u+=X*W+aa*Z;p+=W*W+Z*Z}t*=2;v*=2;u*=2;return this.getMinimumErrorAngleFromParam(t,v,u,s,q,p,Q)},optimizeParamZ:function(z,y,af,R,k,r,Q){var P=this._projection_mat_ref;var m=z.sin_val;var x=z.cos_val;var l=y.sin_val;var w=y.cos_val;var t,v,u,s,q,p;t=v=u=s=q=p=0;for(var V=0;V<r;V++){var F,E,D;F=R[V].x;E=R[V].y;D=R[V].z;var I=P.m00;var H=P.m01;var G=P.m02;var o=P.m11;var n=P.m12;var U=(I*(-m*l*F-x*E+m*w*D)+H*(F*w+l*D));var T=(H*(m*F*l+x*E-m*D*w)+I*(w*F+l*D));var S=I*af.x+H*(af.y)+G*(-x*l)*F+G*(m)*E+G*((w*x)*D+af.z);var C=o*(F*w+l*D);var B=o*(m*F*l+x*E-m*D*w);var A=(o*af.y+n*(-x*l)*F+n*((m)*E+(w*x)*D+af.z));var ag=0;var ad=0;var ac=((-x*l)*F+(m)*E+(w*x)*D+af.z);var g=k[V].x;var ae=k[V].y;var ab,aa,Z,Y,X,W;ab=(g*ag-U);aa=(g*ad-T);Z=(g*ac-S);Y=(ae*ag-C);X=(ae*ad-B);W=(ae*ac-A);t+=Y*X+ab*aa;q+=Y*Y+ab*ab;v+=Y*W+ab*Z;s+=X*X+aa*aa;u+=X*W+aa*Z;p+=W*W+Z*Z}t*=2;v*=2;u*=2;return this.getMinimumErrorAngleFromParam(t,v,u,s,q,p,Q)},modifyMatrix:function(c,g,f,e,d){var a=this.__angles_in;var b=this.__ang;this.rotation2Sincos_ZXY(c,a,b);b.x+=this.optimizeParamX(a[1],a[2],g,f,e,d,b.x);b.y+=this.optimizeParamY(a[0],a[2],g,f,e,d,b.y);b.z+=this.optimizeParamZ(a[0],a[1],g,f,e,d,b.z);c.setZXYAngle_Number(b.x,b.y,b.z);return},getMinimumErrorAngleFromParam:function(e,g,f,d,c,b,y){var a=this.__sin_table;var p=(c-d)/e;var s=g/e;var r=-f/e;var w=NyAREquationSolver.solve4Equation(-4*p*p-4,4*r-4*s*p,4*p*p-(r*r-4)-s*s,4*s*p-2*r,s*s-1,a);var q=Number.MAX_VALUE;var o=Number.MAX_VALUE;var u=Number.MAX_VALUE;var t=Number.MAX_VALUE;for(var x=0;x<w;x++){var k=a[x];var v=Math.sqrt(1-(k*k));var B=2*v*k*p+k*(r-k)+v*(v+s);var A=2*(-v)*k*p+k*(r-k)+(-v)*((-v)+s);B=B<0?-B:B;A=A<0?-A:A;v=(B<A)?v:-v;var z=Math.atan2(k,v);var m=c*k*k+(e*v+g)*k+d*v*v+f*v+b;if(u>m){t=u;o=q;u=m;q=z}else{if(t>m){t=m;o=z}}}var n;n=q-y;if(n>Math.PI){n=(q-Math.PI*2)-y}else{if(n<-Math.PI){n=(q+Math.PI*2)-y}}var l;l=o-y;if(l>Math.PI){l=(o-Math.PI*2)-y}else{if(l<-Math.PI){l=(o+Math.PI*2)-y}}return Math.abs(l)<Math.abs(n)?l:n}});TSinCosValue=ASKlass("TSinCosValue",{cos_val:0,sin_val:0,createArray:function(c){var a=new Array(c);for(var b=0;b<c;b++){a[b]=new TSinCosValue()}return a}});NyARRotMatrix=ASKlass("NyARRotMatrix",NyARDoubleMatrix33,{NyARRotMatrix:function(a){this.__initRot_vec1=new NyARRotVector(a);this.__initRot_vec2=new NyARRotVector(a);return},__initRot_vec1:null,__initRot_vec2:null,initRotByPrevResult:function(a){this.m00=a.m00;this.m01=a.m01;this.m02=a.m02;this.m10=a.m10;this.m11=a.m11;this.m12=a.m12;this.m20=a.m20;this.m21=a.m21;this.m22=a.m22;return},initRotBySquare:function(i,f){var e=this.__initRot_vec1;var d=this.__initRot_vec2;e.exteriorProductFromLinear(i[0],i[2]);e.checkVectorByVertex(f[0],f[1]);d.exteriorProductFromLinear(i[1],i[3]);d.checkVectorByVertex(f[3],f[0]);NyARRotVector.checkRotation(e,d);this.m00=e.v1;this.m10=e.v2;this.m20=e.v3;this.m01=d.v1;this.m11=d.v2;this.m21=d.v3;var g=e.v2*d.v3-e.v3*d.v2;var a=e.v3*d.v1-e.v1*d.v3;var c=e.v1*d.v2-e.v2*d.v1;var b=Math.sqrt(g*g+a*a+c*c);this.m02=g/b;this.m12=a/b;this.m22=c/b;return},getPoint3d:function(b,c){var a=b.x;var e=b.y;var d=b.z;c.x=this.m00*a+this.m01*e+this.m02*d;c.y=this.m10*a+this.m11*e+this.m12*d;c.z=this.m20*a+this.m21*e+this.m22*d;return},getPoint3dBatch:function(a,d,k){for(var c=k-1;c>=0;c--){var b=d[c];var l=a[c];var g=l.x;var f=l.y;var e=l.z;b.x=this.m00*g+this.m01*f+this.m02*e;b.y=this.m10*g+this.m11*f+this.m12*e;b.z=this.m20*g+this.m21*f+this.m22*e}return}});NyARRotVector=ASKlass("NyARRotVector",{v1:0,v2:0,v3:0,_projection_mat_ref:null,_inv_cpara_array_ref:null,NyARRotVector:function(c){var a=new NyARMat(3,3);var b=a.getArray();b[0][0]=c.m00;b[0][1]=c.m01;b[0][2]=c.m02;b[1][0]=c.m10;b[1][1]=c.m11;b[1][2]=c.m12;b[2][0]=c.m20;b[2][1]=c.m21;b[2][2]=c.m22;a.matrixSelfInv();this._projection_mat_ref=c;this._inv_cpara_array_ref=a.getArray()},exteriorProductFromLinear:function(e,c){var a=this._projection_mat_ref;var f=e.dy*c.dx-c.dy*e.dx;var d=e.dx*c.c-c.dx*e.c;var b=e.c*c.dy-c.c*e.dy;var l=f*(a.m01*a.m12-a.m02*a.m11)+d*a.m11-b*a.m01;var k=-f*a.m00*a.m12+b*a.m00;var i=f*a.m00*a.m11;var g=Math.sqrt(l*l+k*k+i*i);this.v1=l/g;this.v2=k/g;this.v3=i/g;return},checkVectorByVertex:function(q,c){var e;var b=this._inv_cpara_array_ref;var p=b[0][0]*q.x*10+b[0][1]*q.y*10+b[0][2]*10;var o=b[1][0]*q.x*10+b[1][1]*q.y*10+b[1][2]*10;var m=b[2][0]*q.x*10+b[2][1]*q.y*10+b[2][2]*10;var k=p+this.v1;var g=o+this.v2;var d=m+this.v3;var a=this._projection_mat_ref;e=a.m20*p+a.m21*o+a.m22*m;if(e==0){throw new NyARException()}var n=(a.m00*p+a.m01*o+a.m02*m)/e;var l=(a.m10*p+a.m11*o+a.m12*m)/e;e=a.m20*k+a.m21*g+a.m22*d;if(e==0){throw new NyARException()}var i=(a.m00*k+a.m01*g+a.m02*d)/e;var f=(a.m10*k+a.m11*g+a.m12*d)/e;var r=(c.x-q.x)*(i-n)+(c.y-q.y)*(f-l);if(r<0){this.v1=-this.v1;this.v2=-this.v2;this.v3=-this.v3}},checkRotation:function(p,o){var I;var O;var i=p.v1;var g=p.v2;var e=p.v3;var L=o.v1;var K=o.v2;var J=o.v3;var z=g*J-e*K;var x=e*L-i*J;var u=i*K-g*L;I=Math.sqrt(z*z+x*x+u*u);if(I==0){throw new NyARException()}z/=I;x/=I;u/=I;var G=i*L+g*K+e*J;if(G<0){G=-G}var H=(Math.sqrt(G+1)+Math.sqrt(1-G))*0.5;if(x*i-g*z!=0){O=0}else{if(u*i-e*z!=0){I=g;g=e;e=I;I=x;x=u;u=I;O=1}else{I=i;i=e;e=I;I=z;z=u;u=I;O=2}}if(x*i-g*z==0){throw new NyARException()}var B,A,y,v;var U,T,S,R;var Q,F,n;var P,E,m;var N,D,l;var M,C,k;B=(g*u-x*e)/(x*i-g*z);A=(x*H)/(x*i-g*z);y=(i*u-z*e)/(z*g-i*x);v=(z*H)/(z*g-i*x);U=B*B+y*y+1;T=B*A+y*v;S=A*A+v*v-1;R=T*T-U*S;if(R<0){throw new NyARException()}n=(-T+Math.sqrt(R))/U;Q=B*n+A;F=y*n+v;m=(-T-Math.sqrt(R))/U;P=B*m+A;E=y*m+v;if(O==1){I=F;F=n;n=I;I=E;E=m;m=I;I=g;g=e;e=I;I=x;x=u;u=I;O=0}if(O==2){I=Q;Q=n;n=I;I=P;P=m;m=I;I=i;i=e;e=I;I=z;z=u;u=I;O=0}if(x*L-K*z!=0){O=0}else{if(u*L-J*z!=0){I=K;K=J;J=I;I=x;x=u;u=I;O=1}else{I=L;L=J;J=I;I=z;z=u;u=I;O=2}}if(x*L-K*z==0){throw new NyARException()}B=(K*u-x*J)/(x*L-K*z);A=(x*H)/(x*L-K*z);y=(L*u-z*J)/(z*K-L*x);v=(z*H)/(z*K-L*x);U=B*B+y*y+1;T=B*A+y*v;S=A*A+v*v-1;R=T*T-U*S;if(R<0){throw new NyARException()}l=(-T+Math.sqrt(R))/U;N=B*l+A;D=y*l+v;k=(-T-Math.sqrt(R))/U;M=B*k+A;C=y*k+v;if(O==1){I=D;D=l;l=I;I=C;C=k;k=I;I=K;K=J;J=I;I=x;x=u;u=I;O=0}if(O==2){I=N;N=l;l=I;I=M;M=k;k=I;I=L;L=J;J=I;I=z;z=u;u=I;O=0}var t=Q*N+F*D+n*l;if(t<0){t=-t}var s=Q*M+F*C+n*k;if(s<0){s=-s}var r=P*N+E*D+m*l;if(r<0){r=-r}var q=P*M+E*C+m*k;if(q<0){q=-q}if(t<s){if(t<r){if(t<q){p.v1=Q;p.v2=F;p.v3=n;o.v1=N;o.v2=D;o.v3=l}else{p.v1=P;p.v2=E;p.v3=m;o.v1=M;o.v2=C;o.v3=k}}else{if(r<q){p.v1=P;p.v2=E;p.v3=m;o.v1=N;o.v2=D;o.v3=l}else{p.v1=P;p.v2=E;p.v3=m;o.v1=M;o.v2=C;o.v3=k}}}else{if(s<r){if(s<q){p.v1=Q;p.v2=F;p.v3=n;o.v1=M;o.v2=C;o.v3=k}else{p.v1=P;p.v2=E;p.v3=m;o.v1=M;o.v2=C;o.v3=k}}else{if(r<q){p.v1=P;p.v2=E;p.v3=m;o.v1=N;o.v2=D;o.v3=l}else{p.v1=P;p.v2=E;p.v3=m;o.v1=M;o.v2=C;o.v3=k}}}return}});INyARTransportVectorSolver=ASKlass("INyARTransportVectorSolver",{set2dVertex:function(a,b){},solveTransportVector:function(b,a){}});NyARTransportVectorSolver=ASKlass("NyARTransportVectorSolver",INyARTransportVectorSolver,{_cx:null,_cy:null,_projection_mat:null,_nmber_of_vertex:0,NyARTransportVectorSolver:function(b,a){this._projection_mat=b;this._cx=new FloatVector(a);this._cy=new FloatVector(a);return},_a00:0,_a01_10:0,_a02_20:0,_a11:0,_a12_21:0,_a22:0,set2dVertex:function(o,r){var f=this._cx;var d=this._cy;var b;var q=this._projection_mat.m00;var p=this._projection_mat.m01;var c=this._projection_mat.m11;var a=this._projection_mat.m12;var n=this._projection_mat.m02;var m,l,g,e;this._a00=r*q*q;this._a01_10=r*q*p;this._a11=r*(p*p+c*c);b=0;m=l=0;for(var k=0;k<r;k++){g=n-(f[k]=o[k].x);e=a-(d[k]=o[k].y);m+=g;l+=e;b+=g*g+e*e}this._a02_20=m*q;this._a12_21=p*m+c*l;this._a22=b;this._nmber_of_vertex=r;return},solveTransportVector:function(B,C){var z=this._nmber_of_vertex;var k=this._projection_mat.m00;var e=this._projection_mat.m01;var d=this._projection_mat.m02;var x=this._projection_mat.m11;var w=this._projection_mat.m12;var b=this._cx;var a=this._cy;var n,m,g;n=m=g=0;for(var A=0;A<z;A++){var v=B[A].z*b[A]-k*B[A].x-e*B[A].y-d*B[A].z;var u=B[A].z*a[A]-x*B[A].y-w*B[A].z;n+=v;m+=u;g+=b[A]*v+a[A]*u}g=d*n+w*m-g;m=e*n+x*m;n=k*n;var F=this._a00;var E=this._a01_10;var D=this._a02_20;var l=this._a11;var f=this._a12_21;var y=this._a22;var t=y*m-f*g;var s=f*m-l*g;var r=E*g-D*m;var q=f*f-l*y;var p=D*f-E*y;var o=D*l-E*f;var c=F*q-E*p+D*o;C.x=(E*t-D*s+n*q)/c;C.y=-(F*t+D*r+n*p)/c;C.z=(F*s+E*r+n*o)/c;return}});FLARTransMatResult=NyARTransMatResult;NyARMath=Klass({sqNorm_NyARDoublePoint2d:function(c,b){var a,d;a=b.x-c.x;d=b.y-c.y;return a*a+d*d},sqNorm_Number:function(c,b,e,d){var a,f;a=e-c;f=d-b;return a*a+f*f},sqNorm_NyARDoublePoint3d:function(c,b){var a,e,d;a=b.x-c.x;e=b.y-c.y;d=b.z-c.z;return a*a+e*e+d*d},cubeRoot:function(b){var a=Math.pow(Math.abs(b),1/3);return(b>=0)?a:-a}});NyAREquationSolver=Klass({solve2Equation_3:function(c,b,a,d){NyAS3Utils.assert(c!=0);return this.solve2Equation_2b(b/c,a/c,d,0)},solve2Equation_2a:function(b,a,c){return this.solve2Equation_2b(b,a,c,0)},solve2Equation_2b:function(b,a,e,d){var c=b*b-4*a;if(c<0){return 0}if(c==0){e[d+0]=-b/(2);return 1}c=Math.sqrt(c);e[d+0]=(-b+c)/(2);e[d+1]=(-b-c)/(2);return 2},solve3Equation_4:function(c,b,a,e,d){NyAS3Utils.assert(c!=0);return this.solve3Equation_3(b/c,a/c,e/c,d)},solve3Equation_3:function(k,g,e,i){var f,m,d,c;m=k/(3);d=m*m-g/3;c=(m*(g-2*m*m)-e)/2;if((f=c*c-d*d*d)==0){c=NyARMath.cubeRoot(c);i[0]=2*c-m;i[1]=-c-m;return 2}else{if(f>0){var a=NyARMath.cubeRoot(c+((c>0)?1:-1)*Math.sqrt(f));var l=d/a;i[0]=a+l-m;return 1}else{f=2*Math.sqrt(d);var n=Math.acos(c/(d*f/2));i[0]=f*Math.cos(n/3)-m;i[1]=f*Math.cos((n+2*Math.PI)/3)-m;i[2]=f*Math.cos((n+4*Math.PI)/3)-m;return 3}}},solve4Equation:function(t,s,n,i,f,A){NyAS3Utils.assert(t!=0);var b,c,d,e,v;b=s/t;c=n/t;d=i/t;e=f/t;v=b/4;var z,y,x;var m=v*v;z=c-6*m;y=d+v*(-2*c+8*m);x=e+v*(-d+c*v)-3*m*m;if(y==0){var o,k;var C=this.solve2Equation_2b(z,x,A,0);switch(C){case 0:return 0;case 1:o=A[0];if(o<0){return 0}if(o==0){A[0]=0-v;return 1}o=Math.sqrt(o);A[0]=o-v;A[1]=-o-v;return 2;case 2:o=A[0];k=A[1];var g=0;if(o>0){o=Math.sqrt(o);A[0]=o-v;A[1]=-o-v;g+=2}if(k>0){k=Math.sqrt(k);A[g+0]=k-v;A[g+1]=-k-v;g+=2}return g;default:throw new NyARException()}}else{var w=this.solve3Equation_1((2*z),(-4*x)+(z*z),-y*y);if(w<0){return 0}var l=Math.sqrt(w);var B,a;B=this.solve2Equation_2b(-l,(z+w)/2+l*y/(2*w),A,0);switch(B){case 0:break;case 1:A[0]=A[0]-v;break;case 2:A[0]=A[0]-v;A[1]=A[1]-v;break;default:throw new NyARException()}a=this.solve2Equation_2b(l,(z+w)/2-l*y/(2*w),A,B);switch(a){case 0:break;case 1:A[B+0]=A[B+0]-v;break;case 2:A[B+0]=A[B+0]-v;A[B+1]=A[B+1]-v;break;default:throw new NyARException()}return B+a}},solve3Equation_1:function(i,g,e){var f,l,d,c;l=i/(3);d=l*l-g/3;c=(l*(g-2*l*l)-e)/2;if((f=c*c-d*d*d)==0){c=NyARMath.cubeRoot(c);return 2*c-l}else{if(f>0){var a=NyARMath.cubeRoot(c+((c>0)?1:-1)*Math.sqrt(f));var k=d/a;return a+k-l}else{f=2*Math.sqrt(d);var m=Math.acos(c/(d*f/2));return f*Math.cos(m/3)-l}}}});NyARPerspectiveParamGenerator_O1=Klass({_local_x:0,_local_y:0,_width:0,_height:0,initialize:function(b,a,d,c){this._height=c;this._width=d;this._local_x=b;this._local_y=a;return},getParam:function(X,v){var s=this._local_x;var r=this._local_y;var B=s+this._width;var z=r+this._height;var g;var m,l,ad,ab,K,H,p,n;var e,c,b,a,V,U,T,S,x,w,u,t,k,i,f,d;var R,Q,O,M,J,G;var ak,aj,ai,ah;var ag,af,ae,ac,aa,Z,Y,W;var P,N,L,I,E,D,A,y;ak=X[0].x;aj=X[1].x;ai=X[2].x;ah=X[3].x;m=-s*ak;l=-r*ak;ad=-B*aj;ab=-r*aj;K=-B*ai;H=-z*ai;p=-s*ah;n=-z*ah;R=K*n-H*p;M=H*s-B*n;J=B*p-K*s;Q=z*(H-n);O=z*(p-K);G=z*(B-s);V=-ad*M-ab*J-B*R;e=(ad*Q+ab*O)+r*R;x=(ab*G-B*Q)+r*M;k=(-B*O-ad*G)+r*J;R=p*l-n*m;Q=n*r-z*l;O=z*m-p*r;M=s*(n-l);J=s*(m-p);G=s*(r-z);c=-z*R-K*Q-H*O;U=(K*M+H*J)+B*R;w=(-H*G-z*M)+B*Q;i=(-z*J+K*G)+B*O;R=m*ab-l*ad;M=l*B-s*ab;J=s*ad-m*B;Q=r*(l-ab);O=r*(ad-m);G=r*(s-B);T=-p*M-n*J-s*R;b=(p*Q+n*O)+z*R;u=(n*G-s*Q)+z*M;f=(-s*O-p*G)+z*J;R=ad*H-ab*K;Q=ab*z-r*H;O=r*K-ad*z;M=B*(ab-H);J=B*(K-ad);G=B*(z-r);a=-r*R-m*Q-l*O;S=m*M+l*J+s*R;t=-l*G-r*M+s*Q;d=-r*J+m*G+s*O;g=(s*(e+a)+B*(c+b));if(g==0){g=0.0001}g=1/g;ag=(e*ak+c*aj+b*ai+a*ah)*g;af=(e+c+b+a)*g;ae=(V*ak+U*aj+T*ai+S*ah)*g;ac=(V+U+T+S)*g;aa=(x*ak+w*aj+u*ai+t*ah)*g;Z=(x+w+u+t)*g;Y=(k*ak+i*aj+f*ai+d*ah)*g;W=(k+i+f+d)*g;ak=X[0].y;aj=X[1].y;ai=X[2].y;ah=X[3].y;m=-s*ak;l=-r*ak;ad=-B*aj;ab=-r*aj;K=-B*ai;H=-z*ai;p=-s*ah;n=-z*ah;R=K*n-H*p;M=H*s-B*n;J=B*p-K*s;Q=z*(H-n);O=z*(p-K);G=z*(B-s);V=-ad*M-ab*J-B*R;e=(ad*Q+ab*O)+r*R;x=(ab*G-B*Q)+r*M;k=(-B*O-ad*G)+r*J;R=p*l-n*m;Q=n*r-z*l;O=z*m-p*r;M=s*(n-l);J=s*(m-p);G=s*(r-z);c=-z*R-K*Q-H*O;U=(K*M+H*J)+B*R;w=(-H*G-z*M)+B*Q;i=(-z*J+K*G)+B*O;R=m*ab-l*ad;M=l*B-s*ab;J=s*ad-m*B;Q=r*(l-ab);O=r*(ad-m);G=r*(s-B);T=-p*M-n*J-s*R;b=(p*Q+n*O)+z*R;u=(n*G-s*Q)+z*M;f=(-s*O-p*G)+z*J;R=ad*H-ab*K;Q=ab*z-r*H;O=r*K-ad*z;M=B*(ab-H);J=B*(K-ad);G=B*(z-r);a=-r*R-m*Q-l*O;S=m*M+l*J+s*R;t=-l*G-r*M+s*Q;d=-r*J+m*G+s*O;g=(s*(e+a)+B*(c+b));if(g==0){g=0.0001}g=1/g;P=(e*ak+c*aj+b*ai+a*ah)*g;N=(e+c+b+a)*g;L=(V*ak+U*aj+T*ai+S*ah)*g;I=(V+U+T+S)*g;E=(x*ak+w*aj+u*ai+t*ah)*g;D=(x+w+u+t)*g;A=(k*ak+i*aj+f*ai+d*ah)*g;y=(k+i+f+d)*g;g=Z*(-y)-(-D)*W;if(g==0){g=0.0001}g=1/g;var q,o;v[2]=q=(-y*g)*(aa-E)+(D*g)*(Y-A);v[5]=o=(-W*g)*(aa-E)+(Z*g)*(Y-A);v[6]=aa-q*Z;v[7]=Y-q*W;v[0]=ag-q*af;v[1]=ae-q*ac;v[3]=P-o*N;v[4]=L-o*I;return true}});NyIdMarkerParam=ASKlass("NyIdMarkerParam",{direction:0,threshold:0});NyIdMarkerPattern=ASKlass("NyIdMarkerPattern",{model:0,ctrl_domain:0,ctrl_mask:0,check:0,data:new IntVector(32)});TThreshold=ASKlass("TThreshold",{th_h:0,th_l:0,th:0,lt_x:0,lt_y:0,rb_x:0,rb_y:0});THighAndLow=ASKlass("THighAndLow",{h:0,l:0});_bit_table_3=new IntVector([25,26,27,28,29,30,31,48,9,10,11,12,13,32,47,24,1,2,3,14,33,46,23,8,0,4,15,34,45,22,7,6,5,16,35,44,21,20,19,18,17,36,43,42,41,40,39,38,37]);_bit_table_2=new IntVector([9,10,11,12,13,24,1,2,3,14,23,8,0,4,15,22,7,6,5,16,21,20,19,18,17]);MarkerPattEncoder=ASKlass("MarkerPattEncoder",{_bit_table_2:_bit_table_2,_bit_table_3:_bit_table_3,_bit_tables:[_bit_table_2,_bit_table_3,null,null,null,null,null],_bit_table:null,_bits:new IntVector(16),_work:new IntVector(16),_model:0,setBitByBitIndex:function(d,a){NyAS3Utils.assert(a==0||a==1);var b=this._bit_table[d];if(b==0){this._bits[0]=a}else{var c=toInt((b-1)/8)+1;var e=(b-1)%8;this._bits[c]=(this._bits[c]&(~(1<<e)))|(a<<e)}return},setBit:function(d,a){NyAS3Utils.assert(a==0||a==1);if(d==0){this._bits[0]=a}else{var b=toInt((d-1)/8)+1;var c=(d-1)%8;this._bits[b]=(this._bits[b]&(~(1<<c)))|(a<<c)}return},getBit:function(c){if(c==0){return this._bits[0]}else{var a=toInt((c-1)/8)+1;var b=(c-1)%8;return(this._bits[a]>>(b))&(1)}},getModel:function(){return this._model},getControlValue:function(c,a){var b;switch(c){case 2:b=(a[2]&14)>>1;return b>=5?b-1:b;case 3:b=(a[4]&62)>>1;return b>=21?b-1:b;case 4:case 5:case 6:case 7:default:break}return -1},getCheckValue:function(c,a){var b;switch(c){case 2:b=(a[2]&224)>>5;return b>5?b-1:b;case 3:b=((a[4]&128)>>7)|((a[5]&15)<<1);return b>21?b-1:b;case 4:case 5:case 6:case 7:default:break}return -1},initEncoder:function(a){if(a>3||a<2){return false}this._bit_table=this._bit_tables[a-2];this._model=a;return true},getDirection:function(){var d,e,f,a;var c;switch(this._model){case 2:e=this._bits[2]&31;f=((this._bits[2]&240)>>4)|((this._bits[3]&1)<<4);a=this._bits[3]&31;d=((this._bits[3]&240)>>4)|((this._bits[2]&1)<<4);c=10;break;case 3:e=this._bits[4]&127;f=((this._bits[4]&192)>>6)|((this._bits[5]&31)<<2);a=((this._bits[5]&240)>>4)|((this._bits[6]&7)<<4);d=((this._bits[6]&252)>>2)|((this._bits[4]&1)<<6);c=42;break;default:return -3}if(e==c){if(f==c){return(a!=c&&d!=c)?2:-2}else{if(d==c){return(a!=c&&f!=c)?3:-2}}}else{if(a==c){if(f==c){return(e!=c&&d!=c)?1:-2}else{if(d==c){return(e!=c&&f!=c)?0:-2}}}}return -1},encode:function(e){var c=this.getDirection();if(c<0){return -1}this.getRotatedBits(c,e.data);var b=this._model;e.model=b;var a=this.getControlValue(b,e.data);e.check=this.getCheckValue(b,e.data);e.ctrl_mask=a%5;e.ctrl_domain=toInt(a/5);if(e.ctrl_domain!=0||e.ctrl_mask!=0){return -1}return c},getRotatedBits:function(d,e){var a=d*2;var c=8-a;var b;e[0]=this._bits[0];b=this._bits[1];e[1]=((b<<a)|(b>>c))&255;a=d*4;c=16-a;b=this._bits[2]|(this._bits[3]<<8);b=(b<<a)|(b>>c);e[2]=b&255;e[3]=(b>>8)&255;if(this._model<2){return}a=d*6;c=24-a;b=this._bits[4]|(this._bits[5]<<8)|(this._bits[6]<<16);b=(b<<a)|(b>>c);e[4]=b&255;e[5]=(b>>8)&255;e[6]=(b>>16)&255;if(this._model<3){return}return},shiftLeft:function(g,e,b,k){var d;var a=this._work;var f=k%8;for(d=b-1;d>=1;d--){a[d]=(g[d+e]<<f)|(255&(g[d+e-1]>>(8-f)))}a[0]=(g[e]<<f)|(255&(g[e+b-1]>>(8-f)));var c=toInt(k/8)%b;for(d=b-1;d>=0;d--){g[(c+d)%b+e]=255&a[d]}return}});INyIdMarkerData=ASKlass("INyIdMarkerData",{isEqual:function(a){},copyFrom:function(a){}});NyIdMarkerPickup=ASKlass("NyIdMarkerPickup",{_perspective_reader:null,__pickFromRaster_th:new TThreshold(),__pickFromRaster_encoder:new MarkerPattEncoder(),NyIdMarkerPickup:function(){this._perspective_reader=new PerspectivePixelReader();return},init:function(){this._perspective_reader.newFrame()},pickFromRaster:function(c,e,b,k){if(!this._perspective_reader.setSourceSquare(e)){if(window.DEBUG){console.log("NyIdMarkerPickup.pickFromRaster: could not setSourceSquare")}return false}var g=c.getGrayPixelReader();var f=c.getSize();var a=this.__pickFromRaster_th;var l=this.__pickFromRaster_encoder;this._perspective_reader.detectThresholdValue(g,f,a);if(!this._perspective_reader.readDataBits(g,f,a,l)){if(window.DEBUG){console.log("NyIdMarkerPickup.pickFromRaster: could not readDataBits")}return false}var i=l.encode(b);if(i<0){if(window.DEBUG){console.log("NyIdMarkerPickup.pickFromRaster: could not encode")}return false}k.direction=i;k.threshold=a.th;return true}});PerspectivePixelReader=ASKlass("PerspectivePixelReader",{_param_gen:new NyARPerspectiveParamGenerator_O1(1,1,100,100),_cparam:new FloatVector(8),PerspectivePixelReader:function(){return},maxPreviousFrameAge:1,newFrame:function(){for(var b in this.previousFrames){var a=this.previousFrames[b];a.age++;if(a.age>this.maxPreviousFrameAge){delete this.previousFrames[b]}}},setSourceSquare:function(e){var a=0,f=0;for(var b=0;b<4;b++){a+=e[b].x;f+=e[b].y}a/=4;f/=4;var d=toInt(a/10);var c=toInt(f/10);this.centerPoint[0]=d;this.centerPoint[1]=c;return this._param_gen.getParam(e,this._cparam)},rectPixels:function(e,l,n,m,D,A,L,g,t,u){var a=this._cparam;var s=this._ref_x;var p=this._ref_y;var b=this._pixcel_temp;var K=l.w;var H=l.h;var B=t;var o=a[6];var w=a[0];var r=a[3];for(var C=0;C<g;C++){var J=1+C*A+m;var F=a[1]*J+a[2];var E=a[4]*J+a[5];var I=a[7]*J+1;var v=0;var z;for(z=0;z<L;z++){var q=1+z*D+n;var G=o*q+I;var k=toInt((w*q+F)/G);var f=toInt((r*q+E)/G);if(k<0||f<0||k>=K||f>=H){return false}s[v]=k;p[v]=f;v++}e.getPixelSet(s,p,L,b);for(z=0;z<L;z++){var c=z;u[B]=b[c];B++}}return true},checkFreqWidth:function(b,k){var g=b[1]-b[0];var e=k*2-1;for(var d=1;d<e;d++){var f=b[d+1]-b[d];var a=f*100/g;if(a>150||a<50){return false}g=f}return true},getMaxFreq:function(g,b,f){var d=-1;var a=0;var e;for(e=0;e<this.MAX_FREQ;e++){if(a<g[e]){d=e;a=g[e]}}if(d==-1){return -1}var c=(d-1)*d;for(e=0;e<d*2;e++){f[e]=b[c+e]*this.FRQ_STEP/a}return d},FRQ_EDGE:10,FRQ_STEP:2,FRQ_POINTS:(100-(5*2))/2,MIN_FREQ:3,MAX_FREQ:10,FREQ_SAMPLE_NUM:4,MAX_DATA_BITS:10+10-1,_ref_x:new IntVector(108),_ref_y:new IntVector(108),_pixcel_temp:new IntVector(108),_freq_count_table:new IntVector(10),_freq_table:new IntVector((10*2-1)*10*2/2),getRowFrequency:function(k,p,l,m,g,z){var E;var w=this._freq_count_table;var a=this._freq_table;var b=this._cparam;var v=this._ref_x;var s=this._ref_y;var f=this._pixcel_temp;for(E=0;E<10;E++){w[E]=0}for(E=0;E<110;E++){a[E]=0}var L=p.w;var I=p.h;var B=b[0];var u=b[3];var q=b[6];var c;if(window.DEBUG){c=document.getElementById("debugCanvas").getContext("2d");c.fillStyle="orange"}for(E=0;E<this.FREQ_SAMPLE_NUM;E++){var C;var K=1+l+E;var G=b[1]*K+b[2];var F=b[4]*K+b[5];var J=b[7]*K+1;var A=0;for(C=0;C<this.FRQ_POINTS;C++){var t=1+C*this.FRQ_STEP+this.FRQ_EDGE;var H=(q*t)+J;var o=toInt((B*t+G)/H);var n=toInt((u*t+F)/H);if(o<0||n<0||o>=L||n>=I){return -1}v[A]=o;s[A]=n;A++}k.getPixelSet(v,s,this.FRQ_POINTS,f);if(window.DEBUG){for(var D=0;D<this.FRQ_POINTS;D++){c.fillRect(v[D],s[D],1,1)}}var e=this.getFreqInfo(f,m,g,z);if(e<this.MIN_FREQ||e>this.MAX_FREQ){continue}if(!this.checkFreqWidth(z,e)){continue}w[e]++;var r=(e-1)*e;for(C=0;C<e*2;C++){a[r+C]+=z[C]}}return this.getMaxFreq(w,a,z)},getColFrequency:function(l,p,L,m,k,A){var F;var c=this._cparam;var v=this._ref_x;var s=this._ref_y;var g=this._pixcel_temp;var w=this._freq_count_table;for(F=0;F<10;F++){w[F]=0}var b=this._freq_table;for(F=0;F<110;F++){b[F]=0}var K=p.w;var H=p.h;var r=c[7];var z=c[4];var D=c[1];var e;if(window.DEBUG){e=document.getElementById("debugCanvas").getContext("2d");e.fillStyle="green"}for(F=0;F<this.FREQ_SAMPLE_NUM;F++){var C;var u=1+F+L;var J=c[6]*u;var I=c[0]*u+c[2];var t=c[3]*u+c[5];var B=0;for(C=0;C<this.FRQ_POINTS;C++){var a=1+C*this.FRQ_STEP+this.FRQ_EDGE;var G=J+r*a+1;var o=toInt((I+D*a)/G);var n=toInt((t+z*a)/G);if(o<0||n<0||o>=K||n>=H){return -1}v[B]=o;s[B]=n;B++}l.getPixelSet(v,s,this.FRQ_POINTS,g);if(window.DEBUG){for(var E=0;E<this.FRQ_POINTS;E++){e.fillRect(v[E],s[E],1,1)}}var f=this.getFreqInfo(g,m,k,A);if(f<this.MIN_FREQ||f>this.MAX_FREQ){continue}if(!this.checkFreqWidth(A,f)){continue}w[f]++;var q=(f-1)*f;for(C=0;C<f*2;C++){b[q+C]+=A[C]}}return this.getMaxFreq(w,b,A)},getFreqInfo:function(e,l,f,a){var d=0;var c=0;var b=0;var g,k;while(d<this.FRQ_POINTS){while(d<this.FRQ_POINTS){g=d;k=e[g];if(k>l){a[c+b]=d;c++;break}d++}d++;while(d<this.FRQ_POINTS){g=d;k=e[g];if(k<=f){a[c+b]=d;b++;break}d++}d++}return c==b?c:-1},THRESHOLD_EDGE:10,THRESHOLD_STEP:2,THRESHOLD_WIDTH:10,THRESHOLD_PIXEL:10/2,THRESHOLD_SAMPLE:5*5,THRESHOLD_SAMPLE_LT:10,THRESHOLD_SAMPLE_RB:100-10-10,getPtailHighAndLow:function(f,g){var l,m,n,o,a,b,c,d;l=m=n=o=a=b=c=d=f[0];for(var e=f.length-1;e>=1;e--){var k=f[e];if(o<k){if(n<k){if(m<k){if(l<k){o=n;n=m;m=l;l=k}else{o=n;n=m;m=k}}else{o=n;n=k}}else{o=k}}if(d>k){if(c>k){if(b>k){if(a>k){d=c;c=b;b=a;a=k}else{d=c;c=b;b=k}}else{d=c;c=k}}else{d=k}}}g.l=(d+c+b+a)/4;g.h=(o+n+m+l)/4;return},__detectThresholdValue_hl:new THighAndLow(),__detectThresholdValue_tpt:new NyARIntPoint2d(),_th_pixels:new IntVector(5*5*4),detectThresholdValue:function(i,r,k){var l=this._th_pixels;this.rectPixels(i,r,this.THRESHOLD_SAMPLE_LT,this.THRESHOLD_SAMPLE_LT,this.THRESHOLD_STEP,this.THRESHOLD_STEP,this.THRESHOLD_PIXEL,this.THRESHOLD_PIXEL,0,l);this.rectPixels(i,r,this.THRESHOLD_SAMPLE_LT,this.THRESHOLD_SAMPLE_RB,this.THRESHOLD_STEP,this.THRESHOLD_STEP,this.THRESHOLD_PIXEL,this.THRESHOLD_PIXEL,this.THRESHOLD_SAMPLE,l);this.rectPixels(i,r,this.THRESHOLD_SAMPLE_RB,this.THRESHOLD_SAMPLE_LT,this.THRESHOLD_STEP,this.THRESHOLD_STEP,this.THRESHOLD_PIXEL,this.THRESHOLD_PIXEL,this.THRESHOLD_SAMPLE*2,l);this.rectPixels(i,r,this.THRESHOLD_SAMPLE_RB,this.THRESHOLD_SAMPLE_RB,this.THRESHOLD_STEP,this.THRESHOLD_STEP,this.THRESHOLD_PIXEL,this.THRESHOLD_PIXEL,this.THRESHOLD_SAMPLE*3,l);var b=this.__detectThresholdValue_hl;this.getPtailHighAndLow(l,b);var a=(b.h+b.l)/2;var n=(b.h-b.l)/5;k.th=a;k.th_h=a+n;k.th_l=a-n;var o,m,q,p,e,c,g,f;var d=this.__detectThresholdValue_tpt;if(this.getHighPixelCenter(0,l,this.THRESHOLD_PIXEL,this.THRESHOLD_PIXEL,a,d)){o=d.x*this.THRESHOLD_STEP;m=d.y*this.THRESHOLD_STEP}else{o=11;m=11}if(this.getHighPixelCenter(this.THRESHOLD_SAMPLE*1,l,this.THRESHOLD_PIXEL,this.THRESHOLD_PIXEL,a,d)){q=d.x*this.THRESHOLD_STEP;p=d.y*this.THRESHOLD_STEP}else{q=11;p=-1}if(this.getHighPixelCenter(this.THRESHOLD_SAMPLE*2,l,this.THRESHOLD_PIXEL,this.THRESHOLD_PIXEL,a,d)){e=d.x*this.THRESHOLD_STEP;c=d.y*this.THRESHOLD_STEP}else{e=-1;c=11}if(this.getHighPixelCenter(this.THRESHOLD_SAMPLE*3,l,this.THRESHOLD_PIXEL,this.THRESHOLD_PIXEL,a,d)){g=d.x*this.THRESHOLD_STEP;f=d.y*this.THRESHOLD_STEP}else{g=-1;f=-1}k.lt_x=(o+q)/2+this.THRESHOLD_SAMPLE_LT-1;k.rb_x=(e+g)/2+this.THRESHOLD_SAMPLE_RB+1;k.lt_y=(m+c)/2+this.THRESHOLD_SAMPLE_LT-1;k.rb_y=(p+f)/2+this.THRESHOLD_SAMPLE_RB+1;return},getHighPixelCenter:function(d,b,c,l,g,e){var m=d;var a=0;var o=0;var n=0;for(var k=0;k<l;k++){for(var f=0;f<c;f++){if(b[m++]>g){a+=f;o+=k;n++}}}if(n>0){a/=n;o/=n}else{return false}e.x=a;e.y=o;return true},__detectDataBitsIndex_freq_index1:new IntVector((100-(5*2))/2),__detectDataBitsIndex_freq_index2:new IntVector((100-(5*2))/2),detectDataBitsIndex:function(d,n,q,o,f){var u;var p=this.__detectDataBitsIndex_freq_index1;var l=this.__detectDataBitsIndex_freq_index2;var g=q.rb_y-q.lt_y;var b=this.getRowFrequency(d,n,q.lt_y,q.th_h,q.th_l,p);var t=this.getRowFrequency(d,n,q.rb_y,q.th_h,q.th_l,l);if((b<0&&t<0)||b==t){if(window.DEBUG){console.log("bad row frq",b,t)}return -1}var s,a;var c;if(b>t){s=b;c=p}else{s=t;c=l}for(u=0;u<s+s-1;u++){o[u*2]=((c[u+1]-c[u])*2/5+c[u])+this.FRQ_EDGE;o[u*2+1]=((c[u+1]-c[u])*3/5+c[u])+this.FRQ_EDGE}var v=q.rb_x-q.lt_x;var r=this.getColFrequency(d,n,q.lt_x,q.th_h,q.th_l,p);var e=this.getColFrequency(d,n,q.rb_x,q.th_h,q.th_l,l);if((r<0&&e<0)||r==e){if(window.DEBUG){console.log("bad col frq",r,e)}return -1}if(r>e){a=r;c=p}else{a=e;c=l}if(a!=s){if(window.DEBUG){console.log("freq mismatch",a,s)}return -1}for(u=0;u<a+a-1;u++){var m=c[u];var k=c[u+1]-m;f[u*2]=((k)*2/5+m)+this.FRQ_EDGE;f[u*2+1]=((k)*3/5+m)+this.FRQ_EDGE}if(a>this.MAX_FREQ){if(window.DEBUG){console.log("too high freq",a)}return -1}return a},__readDataBits_index_bit_x:new FloatVector(19*2),__readDataBits_index_bit_y:new FloatVector(19*2),previousFrames:{},centerPoint:new IntVector(2),getPreviousFrameSize:function(e,d){var b=this.centerPoint[0],f=this.centerPoint[1];var c=this.previousFrames;var a=(c[b+":"+f]||c[(b-1)+":"+f]||c[(b+1)+":"+f]||c[b+":"+(f-1)]||c[(b-1)+":"+(f-1)]||c[(b+1)+":"+(f-1)]||c[b+":"+(f+1)]||c[(b-1)+":"+(f+1)]||c[(b+1)+":"+(f+1)]);if(!a){return -1}e.set(a.index_x);d.set(a.index_y);return a.size},setPreviousFrameSize:function(b,d,c){var a=this.previousFrames[this.centerPoint[0]+":"+this.centerPoint[1]];if(!a){a={age:0,size:b,index_x:new FloatVector(d),index_y:new FloatVector(c)};this.previousFrames[this.centerPoint[0]+":"+this.centerPoint[1]]=a;return}a.age=0;a.size=b;a.index_x.set(d);a.index_y.set(c)},readDataBits:function(G,a,k,O){var R=this.__readDataBits_index_bit_x;var Q=this.__readDataBits_index_bit_y;var l=this.detectDataBitsIndex(G,a,k,R,Q);if(l<0){l=this.getPreviousFrameSize(R,Q)}var I=l+l-1;if(l<0){if(window.DEBUG){console.log("readDataBits: size < 0")}return false}if(!O.initEncoder(l-1)){if(window.DEBUG){console.log("readDataBits: initEncoder")}return false}var t=this._cparam;var n=this._ref_x;var m=this._ref_y;var H=this._pixcel_temp;var C=t[0];var B=t[1];var z=t[3];var v=t[6];var b=k.th;var J=0;for(var N=0;N<I;N++){var o;var A=1+Q[N*2+0];var y=1+Q[N*2+1];var g=B*A+t[2];var e=t[4]*A+t[5];var S=t[7]*A+1;var x=B*y+t[2];var w=t[4]*y+t[5];var L=t[7]*y+1;var q=0;for(o=0;o<I;o++){var P;var M=1+R[o*2+0];var K=1+R[o*2+1];var f=v*M;var F=C*M;var s=z*M;var c=v*K;var E=C*K;var r=z*K;P=f+S;n[q]=toInt((F+g)/P);m[q]=toInt((s+e)/P);q++;P=f+L;n[q]=toInt((F+x)/P);m[q]=toInt((s+w)/P);q++;P=c+S;n[q]=toInt((E+g)/P);m[q]=toInt((r+e)/P);q++;P=c+L;n[q]=toInt((E+x)/P);m[q]=toInt((r+w)/P);q++}G.getPixelSet(n,m,I*4,H);for(o=0;o<I;o++){var D=o*4;var u=(H[D+0]+H[D+1]+H[D+2]+H[D+3])/(4);O.setBitByBitIndex(J,u>b?0:1);J++}}this.setPreviousFrameSize(l,R,Q);return true},setSquare:function(a){if(!this._param_gen.getParam(a,this._cparam)){return false}return true}});MarkerPattDecoder=ASKlass("MarkerPattDecoder",{decode:function(b,c,a){}});INyIdMarkerDataEncoder=ASKlass("INyIdMarkerDataEncoder",{encode:function(a,b){},createDataInstance:function(){}});NyIdMarkerDataEncoder_RawBit=ASKlass("NyIdMarkerDataEncoder_RawBit",INyIdMarkerDataEncoder,{_DOMAIN_ID:0,_mod_data:new IntVector([7,31,127,511,2047,4095]),encode:function(a,b){var c=(b);if(a.ctrl_domain!=this._DOMAIN_ID){return false}var g=(a.model*2-1);var e=(((g*g))/8)+1;var f=0;for(var d=0;d<e;d++){c.packet[d]=a.data[d];f+=a.data[d]}f=f%this._mod_data[a.model-2];if(a.check!=f){return false}c.length=e;return true},createDataInstance:function(){return new NyIdMarkerData_RawBit()}});NyIdMarkerData_RawBit=ASKlass("NyIdMarkerData_RawBit",INyIdMarkerData,{packet:new IntVector(22),length:0,isEqual:function(c){var b=(c);if(b.length!=this.length){return false}for(var a=b.length-1;a>=0;a--){if(b.packet[a]!=this.packet[a]){return false}}return true},copyFrom:function(b){var a=(b);ArrayUtils.copyInt(a.packet,0,this.packet,0,a.length);this.length=a.length;return}});INyARColorPatt=ASKlass("INyARColorPatt",INyARRgbRaster,{pickFromRaster:function(b,a){}});NyARColorPatt_Perspective=ASKlass("NyARColorPatt_Perspective",INyARColorPatt,{_patdata:null,_pickup_lt:new NyARIntPoint2d(),_resolution:0,_size:null,_perspective_gen:null,_pixelreader:null,LOCAL_LT:1,BUFFER_FORMAT:NyARBufferType.INT1D_X8R8G8B8_32,initializeInstance:function(c,b,a){NyAS3Utils.assert(c>2&&b>2);this._resolution=a;this._size=new NyARIntSize(c,b);this._patdata=new IntVector(b*c);this._pixelreader=new NyARRgbPixelReader_INT1D_X8R8G8B8_32(this._patdata,this._size);return},NyARColorPatt_Perspective:function(d,c,b,a){if(a==null){a=-1}if(a==-1){this.initializeInstance(d,c,b);this.setEdgeSize(0,0,b)}else{this.initializeInstance(d,c,b);this.setEdgeSizeByPercent(a,a,b)}return},setEdgeSize:function(c,b,a){NyAS3Utils.assert(c>=0);NyAS3Utils.assert(b>=0);this._perspective_gen=new NyARPerspectiveParamGenerator_O1(this.LOCAL_LT,this.LOCAL_LT,(c*2+this._size.w)*a,(b*2+this._size.h)*a);this._pickup_lt.x=c*a+this.LOCAL_LT;this._pickup_lt.y=b*a+this.LOCAL_LT;return},setEdgeSizeByPercent:function(c,b,a){NyAS3Utils.assert(c>=0);NyAS3Utils.assert(b>=0);this.setEdgeSize(this._size.w*c/50,this._size.h*b/50,a);return},getWidth:function(){return this._size.w},getHeight:function(){return this._size.h},getSize:function(){return this._size},getRgbPixelReader:function(){return this._pixelreader},getBuffer:function(){return this._patdata},hasBuffer:function(){return this._patdata!=null},wrapBuffer:function(a){NyARException.notImplement()},getBufferType:function(){return this.BUFFER_FORMAT},isEqualBufferType:function(a){return this.BUFFER_FORMAT==a},__pickFromRaster_rgb_tmp:new IntVector(3),__pickFromRaster_cpara:new FloatVector(8),pickFromRaster:function(u,c){var i=this.__pickFromRaster_cpara;if(!this._perspective_gen.getParam(c,i)){return false}var w=this._resolution;var B=u.getWidth();var A=u.getHeight();var z=w*w;var m=this.__pickFromRaster_rgb_tmp;var a=u.getRgbPixelReader();var v=0;for(var k=0;k<this._size.h*w;k+=w){for(var l=0;l<this._size.w*w;l+=w){var t,C,E;t=C=E=0;for(var q=k;q<k+w;q++){var e=this._pickup_lt.y+q;for(var s=l;s<l+w;s++){var f=this._pickup_lt.x+s;var D=i[6]*f+i[7]*e+1;var o=toInt((i[0]*f+i[1]*e+i[2])/D);var n=toInt((i[3]*f+i[4]*e+i[5])/D);if(o<0){o=0}if(o>=B){o=B-1}if(n<0){n=0}if(n>=A){n=A-1}a.getPixel(o,n,m);t+=m[0];C+=m[1];E+=m[2]}}t/=z;C/=z;E/=z;this._patdata[v]=((t&255)<<16)|((C&255)<<8)|((E&255));v++}}return true}});NyARColorPatt_Perspective_O2=ASKlass("NyARColorPatt_Perspective_O2",NyARColorPatt_Perspective,{_pickup:null,NyARColorPatt_Perspective_O2:function(d,c,b,a){NyARColorPatt_Perspective.initialize.call(this,d,c,b,a);switch(b){case 1:this._pickup=new NyARPickFromRaster_1(this._pickup_lt,this._size);break;case 2:this._pickup=new NyARPickFromRaster_2x(this._pickup_lt,this._size);break;case 4:this._pickup=new NyARPickFromRaster_4x(this._pickup_lt,this._size);break;default:this._pickup=new NyARPickFromRaster_N(this._pickup_lt,b,this._size)}return},pickFromRaster:function(c,b){var a=this.__pickFromRaster_cpara;if(!this._perspective_gen.getParam(b,a)){return false}this._pickup.pickFromRaster(a,c,this._patdata);return true}});IpickFromRaster_Impl=ASKlass("IpickFromRaster_Impl",{pickFromRaster:function(a,c,b){}});NyARPickFromRaster_1=ASKlass("NyARPickFromRaster_1",IpickFromRaster_Impl,{_size_ref:null,_lt_ref:null,NyARPickFromRaster_1:function(b,a){this._lt_ref=b;this._size_ref=a;this._rgb_temp=new IntVector(a.w*3);this._rgb_px=new IntVector(a.w);this._rgb_py=new IntVector(a.w);return},_rgb_temp:null,_rgb_px:null,_rgb_py:null,pickFromRaster:function(s,v,w){var a,c;var r,q;var E=v.getWidth();var C=v.getHeight();var G=this._size_ref.w;var m=this._rgb_temp;var n=this._rgb_px;var l=this._rgb_py;var I=s[0];var F=s[3];var B=s[6];var H=s[1];var D=s[4];var A=s[7];var i=this._lt_ref.y;var k=this._lt_ref.x;var b=v.getRgbPixelReader();var z=0;var J,o;var d=H*i+s[2]+I*k;var f=D*i+s[5]+F*k;var t=A*i+1+B*k;for(var e=this._size_ref.h-1;e>=0;e--){c=1/(t);a=-B/(t*(t+B));J=d;o=f;var g;for(g=G-1;g>=0;g--){r=n[g]=toInt(J*c);q=l[g]=toInt(o*c);if(r<0||r>=E||q<0||q>=C){if(r<0){n[g]=0}else{if(r>=E){n[g]=E-1}}if(q<0){l[g]=0}else{if(q>=C){l[g]=C-1}}}J+=I;o+=F;c+=a}d+=H;f+=D;t+=A;b.getPixelSet(n,l,G,m);for(g=G-1;g>=0;g--){var u=g*3;w[z]=(m[u]<<16)|(m[u+1]<<8)|((m[u+2]&255));z++}}return}});NyARPickFromRaster_2x=ASKlass("NyARPickFromRaster_2x",IpickFromRaster_Impl,{_size_ref:null,_lt_ref:null,NyARPickFromRaster_2x:function(b,a){this._lt_ref=b;this._size_ref=a;this._rgb_temp=new IntVector(a.w*4*3);this._rgb_px=new IntVector(a.w*4);this._rgb_py=new IntVector(a.w*4);return},_rgb_temp:null,_rgb_px:null,_rgb_py:null,pickFromRaster:function(K,k,aa){var T,Y,S,X;var M,L;var P=k.getWidth();var O=k.getHeight();var o=this._size_ref.w;var A=this._rgb_temp;var i=this._rgb_px;var e=this._rgb_py;var F=K[0];var B=K[3];var w=K[6];var E=K[1];var z=K[4];var v=K[7];var d=this._lt_ref.y;var f=this._lt_ref.x;var u=k.getRgbPixelReader();var Q=0;var c,t;var J=E*d+K[2]+F*f;var W=z*d+K[5]+B*f;var H=v*d+1+w*f;var a,s;var I=J+E;var U=W+z;var G=H+v;var q=E+E;var l=v+v;var m=z+z;for(var C=this._size_ref.h-1;C>=0;C--){c=J;t=W;a=I;s=U;Y=1/(H);T=-w/(H*(H+w));X=1/(G);S=-w/(G*(G+w));var R=o*2*2-1;var D;for(D=o*2-1;D>=0;D--){M=i[R]=toInt(c*Y);L=e[R]=toInt(t*Y);if(M<0||M>=P||L<0||L>=O){if(M<0){i[R]=0}else{if(M>=P){i[R]=P-1}}if(L<0){e[R]=0}else{if(L>=O){e[R]=O-1}}}c+=F;t+=B;Y+=T;R--;M=i[R]=toInt(a*X);L=e[R]=toInt(s*X);if(M<0||M>=P||L<0||L>=O){if(M<0){i[R]=0}else{if(M>=P){i[R]=P-1}}if(L<0){e[R]=0}else{if(L>=O){e[R]=O-1}}}a+=F;s+=B;X+=S;R--}H+=l;G+=l;J+=q;W+=m;I+=q;U+=m;u.getPixelSet(i,e,o*4,A);for(D=o-1;D>=0;D--){var Z=D*12;var N=(A[Z+0]+A[Z+3]+A[Z+6]+A[Z+9])/4;var V=(A[Z+1]+A[Z+4]+A[Z+7]+A[Z+10])/4;var ab=(A[Z+2]+A[Z+5]+A[Z+8]+A[Z+11])/4;aa[Q]=(N<<16)|(V<<8)|((ab&255));Q++}}return}});NyARPickFromRaster_4x=ASKlass("NyARPickFromRaster_4x",IpickFromRaster_Impl,{_size_ref:null,_lt_ref:null,NyARPickFromRaster_4x:function(b,a){this._lt_ref=b;this._size_ref=a;this._rgb_temp=new IntVector(4*4*3);this._rgb_px=new IntVector(4*4);this._rgb_py=new IntVector(4*4);return},_rgb_temp:null,_rgb_px:null,_rgb_py:null,pickFromRaster:function(I,o,X){var K,J;var W,Q;var l,L,v;var n=this._rgb_px;var i=this._rgb_py;var M,S,Z;var O=o.getWidth();var N=o.getHeight();var B=this._rgb_temp;var H=I[0];var C=I[3];var w=I[6];var G=I[1];var D=I[2];var A=I[4];var z=I[5];var u=I[7];var k=this._lt_ref.x;var t=o.getRgbPixelReader();var P=0;var q=this._lt_ref.y;for(var E=this._size_ref.h-1;E>=0;E--,q+=4){var f=G*q+D;var Y=A*q+z;var R=u*q+1;var e=f+G;var c=e+G;var a=c+G;var V=Y+A;var U=V+A;var T=U+A;var s=k;for(var F=this._size_ref.w-1;F>=0;F--,s+=4){l=w*s;L=H*s;v=C*s;l+=R;Q=1/l;W=-u/((l+u)*l);K=n[0]=toInt((L+f)*Q);J=i[0]=toInt((v+Y)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[0]=0}else{if(K>=O){n[0]=O-1}}if(J<0){i[0]=0}else{if(J>=N){i[0]=N-1}}}Q+=W;K=n[4]=toInt((L+e)*Q);J=i[4]=toInt((v+V)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[4]=0}else{if(K>=O){n[4]=O-1}}if(J<0){i[4]=0}else{if(J>=N){i[4]=N-1}}}Q+=W;K=n[8]=toInt((L+c)*Q);J=i[8]=toInt((v+U)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[8]=0}else{if(K>=O){n[8]=O-1}}if(J<0){i[8]=0}else{if(J>=N){i[8]=N-1}}}Q+=W;K=n[12]=toInt((L+a)*Q);J=i[12]=toInt((v+T)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[12]=0}else{if(K>=O){n[12]=O-1}}if(J<0){i[12]=0}else{if(J>=N){i[12]=N-1}}}l+=w;L+=H;v+=C;Q=1/l;W=-u/((l+u)*l);K=n[1]=toInt((L+f)*Q);J=i[1]=toInt((v+Y)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[1]=0}else{if(K>=O){n[1]=O-1}}if(J<0){i[1]=0}else{if(J>=N){i[1]=N-1}}}Q+=W;K=n[5]=toInt((L+e)*Q);J=i[5]=toInt((v+V)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[5]=0}else{if(K>=O){n[5]=O-1}}if(J<0){i[5]=0}else{if(J>=N){i[5]=N-1}}}Q+=W;K=n[9]=toInt((L+c)*Q);J=i[9]=toInt((v+U)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[9]=0}else{if(K>=O){n[9]=O-1}}if(J<0){i[9]=0}else{if(J>=N){i[9]=N-1}}}Q+=W;K=n[13]=toInt((L+a)*Q);J=i[13]=toInt((v+T)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[13]=0}else{if(K>=O){n[13]=O-1}}if(J<0){i[13]=0}else{if(J>=N){i[13]=N-1}}}l+=w;L+=H;v+=C;Q=1/l;W=-u/((l+u)*l);K=n[2]=toInt((L+f)*Q);J=i[2]=toInt((v+Y)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[2]=0}else{if(K>=O){n[2]=O-1}}if(J<0){i[2]=0}else{if(J>=N){i[2]=N-1}}}Q+=W;K=n[6]=toInt((L+e)*Q);J=i[6]=toInt((v+V)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[6]=0}else{if(K>=O){n[6]=O-1}}if(J<0){i[6]=0}else{if(J>=N){i[6]=N-1}}}Q+=W;K=n[10]=toInt((L+c)*Q);J=i[10]=toInt((v+U)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[10]=0}else{if(K>=O){n[10]=O-1}}if(J<0){i[10]=0}else{if(J>=N){i[10]=N-1}}}Q+=W;K=n[14]=toInt((L+a)*Q);J=i[14]=toInt((v+T)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[14]=0}else{if(K>=O){n[14]=O-1}}if(J<0){i[14]=0}else{if(J>=N){i[14]=N-1}}}l+=w;L+=H;v+=C;Q=1/l;W=-u/((l+u)*l);K=n[3]=toInt((L+f)*Q);J=i[3]=toInt((v+Y)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[3]=0}else{if(K>=O){n[3]=O-1}}if(J<0){i[3]=0}else{if(J>=N){i[3]=N-1}}}Q+=W;K=n[7]=toInt((L+e)*Q);J=i[7]=toInt((v+V)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[7]=0}else{if(K>=O){n[7]=O-1}}if(J<0){i[7]=0}else{if(J>=N){i[7]=N-1}}}Q+=W;K=n[11]=toInt((L+c)*Q);J=i[11]=toInt((v+U)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[11]=0}else{if(K>=O){n[11]=O-1}}if(J<0){i[11]=0}else{if(J>=N){i[11]=N-1}}}Q+=W;K=n[15]=toInt((L+a)*Q);J=i[15]=toInt((v+T)*Q);if(K<0||K>=O||J<0||J>=N){if(K<0){n[15]=0}else{if(K>=O){n[15]=O-1}}if(J<0){i[15]=0}else{if(J>=N){i[15]=N-1}}}t.getPixelSet(n,i,4*4,B);M=(B[0]+B[3]+B[6]+B[9]+B[12]+B[15]+B[18]+B[21]+B[24]+B[27]+B[30]+B[33]+B[36]+B[39]+B[42]+B[45])/16;S=(B[1]+B[4]+B[7]+B[10]+B[13]+B[16]+B[19]+B[22]+B[25]+B[28]+B[31]+B[34]+B[37]+B[40]+B[43]+B[46])/16;Z=(B[2]+B[5]+B[8]+B[11]+B[14]+B[17]+B[20]+B[23]+B[26]+B[29]+B[32]+B[35]+B[38]+B[41]+B[44]+B[47])/16;X[P]=((M&255)<<16)|((S&255)<<8)|((Z&255));P++}}return}});NyARPickFromRaster_N=ASKlass("NyARPickFromRaster_N",IpickFromRaster_Impl,{_resolution:0,_size_ref:null,_lt_ref:null,NyARPickFromRaster_N:function(c,b,a){this._lt_ref=c;this._resolution=b;this._size_ref=a;this._rgb_temp=new IntVector(b*b*3);this._rgb_px=new IntVector(b*b);this._rgb_py=new IntVector(b*b);this._cp1cy_cp2=new FloatVector(b);this._cp4cy_cp5=new FloatVector(b);this._cp7cy_1=new FloatVector(b);return},_rgb_temp:null,_rgb_px:null,_rgb_py:null,_cp1cy_cp2:null,_cp4cy_cp5:null,_cp7cy_1:null,pickFromRaster:function(M,l,af){var s,q;var O,N;var P;var S,ad,ag;var R=this._resolution;var C=R*R;var U=l.getWidth();var T=l.getHeight();var D=this._rgb_temp;var k=this._rgb_px;var c=this._rgb_py;var L=this._cp1cy_cp2;var K=this._cp4cy_cp5;var o=this._cp7cy_1;var J=M[0];var E=M[3];var z=M[6];var H=M[1];var F=M[2];var B=M[4];var A=M[5];var v=M[7];var a=this._lt_ref.y;var e=this._lt_ref.x;var t=l.getRgbPixelReader();var V=0;for(var G=0;G<this._size_ref.h*R;G+=R){P=a+G;L[0]=H*P+F;K[0]=B*P+A;o[0]=v*P+1;for(q=1;q<R;q++){L[q]=L[q-1]+H;K[q]=K[q-1]+B;o[q]=o[q-1]+v}for(var I=0;I<this._size_ref.w*R;I+=R){var Y=0;P=e+I;for(q=R-1;q>=0;q--){var Q=J*P+L[q];var f=z*P+o[q];var u=E*P+K[q];var Z=1/(f);var ae=-z/(f*(f+z));var ac=Q*Z;var ab=u*Z;var X=Q*ae+J*(Z+ae);var W=u*ae+E*(Z+ae);for(s=R-1;s>=0;s--){O=k[Y]=toInt(ac);N=c[Y]=toInt(ab);if(O<0||O>=U||N<0||N>=T){if(O<0){k[Y]=0}else{if(O>=U){k[Y]=U-1}}if(N<0){c[Y]=0}else{if(N>=T){c[Y]=T-1}}}Y++;ac+=X;ab+=W}}t.getPixelSet(k,c,C,D);S=ad=ag=0;for(var aa=C*3-1;aa>0;){ag+=D[aa--];ad+=D[aa--];S+=D[aa--]}S/=C;ad/=C;ag/=C;af[V]=((S&255)<<16)|((ad&255)<<8)|((ag&255));V++}}return}});FLSingleARMarkerProcesser=ASKlass("FLSingleARMarkerProcesser",{tag:null,_lost_delay_count:0,_lost_delay:5,_square_detect:null,_transmat:null,_offset:null,_threshold:110,_bin_raster:null,_tobin_filter:null,_current_arcode_index:-1,_threshold_detect:null,FLSingleARMarkerProcesser:function(){return},_initialized:false,initInstance:function(a){NyAS3Utils.assert(this._initialized==false);var b=a.getScreenSize();this._square_detect=new FLARSquareContourDetector(b);this._transmat=new NyARTransMat(a);this._tobin_filter=new FLARRasterFilter_Threshold(110);this._bin_raster=new FLARBinRaster(b.w,b.h);this._threshold_detect=new FLARRasterThresholdAnalyzer_SlidePTile(15,4);this._initialized=true;this._detectmarker_cb=new FLARDetectSquareCB_1(a);this._offset=new NyARRectOffset();return},setARCodeTable:function(c,b,a){if(this._current_arcode_index!=-1){this.reset(true)}this._detectmarker_cb.setNyARCodeTable(c,b);this._offset.setSquare(a);return},reset:function(a){if(this._current_arcode_index!=-1&&a==false){this.onLeaveHandler()}this._current_arcode_index=-1;return},_detectmarker_cb:null,detectMarker:function(a){NyAS3Utils.assert(this._bin_raster.getSize().isEqualSize_int(a.getSize().w,a.getSize().h));this._tobin_filter.setThreshold(this._threshold);this._tobin_filter.doFilter(a,this._bin_raster);this._detectmarker_cb.init(a,this._current_arcode_index);this._square_detect.detectMarkerCB(this._bin_raster,this._detectmarker_cb);var c=updateStatus(this._detectmarker_cb.square,this._detectmarker_cb.code_index);if(!c){var b=this._threshold_detect.analyzeRaster(a);this._threshold=(this._threshold+b)/2}return},setConfidenceThreshold:function(b,a){this._detectmarker_cb.cf_threshold_exist=a;this._detectmarker_cb.cf_threshold_new=b},__NyARSquare_result:new FLARTransMatResult(),updateStatus:function(b,c){var a=this.__NyARSquare_result;if(this._current_arcode_index<0){if(c<0){return false}else{this._current_arcode_index=c;this.onEnterHandler(c);this._transmat.transMat(b,this._offset,a);this.onUpdateHandler(b,a);this._lost_delay_count=0;return true}}else{if(c<0){this._lost_delay_count++;if(this._lost_delay<this._lost_delay_count){this._current_arcode_index=-1;this.onLeaveHandler()}return false}else{if(c==this._current_arcode_index){this._transmat.transMat(b,this._offset,a);this.onUpdateHandler(b,a);this._lost_delay_count=0;return true}else{throw new NyARException()}}}},onEnterHandler:function(a){throw new NyARException("onEnterHandler not implemented.")},onLeaveHandler:function(){throw new NyARException("onLeaveHandler not implemented.")},onUpdateHandler:function(b,a){throw new NyARException("onUpdateHandler not implemented.")}});FLARDetectSquareCB_1=ASKlass("DetectSquareCB",{square:new FLARSquare(),confidence:0,code_index:-1,cf_threshold_new:0.5,cf_threshold_exist:0.3,_ref_raster:null,_inst_patt:null,_deviation_data:null,_match_patt:null,__detectMarkerLite_mr:new NyARMatchPattResult(),_coordline:null,DetectSquareCB:function(a){this._match_patt=null;this._coordline=new NyARCoord2Linear(a.getScreenSize(),a.getDistortionFactor());return},setNyARCodeTable:function(a,c){this._deviation_data=new NyARMatchPattDeviationColorData(c,c);this._inst_patt=new NyARColorPatt_Perspective_O2(c,c,4,25);this._match_patt=new Array(a.length);for(var b=0;b<a.length;b++){this._match_patt[b]=new NyARMatchPatt_Color_WITHOUT_PCA(a[b])}},__tmp_vertex:NyARIntPoint2d.createArray(4),_target_id:0,init:function(a,b){this._ref_raster=a;this._target_id=b;this.code_index=-1;this.confidence=Number.MIN_VALUE},onSquareDetect:function(f,c,b,o,m){if(this._match_patt==null){return}var n=this.__tmp_vertex;n[0].x=c[m[0]];n[0].y=b[m[0]];n[1].x=c[m[1]];n[1].y=b[m[1]];n[2].x=c[m[2]];n[2].y=b[m[2]];n[3].x=c[m[3]];n[3].y=b[m[3]];if(!this._inst_patt.pickFromRaster(this._ref_raster,n)){return}this._deviation_data.setRaster(this._inst_patt);var d=this.__detectMarkerLite_mr;var q=0;var e=0;var l=0;var k;for(k=0;k<this._match_patt.length;k++){this._match_patt[k].evaluate(this._deviation_data,d);var g=d.confidence;if(l<g){q=k;l=g;e=d.direction}}if(this._target_id==-1){if(l<this.cf_threshold_new){return}if(this.confidence>l){return}this.code_index=q}else{if(q!=this._target_id){return}if(l<this.cf_threshold_exist){return}if(this.confidence>l){return}this.code_index=this._target_id}this.confidence=l;var a=this.square;for(k=0;k<4;k++){var p=(k+4-e)%4;this._coordline.coord2Line(m[p],m[(p+1)%4],c,b,o,a.line[k])}for(k=0;k<4;k++){if(!NyARLinear.crossPos(a.line[k],a.line[(k+3)%4],a.sqvertex[k])){throw new NyARException()}}}});FLSingleNyIdMarkerProcesser=ASKlass("FLSingleNyIdMarkerProcesser",{tag:null,_lost_delay_count:0,_lost_delay:5,_square_detect:null,_transmat:null,_offset:null,_is_active:null,_current_threshold:110,_bin_raster:null,_tobin_filter:null,_callback:null,_data_current:null,FLSingleNyIdMarkerProcesser:function(){return},_initialized:false,initInstance:function(a,d,b){NyAS3Utils.assert(this._initialized==false);var c=a.getScreenSize();this._square_detect=new FLARSquareContourDetector(c);this._transmat=new NyARTransMat(a);this._callback=new FLARDetectSquareCB_2(a,d);this._bin_raster=new FLARBinRaster(c.w,c.h);this._data_current=d.createDataInstance();this._tobin_filter=new FLARRasterFilter_Threshold(110);this._threshold_detect=new FLARRasterThresholdAnalyzer_SlidePTile(15,4);this._initialized=true;this._is_active=false;this._offset=new NyARRectOffset();this._offset.setSquare(b);return},setMarkerWidth:function(a){this._offset.setSquare(a);return},reset:function(a){if(a==false&&this._is_active){this.onLeaveHandler()}this._is_active=false;return},detectMarker:function(a){if(!this._bin_raster.getSize().isEqualSize_int(a.getSize().w,a.getSize().h)){throw new NyARException()}this._tobin_filter.setThreshold(this._current_threshold);this._tobin_filter.doFilter(a,this._bin_raster);this._callback.init(a,this._is_active?this._data_current:null);this._square_detect.detectMarkerCB(this._bin_raster,this._callback);var c=updateStatus(this._callback.square,this._callback.marker_data);if(c){this._current_threshold=(this._current_threshold+this._callback.threshold)/2}else{var b=this._threshold_detect.analyzeRaster(a);this._current_threshold=(this._current_threshold+b)/2}return},_threshold_detect:null,__NyARSquare_result:new FLARTransMatResult(),updateStatus:function(c,b){var d=false;var a=this.__NyARSquare_result;if(!this._is_active){if(b==null){this._is_active=false}else{this._data_current.copyFrom(b);this.onEnterHandler(this._data_current);this._transmat.transMat(c,this._offset,a);this.onUpdateHandler(c,a);this._lost_delay_count=0;this._is_active=true;d=true}}else{if(b==null){this._lost_delay_count++;if(this._lost_delay<this._lost_delay_count){this.onLeaveHandler();this._is_active=false}}else{if(this._data_current.isEqual(b)){this._transmat.transMatContinue(c,this._offset,a);this.onUpdateHandler(c,a);this._lost_delay_count=0;d=true}else{throw new NyARException()}}}return d},onEnterHandler:function(a){throw new NyARException("onEnterHandler not implemented.")},onLeaveHandler:function(){throw new NyARException("onLeaveHandler not implemented.")},onUpdateHandler:function(b,a){throw new NyARException("onUpdateHandler not implemented.")}});FLARDetectSquareCB_2=ASKlass("DetectSquareCB",{square:new FLARSquare(),marker_data:null,threshold:0,_ref_raster:null,_current_data:null,_id_pickup:new NyIdMarkerPickup(),_coordline:null,_encoder:null,_data_temp:null,_prev_data:null,DetectSquareCB:function(a,b){this._coordline=new NyARCoord2Linear(a.getScreenSize(),a.getDistortionFactor());this._data_temp=b.createDataInstance();this._current_data=b.createDataInstance();this._encoder=b;return},__tmp_vertex:NyARIntPoint2d.createArray(4),init:function(a,b){this.marker_data=null;this._prev_data=b;this._ref_raster=a},_marker_param:new NyIdMarkerParam(),_marker_data:new NyIdMarkerPattern(),onSquareDetect:function(e,c,b,l,g){if(this.marker_data!=null){return}var k=this.__tmp_vertex;k[0].x=c[g[0]];k[0].y=b[g[0]];k[1].x=c[g[1]];k[1].y=b[g[1]];k[2].x=c[g[2]];k[2].y=b[g[2]];k[3].x=c[g[3]];k[3].y=b[g[3]];var d=this._marker_param;var m=this._marker_data;if(!this._id_pickup.pickFromRaster(this._ref_raster,k,m,d)){return}if(!this._encoder.encode(m,this._data_temp)){return}if(this._prev_data==null){this._current_data.copyFrom(this._data_temp)}else{if(!this._prev_data.isEqual((this._data_temp))){return}}var a=this.square;var f;for(f=0;f<4;f++){var n=(f+4-d.direction)%4;this._coordline.coord2Line(g[n],g[(n+1)%4],c,b,l,a.line[f])}for(f=0;f<4;f++){if(!NyARLinear.crossPos(a.line[f],a.line[(f+3)%4],a.sqvertex[f])){throw new NyARException()}}this.threshold=d.threshold;this.marker_data=this._current_data}});NyARCustomSingleDetectMarker=ASKlass("NyARCustomSingleDetectMarker",{_is_continue:false,_square_detect:null,_transmat:null,_bin_raster:null,_tobin_filter:null,_detect_cb:null,_offset:null,NyARCustomSingleDetectMarker:function(){return},initInstance:function(e,i,g,a,f,b,c){var d=f.getScreenSize();this._square_detect=i;this._transmat=g;this._tobin_filter=a;this._bin_raster=new NyARBinRaster(d.w,d.h);this._detect_cb=new DetectSquareCB_3(e,b,f);this._offset=new NyARRectOffset();this._offset.setSquare(c);return},detectMarkerLiteB:function(a){if(!this._bin_raster.getSize().isEqualSize_NyARIntSize(a.getSize())){throw new NyARException()}this._tobin_filter.doFilter(a,this._bin_raster);this._detect_cb.init(a);this._square_detect.detectMarkerCB(this._bin_raster,_detect_cb);if(this._detect_cb.confidence==0){return false}return true},getTransmationMatrix:function(a){if(this._is_continue){this._transmat.transMatContinue(this._detect_cb.square,this._offset,a)}else{this._transmat.transMat(this._detect_cb.square,this._offset,a)}return},refSquare:function(){return this._detect_cb.square},getConfidence:function(){return this._detect_cb.confidence},setContinueMode:function(a){this._is_continue=a}});DetectSquareCB_3=ASKlass("DetectSquareCB",NyARSquareContourDetector_IDetectMarkerCallback,{confidence:0,square:new NyARSquare(),_ref_raster:null,_inst_patt:null,_deviation_data:null,_match_patt:null,__detectMarkerLite_mr:new NyARMatchPattResult(),_coordline:null,DetectSquareCB:function(a,c,b){this._inst_patt=a;this._deviation_data=new NyARMatchPattDeviationColorData(c.getWidth(),c.getHeight());this._coordline=new NyARCoord2Linear(b.getScreenSize(),b.getDistortionFactor());this._match_patt=new NyARMatchPatt_Color_WITHOUT_PCA(c);return},__tmp_vertex:NyARIntPoint2d.createArray(4),onSquareDetect:function(e,c,b,l,f){var g;var d=this.__detectMarkerLite_mr;var k=this.__tmp_vertex;k[0].x=c[f[0]];k[0].y=b[f[0]];k[1].x=c[f[1]];k[1].y=b[f[1]];k[2].x=c[f[2]];k[2].y=b[f[2]];k[3].x=c[f[3]];k[3].y=b[f[3]];if(!this._inst_patt.pickFromRaster(this._ref_raster,k)){return}this._deviation_data.setRaster(this._inst_patt);if(!this._match_patt.evaluate(this._deviation_data,d)){return}if(this.confidence>d.confidence){return}var a=this.square;this.confidence=d.confidence;for(g=0;g<4;g++){var m=(g+4-d.direction)%4;this._coordline.coord2Line(f[m],f[(m+1)%4],c,b,l,a.line[g])}for(g=0;g<4;g++){if(!NyARLinear.crossPos(a.line[g],a.line[(g+3)%4],a.sqvertex[g])){throw new NyARException()}}},init:function(a){this.confidence=0;this._ref_raster=a}});NyARDetectMarker=ASKlass("NyARDetectMarker",{_detect_cb:null,AR_SQUARE_MAX:300,_is_continue:false,_square_detect:null,_transmat:null,_offset:null,NyARDetectMarker:function(c,a,e,b,d){this.initInstance(c,a,e,b,d);return},initInstance:function(c,k,l,b,d){var g=c.getScreenSize();var e=k[0].getWidth();var a=k[0].getHeight();this._detect_cb=new NyARDetectSquareCB(new NyARColorPatt_Perspective_O2(e,a,4,25),k,b,c);this._transmat=new NyARTransMat(c);this._square_detect=new NyARSquareContourDetector_Rle(c.getScreenSize());this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(100,d);this._offset=NyARRectOffset.createArray(b);for(var f=0;f<b;f++){this._offset[f].setSquare(l[f])}this._bin_raster=new NyARBinRaster(g.w,g.h);return},_bin_raster:null,_tobin_filter:null,detectMarkerLite:function(a,b){if(!this._bin_raster.getSize().isEqualSize_NyARIntSize(a.getSize())){throw new NyARException()}(NyARRasterFilter_ARToolkitThreshold(this._tobin_filter)).setThreshold(b);this._tobin_filter.doFilter(a,this._bin_raster);this._detect_cb.init(a);this._square_detect.detectMarkerCB(this._bin_raster,this._detect_cb);return this._detect_cb.result_stack.getLength()},getTransmationMatrix:function(c,b){var a=this._detect_cb.result_stack.getItem(c);if(_is_continue){_transmat.transMatContinue(a.square,this._offset[a.arcode_id],b)}else{_transmat.transMat(a.square,this._offset[a.arcode_id],b)}return},getConfidence:function(a){return this._detect_cb.result_stack.getItem(a).confidence},getARCodeIndex:function(a){return this._detect_cb.result_stack.getItem(a).arcode_id},setContinueMode:function(a){this._is_continue=a}});NyARDetectMarkerResult=ASKlass("NyARDetectMarkerResult",{arcode_id:0,confidence:0,square:new NyARSquare()});NyARDetectMarkerResultStack=ASKlass("NyARDetectMarkerResultStack ",NyARObjectStack,{NyARDetectMarkerResultStack:function(a){NyARObjectStack.initialize.call(this,a)},createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new NyARDetectMarkerResult()}return(a)}});NyARDetectSquareCB=ASKlass("NyARDetectSquareCB ",NyARSquareContourDetector_IDetectMarkerCallback,{result_stack:new NyARDetectMarkerResultStack(NyARDetectMarker.AR_SQUARE_MAX),_ref_raster:null,_inst_patt:null,_deviation_data:null,_match_patt:null,__detectMarkerLite_mr:new NyARMatchPattResult(),_coordline:null,NyARDetectSquareCB:function(b,d,g,c){var a=d[0].getWidth();var f=d[0].getHeight();this._inst_patt=b;this._coordline=new NyARCoord2Linear(c.getScreenSize(),c.getDistortionFactor());this._deviation_data=new NyARMatchPattDeviationColorData(a,f);this._match_patt=new Array(g);this._match_patt[0]=new NyARMatchPatt_Color_WITHOUT_PCA(d[0]);for(var e=1;e<g;e++){if(a!=d[e].getWidth()||f!=d[e].getHeight()){throw new NyARException()}this._match_patt[e]=new NyARMatchPatt_Color_WITHOUT_PCA(d[e])}return},__tmp_vertex:NyARIntPoint2d.createArray(4),onSquareDetect:function(f,c,b,n,k){var d=this.__detectMarkerLite_mr;var l=this.__tmp_vertex;l[0].x=c[k[0]];l[0].y=b[k[0]];l[1].x=c[k[1]];l[1].y=b[k[1]];l[2].x=c[k[2]];l[2].y=b[k[2]];l[3].x=c[k[3]];l[3].y=b[k[3]];if(!this._inst_patt.pickFromRaster(this._ref_raster,l)){return}this._deviation_data.setRaster(this._inst_patt);var e,o;var m;this._match_patt[0].evaluate(this._deviation_data,d);e=0;o=d.direction;m=d.confidence;var g;for(g=1;g<this._match_patt.length;g++){this._match_patt[g].evaluate(this._deviation_data,d);if(m>d.confidence){continue}e=g;o=d.direction;m=d.confidence}var q=this.result_stack.prePush();q.arcode_id=e;q.confidence=m;var a=q.square;for(g=0;g<4;g++){var p=(g+4-o)%4;this._coordline.coord2Line(k[p],k[(p+1)%4],c,b,n,a.line[g])}for(g=0;g<4;g++){if(!NyARLinear.crossPos(a.line[g],a.line[(g+3)%4],a.sqvertex[g])){throw new NyARException()}}},init:function(a){this._ref_raster=a;this.result_stack.clear()}});NyARSingleDetectMarker=ASKlass("NyARSingleDetectMarker",NyARCustomSingleDetectMarker,{PF_ARTOOLKIT_COMPATIBLE:1,PF_NYARTOOLKIT:2,PF_NYARTOOLKIT_ARTOOLKIT_FITTING:100,PF_TEST2:201,NyARSingleDetectMarker:function(c,a,e,d,b){if(b==null){b=this.PF_NYARTOOLKIT}NyARCustomSingleDetectMarker.initialize.call(this);this.initInstance2(c,a,e,d,b);return},initInstance2:function(c,i,k,d,b){var a=new NyARRasterFilter_ARToolkitThreshold(100,d);var e;var f;var g;switch(b){case this.PF_NYARTOOLKIT:e=new NyARColorPatt_Perspective_O2(i.getWidth(),i.getHeight(),4,25);f=new NyARSquareContourDetector_Rle(c.getScreenSize());g=new NyARTransMat(c);break;default:throw new NyARException()}NyARCustomSingleDetectMarker.initInstance.call(this,e,f,g,a,c,i,k)},detectMarkerLite:function(a,b){(NyARRasterFilter_ARToolkitThreshold(this._tobin_filter)).setThreshold(b);return NyARCustomSingleDetectMarker.detectMarkerLiteB.call(this,a)}});FLARDetectMarkerResult=ASKlass("FLARDetectMarkerResult",{arcode_id:0,confidence:0,direction:0,square:new NyARSquare()});FLARDetectMarkerResultStack=ASKlass("FLARDetectMarkerResultStack",NyARObjectStack,{FLARDetectMarkerResultStack:function(a){NyARObjectStack.initialize.call(this,a)},createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new FLARDetectMarkerResult()}return(a)}});FLARMultiMarkerDetector=ASKlass("FLARMultiMarkerDetector",{_detect_cb:null,AR_SQUARE_MAX:300,_is_continue:false,_square_detect:null,_transmat:null,_offset:null,_flarcode:null,FLARMultiMarkerDetector:function(c,a,d,b){this.initInstance(c,a,d,b);return},initInstance:function(d,l,n,b){var k=d.getScreenSize();var e=l[0].getWidth();var a=l[0].getHeight();var c=(100-l[0].markerPercentWidth)/2;var m=(100-l[0].markerPercentHeight)/2;var g=new NyARColorPatt_Perspective_O2(e,a,4,c);g.setEdgeSizeByPercent(c,m,4);this._detect_cb=new MultiDetectSquareCB(g,l,b,d);this._transmat=new NyARTransMat(d);this._square_detect=new FLARSquareContourDetector(d.getScreenSize());this._tobin_filter=new FLARRasterFilter_Threshold(100);this._offset=NyARRectOffset.createArray(b);for(var f=0;f<b;f++){this._offset[f].setSquare(n[f])}this._bin_raster=new FLARBinRaster(k.w,k.h);return},_bin_raster:null,_tobin_filter:null,detectMarkerLite:function(a,d){if(!this._bin_raster.getSize().isEqualSize_NyARIntSize(a.getSize())){throw new NyARException()}if(d!=-1){(FLARRasterFilter_Threshold(this._tobin_filter)).setThreshold(d);this._tobin_filter.doFilter(a,this._bin_raster)}else{var b=(a.getBuffer());var c=((this._bin_raster).getBuffer());c.copyPixels(b,b.rect,new Point())}this._detect_cb.init(a);this._square_detect.detectMarkerCB(this._bin_raster,this._detect_cb);return this._detect_cb.result_stack.getLength()},getTransformMatrix:function(c,b){var a=this._detect_cb.result_stack.getItem(c);if(_is_continue){_transmat.transMatContinue(a.square,this._offset[a.arcode_id],b)}else{_transmat.transMat(a.square,this._offset[a.arcode_id],b)}return},getConfidence:function(a){return this._detect_cb.result_stack.getItem(a).confidence},getARCodeIndex:function(a){return this._detect_cb.result_stack.getItem(a).arcode_id},getDirection:function(a){return this._detect_cb.result_stack.getItem(a).direction},getSquare:function(a){return this._detect_cb.result_stack.getItem(a).square},setContinueMode:function(a){this._is_continue=a},setAreaRange:function(b,c){if(b==null){b=100000}if(c==null){c=70}if(b<0){b=FLARLabeling.AR_AREA_MAX}if(c<0){c=FLARLabeling.AR_AREA_MIN}if(b<c){var a=b;b=c;c=a}this._square_detect.setAreaRange(b,c)},thresholdedBitmapData:function(){try{return((this._bin_raster).getBuffer())}catch(a){return null}return null}});FLARSingleMarkerDetector=ASKlass("FLARSingleMarkerDetector",{_is_continue:false,_square_detect:null,_transmat:null,_bin_raster:null,_tobin_filter:null,_detect_cb:null,_offset:null,FLARSingleMarkerDetector:function(c,g,k){var a=new FLARRasterFilter_Threshold(100);var d;var e;var f;var b=(100-g.markerPercentWidth)/2;var i=(100-g.markerPercentHeight)/2;d=new NyARColorPatt_Perspective_O2(g.getWidth(),g.getHeight(),4,b);d.setEdgeSizeByPercent(b,i,4);e=new FLARSquareContourDetector(c.getScreenSize());f=new NyARTransMat(c);this.initInstance(d,e,f,a,c,g,k);return},initInstance:function(e,i,g,a,f,b,c){var d=f.getScreenSize();this._square_detect=i;this._transmat=g;this._tobin_filter=a;this._bin_raster=new FLARBinRaster(d.w,d.h);this._detect_cb=new SingleDetectSquareCB(e,b,f);this._offset=new NyARRectOffset();this._offset.setSquare(c);return},detectMarkerLite:function(a,b){this._tobin_filter.setThreshold(b);if(!this._bin_raster.getSize().isEqualSize_NyARIntSize(a.getSize())){throw new FLARException()}this._tobin_filter.doFilter(a,this._bin_raster);this._detect_cb.init(a);this._square_detect.detectMarkerCB(this._bin_raster,this._detect_cb);if(this._detect_cb.confidence==0){return false}return true},getTransformMatrix:function(a){if(this._is_continue){this._transmat.transMatContinue(this._detect_cb.square,this._offset,a)}else{this._transmat.transMat(this._detect_cb.square,this._offset,a)}return},getConfidence:function(){return this._detect_cb.confidence},getDirection:function(){return this._detect_cb.direction},getSquare:function(){return this._detect_cb.square},setContinueMode:function(a){this._is_continue=a},setAreaRange:function(b,c){if(b==null){b=100000}if(c==null){c=70}if(b<0){b=FLARLabeling.AR_AREA_MAX}if(c<0){c=FLARLabeling.AR_AREA_MIN}if(b<c){var a=b;b=c;c=a}this._square_detect.setAreaRange(b,c)},thresholdedBitmapData:function(){try{return((this._bin_raster).getBuffer())}catch(a){return null}return null}});MultiDetectSquareCB=ASKlass("MultiDetectSquareCB",{result_stack:new FLARDetectMarkerResultStack(NyARDetectMarker.AR_SQUARE_MAX),_ref_raster:null,_inst_patt:null,_deviation_data:null,_match_patt:null,__detectMarkerLite_mr:new NyARMatchPattResult(),_coordline:null,MultiDetectSquareCB:function(b,d,g,c){var a=d[0].getWidth();var f=d[0].getHeight();this._inst_patt=b;this._coordline=new NyARCoord2Linear(c.getScreenSize(),c.getDistortionFactor());this._deviation_data=new NyARMatchPattDeviationColorData(a,f);this._match_patt=new Array(g);this._match_patt[0]=new NyARMatchPatt_Color_WITHOUT_PCA(d[0]);for(var e=1;e<g;e++){if(a!=d[e].getWidth()||f!=d[e].getHeight()){throw new NyARException()}this._match_patt[e]=new NyARMatchPatt_Color_WITHOUT_PCA(d[e])}return},__tmp_vertex:NyARIntPoint2d.createArray(4),onSquareDetect:function(f,c,b,n,k){var d=this.__detectMarkerLite_mr;var l=this.__tmp_vertex;l[0].x=c[k[0]];l[0].y=b[k[0]];l[1].x=c[k[1]];l[1].y=b[k[1]];l[2].x=c[k[2]];l[2].y=b[k[2]];l[3].x=c[k[3]];l[3].y=b[k[3]];if(!this._inst_patt.pickFromRaster(this._ref_raster,l)){return}this._deviation_data.setRaster(this._inst_patt);var e,o;var m;this._match_patt[0].evaluate(this._deviation_data,d);e=0;o=d.direction;m=d.confidence;var g;for(g=1;g<this._match_patt.length;g++){this._match_patt[g].evaluate(this._deviation_data,d);if(m>d.confidence){continue}e=g;o=d.direction;m=d.confidence}var q=this.result_stack.prePush();q.arcode_id=e;q.confidence=m;q.direction=o;var a=q.square;for(g=0;g<4;g++){var p=(g+4-o)%4;this._coordline.coord2Line(k[p],k[(p+1)%4],c,b,n,a.line[g])}for(g=0;g<4;g++){if(!NyARLinear.crossPos(a.line[g],a.line[(g+3)%4],a.sqvertex[g])){throw new NyARException()}}},init:function(a){this._ref_raster=a;this.result_stack.clear()}});SingleDetectSquareCB=ASKlass("SingleDetectSquareCB",{confidence:0,square:new NyARSquare(),direction:0,_ref_raster:null,_inst_patt:null,_deviation_data:null,_match_patt:null,__detectMarkerLite_mr:new NyARMatchPattResult(),_coordline:null,SingleDetectSquareCB:function(a,c,b){this._inst_patt=a;this._deviation_data=new NyARMatchPattDeviationColorData(c.getWidth(),c.getHeight());this._coordline=new NyARCoord2Linear(b.getScreenSize(),b.getDistortionFactor());this._match_patt=new NyARMatchPatt_Color_WITHOUT_PCA(c);return},__tmp_vertex:NyARIntPoint2d.createArray(4),onSquareDetect:function(e,c,b,l,f){var g;var d=this.__detectMarkerLite_mr;var k=this.__tmp_vertex;k[0].x=c[f[0]];k[0].y=b[f[0]];k[1].x=c[f[1]];k[1].y=b[f[1]];k[2].x=c[f[2]];k[2].y=b[f[2]];k[3].x=c[f[3]];k[3].y=b[f[3]];if(!this._inst_patt.pickFromRaster(this._ref_raster,k)){return}this._deviation_data.setRaster(this._inst_patt);if(!this._match_patt.evaluate(this._deviation_data,d)){return}if(this.confidence>d.confidence){return}var a=this.square;this.confidence=d.confidence;this.direction=d.direction;for(g=0;g<4;g++){var m=(g+4-d.direction)%4;this._coordline.coord2Line(f[m],f[(m+1)%4],c,b,l,a.line[g])}for(g=0;g<4;g++){if(!NyARLinear.crossPos(a.line[g],a.line[(g+3)%4],a.sqvertex[g])){throw new NyARException()}}},init:function(a){this.confidence=0;this._ref_raster=a}});FLARIdMarkerData=ASKlass("FLARIdMarkerData",{_packet:new IntVector(22),_model:0,_controlDomain:0,_controlMask:0,_check:0,_dataDot:0,packetLength:0,FLARIdMarkerData:function(){},isEqual:function(c){if(c==null||!(c instanceof FLARIdMarkerData)){return false}var b=c;if(b.packetLength!=this.packetLength||b._check!=this._check||b._controlDomain!=this._controlDomain||b._controlMask!=this._controlMask||b._dataDot!=this._dataDot||b._model!=this._model){return false}for(var a=b.packetLength-1;a>=0;a--){if(b._packet[a]!=this._packet[a]){return false}}return true},copyFrom:function(c){var b=c;if(b==null){return}this._check=b._check;this._controlDomain=b._controlDomain;this._controlMask=b._controlMask;this._dataDot=b._dataDot;this._model=b._model;this.packetLength=b.packetLength;for(var a=b.packetLength-1;a>=0;a--){this._packet[a]=b._packet[a]}return},setModel:function(a){this._model=a},setControlDomain:function(a){this._controlDomain=a},setControlMask:function(a){this._controlMask=a},setCheck:function(a){this._check=a},setPacketData:function(a,b){if(a<this.packetLength){this._packet[a]=b}else{throw ("packet index over "+a+" >= "+this.packetLength)}},setDataDotLength:function(a){this._dataDot=a},setPacketLength:function(a){this.packetLength=a},dataDotLength:function(){return this._dataDot},model:function(){return this._model},controlDomain:function(){return this._controlDomain},controlMask:function(){return this._controlMask},check:function(){return this._check},getPacketData:function(a){if(this.packetLength<=a){throw new ArgumentError("packet index over")}return this._packet[a]}});FLARDetectIdMarkerResult=ASKlass("FLARDetectIdMarkerResult",{arcode_id:0,direction:0,markerdata:new FLARIdMarkerData(),square:new NyARSquare()});FLARDetectIdMarkerResultStack=ASKlass("FLARDetectIdMarkerResultStack",NyARObjectStack,{FLARDetectIdMarkerResultStack:function(a){NyARObjectStack.initialize.call(this,a)},createArray:function(b){var a=new Array(b);for(var c=0;c<b;c++){a[c]=new FLARDetectIdMarkerResult()}return(a)}});FLARMultiIdMarkerDetectCB=ASKlass("FLARMultiIdMarkerDetectCB",{result_stack:new FLARDetectIdMarkerResultStack(NyARDetectMarker.AR_SQUARE_MAX),square:new FLARSquare(),marker_data:null,threshold:0,direction:0,_ref_raster:null,_current_data:null,_data_temp:null,_prev_data:null,_id_pickup:new NyIdMarkerPickup(),_coordline:null,_encoder:null,__tmp_vertex:NyARIntPoint2d.createArray(4),_marker_param:new NyIdMarkerParam(),_maker_pattern:new NyIdMarkerPattern(),FLARMultiIdMarkerDetectCB:function(a,b){this._coordline=new NyARCoord2Linear(a.getScreenSize(),a.getDistortionFactor());this._data_temp=b.createDataInstance();this._current_data=b.createDataInstance();this._encoder=b;return},init:function(a){this.marker_data=null;this.result_stack.clear();this._id_pickup.init();this._ref_raster=a},_previous_verts:{},onSquareDetect:function(e,c,b,q,n){var p=this.__tmp_vertex;p[0].x=c[n[0]];p[0].y=b[n[0]];p[1].x=c[n[1]];p[1].y=b[n[1]];p[2].x=c[n[2]];p[2].y=b[n[2]];p[3].x=c[n[3]];p[3].y=b[n[3]];var d=this._marker_param;var r=this._maker_pattern;var m;if(window.DEBUG){m=document.getElementById("debugCanvas").getContext("2d");m.fillStyle="blue";for(var l=0;l<4;l++){m.fillRect(p[l].x-2,p[l].y-2,5,5)}}var g=0,f=0;for(var l=0;l<4;l++){g+=p[l].x;f+=p[l].y}g/=4;f/=4;var o=this._id_pickup.pickFromRaster(this._ref_raster,p,r,d);if(!o){if(window.DEBUG){m.fillStyle="#ff0000";m.fillText("No pick",g+3,f)}return}var k=this._encoder.encode(r,this._data_temp);if(!k){return}this._current_data.copyFrom(this._data_temp);this.marker_data=this._current_data;this.threshold=d.threshold;this.direction=d.direction;var t=this.result_stack.prePush();t.direction=this.direction;t.markerdata.copyFrom(this.marker_data);t.arcode_id=this.getId(t.markerdata);if(window.DEBUG){m.fillStyle="#00ffff";m.fillText(t.arcode_id,g+3,f)}var a=t.square;var l;for(l=0;l<4;l++){var s=(l+4-d.direction)%4;this._coordline.coord2Line(n[s],n[(s+1)%4],c,b,q,a.line[l])}for(l=0;l<4;l++){if(!NyARLinear.crossPos(a.line[l],a.line[(l+3)%4],a.sqvertex[l])){throw new NyARException()}}},getId:function(c){var b;if(c.packetLength>4){b=-1}else{b=0;for(var a=0;a<c.packetLength;a++){b=(b<<8)|c.getPacketData(a)}}return b}});FLARMultiIdMarkerDetector=ASKlass("FLARMultiIdMarkerDetector",{_is_continue:false,_square_detect:null,_offset:null,_current_threshold:110,_bin_raster:null,_tobin_filter:null,_callback:null,_data_current:null,_threshold_detect:null,_transmat:null,FLARMultiIdMarkerDetector:function(a,b){var d=a.getScreenSize();var c=new FLARIdMarkerDataEncoder_RawBit();this._square_detect=new FLARSquareContourDetector(d);this._callback=new FLARMultiIdMarkerDetectCB(a,c);this._transmat=new NyARTransMat(a);this._bin_raster=new FLARBinRaster(d.w,d.h);this._data_current=c.createDataInstance();this._tobin_filter=new FLARRasterFilter_Threshold(110);this._threshold_detect=new FLARRasterThresholdAnalyzer_SlidePTile(15,4);this._offset=new NyARRectOffset();this._offset.setSquare(b);return},detectMarkerLite:function(a,b){if(!this._bin_raster.getSize().isEqualSize_int(a.getSize().w,a.getSize().h)){throw new FLARException()}this._tobin_filter.setThreshold(b);this._tobin_filter.doFilter(a,this._bin_raster);this._callback.init(this._bin_raster);this._square_detect.detectMarkerCB(this._bin_raster,this._callback);return this._callback.result_stack.getLength()},getTransformMatrix:function(c,b){var a=this._callback.result_stack.getItem(c);if(this._is_continue){this._transmat.transMatContinue(a.square,this._offset,b)}else{this._transmat.transMat(a.square,this._offset,b)}return},getIdMarkerData:function(b){var a=new FLARIdMarkerData();a.copyFrom(this._callback.result_stack.getItem(b).markerdata);return a},getARCodeIndex:function(a){return this._callback.result_stack.getItem(a).arcode_id},getDirection:function(a){return this._callback.result_stack.getItem(a).direction},getSquare:function(a){return this._callback.result_stack.getItem(a).square},setContinueMode:function(a){this._is_continue=a},thresholdedBitmapData:function(){try{return((this._bin_raster).getBuffer())}catch(a){return null}return null}});FLARSingleIdMarkerDetectCB=ASKlass("FLARSingleIdMarkerDetectCB",{square:new FLARSquare(),marker_data:null,threshold:0,direction:0,_ref_raster:null,_current_data:null,_data_temp:null,_prev_data:null,_id_pickup:new NyIdMarkerPickup(),_coordline:null,_encoder:null,__tmp_vertex:NyARIntPoint2d.createArray(4),_marker_param:new NyIdMarkerParam(),_maker_pattern:new NyIdMarkerPattern(),FLARSingleIdMarkerDetectCB:function(a,b){this._coordline=new NyARCoord2Linear(a.getScreenSize(),a.getDistortionFactor());this._data_temp=b.createDataInstance();this._current_data=b.createDataInstance();this._encoder=b;return},init:function(a,b){this.marker_data=null;this._prev_data=b;this._ref_raster=a},onSquareDetect:function(e,c,b,n,k){if(this.marker_data!=null){return}var m=this.__tmp_vertex;m[0].x=c[k[0]];m[0].y=b[k[0]];m[1].x=c[k[1]];m[1].y=b[k[1]];m[2].x=c[k[2]];m[2].y=b[k[2]];m[3].x=c[k[3]];m[3].y=b[k[3]];var d=this._marker_param;var o=this._maker_pattern;var l=this._id_pickup.pickFromRaster(this._ref_raster,m,o,d);if(window.DEBUG){var g=document.getElementById("debugCanvas").getContext("2d");g.fillStyle="blue";for(var f=0;f<4;f++){g.fillRect(m[f].x-2,m[f].y-2,5,5)}}if(!l){return}this.direction=d.direction;if(!this._encoder.encode(o,this._data_temp)){return}if(this._prev_data==null){this._current_data.copyFrom(this._data_temp)}else{if(!this._prev_data.isEqual((this._data_temp))){return}}var a=this.square;var f;for(f=0;f<4;f++){var p=(f+4-d.direction)%4;this._coordline.coord2Line(k[p],k[(p+1)%4],c,b,n,a.line[f])}for(f=0;f<4;f++){if(!NyARLinear.crossPos(a.line[f],a.line[(f+3)%4],a.sqvertex[f])){throw new NyARException()}}this.threshold=d.threshold;this.marker_data=this._current_data}});FLARSingleIdMarkerDetector=ASKlass("FLARSingleIdMarkerDetector",{_is_continue:false,_square_detect:null,_offset:null,_is_active:null,_current_threshold:110,_bin_raster:null,_tobin_filter:null,_callback:null,_data_current:null,_threshold_detect:null,_transmat:null,FLARSingleIdMarkerDetector:function(a,b){var d=a.getScreenSize();var c=new FLARIdMarkerDataEncoder_RawBit();this._square_detect=new FLARSquareContourDetector(d);this._callback=new FLARSingleIdMarkerDetectCB(a,c);this._transmat=new NyARTransMat(a);this._bin_raster=new FLARBinRaster(d.w,d.h);this._data_current=c.createDataInstance();this._tobin_filter=new FLARRasterFilter_Threshold(110);this._threshold_detect=new FLARRasterThresholdAnalyzer_SlidePTile(15,4);this._offset=new NyARRectOffset();this._offset.setSquare(b);return},detectMarkerLite:function(a,b){if(!this._bin_raster.getSize().isEqualSize_int(a.getSize().w,a.getSize().h)){throw new FLARException()}this._tobin_filter.setThreshold(b);this._tobin_filter.doFilter(a,this._bin_raster);this._callback.init(this._bin_raster,this._is_active?this._data_current:null);this._square_detect.detectMarkerCB(this._bin_raster,this._callback);if(this._callback.marker_data==null){this._is_active=false;return false}this._is_active=true;this._data_current.copyFrom(this._callback.marker_data);return true},getIdMarkerData:function(){var a=new FLARIdMarkerData();a.copyFrom(this._callback.marker_data);return a},getDirection:function(){return this._callback.direction},getTransformMatrix:function(a){if(this._is_continue){this._transmat.transMatContinue(this._callback.square,this._offset,a)}else{this._transmat.transMat(this._callback.square,this._offset,a)}return},setContinueMode:function(a){this._is_continue=a}});FLARIdMarkerDataEncoder_RawBit=ASKlass("FLARIdMarkerDataEncoder_RawBit",{_DOMAIN_ID:0,_mod_data:new IntVector([7,31,127,511,2047,4095]),encode:function(a,b){var c=b;if(c==null){throw new FLARException('type of o_dest must be "FLARIdMarkerData"')}if(a.ctrl_domain!=this._DOMAIN_ID){return false}c.setCheck(a.check);c.setControlDomain(a.ctrl_domain);c.setControlMask(a.ctrl_mask);c.setModel(a.model);var g=toInt(a.model*2-1);c.setDataDotLength(g);var e=toInt((g*g)/8)+1;c.setPacketLength(e);var f=0;for(var d=0;d<e;d++){c.setPacketData(d,a.data[d]);f+=a.data[d]}f=f%this._mod_data[a.model-2];if(a.check!=f){return false}return true},createDataInstance:function(){return new FLARIdMarkerData()}});SingleARMarkerProcesser=ASKlass("SingleARMarkerProcesser",{tag:null,_lost_delay_count:0,_lost_delay:5,_square_detect:null,_transmat:null,_offset:null,_threshold:110,_bin_raster:null,_tobin_filter:null,_current_arcode_index:-1,_threshold_detect:null,SingleARMarkerProcesser:function(){return},_initialized:false,initInstance:function(a,b){NyAS3Utils.assert(this._initialized==false);var c=a.getScreenSize();this._square_detect=new NyARSquareContourDetector_Rle(c);this._transmat=new NyARTransMat(a);this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(110,b);this._bin_raster=new NyARBinRaster(c.w,c.h);this._threshold_detect=new NyARRasterThresholdAnalyzer_SlidePTile(15,b,4);this._initialized=true;this._detectmarker_cb=new DetectSquareCB_1(a);this._offset=new NyARRectOffset();return},setARCodeTable:function(c,b,a){if(this._current_arcode_index!=-1){this.reset(true)}this._detectmarker_cb.setNyARCodeTable(c,b);this._offset.setSquare(a);return},reset:function(a){if(this._current_arcode_index!=-1&&a==false){this.onLeaveHandler()}this._current_arcode_index=-1;return},_detectmarker_cb:null,detectMarker:function(a){NyAS3Utils.assert(this._bin_raster.getSize().isEqualSize_int(a.getSize().w,a.getSize().h));this._tobin_filter.setThreshold(this._threshold);this._tobin_filter.doFilter(a,this._bin_raster);this._detectmarker_cb.init(a,this._current_arcode_index);this._square_detect.detectMarkerCB(this._bin_raster,this._detectmarker_cb);var c=updateStatus(this._detectmarker_cb.square,this._detectmarker_cb.code_index);if(!c){var b=this._threshold_detect.analyzeRaster(a);this._threshold=(this._threshold+b)/2}return},setConfidenceThreshold:function(b,a){this._detectmarker_cb.cf_threshold_exist=a;this._detectmarker_cb.cf_threshold_new=b},__NyARSquare_result:new NyARTransMatResult(),updateStatus:function(b,c){var a=this.__NyARSquare_result;if(this._current_arcode_index<0){if(c<0){return false}else{this._current_arcode_index=c;this.onEnterHandler(c);this._transmat.transMat(b,this._offset,a);this.onUpdateHandler(b,a);this._lost_delay_count=0;return true}}else{if(c<0){this._lost_delay_count++;if(this._lost_delay<this._lost_delay_count){this._current_arcode_index=-1;this.onLeaveHandler()}return false}else{if(c==this._current_arcode_index){this._transmat.transMatContinue(b,this._offset,a);this.onUpdateHandler(b,a);this._lost_delay_count=0;return true}else{throw new NyARException()}}}},onEnterHandler:function(a){throw new NyARException("onEnterHandler not implemented.")},onLeaveHandler:function(){throw new NyARException("onLeaveHandler not implemented.")},onUpdateHandler:function(b,a){throw new NyARException("onUpdateHandler not implemented.")}});DetectSquareCB_1=ASKlass("DetectSquareCB",NyARSquareContourDetector_IDetectMarkerCallback,{square:new NyARSquare(),confidence:0,code_index:-1,cf_threshold_new:0.5,cf_threshold_exist:0.3,_ref_raster:null,_inst_patt:null,_deviation_data:null,_match_patt:null,__detectMarkerLite_mr:new NyARMatchPattResult(),_coordline:null,DetectSquareCB:function(a){this._match_patt=null;this._coordline=new NyARCoord2Linear(a.getScreenSize(),a.getDistortionFactor());return},setNyARCodeTable:function(a,c){this._deviation_data=new NyARMatchPattDeviationColorData(c,c);this._inst_patt=new NyARColorPatt_Perspective_O2(c,c,4,25);this._match_patt=new Array(a.length);for(var b=0;b<a.length;b++){this._match_patt[b]=new NyARMatchPatt_Color_WITHOUT_PCA(a[b])}},__tmp_vertex:NyARIntPoint2d.createArray(4),_target_id:0,init:function(a,b){this._ref_raster=a;this._target_id=b;this.code_index=-1;this.confidence=Number.MIN_VALUE},onSquareDetect:function(f,c,b,o,m){if(this._match_patt==null){return}var n=this.__tmp_vertex;n[0].x=c[m[0]];n[0].y=b[m[0]];n[1].x=c[m[1]];n[1].y=b[m[1]];n[2].x=c[m[2]];n[2].y=b[m[2]];n[3].x=c[m[3]];n[3].y=b[m[3]];if(!this._inst_patt.pickFromRaster(this._ref_raster,n)){return}this._deviation_data.setRaster(this._inst_patt);var d=this.__detectMarkerLite_mr;var q=0;var e=0;var l=0;var k;for(k=0;k<this._match_patt.length;k++){this._match_patt[k].evaluate(this._deviation_data,d);var g=d.confidence;if(l<g){q=k;l=g;e=d.direction}}if(this._target_id==-1){if(l<this.cf_threshold_new){return}if(this.confidence>l){return}this.code_index=q}else{if(q!=this._target_id){return}if(l<this.cf_threshold_exist){return}if(this.confidence>l){return}this.code_index=this._target_id}this.confidence=l;var a=this.square;for(k=0;k<4;k++){var p=(k+4-e)%4;this._coordline.coord2Line(m[p],m[(p+1)%4],c,b,o,a.line[k])}for(k=0;k<4;k++){if(!NyARLinear.crossPos(a.line[k],a.line[(k+3)%4],a.sqvertex[k])){throw new NyARException()}}}});SingleNyIdMarkerProcesser=ASKlass("SingleNyIdMarkerProcesser",{tag:null,_lost_delay_count:0,_lost_delay:5,_square_detect:null,_transmat:null,_offset:null,_is_active:null,_current_threshold:110,_bin_raster:null,_tobin_filter:null,_callback:null,_data_current:null,SingleNyIdMarkerProcesser:function(){return},_initialized:false,initInstance:function(a,d,b,e){NyAS3Utils.assert(this._initialized==false);var c=a.getScreenSize();this._square_detect=new NyARSquareContourDetector_Rle(c);this._transmat=new NyARTransMat(a);this._callback=new DetectSquareCB_2(a,d);this._bin_raster=new NyARBinRaster(c.w,c.h);this._data_current=d.createDataInstance();this._tobin_filter=new NyARRasterFilter_ARToolkitThreshold(110,e);this._threshold_detect=new NyARRasterThresholdAnalyzer_SlidePTile(15,e,4);this._initialized=true;this._is_active=false;this._offset=new NyARRectOffset();this._offset.setSquare(b);return},setMarkerWidth:function(a){this._offset.setSquare(a);return},reset:function(a){if(a==false&&this._is_active){this.onLeaveHandler()}this._is_active=false;return},detectMarker:function(a){if(!this._bin_raster.getSize().isEqualSize_int(a.getSize().w,a.getSize().h)){throw new NyARException()}this._tobin_filter.setThreshold(this._current_threshold);this._tobin_filter.doFilter(a,this._bin_raster);this._callback.init(a,this._is_active?this._data_current:null);this._square_detect.detectMarkerCB(this._bin_raster,this._callback);var c=updateStatus(this._callback.square,this._callback.marker_data);if(c){this._current_threshold=(this._current_threshold+this._callback.threshold)/2}else{var b=this._threshold_detect.analyzeRaster(a);this._current_threshold=(this._current_threshold+b)/2}return},_threshold_detect:null,__NyARSquare_result:new NyARTransMatResult(),updateStatus:function(c,b){var d=false;var a=this.__NyARSquare_result;if(!this._is_active){if(b==null){this._is_active=false}else{this._data_current.copyFrom(b);this.onEnterHandler(this._data_current);this._transmat.transMat(c,this._offset,a);this.onUpdateHandler(c,a);this._lost_delay_count=0;this._is_active=true;d=true}}else{if(b==null){this._lost_delay_count++;if(this._lost_delay<this._lost_delay_count){this.onLeaveHandler();this._is_active=false}}else{if(this._data_current.isEqual(b)){this._transmat.transMatContinue(c,this._offset,a);this.onUpdateHandler(c,a);this._lost_delay_count=0;d=true}else{throw new NyARException()}}}return d},onEnterHandler:function(a){throw new NyARException("onEnterHandler not implemented.")},onLeaveHandler:function(){throw new NyARException("onLeaveHandler not implemented.")},onUpdateHandler:function(b,a){throw new NyARException("onUpdateHandler not implemented.")}});DetectSquareCB_2=ASKlass("DetectSquareCB",NyARSquareContourDetector_IDetectMarkerCallback,{square:new NyARSquare(),marker_data:null,threshold:0,_ref_raster:null,_current_data:null,_id_pickup:new NyIdMarkerPickup(),_coordline:null,_encoder:null,_data_temp:null,_prev_data:null,DetectSquareCB:function(a,b){this._coordline=new NyARCoord2Linear(a.getScreenSize(),a.getDistortionFactor());this._data_temp=b.createDataInstance();this._current_data=b.createDataInstance();this._encoder=b;return},__tmp_vertex:NyARIntPoint2d.createArray(4),init:function(a,b){this.marker_data=null;this._prev_data=b;this._ref_raster=a},_marker_param:new NyIdMarkerParam(),_marker_data:new NyIdMarkerPattern(),onSquareDetect:function(e,c,b,l,g){if(this.marker_data!=null){return}var k=this.__tmp_vertex;k[0].x=c[g[0]];k[0].y=b[g[0]];k[1].x=c[g[1]];k[1].y=b[g[1]];k[2].x=c[g[2]];k[2].y=b[g[2]];k[3].x=c[g[3]];k[3].y=b[g[3]];var d=this._marker_param;var m=this._marker_data;if(!this._id_pickup.pickFromRaster(this._ref_raster,k,m,d)){return}if(!this._encoder.encode(m,this._data_temp)){return}if(this._prev_data==null){this._current_data.copyFrom(this._data_temp)}else{if(!this._prev_data.isEqual((this._data_temp))){return}}var a=this.square;var f;for(f=0;f<4;f++){var n=(f+4-d.direction)%4;this._coordline.coord2Line(g[n],g[(n+1)%4],c,b,l,a.line[f])}for(f=0;f<4;f++){if(!NyARLinear.crossPos(a.line[f],a.line[(f+3)%4],a.sqvertex[f])){throw new NyARException()}}this.threshold=d.threshold;this.marker_data=this._current_data}});TransformedBitmapPickup=ASKlass("TransformedBitmapPickup",NyARColorPatt_Perspective_O2,{_work_points:NyARIntPoint2d.createArray(4),_ref_perspective:null,TransformedBitmapPickup:function(a,d,c,b){NyARColorPatt_Perspective_O2.initialize.call(this,d,c,b,0);this._ref_perspective=a},pickupImage2d:function(g,c,t,v,k,e){var a,w,u,l,i;a=this._ref_perspective.m00;w=this._ref_perspective.m01;u=this._ref_perspective.m02;l=this._ref_perspective.m11;i=this._ref_perspective.m12;var d=this._work_points;var o,n,m;var r,b,p;var q=e.m00;var s=e.m10;var f=e.m20;o=e.m01*t+e.m03;n=e.m11*t+e.m13;m=e.m21*t+e.m23;r=q*c+o;b=s*c+n;p=f*c+m;d[0].x=toInt((r*a+b*w+p*u)/p);d[0].y=toInt((b*l+p*i)/p);r=q*v+o;b=s*v+n;p=f*v+m;d[1].x=toInt((r*a+b*w+p*u)/p);d[1].y=toInt((b*l+p*i)/p);o=e.m01*k+e.m03;n=e.m11*k+e.m13;m=e.m21*k+e.m23;r=q*v+o;b=s*v+n;p=f*v+m;d[2].x=toInt((r*a+b*w+p*u)/p);d[2].y=toInt((b*l+p*i)/p);r=q*c+o;b=s*c+n;p=f*c+m;d[3].x=toInt((r*a+b*w+p*u)/p);d[3].y=toInt((b*l+p*i)/p);return this.pickFromRaster(g,d)}});