From 6a48fca4c45b6f4c80bfa8bcacbed5abd0e69ec2 Mon Sep 17 00:00:00 2001 From: alemart <221477+alemart@users.noreply.github.com> Date: Tue, 2 Jul 2024 23:16:51 -0300 Subject: [PATCH] Update scripts --- dist/speedy-vision.js | 8 ++++---- dist/speedy-vision.min.js | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/speedy-vision.js b/dist/speedy-vision.js index 3fa5320f..e53a29f9 100644 --- a/dist/speedy-vision.js +++ b/dist/speedy-vision.js @@ -5,7 +5,7 @@ * https://github.com/alemart/speedy-vision * * @license Apache-2.0 - * Date: 2024-07-03T01:32:00.614Z + * Date: 2024-07-03T02:16:25.769Z */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') @@ -9067,8 +9067,8 @@ class SpeedyVideoMediaSource extends SpeedyMediaSource { */ _load(video) { if (this.isLoaded()) this.release(); - setTimeout(() => video.load()); // tweak for slow connections - + utils/* Utils */.A.log('Loading a video...'); + video.load(); return SpeedyVideoMediaSource._waitUntilPlayable(video).then(() => { return SpeedyVideoMediaSource._handleAutoplay(video).then(() => { this._data = video; @@ -9123,7 +9123,7 @@ class SpeedyVideoMediaSource extends SpeedyMediaSource { * @returns {SpeedyPromise} resolves to the input video when it can be played */ static _waitUntilPlayable(video) { - const TIMEOUT = 15000, + const TIMEOUT = 30000, INTERVAL = 500; if (video.readyState >= 3) return speedy_promise/* SpeedyPromise */.i.resolve(video); return new speedy_promise/* SpeedyPromise */.i((resolve, reject) => { diff --git a/dist/speedy-vision.min.js b/dist/speedy-vision.min.js index 15d2f266..2cdb290b 100644 --- a/dist/speedy-vision.min.js +++ b/dist/speedy-vision.min.js @@ -5,6 +5,6 @@ * https://github.com/alemart/speedy-vision * * @license Apache-2.0 - * Date: 2024-07-03T01:32:05.725Z + * Date: 2024-07-03T02:16:30.277Z */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Speedy=t():e.Speedy=t()}(self,(()=>(()=>{var e={2199:(e,t,n)=>{"use strict";n.d(t,{w:()=>d});var i=n(6634),o=n(1001),s=n(9037),r=n(8581);let A="raf",a="default";class d extends i.Q{static get powerPreference(){return o.c.powerPreference}static set powerPreference(e){o.c.powerPreference=e}static get gpuPollingMode(){return A}static set gpuPollingMode(e){if("raf"!==e&&"asap"!==e)throw new r.qw(`Invalid GPU polling mode: "${e}"`);A=e}static get logging(){return a}static set logging(e){if("default"!==e&&"none"!==e&&"diagnostic"!==e)throw new r.qw(`Invalid logging mode: "${e}"`);"diagnostic"===e&&s.A.log("%c DIAGNOSTIC MODE ","background:red;color:white;font-size:36pt;font-weight:bold"),a=e}}},6306:(e,t,n)=>{"use strict";n.d(t,{r:()=>A});var i=n(6465),o=n(9037),s=n(8581);const r=Object.freeze({float32:Float32Array});class A{constructor(e,t,n){o.A.assert(e>0&&t>0),o.A.assert(n===A.DEFAULT_DTYPE),this._rows=0|e,this._columns=0|t,this._dtype=n}get rows(){return this._rows}get columns(){return this._columns}get dtype(){return this._dtype}static get DEFAULT_DTYPE(){return"float32"}static get BUFFER_TYPE(){return r}plus(e){return new u(this,e)}minus(e){return new I(this,e)}times(e){return"number"==typeof e?new p(this,e):new f(this,e)}transpose(){return new g(this)}inverse(){return new h(this)}compMult(e){return new m(this,e)}ldiv(e){return new C(this,e)}toString(){return`SpeedyMatrixExpr(rows=${this.rows}, columns=${this.columns})`}_evaluate(e,t){throw new s.aQ}}const{SpeedyMatrix:a}=n(4188);class d extends A{constructor(e,t,n){super(e,t,n),this._tempMatrix=a.Zeros(this.rows,this.columns,this.dtype)}}class c extends d{constructor(e,t,n){super(e,t,n.dtype),this._operand=n}_evaluate(e,t){const n=this._operand._evaluate(e,t),o=this._tempMatrix,s=i.U.allocateMat32(e,t,o),r=i.U.allocateMat32(e,t,n);return i.U.copyToMat32(e,t,r,n),this._compute(e,t,s,r),i.U.copyFromMat32(e,t,s,o),i.U.deallocateMat32(e,t,r),i.U.deallocateMat32(e,t,s),o}_compute(e,t,n,i){throw new s.aQ}}class l extends d{constructor(e,t,n,i){o.A.assert(n.dtype===i.dtype),super(e,t,n.dtype),this._left=n,this._right=i}_evaluate(e,t){const n=this._left._evaluate(e,t),o=this._right._evaluate(e,t),s=this._tempMatrix,r=i.U.allocateMat32(e,t,s),A=i.U.allocateMat32(e,t,n),a=i.U.allocateMat32(e,t,o);return i.U.copyToMat32(e,t,A,n),i.U.copyToMat32(e,t,a,o),this._compute(e,t,r,A,a),i.U.copyFromMat32(e,t,r,s),i.U.deallocateMat32(e,t,a),i.U.deallocateMat32(e,t,A),i.U.deallocateMat32(e,t,r),s}_compute(e,t,n,i,o){throw new s.aQ}}class g extends c{constructor(e){super(e.columns,e.rows,e)}_compute(e,t,n,i){e.exports.Mat32_transpose(n,i)}}class h extends c{constructor(e){o.A.assert(e.rows===e.columns),super(e.rows,e.columns,e),this._size=e.rows}_compute(e,t,n,i){switch(this._size){case 0:break;case 1:e.exports.Mat32_inverse1(n,i);break;case 2:e.exports.Mat32_inverse2(n,i);break;case 3:e.exports.Mat32_inverse3(n,i);break;default:e.exports.Mat32_qr_inverse(n,i)}}}class p extends c{constructor(e,t){super(e.rows,e.columns,e),this._scalar=+t}_compute(e,t,n,i){e.exports.Mat32_scale(n,i,this._scalar)}}class u extends l{constructor(e,t){o.A.assert(e.rows===t.rows&&e.columns===t.columns),super(e.rows,e.columns,e,t)}_compute(e,t,n,i,o){e.exports.Mat32_add(n,i,o)}}class I extends l{constructor(e,t){o.A.assert(e.rows===t.rows&&e.columns===t.columns),super(e.rows,e.columns,e,t)}_compute(e,t,n,i,o){e.exports.Mat32_subtract(n,i,o)}}class f extends l{constructor(e,t){o.A.assert(e.columns===t.rows),super(e.rows,t.columns,e,t)}_compute(e,t,n,i,o){e.exports.Mat32_multiply(n,i,o)}}class m extends l{constructor(e,t){o.A.assert(e.rows===t.rows&&e.columns===t.columns),super(t.rows,t.columns,e,t)}_compute(e,t,n,i,o){e.exports.Mat32_compmult(n,i,o)}}class C extends l{constructor(e,t){const n=e.rows,i=e.columns;o.A.assert(n>=i&&t.rows===n&&1===t.columns),super(i,1,e,t)}_compute(e,t,n,i,o){e.exports.Mat32_qr_ols(n,i,o,2)}}},6465:(e,t,n)=>{"use strict";n.d(t,{U:()=>h});var i=n(9192),o=n(8581),s=n(9037),r=n(3816);const A=n(3575);let a=null,d=null;const c={as:{object:l="undefined"==typeof WebAssembly?new Uint8Array(1024):new WebAssembly.Memory({initial:16,maximum:256}),uint8:new Uint8Array(l.buffer),int32:new Int32Array(l.buffer),uint32:new Uint32Array(l.buffer),float32:new Float32Array(l.buffer),float64:new Float64Array(l.buffer)}};var l,g;class h{static ready(){return"undefined"==typeof WebAssembly?i.i.reject(new o.EM("This application requires WebAssembly. Please update your system.")):r.LITTLE_ENDIAN?new i.i(((e,t)=>{h._ready(e,t)})):i.i.reject(new o.EM("Can't run WebAssembly code: not in a little-endian machine!"))}static get handle(){if(!a||!d)throw new o.NO("Can't get WASM handle: routines not yet loaded");return{wasm:a,memory:c,module:d}}static imports(e){const t=new p(e);return Object.getOwnPropertyNames(p.prototype).filter((e=>"function"==typeof t[e]&&"constructor"!==e)).reduce(((e,n)=>(e[n]=t[n],e)),Object.create(null))}static allocateMat32(e,t,n){const i=e.exports.malloc(n.data.byteLength);return e.exports.Mat32_create(n.rows,n.columns,n.step0,n.step1,n._data.length,i)}static deallocateMat32(e,t,n){const i=e.exports.Mat32_data(n);return e.exports.free(n),e.exports.free(i),0}static copyToMat32(e,t,n,i){s.A.assert(i.data.byteLength===e.exports.Mat32_dataSize(n));const o=e.exports.Mat32_data(n);return t.as.float32.set(i.data,o/Float32Array.BYTES_PER_ELEMENT),n}static copyFromMat32(e,t,n,i){s.A.assert(i.data.byteLength===e.exports.Mat32_dataSize(n));const o=e.exports.Mat32_data(n)/Float32Array.BYTES_PER_ELEMENT;for(let e=i.data.length-1;e>=0;e--)i.data[e]=t.as.float32[o+e];return n}static _ready(e,t,n=1e3){null!==a&&null!==d?e({wasm:a,memory:c,module:d}):n<=0?t(new o.MU("Can't load WASM routines")):setTimeout(h._ready,0,e,t,n-1)}}class p{constructor(e){return Object.getOwnPropertyNames(this.constructor.prototype).filter((e=>"function"==typeof this[e])).filter((e=>"constructor"!==e)).forEach((e=>{this[e]=this[e].bind(this)})),this.memory=e,this.cstring=new u(e),Object.freeze(this)}print(e){s.A.log(this.cstring.get(e))}fatal(e){throw new o.NO(this.cstring.get(e))}bytefill(e,t,n){this.memory.as.uint8.fill(e,t,n)}copyWithin(e,t,n){this.memory.as.uint8.copyWithin(e,t,n)}}class u{constructor(e){this._decoder=new TextDecoder("utf-8"),this._memory=e}get(e){const t=this._memory.as.uint8,n=this._memory.as.uint8.byteLength;let i=e;for(;i(e=>Uint8Array.from(atob(e),(e=>e.charCodeAt(0))))(e))).then((e=>WebAssembly.instantiate(e,{env:Object.assign({memory:g.as.object},h.imports(g))}))).then((e=>{a=e.instance,d=e.module,e.instance.exports.srand(.001*Date.now()&4294967295),s.A.log("The WebAssembly routines have been loaded!")})).catch((e=>{throw new o.NO(`Can't load the WebAssembly routines: ${e}`,e)}))},4188:(e,t,n)=>{"use strict";n.r(t),n.d(t,{SpeedyMatrix:()=>A});var i=n(6306),o=n(6465),s=n(9192),r=n(9037);class A extends i.r{constructor(e,t,n,o,s){super(e,t,i.r.DEFAULT_DTYPE),r.A.assert(s.constructor===i.r.BUFFER_TYPE[this.dtype]),r.A.assert(n>0&&o>=n),r.A.assert(s.length+e*t===0||s.length===1+n*(e-1)+o*(t-1)),this._step0=0|n,this._step1=0|o,this._data=s}static Create(e,t,n,o=i.r.DEFAULT_DTYPE){return r.A.assert(e*t>0,"Can't create a matrix without a shape"),r.A.assert(e*t===n.length,`Can't create matrix: expected ${e*t} entries, but found ${n.length}`),r.A.assert(Object.prototype.hasOwnProperty.call(i.r.BUFFER_TYPE,o),`Invalid dtype: "${o}"`),new A(e,t,1,e,Reflect.construct(i.r.BUFFER_TYPE[o],[n]))}static Zeros(e,t=e,n=i.r.DEFAULT_DTYPE){return r.A.assert(e*t>0,"Can't create a matrix without a shape"),r.A.assert(Object.prototype.hasOwnProperty.call(i.r.BUFFER_TYPE,n),`Invalid dtype: "${n}"`),new A(e,t,1,e,Reflect.construct(i.r.BUFFER_TYPE[n],[e*t]))}static Ones(e,t=e,n=i.r.DEFAULT_DTYPE){return r.A.assert(e*t>0,"Can't create a matrix without a shape"),r.A.assert(Object.prototype.hasOwnProperty.call(i.r.BUFFER_TYPE,n),`Invalid dtype: "${n}"`),new A(e,t,1,e,Reflect.construct(i.r.BUFFER_TYPE[n],[e*t]).fill(1))}static Eye(e,t=e,n=i.r.DEFAULT_DTYPE){r.A.assert(e*t>0,"Can't create a matrix without a shape"),r.A.assert(Object.prototype.hasOwnProperty.call(i.r.BUFFER_TYPE,n),`Invalid dtype: "${n}"`);const o=Reflect.construct(i.r.BUFFER_TYPE[n],[e*t]);for(let n=Math.min(e,t)-1;n>=0;n--)o[n*e+n]=1;return new A(e,t,1,e,o)}static From(e){return A.Zeros(e.rows,e.columns,e.dtype).setToSync(e)}static ready(){return o.U.ready().then((e=>{}))}get data(){return this._data}get step0(){return this._step0}get step1(){return this._step1}block(e,t,n,i){r.A.assert(e<=t&&n<=i,`Invalid indices: [${e}:${t},${n}:${i}]`),e=Math.max(e,0),t=Math.min(t,this._rows-1),n=Math.max(n,0);const o=t-e+1,s=(i=Math.min(i,this._columns-1))-n+1,a=this._step0,d=this._step1,c=e*a+n*d,l=1+t*a+i*d;return new A(o,s,a,d,this._data.subarray(c,l))}row(e){return this.block(e,e,0,this._columns-1)}column(e){return this.block(0,this._rows-1,e,e)}diagonal(){const e=Math.min(this._rows,this._columns),t=e,n=this._step0+this._step1,i=1+(e-1)*n;return new A(t,1,n,n,this._data.subarray(0,i))}at(e,t){return e>=0&&e=0&&te.toFixed(5);return`SpeedyMatrix(rows=${e}, columns=${t}, data=[\n${i.map((e=>" "+e.map(o).join(", "))).join(",\n")}\n])`}setTo(e){return o.U.ready().then((t=>this.setToSync(e)))}setToSync(e){const{wasm:t,memory:n}=o.U.handle,i=e._evaluate(t,n);r.A.assert(this._rows===i._rows&&this._columns===i._columns&&this.dtype===i.dtype,`Can't set the values of a ${this.rows} x ${this.columns} ${this.dtype} matrix to those of a ${i.rows} x ${i.columns} ${i.dtype} matrix`);const s=this._step0,A=this._step1,a=i._step0,d=i._step1;if(s===a&&A===d&&this._data.length===i._data.length)this._data.set(i._data);else for(let e=this._columns-1;e>=0;e--)for(let t=this._rows-1;t>=0;t--)this._data[t*s+e*A]=i._data[t*a+e*d];return this}fill(e){return this.fillSync(e),s.i.resolve(this)}fillSync(e){if(e=+e,this._rows*this._columns===this._data.length)return this._data.fill(e),this;for(let t=0;t{"use strict";n.d(t,{Q:()=>o});var i=n(8581);class o{constructor(){throw new i.aQ("Namespaces can't be instantiated")}}},9192:(e,t,n)=>{"use strict";n.d(t,{i:()=>o});const i="undefined"!=typeof queueMicrotask&&queueMicrotask||"undefined"!=typeof process&&process.nextTick||(e=>Promise.resolve().then((()=>e())));class o{constructor(e){this._state=0,this._value=void 0,this._onFulfillment=null,this._onRejection=null,this._children=0,this[0]=this,this._parent=void 0,this._flags=0,this._fulfill=this._fulfill.bind(this),this._reject=this._reject.bind(this),this._resolve=this._resolve.bind(this),this._broadcastIfAsync=this._broadcastIfAsync.bind(this),e(this._fulfill,this._reject)}then(e,t=null){const n=new o(this._nop);return n._onFulfillment="function"==typeof e&&e,n._onRejection="function"==typeof t&&t,n._parent=this,this[this._children++]=n,this._flags&=-2,this._notify(),n}catch(e){return this.then(null,e)}finally(e){const t=t=>(e(),t);return this.then(t,t)}turbocharge(){let e=this;for(this._flags|=1;void 0!==e._parent;)e=e._parent,e._flags|=1;return e._notify(),this}toString(){switch(this._state){case 0:return"SpeedyPromise { }";case 1:return`SpeedyPromise { ${this._value} }`;case 2:return`SpeedyPromise { ${this._value} }`;default:return""}}get[Symbol.toStringTag](){return"SpeedyPromise"}static resolve(e){const t=new o(this._snop);return"object"==typeof e&&null!==e&&"then"in e||"function"==typeof e&&"then"in e?t._resolve(e):(t._value=e,t._state=1),t}static reject(e){const t=new o(this._snop);return t._value=e,t._state=2,t}static all(e){return new o(((t,n)=>{const i=[];for(const t of e)i.push(t);const s=i.length;if(0==s)return void t([]);let r=s;const A=new Array(s),a=e=>n=>{A[e]=n,0==--r&&t(A)};for(let e=0;e{const i=[];for(const t of e)i.push(t);const s=i.length;for(let e=0;e{n(e),n=i=this._nop}),(e=>{i(e),n=i=this._nop}))}catch(e){n!==this._nop&&i!==this._nop&&this._reject(e)}}else this._fulfill(e)}catch(e){this._reject(e)}else e.then(this._resolve,this._reject)}}_nop(){}static _snop(){}}},9420:(e,t,n)=>{"use strict";n.d(t,{gx:()=>D,bf:()=>b});var i=n(1001),o=n(9037),s=n(6049),r=n(8581);function A(){A=function(e,t){return new n(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function n(e,i,o){var s=RegExp(e,i);return t.set(s,o||t.get(e)),a(s,n.prototype)}function i(e,n){var i=t.get(n);return Object.keys(i).reduce((function(t,n){var o=i[n];if("number"==typeof o)t[n]=e[o];else{for(var s=0;void 0===e[o[s]]&&s+1]+)>/g,(function(e,t){var n=s[t];return"$"+(Array.isArray(n)?n.join("$"):n)})))}if("function"==typeof o){var r=this;return e[Symbol.replace].call(this,n,(function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(i(e,r)),o.apply(this,e)}))}return e[Symbol.replace].call(this,n,o)},A.apply(this,arguments)}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}const d=n(3816),c=Object.keys(d).filter((e=>"number"==typeof d[e])).reduce(((e,t)=>(e[t]=d[t],e)),{}),l=Object.freeze(Object.assign(Object.assign({},c),{},{FS_USE_CUSTOM_PRECISION:0,FS_OUTPUT_TYPE:0,PIXELCOMPONENT_RED:s.kQ.RED,PIXELCOMPONENT_GREEN:s.kQ.GREEN,PIXELCOMPONENT_BLUE:s.kQ.BLUE,PIXELCOMPONENT_ALPHA:s.kQ.ALPHA})),g=[/\/\*(.|\s)*?\*\//g,/\/\/.*$/gm],h=/^\s*@\s*include\s+"(.*?)"/gm,p=/@(\w+)@/g,u=[A(/@\s*unroll\s+?for\s*\(\s*(int|)\s*(\w+)\s*=\s*(\x2D?\d+|\w+)\s*;\s*\2\s*(<=?)\s*(\x2D?\d+|\w+)\s*;\s*\2\s*\+\+()\s*\)\s*\{\s*([\s\S]+?)\s*\}/g,{counter:2}),A(/@\s*unroll\s+?for\s*\(\s*(int|)\s*(\w+)\s*=\s*(\x2D?\d+|\w+)\s*;\s*\2\s*(<=?)\s*(\x2D?\d+|\w+)\s*;\s*\2\s*\+=\s*(\x2D?\d+)\s*\)\s*\{\s*([\s\S]+?)\s*\}/g,{counter:2})];class I{static generateGLSL(e,t,n=null,s=null){const r=[],A=function(e){o.A.assert(i.c.isInitialized());const t=new Map,n=Object.assign(Object.create(null),l,(s=o.A.platformString(),r=i.c.instance.renderer,Object.freeze({APPLE:0|/(Mac|iOS|iPhone|iPad|iPod)/i.test(s),APPLE_GPU:0|/Apple/.test(r),INTEL_GRAPHICS:0|/Intel.*Graphics/.test(r)})));var s,r;for(const e in n)t.set(e,n[e]);for(const[n,i]of e)t.set(n,i);return t}(e),a=function(e,t,n=null,i=null){const o=[];null!==n&&o.push(n);for(const[t,n]of e)o.push(`#define ${t} ${Number(n)}`);o.push(t),null!==i&&o.push(i);return o.join("\n")}(e,t,n,s);return function(e,t){const n=m.bind(t),i=u.length;for(let t=0;tString(A.has(t)?Number(A.get(t)):(r.push(`Undefined constant ${t}`),0)))).replace(h,((t,n)=>I.generateGLSL(e,f(n)))),e)+r.map((e=>`\n#error ${e}\n`)).join("")}}function f(e){if(String(e).match(/^[a-zA-Z0-9_-]+\.glsl$/))return n(5235)("./"+e);throw new r.kG(`Shader preprocessor: can't read file "${e}"`)}function m(e,t,n,i,s,A,a,d){const c=this,l=Number.isFinite(+i)||c.has(i),g=Number.isFinite(+A)||c.has(A);if(!l||!g){if(c.size>0)throw new r.mB(`Can't unroll loop: unknown limits (start=${i}, end=${A}). Code:\n\n${e}`);return e}let h=c.has(i)?c.get(i):parseInt(i),p=c.has(A)?c.get(A):parseInt(A),u=0==a.length?1:parseInt(a);o.A.assert(h<=p&&u>0);let I=null!==d.match(/\bbreak\s*;/)?"switch(1) { default:\n":"{\n";I+=`${t} ${n};\n`,p+="<="==s?1:0;for(let e=h;ee.trim())).filter((e=>e));for(const n of t)if(n.endsWith("]")){if(!(o=n.match(/(\w+)\s*\[\s*(\d+)\s*\]$/)))throw new r.mB(`Unspecified array length for uniform "${n}" in the shader`);const[t,s]=[o[1],Number(o[2])];for(let n=0;n0)throw new r.Er("Redefinition of shader arguments");for(let t=0;t0)throw new r.Er("Redefinition of externally defined constants of a shader");const t=Object.keys(e);for(const n of t){const t=Number(e[n]);this._defines.set(n,t)}return this}build(){throw new r.aQ}}class Q extends v{constructor(e,t,n){super(e),this._fsSource=String(t),this._vsSource=void 0!==n?String(n):void 0}build(){return new P(_,this._arguments,this._defines,this._fsSource,this._vsSource)}}class w extends v{constructor(e,t,n){super(e),this._fsFilepath=String(t),this._vsFilepath=void 0!==n?String(n):void 0}build(){return new B(_,this._arguments,this._defines,this._fsFilepath,this._vsFilepath)}}function b(e,t=void 0){return new w(_,e,t)}function D(e,t=void 0){return new Q(_,e,t)}},1672:(e,t,n)=>{"use strict";n.r(t),n.d(t,{conv2D:()=>r,convX:()=>A,convY:()=>a});var i=n(9420),o=n(9037),s=n(8581);function r(e,t=1){const n=new Float32Array(e.map((e=>+e*+t))),r=0|Math.sqrt(n.length),A=r>>1;if(r<1||r%2==0)throw new s.qw(`Can't perform a 2D convolution with an invalid kSize of ${r}`);if(r*r!=n.length)throw new s.qw(`Invalid 2D convolution kernel of ${n.length} elements (expected: square)`);const a=A<=7?"pixelAtShortOffset":"pixelAtLongOffset",d=`\n uniform sampler2D image;\n\n void main()\n {\n float alpha = threadPixel(image).a;\n vec4 result = vec4(0.0f);\n\n ${c=(e,t,n)=>`\n result += ${a}(image, ivec2(${0|-n}, ${0|-t})) * float(${+e});\n `,o.A.cartesian(o.A.symmetricRange(A),o.A.symmetricRange(A)).map((e=>c(n[(e[0]+A)*r+(e[1]+A)],e[0],e[1]))).join("\n")}\n\n color = vec4(result.rgb, alpha);\n }\n `;var c;return(0,i.gx)(d).withArguments("image")}function A(e,t=1){return d("x",e,t)}function a(e,t=1){return d("y",e,t)}function d(e,t,n=1){const r=new Float32Array(t.map((e=>+e*+n))),A=r.length,a=A>>1;if(A<1||A%2==0)throw new s.qw(`Can't perform a 1D convolution with an invalid kSize of ${A}`);if("x"!=e&&"y"!=e)throw new s.qw(`Can't perform 1D convolution: invalid axis "${e}"`);const d=a<=7?"pixelAtShortOffset":"pixelAtLongOffset",c=`\n uniform sampler2D image;\n\n void main()\n {\n float alpha = threadPixel(image).a;\n vec4 pixel = vec4(0.0f);\n\n ${l=(t,n)=>"x"==e?`\n pixel += ${d}(image, ivec2(${0|-n}, 0)) * float(${+t});\n `:`\n pixel += ${d}(image, ivec2(0, ${0|-n})) * float(${+t});\n `,o.A.symmetricRange(a).reduce(((e,t)=>e+l(r[t+a],t)),"")}\n\n color = vec4(pixel.rgb, alpha);\n }\n `;var l;return(0,i.gx)(c).withArguments("image")}},1001:(e,t,n)=>{"use strict";n.d(t,{c:()=>l});var i=n(9037),o=n(2199),s=n(3211),r=n(9192),A=n(8581);const a=Symbol();let d=null,c="default";class l extends s.c{constructor(e){i.A.assert(e===a),super(),this._reinitializeOnContextLoss=!0,this._canvas=this._createCanvas(this._reinitialize.bind(this)),this._gl=this._createContext(this._canvas),this._vendor="",this._renderer="",this._readDriverInfo(),"diagnostic"===o.w.logging&&this._logDriverInfo()}static get instance(){return d||(d=new l(a))}get gl(){return this._gl}get canvas(){return this._canvas}get renderer(){return this._renderer}get vendor(){return this._vendor}_createCanvas(e){const t=i.A.createCanvas(16,16);return t.addEventListener("webglcontextlost",(t=>{i.A.warning("Lost WebGL2 context"),setTimeout(e,0),t.preventDefault()}),!1),t}_createContext(e){if(i.A.log(`Creating a ${c} WebGL2 rendering context...`),"undefined"==typeof WebGL2RenderingContext)throw new A.EM("This application requires WebGL2. Please update your system.");const t=e.getContext("webgl2",{premultipliedAlpha:!1,preserveDrawingBuffer:!1,powerPreference:c,alpha:!0,antialias:!1,depth:!1,stencil:!1,desynchronized:!0});if(!t)throw new A.EM("Can't create a WebGL2 Rendering Context. Try a different browser!");return t}_reinitialize(){this._reinitializeOnContextLoss&&(i.A.warning("Reinitializing WebGL2..."),this._canvas.remove(),this._canvas=this._createCanvas(this._reinitialize.bind(this)),this._gl=this._createContext(this._canvas),this._readDriverInfo(),this._notify())}_readDriverInfo(){const e=this._gl;let t=null;navigator.userAgent.includes("Firefox")?(this._vendor="",this._renderer=e.getParameter(e.RENDERER)):null!=(t=e.getExtension("WEBGL_debug_renderer_info"))?(this._vendor=e.getParameter(t.UNMASKED_VENDOR_WEBGL),this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL)):(this._vendor="",this._renderer="")}_logDriverInfo(){i.A.log("Platform: "+i.A.platformString()),i.A.log("GL vendor: "+this.vendor),i.A.log("GL renderer: "+this.renderer)}loseContext(){const e=this._gl,t=e.getExtension("WEBGL_lose_context");if(!t)throw new A.EM("WEBGL_lose_context extension is unavailable");return e.isContextLost()||(this._reinitializeOnContextLoss=!1,t.loseContext()),t}loseAndRestoreContext(e=1){const t=1e3*Math.max(e,0),n=this.loseContext();return new r.i((e=>{setTimeout((()=>{this._reinitializeOnContextLoss=!0,this._reinitialize(),setTimeout((()=>e(n)),0)}),t)}))}static get powerPreference(){return c}static set powerPreference(e){if("default"!==e&&"low-power"!==e&&"high-performance"!==e)throw new A.qw(`Invalid powerPreference: "${e}"`);null!=d&&c===e||(c=e,null!=d&&d.loseAndRestoreContext())}static isInitialized(){return null!=d}}},8581:(e,t,n)=>{"use strict";n.d(t,{EM:()=>o,Er:()=>a,FJ:()=>l,MU:()=>g,NO:()=>I,Uk:()=>u,aQ:()=>r,kG:()=>c,l:()=>d,mB:()=>h,pf:()=>p,qw:()=>A,wB:()=>s,xB:()=>i});class i extends Error{constructor(e,t=null){super([e,t?t.toString():"[speedy-vision.js]"].join("\n-> ")),this._cause=t}get name(){return this.constructor.name}set name(e){}get cause(){return this._cause}}class o extends i{constructor(e="",t=null){super(`Unsupported operation. ${e}`,t)}}class s extends i{constructor(e="",t=null){super(`WebGL error. ${e}`,t)}static from(e){const t=e.getError(),n=["NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL"].find((n=>e[n]==t))||"Unknown";return new s(n)}}class r extends i{constructor(e="",t=null){super(`Can't call abstract method. ${e}`,t)}}class A extends i{constructor(e="",t=null){super(`Illegal argument. ${e}`,t)}}class a extends i{constructor(e="",t=null){super(`Illegal operation. ${e}`,t)}}class d extends i{constructor(e="",t=null){super(`Out of memory. ${e}`,t)}}class c extends i{constructor(e="",t=null){super(`File not found. ${e}`,t)}}class l extends i{constructor(e="",t=null){super(`Resource not loaded. ${e}`,t)}}class g extends i{constructor(e="",t=null){super(`Timeout error. ${e}`,t)}}class h extends i{constructor(e="",t=null){super(`Parse error. ${e}`,t)}}class p extends i{constructor(e="",t=null){super(`Assertion failed. ${e}`,t)}}class u extends i{constructor(e="",t=null){super(`Access denied. ${e}`,t)}}class I extends i{constructor(e="",t=null){super(`WebAssembly error. ${e}`,t)}}},3816:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DEFAULT_ENCODER_CAPACITY:()=>g,FIX_BITS:()=>r,FIX_RESOLUTION:()=>A,LITTLE_ENDIAN:()=>C,LOG2_MAX_DESCRIPTOR_SIZE:()=>h,LOG2_PYRAMID_MAX_SCALE:()=>o,MATCH_INDEX_BITS:()=>u,MATCH_INDEX_MASK:()=>I,MATCH_MAX_DISTANCE:()=>m,MATCH_MAX_INDEX:()=>f,MAX_DESCRIPTOR_SIZE:()=>p,MAX_ENCODER_CAPACITY:()=>l,MAX_TEXTURE_LENGTH:()=>a,MIN_ENCODER_LENGTH:()=>c,MIN_KEYPOINT_SIZE:()=>d,PYRAMID_MAX_LEVELS:()=>i,PYRAMID_MAX_SCALE:()=>s});const i=8,o=0,s=1<{"use strict";n.d(t,{c:()=>i});class i{constructor(){this._subscribers=[],this._thisptr=[],this._args=[]}subscribe(e,t,...n){this._subscribers.push(e),this._thisptr.push(t),this._args.push(n)}unsubscribe(e,t){for(let n=this._subscribers.length-1;n>=0;n--)if(this._subscribers[n]===e&&this._thisptr[n]===t){this._subscribers.splice(n,1),this._thisptr.splice(n,1),this._args.splice(n,1);break}}_notify(){for(let e=0;e{"use strict";n.d(t,{f5:()=>o,kQ:()=>s,kg:()=>r,zu:()=>i});const i=Object.freeze({Image:Symbol("Image"),Video:Symbol("Video"),Canvas:Symbol("Canvas"),OffscreenCanvas:Symbol("OffscreenCanvas"),Bitmap:Symbol("Bitmap"),Data:Symbol("Data")}),o=Object.freeze({RGBA:Symbol("RGBA"),GREY:Symbol("GREY")}),s=Object.freeze({RED:1,GREEN:2,BLUE:4,ALPHA:8,ALL:15}),r=Object.freeze({[s.RED]:0,[s.GREEN]:1,[s.BLUE]:2,[s.ALPHA]:3})},9037:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});var i=n(8581),o=n(9192),s=n(2199);class r{static warning(e,...t){"none"!==s.w.logging&&console.warn("[speedy-vision] "+e,...t)}static log(e,...t){"none"!==s.w.logging&&console.log("[speedy-vision] "+e,...t)}static assert(e,t=""){if(!e)throw new i.pf(t)}static functionArguments(e){const t=e.toString(),n=t.startsWith("function")?"function\\s.*\\(([^)]*)\\)":t.startsWith("(")?"\\(([^)]*)\\).*=>":"([^=]+).*=>",o=new RegExp(n).exec(t);if(null!==o){return o[1].replace(/\/\*.*?\*\//g,"").split(",").map((e=>e.replace(/=.*$/,"").trim())).filter((e=>e))}throw new i.mB(`Can't detect function arguments of ${t}`)}static getAllPropertyDescriptors(e){if(e){const t=Object.getPrototypeOf(e);return Object.assign(Object.assign({},r.getAllPropertyDescriptors(t)),Object.getOwnPropertyDescriptors(e))}return Object.create(null)}static createCanvas(e,t){const n=document.createElement("canvas");return n.width=e,n.height=t,n}static gaussianKernel(e,t=0,n=!0){if(0==t&&(t=0|Math.ceil(5*e),t+=1-t%2),(t|=0)<1||t%2==0)throw new i.qw(`Invalid kernel size given to gaussianKernel: ${t} x 1`);if(e<=0)throw new i.qw(`Invalid sigma given to gaussianKernel: ${e}`);const o=new Array(t),s=t>>1,r=1.4142135623730951*+e,A=.3275911,a=.254829592,d=-.284496736,c=1.421413741,l=-1.453152027,g=1.061405429;let h=0;for(let e=0;e=1&&n%2==1);let i=new Array(n*n),o=0;for(let s=0;st.map((t=>[e,t])))))}static symmetricRange(e){if((e|=0)<0)throw new i.qw("Expected a non-negative integer as input");return[...Array(2*e+1).keys()].map((t=>t-e))}static range(e){if((e|=0)<=0)throw new i.qw("Expected a positive integer as input");return[...Array(e).keys()]}static shuffle(e){const t=e.length,n=t-1;for(let i=0;i>10,n=1023&e,i=1-2*((65535&e)>>15);if(0==t)return 0==n?0*i:i*n*5.960464477539063e-8;if(31==t)return 0==n?i*Number.POSITIVE_INFINITY:Number.NaN;return i*(t>=15?1<{navigator.mediaDevices.getUserMedia(e).then((n=>{const i=document.createElement("video");i.onloadedmetadata=()=>{i.play(),r.log(`The camera is on! Resolution: ${i.videoWidth} x ${i.videoHeight}`),t(i)},i.setAttribute("playsinline",""),i.setAttribute("autoplay",""),!1!==e.audio&&void 0!==e.audio||i.setAttribute("muted",""),i.srcObject=n})).catch((t=>{"NotAllowedError"===t.name?n(new i.Uk("Please give access to the camera and reload the page.",t)):"OverconstrainedError"===t.name||"NotFoundError"===t.name?n(new i.EM(`Can't access the webcam with the requested constraints: ${JSON.stringify(e)}.`,t)):n(new i.xB("Can't access the webcam.",t))}))}))}static formatBinaryData(e){const t=new Uint8Array(e);return Array.from(t,(e=>e.toString(16).padStart(2,"0"))).join(" ")}static platformString(){return"object"==typeof navigator.userAgentData?navigator.userAgentData.platform:navigator.platform}}},5235:(e,t,n)=>{var i={"./colors.glsl":8609,"./filters.glsl":4672,"./fixed-point.glsl":9778,"./float16.glsl":8710,"./global.glsl":2434,"./int32.glsl":439,"./keypoint-descriptors.glsl":8545,"./keypoint-matches.glsl":6762,"./keypoints.glsl":7639,"./math.glsl":431,"./platform.glsl":6822,"./pyramids.glsl":2728,"./subpixel.glsl":6823};function o(e){var t=s(e);return n(t)}function s(e){if(!n.o(i,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return i[e]}o.keys=function(){return Object.keys(i)},o.resolve=s,e.exports=o,o.id=5235},4606:(e,t,n)=>{var i={"./filters/convolution":1672,"./filters/convolution.js":1672,"./filters/convolution1d.glsl":8211,"./filters/convolution2d.glsl":7360,"./filters/fast-median.glsl":8191,"./filters/nightvision.glsl":4438,"./filters/normalize-image.glsl":5867,"./filters/rgb2grey.glsl":9252,"./include/colors.glsl":8609,"./include/filters.glsl":4672,"./include/fixed-point.glsl":9778,"./include/float16.glsl":8710,"./include/global.glsl":2434,"./include/int32.glsl":439,"./include/keypoint-descriptors.glsl":8545,"./include/keypoint-matches.glsl":6762,"./include/keypoints.glsl":7639,"./include/math.glsl":431,"./include/platform.glsl":6822,"./include/pyramids.glsl":2728,"./include/subpixel.glsl":6823,"./keypoints/allocate-descriptors.glsl":1341,"./keypoints/allocate-extra.glsl":7833,"./keypoints/apply-homography.glsl":2352,"./keypoints/bf-knn.glsl":7541,"./keypoints/clip-border.glsl":4868,"./keypoints/clip.glsl":5591,"./keypoints/distance-filter.glsl":191,"./keypoints/encode-keypoint-long-offsets.glsl":5467,"./keypoints/encode-keypoint-offsets.glsl":336,"./keypoints/encode-keypoint-positions.glsl":8968,"./keypoints/encode-keypoint-properties.glsl":1733,"./keypoints/encode-keypoints.glsl":9674,"./keypoints/encode-null-keypoints.glsl":2090,"./keypoints/fast.glsl":1855,"./keypoints/fast.vs.glsl":4824,"./keypoints/hamming-distance-filter.glsl":2381,"./keypoints/harris-cutoff.glsl":6060,"./keypoints/harris.glsl":9974,"./keypoints/knn-init.glsl":3047,"./keypoints/knn-transfer.glsl":3266,"./keypoints/laplacian.glsl":8018,"./keypoints/lk.glsl":3168,"./keypoints/lookup-of-locations.glsl":3890,"./keypoints/lookup-of-locations.vs.glsl":8647,"./keypoints/lsh-knn.glsl":4776,"./keypoints/mix-keypoints.glsl":2648,"./keypoints/nonmax-scale.glsl":8825,"./keypoints/nonmax-space.glsl":5693,"./keypoints/nonmax-suppression.glsl":9280,"./keypoints/orb-descriptor.glsl":9108,"./keypoints/orb-orientation.glsl":7137,"./keypoints/refine-scale.glsl":9739,"./keypoints/score-findmax.glsl":8231,"./keypoints/shuffle.glsl":2518,"./keypoints/sort-keypoints.glsl":8096,"./keypoints/subpixel-refinement.glsl":5795,"./keypoints/transfer-flow.glsl":3169,"./keypoints/transfer-orientation.glsl":1337,"./keypoints/transfer-to-extra.glsl":6187,"./keypoints/upload-keypoints.glsl":477,"./pyramids/downsample2.glsl":4050,"./pyramids/upsample2.glsl":5545,"./transforms/additive-mix.glsl":7113,"./transforms/resize.glsl":1202,"./transforms/warp-perspective.glsl":7971,"./utils/copy-components.glsl":6122,"./utils/copy-raster.glsl":371,"./utils/copy.glsl":7307,"./utils/fill-components.glsl":8614,"./utils/fill.glsl":6271,"./utils/flip-y.vs.glsl":3016,"./utils/scan-minmax2d.glsl":3630,"./utils/sobel-derivatives.glsl":8508,"./utils/sobel-derivatives.vs.glsl":8073};function o(e){var t=s(e);return n(t)}function s(e){if(!n.o(i,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return i[e]}o.keys=function(){return Object.keys(i)},o.resolve=s,e.exports=o,o.id=4606},8211:e=>{e.exports="#if !defined(KERNEL_SIZE) || !defined(AXIS) || (AXIS != 0 && AXIS != 1)\n#error Undefined KERNEL_SIZE / AXIS\n#endif\nuniform sampler2D image;\nuniform float kernel[@KERNEL_SIZE@];\nconst ivec2 axis = ivec2(1-AXIS, AXIS);\n#define S(x,k) result += pixelAtShortOffset(image, ivec2((x),(x)) * axis) * kernel[k]\nvoid main()\n{\nvec4 result = vec4(0.0f);\n#if KERNEL_SIZE == 3\nS(-1, 2);\nS( 0, 1);\nS( 1, 0);\n#elif KERNEL_SIZE == 5\nS(-2, 4);\nS(-1, 3);\nS( 0, 2);\nS( 1, 1);\nS( 2, 0);\n#elif KERNEL_SIZE == 7\nS(-3, 6);\nS(-2, 5);\nS(-1, 4);\nS( 0, 3);\nS( 1, 2);\nS( 2, 1);\nS( 3, 0);\n#elif KERNEL_SIZE == 9\nS(-4, 8);\nS(-3, 7);\nS(-2, 6);\nS(-1, 5);\nS( 0, 4);\nS( 1, 3);\nS( 2, 2);\nS( 3, 1);\nS( 4, 0);\n#elif KERNEL_SIZE == 11\nS(-5, 10);\nS(-4, 9);\nS(-3, 8);\nS(-2, 7);\nS(-1, 6);\nS( 0, 5);\nS( 1, 4);\nS( 2, 3);\nS( 3, 2);\nS( 4, 1);\nS( 5, 0);\n#elif KERNEL_SIZE == 13\nS(-6, 12);\nS(-5, 11);\nS(-4, 10);\nS(-3, 9);\nS(-2, 8);\nS(-1, 7);\nS( 0, 6);\nS( 1, 5);\nS( 2, 4);\nS( 3, 3);\nS( 4, 2);\nS( 5, 1);\nS( 6, 0);\n#elif KERNEL_SIZE == 15\nS(-7, 14);\nS(-6, 13);\nS(-5, 12);\nS(-4, 11);\nS(-3, 10);\nS(-2, 9);\nS(-1, 8);\nS( 0, 7);\nS( 1, 6);\nS( 2, 5);\nS( 3, 4);\nS( 4, 3);\nS( 5, 2);\nS( 6, 1);\nS( 7, 0);\n#else\n#error Invalid parameters\n#endif\ncolor = vec4(result.rgb, 1.0f);\n}"},7360:e=>{e.exports="#ifndef KERNEL_SIZE_SQUARED\n#error Must define KERNEL_SIZE_SQUARED\n#endif\nuniform sampler2D image;\nuniform float kernel[@KERNEL_SIZE_SQUARED@];\n#define S(x,y,k) result += pixelAtShortOffset(image, ivec2((x),(y))) * kernel[k]\nvoid main()\n{\nvec4 result = vec4(0.0f);\n#if KERNEL_SIZE_SQUARED == 9\nS(-1,-1, 8);\nS(-1, 0, 7);\nS(-1, 1, 6);\nS( 0,-1, 5);\nS( 0, 0, 4);\nS( 0, 1, 3);\nS( 1,-1, 2);\nS( 1, 0, 1);\nS( 1, 1, 0);\n#elif KERNEL_SIZE_SQUARED == 25\nS(-2,-2, 24);\nS(-2,-1, 23);\nS(-2, 0, 22);\nS(-2, 1, 21);\nS(-2, 2, 20);\nS(-1,-2, 19);\nS(-1,-1, 18);\nS(-1, 0, 17);\nS(-1, 1, 16);\nS(-1, 2, 15);\nS( 0,-2, 14);\nS( 0,-1, 13);\nS( 0, 0, 12);\nS( 0, 1, 11);\nS( 0, 2, 10);\nS( 1,-2, 9);\nS( 1,-1, 8);\nS( 1, 0, 7);\nS( 1, 1, 6);\nS( 1, 2, 5);\nS( 2,-2, 4);\nS( 2,-1, 3);\nS( 2, 0, 2);\nS( 2, 1, 1);\nS( 2, 2, 0);\n#elif KERNEL_SIZE_SQUARED == 49\nS(-3,-3, 48);\nS(-3,-2, 47);\nS(-3,-1, 46);\nS(-3, 0, 45);\nS(-3, 1, 44);\nS(-3, 2, 43);\nS(-3, 3, 42);\nS(-2,-3, 41);\nS(-2,-2, 40);\nS(-2,-1, 39);\nS(-2, 0, 38);\nS(-2, 1, 37);\nS(-2, 2, 36);\nS(-2, 3, 35);\nS(-1,-3, 34);\nS(-1,-2, 33);\nS(-1,-1, 32);\nS(-1, 0, 31);\nS(-1, 1, 30);\nS(-1, 2, 29);\nS(-1, 3, 28);\nS( 0,-3, 27);\nS( 0,-2, 26);\nS( 0,-1, 25);\nS( 0, 0, 24);\nS( 0, 1, 23);\nS( 0, 2, 22);\nS( 0, 3, 21);\nS( 1,-3, 20);\nS( 1,-2, 19);\nS( 1,-1, 18);\nS( 1, 0, 17);\nS( 1, 1, 16);\nS( 1, 2, 15);\nS( 1, 3, 14);\nS( 2,-3, 13);\nS( 2,-2, 12);\nS( 2,-1, 11);\nS( 2, 0, 10);\nS( 2, 1, 9);\nS( 2, 2, 8);\nS( 2, 3, 7);\nS( 3,-3, 6);\nS( 3,-2, 5);\nS( 3,-1, 4);\nS( 3, 0, 3);\nS( 3, 1, 2);\nS( 3, 2, 1);\nS( 3, 3, 0);\n#else\n#error Invalid KERNEL_SIZE_SQUARED\n#endif\ncolor = vec4(result.rgb, 1.0f);\n}"},8191:e=>{e.exports="uniform sampler2D image;\n#define X(i,j) t = vec2(min(p[i], p[j]), max(p[i], p[j])); p[i] = t.x; p[j] = t.y;\n#define S(i,x,y) p[i] = pixelAtShortOffset(image, ivec2((x),(y))).g\nvoid main()\n{\nfloat median;\nvec2 t;\n#if !defined(KERNEL_SIZE)\n#error Must define KERNEL_SIZE\n#elif KERNEL_SIZE == 3\nfloat p[9];\nS(0,-1,-1);\nS(1, 0,-1);\nS(2, 1,-1);\nS(3,-1, 0);\nS(4, 0, 0);\nS(5, 1, 0);\nS(6,-1, 1);\nS(7, 0, 1);\nS(8, 1, 1);\nX(1,2);X(4,5);X(7,8);X(0,1);X(3,4);X(6,7);X(1,2);X(4,5);X(7,8);X(0,3);X(5,8);X(4,7);X(3,6);X(1,4);X(2,5);X(4,7);X(4,2);X(6,4);X(4,2);\nmedian = p[4];\n#elif KERNEL_SIZE == 5\nfloat p[25];\nS( 0,-2,-2);\nS( 1,-1,-2);\nS( 2, 0,-2);\nS( 3, 1,-2);\nS( 4, 2,-2);\nS( 5,-2,-1);\nS( 6,-1,-1);\nS( 7, 0,-1);\nS( 8, 1,-1);\nS( 9, 2,-1);\nS(10,-2, 0);\nS(11,-1, 0);\nS(12, 0, 0);\nS(13, 1, 0);\nS(14, 2, 0);\nS(15,-2, 1);\nS(16,-1, 1);\nS(17, 0, 1);\nS(18, 1, 1);\nS(19, 2, 1);\nS(20,-2, 2);\nS(21,-1, 2);\nS(22, 0, 2);\nS(23, 1, 2);\nS(24, 2, 2);\nX(0,1);X(3,4);X(2,4);X(2,3);X(6,7);X(5,7);X(5,6);X(9,10);X(8,10);X(8,9);X(12,13);X(11,13);X(11,12);X(15,16);X(14,16);X(14,15);X(18,19);X(17,19);X(17,18);X(21,22);X(20,22);X(20,21);X(23,24);X(2,5);X(3,6);X(0,6);X(0,3);X(4,7);X(1,7);X(1,4);X(11,14);X(8,14);X(8,11);X(12,15);X(9,15);X(9,12);X(13,16);X(10,16);X(10,13);X(20,23);X(17,23);X(17,20);X(21,24);X(18,24);X(18,21);X(19,22);X(8,17);X(9,18);X(0,18);X(0,9);X(10,19);X(1,19);X(1,10);X(11,20);X(2,20);X(2,11);X(12,21);X(3,21);X(3,12);X(13,22);X(4,22);X(4,13);X(14,23);X(5,23);X(5,14);X(15,24);X(6,24);X(6,15);X(7,16);X(7,19);X(13,21);X(15,23);X(7,13);X(7,15);X(1,9);X(3,11);X(5,17);X(11,17);X(9,17);X(4,10);X(6,12);X(7,14);X(4,6);X(4,7);X(12,14);X(10,14);X(6,7);X(10,12);X(6,10);X(6,17);X(12,17);X(7,17);X(7,10);X(12,18);X(7,12);X(10,18);X(12,20);X(10,20);X(10,12);\nmedian = p[12];\n#elif KERNEL_SIZE == 7\nfloat p[49];\nS( 0,-3,-3);\nS( 1,-2,-3);\nS( 2,-1,-3);\nS( 3, 0,-3);\nS( 4, 1,-3);\nS( 5, 2,-3);\nS( 6, 3,-3);\nS( 7,-3,-2);\nS( 8,-2,-2);\nS( 9,-1,-2);\nS(10, 0,-2);\nS(11, 1,-2);\nS(12, 2,-2);\nS(13, 3,-2);\nS(14,-3,-1);\nS(15,-2,-1);\nS(16,-1,-1);\nS(17, 0,-1);\nS(18, 1,-1);\nS(19, 2,-1);\nS(20, 3,-1);\nS(21,-3, 0);\nS(22,-2, 0);\nS(23,-1, 0);\nS(24, 0, 0);\nS(25, 1, 0);\nS(26, 2, 0);\nS(27, 3, 0);\nS(28,-3, 1);\nS(29,-2, 1);\nS(30,-1, 1);\nS(31, 0, 1);\nS(32, 1, 1);\nS(33, 2, 1);\nS(34, 3, 1);\nS(35,-3, 2);\nS(36,-2, 2);\nS(37,-1, 2);\nS(38, 0, 2);\nS(39, 1, 2);\nS(40, 2, 2);\nS(41, 3, 2);\nS(42,-3, 3);\nS(43,-2, 3);\nS(44,-1, 3);\nS(45, 0, 3);\nS(46, 1, 3);\nS(47, 2, 3);\nS(48, 3, 3);\nX(0,1);X(2,3);X(0,2);X(1,3);X(1,2);X(4,5);X(6,7);X(4,6);X(5,7);X(5,6);X(0,4);X(2,6);X(2,4);X(1,5);X(3,7);X(3,5);X(1,2);X(3,4);X(5,6);X(8,9);X(10,11);X(8,10);X(9,11);X(9,10);X(12,13);X(14,15);X(12,14);X(13,15);X(13,14);X(8,12);X(10,14);X(10,12);X(9,13);X(11,15);X(11,13);X(9,10);X(11,12);X(13,14);X(0,8);X(4,12);X(4,8);X(2,10);X(6,14);X(6,10);X(2,4);X(6,8);X(10,12);X(1,9);X(5,13);X(5,9);X(3,11);X(7,15);X(7,11);X(3,5);X(7,9);X(11,13);X(1,2);X(3,4);X(5,6);X(7,8);X(9,10);X(11,12);X(13,14);X(16,17);X(18,19);X(16,18);X(17,19);X(17,18);X(20,21);X(22,23);X(20,22);X(21,23);X(21,22);X(16,20);X(18,22);X(18,20);X(17,21);X(19,23);X(19,21);X(17,18);X(19,20);X(21,22);X(24,25);X(26,27);X(24,26);X(25,27);X(25,26);X(28,29);X(30,31);X(28,30);X(29,31);X(29,30);X(24,28);X(26,30);X(26,28);X(25,29);X(27,31);X(27,29);X(25,26);X(27,28);X(29,30);X(16,24);X(20,28);X(20,24);X(18,26);X(22,30);X(22,26);X(18,20);X(22,24);X(26,28);X(17,25);X(21,29);X(21,25);X(19,27);X(23,31);X(23,27);X(19,21);X(23,25);X(27,29);X(17,18);X(19,20);X(21,22);X(23,24);X(25,26);X(27,28);X(29,30);X(0,16);X(8,24);X(8,16);X(4,20);X(12,28);X(12,20);X(4,8);X(12,16);X(20,24);X(2,18);X(10,26);X(10,18);X(6,22);X(14,30);X(14,22);X(6,10);X(14,18);X(22,26);X(2,4);X(6,8);X(10,12);X(14,16);X(18,20);X(22,24);X(26,28);X(1,17);X(9,25);X(9,17);X(5,21);X(13,29);X(13,21);X(5,9);X(13,17);X(21,25);X(3,19);X(11,27);X(11,19);X(7,23);X(15,31);X(15,23);X(7,11);X(15,19);X(23,27);X(3,5);X(7,9);X(11,13);X(15,17);X(19,21);X(23,25);X(27,29);X(1,2);X(3,4);X(5,6);X(7,8);X(9,10);X(11,12);X(13,14);X(15,16);X(17,18);X(19,20);X(21,22);X(23,24);X(25,26);X(27,28);X(29,30);X(32,33);X(34,35);X(32,34);X(33,35);X(33,34);X(36,37);X(38,39);X(36,38);X(37,39);X(37,38);X(32,36);X(34,38);X(34,36);X(33,37);X(35,39);X(35,37);X(33,34);X(35,36);X(37,38);X(40,41);X(42,43);X(40,42);X(41,43);X(41,42);X(44,45);X(46,47);X(44,46);X(45,47);X(45,46);X(40,44);X(42,46);X(42,44);X(41,45);X(43,47);X(43,45);X(41,42);X(43,44);X(45,46);X(32,40);X(36,44);X(36,40);X(34,42);X(38,46);X(38,42);X(34,36);X(38,40);X(42,44);X(33,41);X(37,45);X(37,41);X(35,43);X(39,47);X(39,43);X(35,37);X(39,41);X(43,45);X(33,34);X(35,36);X(37,38);X(39,40);X(41,42);X(43,44);X(45,46);X(32,48);X(40,48);X(36,40);X(44,48);X(38,42);X(34,36);X(38,40);X(42,44);X(46,48);X(37,41);X(39,43);X(35,37);X(39,41);X(43,45);X(33,34);X(35,36);X(37,38);X(39,40);X(41,42);X(43,44);X(45,46);X(47,48);X(0,32);X(16,48);X(16,32);X(8,40);X(24,40);X(8,16);X(24,32);X(40,48);X(4,36);X(20,36);X(12,44);X(28,44);X(12,20);X(28,36);X(4,8);X(12,16);X(20,24);X(28,32);X(36,40);X(44,48);X(2,34);X(18,34);X(10,42);X(26,42);X(10,18);X(26,34);X(6,38);X(22,38);X(14,46);X(30,46);X(14,22);X(30,38);X(6,10);X(14,18);X(22,26);X(30,34);X(38,42);X(2,4);X(6,8);X(10,12);X(14,16);X(18,20);X(22,24);X(26,28);X(30,32);X(34,36);X(38,40);X(42,44);X(46,48);X(1,33);X(17,33);X(9,41);X(25,41);X(9,17);X(25,33);X(5,37);X(21,37);X(13,45);X(29,45);X(13,21);X(29,37);X(5,9);X(13,17);X(21,25);X(29,33);X(37,41);X(3,35);X(19,35);X(11,43);X(27,43);X(11,19);X(27,35);X(7,39);X(23,39);X(15,47);X(31,47);X(15,23);X(31,39);X(7,11);X(15,19);X(23,27);X(31,35);X(39,43);X(3,5);X(7,9);X(11,13);X(15,17);X(19,21);X(23,25);X(27,29);X(31,33);X(35,37);X(39,41);X(43,45);X(1,2);X(3,4);X(5,6);X(7,8);X(9,10);X(11,12);X(13,14);X(15,16);X(17,18);X(19,20);X(21,22);X(23,24);\nmedian = p[24];\n#else\n#error Unsupported kernel size\n#endif\ncolor = vec4(median, median, median, 1.0f);\n}"},4438:e=>{e.exports="uniform sampler2D image;\nuniform sampler2D illuminationMap;\nuniform float gain;\nuniform float offset;\nuniform float decay;\n#ifndef GREYSCALE\n#error Must define GREYSCALE\n#endif\n#if GREYSCALE == 0\nconst mat3 rgb2yuv = mat3(\n0.299f, -0.14713f, 0.615f,\n0.587f, -0.28886f, -0.51499f,\n0.114f, 0.436f, -0.10001f\n);\nconst mat3 yuv2rgb = mat3(\n1.0f, 1.0f, 1.0f,\n0.0f, -0.39465f, 2.03211f,\n1.13983f, -0.58060f, 0.0f\n);\n#endif\nconst float eps = 0.0001f;\nconst float sqrt2 = 1.4142135623730951f;\nconst float magic = 20.0f;\nconst vec2 center = vec2(0.5f);\nvoid main()\n{\nvec4 pixel = threadPixel(image);\nvec4 imapPixel = threadPixel(illuminationMap);\nfloat lambda = -sqrt2 * log(max(1.0f - decay, eps));\nfloat dist = length(texCoord - center);\nfloat vgain = gain * exp(-lambda * dist);\nfloat normalizedGain = 2.0f * vgain;\nfloat normalizedOffset = 2.0f * offset - 1.0f;\n#if GREYSCALE != 0\nfloat luma = 1.0 / (1.0 + exp(-normalizedGain * magic * (pixel.g - imapPixel.g)));\nluma = clamp(luma + normalizedOffset, 0.0f, 1.0f);\ncolor = vec4(luma, luma, luma, 1.0f);\n#else\nvec3 yuvPixel = rgb2yuv * pixel.rgb;\nvec3 yuvImapPixel = rgb2yuv * imapPixel.rgb;\nfloat luma = 1.0 / (1.0 + exp(-normalizedGain * magic * (yuvPixel.r - yuvImapPixel.r)));\nluma += normalizedOffset;\nvec3 rgbCorrectedPixel = yuv2rgb * vec3(luma, yuvPixel.gb);\nrgbCorrectedPixel = clamp(rgbCorrectedPixel, 0.0f, 1.0f);\ncolor = vec4(rgbCorrectedPixel, 1.0f);\n#endif\n}"},5867:e=>{e.exports="#ifndef GREYSCALE\n#error Must define GREYSCALE\n#endif\n#if GREYSCALE != 0\nuniform sampler2D minmax2d;\n#else\nuniform sampler2D minmax2dRGB[3];\n#endif\nuniform float minValue;\nuniform float maxValue;\nconst float eps = 1.0f / 255.0f;\nvoid main()\n{\nvec2 minmax = clamp(vec2(minValue, maxValue), 0.0f, 255.0f) / 255.0f;\nvec4 newMin = vec4(minmax.x);\nvec4 newRange = vec4(minmax.y - minmax.x);\nvec4 alpha = vec4(1.0f, newMin.x, newRange.x, 1.0f);\n#if GREYSCALE != 0\nvec4 pixel = threadPixel(minmax2d);\nmat4 channel = mat4(pixel, pixel, pixel, alpha);\n#else\nmat4 channel = mat4(\nthreadPixel(minmax2dRGB[0]),\nthreadPixel(minmax2dRGB[1]),\nthreadPixel(minmax2dRGB[2]),\nalpha\n);\n#endif\nvec4 oldMin = vec4(channel[0].g, channel[1].g, channel[2].g, channel[3].g);\nvec4 oldRange = max(vec4(channel[0].b, channel[1].b, channel[2].b, channel[3].b), eps);\nvec4 oldIntensity = vec4(channel[0].a, channel[1].a, channel[2].a, channel[3].a);\nvec4 newIntensity = (oldIntensity - oldMin) * newRange / oldRange + newMin;\ncolor = newIntensity;\n}"},9252:e=>{e.exports="const vec4 grey = vec4(0.299f, 0.587f, 0.114f, 0.0f);\nuniform sampler2D image;\nvoid main()\n{\nvec4 pixel = threadPixel(image);\nfloat g = dot(pixel, grey);\ncolor = vec4(g, g, g, 1.0f);\n}"},8609:e=>{e.exports="#ifndef _COLORS_GLSL\n#define _COLORS_GLSL\n#define PIXELCOMPONENT_RED @PIXELCOMPONENT_RED@\n#define PIXELCOMPONENT_GREEN @PIXELCOMPONENT_GREEN@\n#define PIXELCOMPONENT_BLUE @PIXELCOMPONENT_BLUE@\n#define PIXELCOMPONENT_ALPHA @PIXELCOMPONENT_ALPHA@\n#endif"},4672:e=>{e.exports="#ifndef _FILTERS_GLSL\n#define _FILTERS_GLSL\nfloat laplacian(sampler2D pyramid, vec2 position, float lod)\n{\nfloat pot = exp2(lod);\nivec2 pyrBaseSize = textureSize(pyramid, 0);\nconst vec3 ones = vec3(1.0f);\nconst mat3 kernel = mat3(\n0,-1, 0,\n-1, 4,-1,\n0,-1, 0\n);\n#define LPC(x,y) pyrSubpixelAtExOffset(pyramid, position, lod, pot, ivec2((x),(y)), pyrBaseSize).g\nmat3 neighborhood = mat3(\n0.0f, LPC(0,-1), 0.0f,\nLPC(-1,0), LPC(0,0), LPC(1,0),\n0.0f, LPC(0,1), 0.0f\n);\nmat3 m = matrixCompMult(neighborhood, kernel);\nreturn dot(ones, vec3(\ndot(m[0], ones),\ndot(m[1], ones),\ndot(m[2], ones)\n)) * (1.0f + lod);\n}\n#endif"},9778:e=>{e.exports="#ifndef _FIXEDPOINT_GLSL\n#define _FIXEDPOINT_GLSL\n#define fixed_t int\n#define fixed2_t ivec2\nconst int FIX_BITS = int(@FIX_BITS@);\nconst float FIX_RESOLUTION = float(@FIX_RESOLUTION@);\n#define itofix(x) fixed_t((x) << FIX_BITS)\n#define fixtoi(f) int((x) >> FIX_BITS)\n#define ftofix(x) fixed_t((x) * FIX_RESOLUTION + 0.5f)\n#define fixtof(f) (float(f) / FIX_RESOLUTION)\n#define ivec2tofix(x) fixed2_t((x) << FIX_BITS)\n#define fixtoivec2(f) ivec2((f) >> FIX_BITS)\n#define vec2tofix(v) fixed2_t((v) * FIX_RESOLUTION + vec2(0.5f))\n#define fixtovec2(f) (vec2(f) / FIX_RESOLUTION)\n#endif"},8710:e=>{e.exports="#ifndef _FLOAT16_GLSL\n#define _FLOAT16_GLSL\n#define encodeFloat16(f) (vec2(packf16(f)) / 255.0f)\n#define decodeFloat16(v) unpackf16(uvec2((v) * 255.0f))\n#define encodePairOfFloat16(f) vec4(encodeFloat16((f).x), encodeFloat16((f).y))\n#define decodePairOfFloat16(v) vec2(decodeFloat16((v).rg), decodeFloat16((v).ba))\n#define encodeNullPairOfFloat16() vec4(1.0f)\n#define isNullPairOfFloat16(v) all(equal((v), encodeNullPairOfFloat16()))\n#define encodeDiscardedPairOfFloat16() vec4(0.0f, 1.0f, 0.0f, 1.0f)\n#define isDiscardedPairOfFloat16(v) all(equal((v), encodeDiscardedPairOfFloat16()))\n#define encodeFloat16NaN() vec2(0.5f, 1.0f)\n#define isEncodedFloat16NaN(v) all(equal((v), encodeFloat16NaN()))\nuvec2 packf16( float f)\n{\nuint y = packHalf2x16(vec2(f, 0.0f));\nreturn uvec2(y, y >> 8u) & 0xFFu;\n}\nfloat unpackf16(uvec2 v)\n{\nv &= 0xFFu;\nreturn unpackHalf2x16(v.x | (v.y << 8u)).x;\n}\nbool isEncodedFloat16Zero(vec2 v)\n{\nuvec2 w = uvec2(v * 255.0f);\nreturn 0u == w.x + w.y * (0x80u - w.y);\n}\n#endif"},2434:e=>{e.exports="#ifndef _GLOBAL_GLSL\n#define _GLOBAL_GLSL\n#define threadLocation() ivec2(texCoord * texSize)\n#define outputSize() ivec2(texSize)\n#define threadPixel(img) textureLod((img), texCoord, 0.0f)\n#define pixelAt(img, pos) texelFetch((img), (pos), 0)\n#define pixelAtShortOffset(img, offset) textureLodOffset((img), texCoord, 0.0f, (offset))\n#define pixelAtLongOffset(img, offset) textureLod((img), texCoord + vec2(offset) / texSize, 0.0f)\n#endif"},439:e=>{e.exports='#ifndef _INT32_GLSL\n#define _INT32_GLSL\n@include "platform.glsl"\nuint decodeUint32(vec4 rgba)\n{\nuvec4 v = uvec4(rgba * 255.0f) & 255u;\nreturn v.x | (v.y << 8u) | (v.z << 16u) | (v.w << 24u);\n}\nvec4 encodeUint32(uint value)\n{\n#if defined(APPLE_GPU) || (defined(APPLE) && defined(INTEL_GRAPHICS))\nuvec4 v = uvec4(value, value / 256u, value / 65536u, value / 16777216u) % 256u;\nreturn vec4(v) / 255.0f;\n#else\nuvec4 v = uvec4(value, value >> 8u, value >> 16u, value >> 24u) & 255u;\nreturn vec4(v) / 255.0f;\n#endif\n}\n#endif'},8545:e=>{e.exports="#ifndef _KEYPOINT_DESCRIPTORS_GLSL\n#define _KEYPOINT_DESCRIPTORS_GLSL\n#if !defined(DESCRIPTOR_SIZE)\n#error Must define DESCRIPTOR_SIZE\n#elif !defined(_KEYPOINTS_GLSL)\n#error Must include keypoints.glsl\n#endif\nuint[DESCRIPTOR_SIZE] readKeypointDescriptor(sampler2D encodedKeypoints, int descriptorSize, int extraSize, int encoderLength, KeypointAddress address)\n{\nint descriptorOffset = sizeofEncodedKeypoint(0, extraSize) / 4;\nKeypointAddress descriptorAddress = KeypointAddress(address.base, descriptorOffset);\nuint[DESCRIPTOR_SIZE] descriptor;\nvec4 pixel; uvec4 bytes;\n@unroll\nfor(int i = 0; i < DESCRIPTOR_SIZE; i += 4) {\npixel = readKeypointData(encodedKeypoints, encoderLength, descriptorAddress);\nbytes = uvec4(pixel * 255.0f);\ndescriptor[i] = bytes.r;\ndescriptor[i+1] = bytes.g;\ndescriptor[i+2] = bytes.b;\ndescriptor[i+3] = bytes.a;\ndescriptorAddress.offset++;\n}\nreturn descriptor;\n}\nuint[DESCRIPTOR_SIZE] readKeypointDescriptorFromDB(sampler2D descriptorDB, int descriptorDBStride, int index)\n{\nuint[DESCRIPTOR_SIZE] descriptor;\nint rasterIndex = index * (DESCRIPTOR_SIZE / 4) * int(index >= 0);\nvec4 pixel; uvec4 bytes; ivec2 pos;\n@unroll\nfor(int i = 0; i < DESCRIPTOR_SIZE; i += 4) {\npos = ivec2(rasterIndex % descriptorDBStride, rasterIndex / descriptorDBStride);\npixel = (index >= 0) ? texelFetch(descriptorDB, pos, 0) : vec4(0.0f);\nbytes = uvec4(pixel * 255.0f);\ndescriptor[i] = bytes.r;\ndescriptor[i+1] = bytes.g;\ndescriptor[i+2] = bytes.b;\ndescriptor[i+3] = bytes.a;\nrasterIndex++;\n}\nreturn descriptor;\n}\nint distanceBetweenKeypointDescriptors(uint[DESCRIPTOR_SIZE] a, uint[DESCRIPTOR_SIZE] b)\n{\nconst int[256] POPCNT = int[256](0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8);\nuvec4 xor, u, v;\nint dist = 0;\nivec4 bits;\n@unroll\nfor(int i = 0; i < DESCRIPTOR_SIZE; i += 4) {\nu = uvec4(a[i], a[i+1], a[i+2], a[i+3]);\nv = uvec4(b[i], b[i+1], b[i+2], b[i+3]);\nxor = (u ^ v) & 255u;\nbits = ivec4(POPCNT[xor.x], POPCNT[xor.y], POPCNT[xor.z], POPCNT[xor.w]);\ndist += bits.x + bits.y + bits.z + bits.w;\n}\nreturn dist;\n}\n#endif"},6762:e=>{e.exports='#ifndef _KEYPOINT_MATCHES_GLSL\n#define _KEYPOINT_MATCHES_GLSL\n@include "int32.glsl"\nconst int MATCH_INDEX_BITS = int(@MATCH_INDEX_BITS@);\nconst int MATCH_INDEX_MASK = int(@MATCH_INDEX_MASK@);\nconst int MATCH_MAX_INDEX = int(@MATCH_MAX_INDEX@);\nconst int MATCH_MAX_DISTANCE = int(@MATCH_MAX_DISTANCE@);\nstruct KeypointMatch\n{\nint index;\nint dist;\n};\nvec4 encodeKeypointMatch(KeypointMatch candidate)\n{\nuint index = uint(candidate.index) & uint(MATCH_INDEX_MASK);\nuint dist = uint(clamp(candidate.dist, 0, MATCH_MAX_DISTANCE));\nuint u32 = index | (dist << MATCH_INDEX_BITS);\nreturn encodeUint32(u32);\n}\nKeypointMatch decodeKeypointMatch(vec4 rgba)\n{\nuint u32 = decodeUint32(rgba);\nint dist = int(u32 >> MATCH_INDEX_BITS);\nint index = int(u32 & uint(MATCH_INDEX_MASK));\nreturn KeypointMatch(index, dist);\n}\nconst KeypointMatch MATCH_NOT_FOUND = KeypointMatch(MATCH_MAX_INDEX, MATCH_MAX_DISTANCE);\n#endif'},7639:e=>{e.exports='#ifndef _KEYPOINTS_GLSL\n#define _KEYPOINTS_GLSL\n@include "math.glsl"\n@include "fixed-point.glsl"\n@include "float16.glsl"\n@include "pyramids.glsl"\nstruct Keypoint\n{\nvec2 position;\nfloat lod;\nfloat orientation;\nfloat score;\nuint flags;\n};\nstruct KeypointAddress\n{\nint base;\nint offset;\n};\nconst int MIN_KEYPOINT_SIZE = int(@MIN_KEYPOINT_SIZE@);\nconst int MAX_DESCRIPTOR_SIZE = int(@MAX_DESCRIPTOR_SIZE@);\nconst uint KPF_NONE = 0u;\nconst uint KPF_NULL = 1u;\nconst uint KPF_DISCARDED = 2u;\n#define encodeKeypointScore(score) encodeFloat16(score)\n#define decodeKeypointScore(encodedScore) decodeFloat16(encodedScore)\n#define encodeKeypointOrientation(angle) ((angle) * INV_PI_OVER_2 + 0.5f)\n#define decodeKeypointOrientation(value) ((value) * TWO_PI - PI)\n#define encodeNullKeypoint() (vec4(1.0f))\n#define encodeDiscardedKeypoint() (vec4(0.0f))\n#define isNullKeypoint(keypoint) ((((keypoint).flags) & KPF_NULL) != 0u)\n#define isDiscardedKeypoint(keypoint) ((((keypoint).flags) & KPF_DISCARDED) != 0u)\n#define isBadKeypoint(keypoint) ((keypoint).score < 0.0f)\n#define sizeofEncodedKeypoint(descriptorSize, extraSize) (MIN_KEYPOINT_SIZE + (descriptorSize) + (extraSize))\n#define sizeofEncodedKeypointHeader() sizeofEncodedKeypoint(0,0)\n#define findKeypointIndex(address, descriptorSize, extraSize) ((address).base / ((sizeofEncodedKeypoint((descriptorSize), (extraSize))) / 4))\nvec4 readKeypointData(sampler2D encodedKeypoints, int encoderLength, KeypointAddress address)\n{\nint rasterIndex = address.base + address.offset;\nvec4 data = pixelAt(encodedKeypoints, ivec2(rasterIndex % encoderLength, rasterIndex / encoderLength));\nreturn rasterIndex < encoderLength * encoderLength ? data : encodeNullKeypoint();\n}\nKeypointAddress findKeypointAddress(ivec2 thread, int encoderLength, int descriptorSize, int extraSize)\n{\nint threadRaster = thread.y * encoderLength + thread.x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nint keypointIndex = int(threadRaster / pixelsPerKeypoint);\nKeypointAddress address = KeypointAddress(\nkeypointIndex * pixelsPerKeypoint,\nthreadRaster % pixelsPerKeypoint\n);\nreturn address;\n}\nKeypoint decodeKeypoint(sampler2D encodedKeypoints, int encoderLength, KeypointAddress address)\n{\nKeypoint keypoint;\nKeypointAddress positionAddress = KeypointAddress(address.base, 0);\nKeypointAddress propertiesAddress = KeypointAddress(address.base, 1);\nvec4 rawEncodedPosition = readKeypointData(encodedKeypoints, encoderLength, positionAddress);\nivec4 encodedPosition = ivec4(rawEncodedPosition * 255.0f);\nkeypoint.position = fixtovec2(fixed2_t(\nencodedPosition.r | (encodedPosition.g << 8),\nencodedPosition.b | (encodedPosition.a << 8)\n));\nvec4 rawEncodedProperties = readKeypointData(encodedKeypoints, encoderLength, propertiesAddress);\nkeypoint.lod = decodeLod(rawEncodedProperties.r);\nkeypoint.orientation = decodeKeypointOrientation(rawEncodedProperties.g);\nkeypoint.score = decodeKeypointScore(rawEncodedProperties.ba);\nbool isNull = all(equal(rawEncodedPosition, vec4(1)));\nbool isDiscarded = all(equal(rawEncodedPosition + rawEncodedProperties, vec4(0)));\nkeypoint.score = (isNull || isDiscarded) ? -1.0f : keypoint.score;\nkeypoint.flags = KPF_NONE;\nkeypoint.flags |= KPF_NULL * uint(isNull);\nkeypoint.flags |= KPF_DISCARDED * uint(isDiscarded);\nreturn keypoint;\n}\nvec4 encodeKeypointPosition(vec2 position)\n{\nconst vec2 zeros = vec2(0.0f);\nfixed2_t pos = vec2tofix(max(position, zeros));\nfixed2_t lo = pos & 255;\nfixed2_t hi = (pos >> 8) & 255;\nreturn vec4(lo.x, hi.x, lo.y, hi.y) / 255.0f;\n}\n#endif'},431:e=>{e.exports="#ifndef _MATH_GLSL\n#define _MATH_GLSL\n#define TWO_PI 6.28318530718f\n#define PI 3.14159265359f\n#define PI_OVER_2 1.57079632679f\n#define PI_OVER_4 0.78539816339f\n#define INV_PI 0.3183098861837907f\n#define INV_PI_OVER_2 0.15915494309189535f\nconst highp float INFINITY = 1.0f / 0.0f;\nfloat fastAtan(float x)\n{\nfloat w = 1.0f - abs(x);\nreturn (w >= 0.0f) ? ((PI_OVER_4 + 0.273f * w) * x) :\n(sign(x) * PI_OVER_2 - (PI_OVER_4 + 0.273f * (1.0f - abs(1.0f / x))) / x);\n}\nfloat fastAtan2(float y, float x)\n{\nreturn (x == 0.0f) ? PI_OVER_2 * sign(y) : fastAtan(y / x) + float(x < 0.0f) * PI * sign(y);\n}\n#endif"},6822:e=>{e.exports="#ifndef _PLATFORM_GLSL\n#define _PLATFORM_GLSL\n#if @APPLE@\n#define APPLE 1\n#endif\n#if @APPLE_GPU@\n#define APPLE_GPU 1\n#endif\n#if @INTEL_GRAPHICS@\n#define INTEL_GRAPHICS 1\n#endif\n#endif"},2728:e=>{e.exports="#ifndef _PYRAMIDS_GLSL\n#define _PYRAMIDS_GLSL\n#define pyrPixel(pyr, lod) textureLod((pyr), texCoord, (lod))\n#define pyrPixelAtOffset(pyr, lod, pot, offset) textureLod((pyr), texCoord + ((pot) * vec2(offset)) / texSize, (lod))\n#define pyrPixelAt(pyr, pos, lod) textureLod((pyr), (vec2(pos) + vec2(0.5f)) / texSize, (lod))\n#define pyrPixelAtEx(pyr, pos, lod, pyrBaseSize) textureLod((pyr), (vec2(pos) + vec2(0.5f)) / vec2(pyrBaseSize), (lod))\n#define pyrSubpixelAtEx(pyr, pos, lod, pyrBaseSize) textureLod((pyr), ((pos) + vec2(0.5f)) / vec2(pyrBaseSize), (lod))\n#define pyrSubpixelAtExOffset(pyr, pos, lod, pot, offset, pyrBaseSize) textureLod((pyr), (((pos) + vec2(0.5f)) + ((pot) * vec2(offset))) / vec2(pyrBaseSize), (lod))\nconst int PYRAMID_MAX_LEVELS = int(@PYRAMID_MAX_LEVELS@);\nconst float F_PYRAMID_MAX_LEVELS = float(@PYRAMID_MAX_LEVELS@);\nconst float LOG2_PYRAMID_MAX_SCALE = float(@LOG2_PYRAMID_MAX_SCALE@);\n#define encodeLod(lod) ((LOG2_PYRAMID_MAX_SCALE + (lod)) / (LOG2_PYRAMID_MAX_SCALE + F_PYRAMID_MAX_LEVELS))\nfloat decodeLod(float encodedLod)\n{\nfloat lod = encodedLod * (LOG2_PYRAMID_MAX_SCALE + F_PYRAMID_MAX_LEVELS) - LOG2_PYRAMID_MAX_SCALE;\nreturn lod - lod * step(1.0f, encodedLod);\n}\n#define LOD_EPS 0.0625f\nconst float ENCODED_LOD_EPS = (LOD_EPS / (LOG2_PYRAMID_MAX_SCALE + F_PYRAMID_MAX_LEVELS));\n#define isSameLod(lod1, lod2) (abs((lod1) - (lod2)) < LOD_EPS)\n#define isSameEncodedLod(alpha1, alpha2) (abs((alpha1) - (alpha2)) < ENCODED_LOD_EPS)\n#endif"},6823:e=>{e.exports="#ifndef _SUBPIXEL_GLSL\n#define _SUBPIXEL_GLSL\n#define subpixelAt(image, pos) textureLod((image), ((pos) + vec2(0.5f)) / texSize, 0.0f)\nvec4 subpixelAtBI(sampler2D image, vec2 pos)\n{\nvec2 frc = fract(pos);\nvec2 ifrc = vec2(1.0f) - frc;\nvec2 p = (floor(pos) + vec2(0.5f)) / vec2(textureSize(image, 0));\nvec4 pix00 = textureLod(image, p, 0.0f);\nvec4 pix10 = textureLodOffset(image, p, 0.0f, ivec2(1,0));\nvec4 pix01 = textureLodOffset(image, p, 0.0f, ivec2(0,1));\nvec4 pix11 = textureLodOffset(image, p, 0.0f, ivec2(1,1));\nmat4 pix = mat4(pix00, pix10, pix01, pix11);\nvec4 mul = vec4(ifrc.x * ifrc.y, frc.x * ifrc.y, ifrc.x * frc.y, frc.x * frc.y);\nreturn pix * mul;\n}\n#endif"},1341:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D inputEncodedKeypoints;\nuniform int inputDescriptorSize;\nuniform int inputExtraSize;\nuniform int inputEncoderLength;\nuniform int outputDescriptorSize;\nuniform int outputExtraSize;\nuniform int outputEncoderLength;\nconst vec4 EMPTY_DESCRIPTOR = vec4(0.0f);\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress myAddress = findKeypointAddress(thread, outputEncoderLength, outputDescriptorSize, outputExtraSize);\nint myIndex = findKeypointIndex(myAddress, outputDescriptorSize, outputExtraSize);\nint headerSize = sizeofEncodedKeypointHeader();\nbool isDescriptor = (myAddress.offset >= (headerSize + outputExtraSize) / 4);\nint addressOffset = myAddress.offset;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(inputDescriptorSize, inputExtraSize) / 4;\nKeypointAddress otherAddress = KeypointAddress(myIndex * pixelsPerKeypoint, addressOffset);\ncolor = isDescriptor ? EMPTY_DESCRIPTOR : readKeypointData(inputEncodedKeypoints, inputEncoderLength, otherAddress);\n}'},7833:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D inputEncodedKeypoints;\nuniform int inputDescriptorSize;\nuniform int inputExtraSize;\nuniform int inputEncoderLength;\nuniform int outputDescriptorSize;\nuniform int outputExtraSize;\nuniform int outputEncoderLength;\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress myAddress = findKeypointAddress(thread, outputEncoderLength, outputDescriptorSize, outputExtraSize);\nint myIndex = findKeypointIndex(myAddress, outputDescriptorSize, outputExtraSize);\nint headerSize = sizeofEncodedKeypointHeader();\nbool isHead = (myAddress.offset < headerSize / 4);\nbool isDescriptor = (myAddress.offset >= (headerSize + outputExtraSize) / 4);\nbool isExtra = (!isHead && !isDescriptor);\nint numberOfExtraPixels = outputExtraSize / 4;\nint addressOffset = myAddress.offset - int(isDescriptor) * numberOfExtraPixels;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(inputDescriptorSize, inputExtraSize) / 4;\nKeypointAddress otherAddress = KeypointAddress(myIndex * pixelsPerKeypoint, addressOffset);\ncolor = isExtra ? vec4(0.0f) : readKeypointData(inputEncodedKeypoints, inputEncoderLength, otherAddress);\n}'},2352:e=>{e.exports='@include "keypoints.glsl"\nuniform mat3 homography;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\ncolor = pixel;\nif(address.offset != 0)\nreturn;\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\nif(isBadKeypoint(keypoint))\nreturn;\nvec3 pos3 = homography * vec3(keypoint.position, 1.0f);\ncolor = encodeKeypointPosition(pos3.xy / pos3.z);\n}'},7541:e=>{e.exports='@include "keypoints.glsl"\n@include "keypoint-descriptors.glsl"\n@include "keypoint-matches.glsl"\nuniform sampler2D encodedMatches;\nuniform sampler2D encodedFilters;\nuniform int matcherLength;\nuniform sampler2D dbEncodedKeypoints;\nuniform int dbDescriptorSize;\nuniform int dbExtraSize;\nuniform int dbEncoderLength;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int passId;\n#ifndef NUMBER_OF_KEYPOINTS_PER_PASS\n#error Undefined NUMBER_OF_KEYPOINTS_PER_PASS\n#endif\nconst int INFINITE_DISTANCE = MATCH_MAX_DISTANCE + 1;\nvoid main()\n{\nivec2 thread = threadLocation();\nint keypointIndex = thread.x + thread.y * matcherLength;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\ncolor = encodeKeypointMatch(MATCH_NOT_FOUND);\nif(isBadKeypoint(keypoint))\nreturn;\nKeypointMatch bestMatch = decodeKeypointMatch(threadPixel(encodedMatches));\nKeypointMatch filterMatch = decodeKeypointMatch(threadPixel(encodedFilters));\nuint[DESCRIPTOR_SIZE] descriptor = readKeypointDescriptor(encodedKeypoints, descriptorSize, extraSize, encoderLength, address);\nuint[DESCRIPTOR_SIZE] dbDescriptor;\nint dbPixelsPerKeypoint = sizeofEncodedKeypoint(dbDescriptorSize, dbExtraSize) / 4;\nfor(int i = 0; i < NUMBER_OF_KEYPOINTS_PER_PASS; i++) {\nint dbKeypointIndex = passId * NUMBER_OF_KEYPOINTS_PER_PASS + i;\nKeypointAddress dbAddress = KeypointAddress(dbKeypointIndex * dbPixelsPerKeypoint, 0);\nKeypoint dbKeypoint = decodeKeypoint(dbEncodedKeypoints, dbEncoderLength, dbAddress);\ndbDescriptor = readKeypointDescriptor(dbEncodedKeypoints, dbDescriptorSize, dbExtraSize, dbEncoderLength, dbAddress);\nint dist = !isBadKeypoint(dbKeypoint) ? distanceBetweenKeypointDescriptors(descriptor, dbDescriptor) : INFINITE_DISTANCE;\nbestMatch.index = all(bvec2(\ndist < bestMatch.dist || (dist == bestMatch.dist && dbKeypointIndex > bestMatch.index),\ndist > filterMatch.dist || (dist == filterMatch.dist && dbKeypointIndex < filterMatch.index)\n)) ? dbKeypointIndex : bestMatch.index;\nbestMatch.dist = dbKeypointIndex == bestMatch.index ? dist : bestMatch.dist;\n}\ncolor = encodeKeypointMatch(bestMatch);\n}'},4868:e=>{e.exports='@include "keypoints.glsl"\nuniform int imageWidth;\nuniform int imageHeight;\nuniform int borderTop;\nuniform int borderRight;\nuniform int borderBottom;\nuniform int borderLeft;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress addr = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, addr);\nvec2 p = keypoint.position;\nbool withinBorder = any(lessThan(\nvec4(p.x, p.y, -p.x, -p.y),\nvec4(borderLeft, borderTop, borderRight - (imageWidth - 1), borderBottom - (imageHeight - 1))\n));\nvec4 pixel = threadPixel(encodedKeypoints);\nvec4 nullPixel = encodeNullKeypoint();\ncolor = withinBorder ? nullPixel : pixel;\n}'},5591:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int maxKeypoints;\nvoid main()\n{\nivec2 thread = threadLocation();\nint newEncoderLength = outputSize().x;\nKeypointAddress address = findKeypointAddress(thread, newEncoderLength, descriptorSize, extraSize);\nint index = findKeypointIndex(address, descriptorSize, extraSize);\nvec4 pixel = readKeypointData(encodedKeypoints, encoderLength, address);\ncolor = index < maxKeypoints ? pixel : encodeNullKeypoint();\n}'},191:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedKeypointsA;\nuniform int encoderLengthA;\nuniform sampler2D encodedKeypointsB;\nuniform int encoderLengthB;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform float threshold;\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint index = findKeypointIndex(address, descriptorSize, extraSize);\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nvec4 data = readKeypointData(encodedKeypointsA, encoderLengthA, address);\ncolor = data;\nif(address.offset >= sizeofEncodedKeypointHeader() / 4)\nreturn;\nKeypoint keypointA = decodeKeypoint(encodedKeypointsA, encoderLengthA, address);\nKeypoint keypointB = decodeKeypoint(encodedKeypointsB, encoderLengthB, address);\ncolor = encodeNullKeypoint();\nif(isNullKeypoint(keypointA) && isNullKeypoint(keypointB))\nreturn;\ncolor = encodeDiscardedKeypoint();\nif(isDiscardedKeypoint(keypointA) || isDiscardedKeypoint(keypointB))\nreturn;\ncolor = encodeDiscardedKeypoint();\nif(isNullKeypoint(keypointA) || isNullKeypoint(keypointB))\nreturn;\nvec2 delta = keypointA.position - keypointB.position;\nbool shouldKeep = (dot(delta, delta) <= threshold * threshold);\ncolor = shouldKeep ? data : encodeDiscardedKeypoint();\n}'},5467:e=>{e.exports='@include "float16.glsl"\nuniform sampler2D offsetsImage;\nuniform ivec2 imageSize;\n#ifndef MAX_ITERATIONS\n#error Undefined MAX_ITERATIONS\n#endif\n#define decodeSkipOffset(pixel) (int((pixel).g * 255.0f) | (int((pixel).a * 255.0f) << 8))\n#define encodeSkipOffset(offset) (vec2((offset) & 255, (offset) >> 8) / 255.0f)\nvoid main()\n{\nvec4 pixel = threadPixel(offsetsImage);\nivec2 thread = threadLocation();\nint rasterIndex = thread.y * imageSize.x + thread.x;\nint offset = decodeSkipOffset(pixel);\nint totalOffset = offset;\nvec2 encodedScore = pixel.rb;\nivec2 pos = thread; int allow = 1;\n@unroll\nfor(int i = 0; i < MAX_ITERATIONS; i++) {\nallow *= int(pos.y < imageSize.y) * int(isEncodedFloat16Zero(pixel.rb));\nrasterIndex += allow * offset;\npos = ivec2(rasterIndex % imageSize.x, rasterIndex / imageSize.x);\npixel = pixelAt(offsetsImage, pos);\noffset = decodeSkipOffset(pixel);\ntotalOffset += allow * offset;\n}\ntotalOffset = min(totalOffset, 65535);\ncolor.rb = encodedScore;\ncolor.ga = encodeSkipOffset(totalOffset);\n}'},336:e=>{e.exports='@include "float16.glsl"\nuniform sampler2D corners;\nuniform ivec2 imageSize;\nvoid main()\n{\nvec4 pixel = threadPixel(corners);\nivec2 pos = threadLocation();\nvec2 encodedScore = pixel.rb;\nint offset = 0, allow = 1, jumped = 0;\n#define READ(j) ; \\\nallow *= int(pos.y < imageSize.y) * int(isEncodedFloat16Zero(pixel.rb)); \\\noffset += allow; \\\npos.x = (pos.x + 1) % imageSize.x; \\\npos.y += int(pos.x == 0); \\\npixel = (0 != (jumped |= int(pos.x == 0))) ? pixelAtShortOffset(corners, ivec2((j),1)) : pixelAtShortOffset(corners, ivec2((j),0))\nREAD(1); READ(2); READ(3); READ(4); READ(5); READ(6); READ(7);\ncolor.rb = encodedScore;\ncolor.ga = vec2(offset, 0) / 255.0f;\n}'},8968:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D offsetsImage;\nuniform ivec2 imageSize;\nuniform int passId;\nuniform int numPasses;\nuniform int keypointLimit;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#define decodeSkipOffset(pixel) (int((pixel).g * 255.0f) | (int((pixel).a * 255.0f) << 8))\nbool findQthKeypoint(int q, int p, inout ivec2 position, out vec4 pixel)\n{\nint notFirstPass = int(passId > 0);\nposition *= notFirstPass;\np |= -(1 - notFirstPass);\np -= notFirstPass;\nint rasterIndex = position.y * imageSize.x + position.x;\nwhile(position.y < imageSize.y && p != q) {\nposition = ivec2(rasterIndex % imageSize.x, rasterIndex / imageSize.x);\npixel = texelFetch(offsetsImage, position, 0);\np += int(!isEncodedFloat16Zero(pixel.rb));\nrasterIndex += max(1, decodeSkipOffset(pixel));\n}\nreturn (p == q);\n}\nvoid main()\n{\nivec2 thread = threadLocation();\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint q = findKeypointIndex(address, descriptorSize, extraSize);\ncolor = vec4(0.0f);\nif(address.offset != 0)\nreturn;\ncolor = threadPixel(encodedKeypoints);\nint numPixels = encoderLength * encoderLength;\nint maxKeypoints = numPixels / pixelsPerKeypoint;\nint maxKeypointsPerPass = maxKeypoints / numPasses + int(maxKeypoints % numPasses != 0);\nint targetPassId = q / maxKeypointsPerPass;\nif(passId != targetPassId)\nreturn;\nint lastIndexFromPrevPass = passId * maxKeypointsPerPass - 1;\nKeypointAddress lastAddressFromPrevPass = KeypointAddress(max(0, lastIndexFromPrevPass) * pixelsPerKeypoint, 0);\nKeypoint lastKeypointFromPrevPass = decodeKeypoint(encodedKeypoints, encoderLength, lastAddressFromPrevPass);\nivec2 position = passId > 0 ? ivec2(lastKeypointFromPrevPass.position) : ivec2(0);\nvec4 pixel;\ncolor = encodeNullKeypoint();\nif(q >= min(maxKeypoints, keypointLimit) || !findQthKeypoint(q, lastIndexFromPrevPass, position, pixel))\nreturn;\ncolor = encodeKeypointPosition(vec2(position));\n}'},1733:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D corners;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvoid main()\n{\nivec2 thread = threadLocation();\nvec4 pixel = threadPixel(encodedKeypoints);\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint q = findKeypointIndex(address, descriptorSize, extraSize);\ncolor = pixel;\nif(address.offset != 1)\nreturn;\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\nvec4 kpix = pixelAt(corners, ivec2(keypoint.position));\nkeypoint.score = decodeFloat16(kpix.rb);\ncolor.r = kpix.a;\ncolor.g = encodeKeypointOrientation(0.0f);\ncolor.ba = encodeKeypointScore(keypoint.score);\n}'},9674:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D corners;\nuniform mediump usampler2D lookupTable;\nuniform int stride;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int encoderCapacity;\nconst uvec2 NULL_ELEMENT = uvec2(0xFFFFu);\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint index = findKeypointIndex(address, descriptorSize, extraSize);\nivec2 pos = ivec2(index % stride, index / stride);\nuvec4 entry = texelFetch(lookupTable, pos, 0);\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nint rasterIndex = address.base + address.offset;\nint numberOfPixels = encoderLength * encoderLength;\nint numberOfValidPixels = numberOfPixels - (numberOfPixels % pixelsPerKeypoint);\nint maxEncoderCapacity = numberOfValidPixels / pixelsPerKeypoint;\ncolor = encodeNullKeypoint();\nif(all(equal(entry.xy, NULL_ELEMENT)) || index >= min(encoderCapacity, maxEncoderCapacity))\nreturn;\ncolor = encodeKeypointPosition(vec2(entry.xy));\nif(address.offset == 0)\nreturn;\ncolor = vec4(0.0f);\nif(address.offset >= sizeofEncodedKeypointHeader() / 4)\nreturn;\nvec4 pixel = texelFetch(corners, ivec2(entry.xy), 0);\nvec2 encodedScore = encodeKeypointScore(decodeFloat16(pixel.rb));\nfloat encodedOrientation = encodeKeypointOrientation(0.0f);\nfloat encodedLod = pixel.a;\ncolor = vec4(encodedLod, encodedOrientation, encodedScore);\n}'},2090:e=>{e.exports='@include "keypoints.glsl"\nvoid main()\n{\ncolor = encodeNullKeypoint();\n}'},1855:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\nuniform sampler2D corners;\nuniform sampler2D pyramid;\nuniform float lod;\nuniform int threshold;\n#define USE_VARYINGS 1\n#if !defined(FAST_TYPE)\n#error Undefined FAST_TYPE\n#elif FAST_TYPE == 916\nin vec2 v_pix0, v_pix1, v_pix2, v_pix3, v_pix4, v_pix5, v_pix6, v_pix7,\nv_pix8, v_pix9, v_pix10,v_pix11,v_pix12,v_pix13,v_pix14,v_pix15;\n#else\n#error Invalid FAST_TYPE\n#endif\n#define PIX(x,y) pyrPixelAtOffset(pyramid, lod, pot, ivec2((x),(y))).g\n#define XIP(v) textureLod(pyramid, (v), lod).g\nvoid main()\n{\nfloat pixel = threadPixel(pyramid).g;\nvec4 prev = threadPixel(corners);\nivec2 thread = threadLocation();\nivec2 size = outputSize();\nfloat pot = exp2(lod);\nfloat t = float(clamp(threshold, 0, 255)) / 255.0f;\nfloat ct = pixel + t, c_t = pixel - t;\ncolor = vec4(prev.r, pixel, prev.ba);\n#if FAST_TYPE == 916\nconst ivec4 margin = ivec4(3, 3, 4, 4);\nif(any(lessThan(ivec4(thread, size - thread), margin)))\nreturn;\n#if USE_VARYINGS\nfloat p0 = XIP(v_pix0), p4 = XIP(v_pix4), p8 = XIP(v_pix8), p12 = XIP(v_pix12);\n#else\nfloat p0 = PIX(0,3), p4 = PIX(3,0), p8 = PIX(0,-3), p12 = PIX(-3,0);\n#endif\nbvec4 brighter = bvec4(p0 > ct, p4 > ct, p8 > ct, p12 > ct);\nbvec4 darker = bvec4(p0 < c_t, p4 < c_t, p8 < c_t, p12 < c_t);\nbvec4 bpairs = bvec4(all(brighter.xy), all(brighter.yz), all(brighter.zw), all(brighter.wx));\nbvec4 dpairs = bvec4(all(darker.xy), all(darker.yz), all(darker.zw), all(darker.wx));\nif(!(any(bpairs) || any(dpairs)))\nreturn;\n#if USE_VARYINGS\nfloat p1 = XIP(v_pix1), p2 = XIP(v_pix2), p3 = XIP(v_pix3),\np5 = XIP(v_pix5), p6 = XIP(v_pix6), p7 = XIP(v_pix7),\np9 = XIP(v_pix9), p10 = XIP(v_pix10), p11 = XIP(v_pix11),\np13 = XIP(v_pix13), p14 = XIP(v_pix14), p15 = XIP(v_pix15);\n#else\nfloat p1 = PIX(1,3), p2 = PIX(2,2), p3 = PIX(3,1),\np5 = PIX(3,-1), p6 = PIX(2,-2), p7 = PIX(1,-3),\np9 = PIX(-1,-3), p10 = PIX(-2,-2), p11 = PIX(-3,-1),\np13 = PIX(-3,1), p14 = PIX(-2,2), p15 = PIX(-1,3);\n#endif\nbool A=(p0>ct),B=(p1>ct),C=(p2>ct),D=(p3>ct),E=(p4>ct),F=(p5>ct),G=(p6>ct),H=(p7>ct),I=(p8>ct),J=(p9>ct),K=(p10>ct),L=(p11>ct),M=(p12>ct),N=(p13>ct),O=(p14>ct),P=(p15>ct),a=(p0 prevScore ? thisResult : color.rba;\n#endif\n}'},4824:e=>{e.exports="uniform mediump float lod;\n#if !defined(FAST_TYPE)\n#error Undefined FAST_TYPE\n#elif FAST_TYPE == 916\nout vec2 v_pix0, v_pix1, v_pix2, v_pix3, v_pix4, v_pix5, v_pix6, v_pix7,\nv_pix8, v_pix9, v_pix10,v_pix11,v_pix12,v_pix13,v_pix14,v_pix15;\n#else\n#error Invalid FAST_TYPE\n#endif\n#define PIX(x,y) (texCoord + ((pot) * vec2((x),(y))) / texSize)\nvoid vsmain()\n{\nfloat pot = exp2(lod);\n#if FAST_TYPE == 916\nv_pix0 = PIX(0,3); v_pix1 = PIX(1,3), v_pix2 = PIX(2,2), v_pix3 = PIX(3,1);\nv_pix4 = PIX(3,0); v_pix5 = PIX(3,-1), v_pix6 = PIX(2,-2), v_pix7 = PIX(1,-3);\nv_pix8 = PIX(0,-3); v_pix9 = PIX(-1,-3), v_pix10 = PIX(-2,-2), v_pix11 = PIX(-3,-1);\nv_pix12 = PIX(-3,0); v_pix13 = PIX(-3,1), v_pix14 = PIX(-2,2), v_pix15 = PIX(-1,3);\n#endif\n}"},2381:e=>{e.exports='@include "keypoints.glsl"\n@include "keypoint-descriptors.glsl"\nuniform sampler2D encodedKeypointsA;\nuniform int encoderLengthA;\nuniform sampler2D encodedKeypointsB;\nuniform int encoderLengthB;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int threshold;\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint index = findKeypointIndex(address, descriptorSize, extraSize);\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nvec4 data = readKeypointData(encodedKeypointsA, encoderLengthA, address);\ncolor = data;\nif(address.offset >= sizeofEncodedKeypointHeader() / 4)\nreturn;\nKeypoint keypointA = decodeKeypoint(encodedKeypointsA, encoderLengthA, address);\nKeypoint keypointB = decodeKeypoint(encodedKeypointsB, encoderLengthB, address);\ncolor = encodeNullKeypoint();\nif(isNullKeypoint(keypointA) && isNullKeypoint(keypointB))\nreturn;\ncolor = encodeDiscardedKeypoint();\nif(isDiscardedKeypoint(keypointA) || isDiscardedKeypoint(keypointB))\nreturn;\ncolor = encodeDiscardedKeypoint();\nif(isNullKeypoint(keypointA) || isNullKeypoint(keypointB))\nreturn;\nuint[DESCRIPTOR_SIZE] descriptorA, descriptorB;\ndescriptorA = readKeypointDescriptor(encodedKeypointsA, descriptorSize, extraSize, encoderLengthA, address);\ndescriptorB = readKeypointDescriptor(encodedKeypointsB, descriptorSize, extraSize, encoderLengthB, address);\nint dist = distanceBetweenKeypointDescriptors(descriptorA, descriptorB);\nbool shouldKeep = (dist <= threshold);\ncolor = shouldKeep ? data : encodeDiscardedKeypoint();\n}'},6060:e=>{e.exports='@include "float16.glsl"\nuniform sampler2D corners;\nuniform sampler2D maxScore;\nuniform float quality;\nvoid main()\n{\nvec4 pixel = threadPixel(corners);\nfloat score = decodeFloat16(pixel.rb);\nfloat maxval = decodeFloat16(threadPixel(maxScore).rb);\nfloat threshold = maxval * clamp(quality, 0.0f, 1.0f);\ncolor = pixel;\ncolor.rb = score >= threshold ? color.rb : encodeFloat16(0.0f);\n}'},9974:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\n@include "filters.glsl"\n#if !defined(WINDOW_SIZE)\n#error Undefined WINDOW_SIZE\n#endif\n#define WINDOW_RADIUS ((WINDOW_SIZE - 1) / 2)\nuniform sampler2D corners;\nuniform sampler2D pyramid;\nuniform sampler2D derivatives;\nuniform float lod;\nuniform float lodStep;\nuniform float gaussian[@WINDOW_SIZE@];\n#define G(x) gaussian[(x) + WINDOW_RADIUS]\n#define W(x,y) (G(x) * G(y))\n#define H(ox,oy) dpix = pixelAtShortOffset(derivatives, ivec2((ox),(oy))); \\\ndf = (1.0f + lod) * decodePairOfFloat16(dpix); \\\nh += vec3(df.x * df.x, df.x * df.y, df.y * df.y) * W((ox),(oy))\nvoid main()\n{\nfloat intensity = 0.0f;\nivec2 thread = threadLocation();\nvec4 pixel = threadPixel(corners);\nvec4 dpix = vec4(0.0f);\nvec2 df = vec2(0.0f);\nvec3 h = vec3(0.0f);\ncolor = pixel;\n#if WINDOW_SIZE == 1\nH(0,0);\n#elif WINDOW_SIZE == 3\nH(-1,-1); H(0,-1); H(1,-1);\nH(-1,0); H(0,0); H(1,0);\nH(-1,1); H(0,1); H(1,1);\n#elif WINDOW_SIZE == 5\nH(-2,-2); H(-1,-2); H(0,-2); H(1,-2); H(2,-2);\nH(-2,-1); H(-1,-1); H(0,-1); H(1,-1); H(2,-1);\nH(-2,0); H(-1,0); H(0,0); H(1,0); H(2,0);\nH(-2,1); H(-1,1); H(0,1); H(1,1); H(2,1);\nH(-2,2); H(-1,2); H(0,2); H(1,2); H(2,2);\n#elif WINDOW_SIZE == 7\nH(-3,-3); H(-2,-3); H(-1,-3); H(0,-3); H(1,-3); H(2,-3); H(3,-3);\nH(-3,-2); H(-2,-2); H(-1,-2); H(0,-2); H(1,-2); H(2,-2); H(3,-2);\nH(-3,-1); H(-2,-1); H(-1,-1); H(0,-1); H(1,-1); H(2,-1); H(3,-1);\nH(-3,0); H(-2,0); H(-1,0); H(0,0); H(1,0); H(2,0); H(3,0);\nH(-3,1); H(-2,1); H(-1,1); H(0,1); H(1,1); H(2,1); H(3,1);\nH(-3,2); H(-2,2); H(-1,2); H(0,2); H(1,2); H(2,2); H(3,2);\nH(-3,3); H(-2,3); H(-1,3); H(0,3); H(1,3); H(2,3); H(3,3);\n#else\n#error Invalid WINDOW_SIZE\n#endif\nfloat response = 0.5f * (h.x + h.z - sqrt((h.x - h.z) * (h.x - h.z) + 4.0f * h.y * h.y));\nresponse /= float(WINDOW_SIZE * WINDOW_SIZE);\nfloat lodPlus = min(float(PYRAMID_MAX_LEVELS - 1), lod + lodStep);\nfloat currentScaleStrength = abs(laplacian(pyramid, vec2(thread), lod));\nfloat previousScaleStrength = abs(laplacian(pyramid, vec2(thread), lodPlus));\nfloat previousResponse = decodeFloat16(pixel.rb);\nvec4 result = vec4(encodeFloat16(response), encodeLod(lod), intensity);\ncolor.rbag = (currentScaleStrength >= previousScaleStrength || previousResponse == 0.0f) ? result : pixel.rbag;\n}'},3047:e=>{e.exports='@include "keypoint-matches.glsl"\nvoid main()\n{\n#if ENCODE_FILTERS != 0\nKeypointMatch initial = KeypointMatch(MATCH_MAX_INDEX, 0);\n#else\nKeypointMatch initial = KeypointMatch(MATCH_MAX_INDEX, MATCH_MAX_DISTANCE);\n#endif\ncolor = encodeKeypointMatch(initial);\n}'},3266:e=>{e.exports='@include "keypoint-matches.glsl"\nuniform sampler2D encodedMatches;\nuniform sampler2D encodedKthMatches;\nuniform int numberOfMatchesPerKeypoint;\nuniform int kthMatch;\nvoid main()\n{\nivec2 thread = threadLocation();\nivec2 matcherSize = textureSize(encodedMatches, 0);\nivec2 kthMatcherSize = textureSize(encodedKthMatches, 0);\nint rasterIndex = thread.y * matcherSize.x + thread.x;\nint matchIndex = rasterIndex / numberOfMatchesPerKeypoint;\nint matchCell = rasterIndex % numberOfMatchesPerKeypoint;\ncolor = threadPixel(encodedMatches);\nif(matchCell != kthMatch)\nreturn;\ncolor = encodeKeypointMatch(MATCH_NOT_FOUND);\nif(matchIndex >= kthMatcherSize.x * kthMatcherSize.y)\nreturn;\nivec2 pos = ivec2(matchIndex % kthMatcherSize.x, matchIndex / kthMatcherSize.x);\ncolor = texelFetch(encodedKthMatches, pos, 0);\n}'},8018:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\n@include "filters.glsl"\nuniform sampler2D corners;\nuniform sampler2D pyramid;\nuniform float lodStep;\nuniform float lodOffset;\nvoid main()\n{\nivec2 thread = threadLocation();\nvec4 pixel = threadPixel(corners);\nfloat lod = decodeLod(pixel.a);\nfloat lodMinus = max(0.0f, lod - lodStep + lodOffset);\nfloat lodPlus = min(float(PYRAMID_MAX_LEVELS - 1), lod + lodStep + lodOffset);\nfloat lapMinus = laplacian(pyramid, vec2(thread), lodMinus);\nfloat lapPlus = abs(lodPlus - lodMinus) < 1e-5 ? lapMinus : laplacian(pyramid, vec2(thread), lodPlus);\ncolor = encodePairOfFloat16(vec2(lapMinus, lapPlus));\n}'},3168:e=>{e.exports='@include "keypoints.glsl"\n@include "float16.glsl"\nuniform sampler2D nextPyramid;\nuniform sampler2D prevPyramid;\nuniform sampler2D encodedFlow;\nuniform sampler2D prevKeypoints;\nuniform int level;\nuniform int depth;\nuniform int numberOfIterations;\nuniform float discardThreshold;\nuniform float epsilon;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#ifndef WINDOW_SIZE\n#error Undefined WINDOW_SIZE\n#endif\n#define NEXT_IMAGE 1\n#define PREV_IMAGE 0\nconst int WINDOW_RADIUS = (WINDOW_SIZE - 1) / 2;\nconst int WINDOW_SIZE_SQUARED = (WINDOW_SIZE) * (WINDOW_SIZE);\nconst int WINDOW_SIZE_PLUS = (WINDOW_SIZE) + 2;\nconst int WINDOW_SIZE_PLUS_SQUARED = WINDOW_SIZE_PLUS * WINDOW_SIZE_PLUS;\nconst int DBL_WINDOW_SIZE_PLUS_SQUARED = 2 * WINDOW_SIZE_PLUS_SQUARED;\nconst int WINDOW_RADIUS_PLUS = (WINDOW_SIZE_PLUS - 1) / 2;\nconst highp float FLT_SCALE = 9.5367431640625e-7;\nconst highp float FLT_EPSILON = 0.00000011920929f;\nint pixelBuffer[DBL_WINDOW_SIZE_PLUS_SQUARED];\n#define prevPixel(index) pixelBuffer[(index)]\n#define nextPixel(index) pixelBuffer[WINDOW_SIZE_PLUS_SQUARED + (index)]\n#define pixelIndex(i, j) (((j) + WINDOW_RADIUS_PLUS) * WINDOW_SIZE_PLUS + ((i) + WINDOW_RADIUS_PLUS))\nivec2 derivBuffer[WINDOW_SIZE_SQUARED];\n#define derivativesAt(x, y) derivBuffer[((y) + WINDOW_RADIUS) * WINDOW_SIZE + ((x) + WINDOW_RADIUS)]\nvoid readWindow(vec2 center, float lod)\n{\nconst int r = WINDOW_RADIUS;\nivec2 pyrBaseSize = textureSize(prevPyramid, 0);\nfloat pot = exp2(lod);\nivec2 offset; int idx;\n#define readPixelsAt(ox, oy) offset = ivec2((ox), (oy)); \\\nidx = pixelIndex(offset.x, offset.y); \\\nnextPixel(idx) = int(255.0f * pyrSubpixelAtExOffset(nextPyramid, center, lod, pot, offset, pyrBaseSize).g); \\\nprevPixel(idx) = int(255.0f * pyrSubpixelAtExOffset(prevPyramid, center, lod, pot, offset, pyrBaseSize).g)\nfor(int j = 0; j < WINDOW_SIZE; j++) {\nfor(int i = 0; i < WINDOW_SIZE; i++) {\nreadPixelsAt(i-r, j-r);\n}\n}\nint r1 = r+1;\nfor(int k = 0; k < WINDOW_SIZE; k++) {\nreadPixelsAt(-r1, k-r);\nreadPixelsAt( r1, k-r);\nreadPixelsAt(k-r,-r1);\nreadPixelsAt(k-r, r1);\n}\nreadPixelsAt(-r1,-r1);\nreadPixelsAt( r1,-r1);\nreadPixelsAt(-r1, r1);\nreadPixelsAt( r1, r1);\n}\nivec2 computeDerivatives(int imageCode, ivec2 offset)\n{\nconst mat3 dx = mat3(\n3, 0, -3,\n10, 0, -10,\n3, 0, -3\n);\nconst mat3 dy = mat3(\n3, 10, 3,\n0, 0, 0,\n-3, -10, -3\n);\nint indexOffset = imageCode * WINDOW_SIZE_PLUS_SQUARED;\nmat3 window = mat3(\npixelBuffer[indexOffset + pixelIndex(offset.x-1, offset.y-1)],\npixelBuffer[indexOffset + pixelIndex(offset.x+0, offset.y-1)],\npixelBuffer[indexOffset + pixelIndex(offset.x+1, offset.y-1)],\npixelBuffer[indexOffset + pixelIndex(offset.x-1, offset.y+0)],\n0.0f,\npixelBuffer[indexOffset + pixelIndex(offset.x+1, offset.y+0)],\npixelBuffer[indexOffset + pixelIndex(offset.x-1, offset.y+1)],\npixelBuffer[indexOffset + pixelIndex(offset.x+0, offset.y+1)],\npixelBuffer[indexOffset + pixelIndex(offset.x+1, offset.y+1)]\n);\nmat3 fx = matrixCompMult(dx, window);\nmat3 fy = matrixCompMult(dy, window);\nconst vec3 ones = vec3(1.0f);\nreturn ivec2(\ndot(fx[0], ones) + dot(fx[1], ones) + dot(fx[2], ones),\ndot(fy[0], ones) + dot(fy[1], ones) + dot(fy[2], ones)\n);\n}\nint readBufferedPixel(int imageCode, ivec2 offset)\n{\nconst int r = WINDOW_RADIUS;\noffset = clamp(offset, -r, r);\nint indexOffset = imageCode * WINDOW_SIZE_PLUS_SQUARED;\nreturn pixelBuffer[indexOffset + pixelIndex(offset.x, offset.y)];\n}\nint readBufferedSubpixel(int imageCode, vec2 offset)\n{\nivec2 p = ivec2(floor(offset));\nvec2 frc = fract(offset);\nvec2 ifrc = vec2(1.0f) - frc;\nvec4 pix = vec4(\nreadBufferedPixel(imageCode, p),\nreadBufferedPixel(imageCode, p + ivec2(1,0)),\nreadBufferedPixel(imageCode, p + ivec2(0,1)),\nreadBufferedPixel(imageCode, p + ivec2(1,1))\n);\nvec4 sub = vec4(\nifrc.x * ifrc.y,\nfrc.x * ifrc.y,\nifrc.x * frc.y,\nfrc.x * frc.y\n);\nreturn int(0.5f + dot(sub*pix, vec4(1.0f)));\n}\nvec2 computeMismatch(vec2 pyrGuess, vec2 localGuess)\n{\nconst int r = WINDOW_RADIUS;\nint timeDerivative;\nivec2 mismatch = ivec2(0);\nint x, y, _x, _y;\nvec2 d = pyrGuess + localGuess;\n#define innerLoop() \\\nfor(_x = 0; _x < WINDOW_SIZE; _x++) { \\\nx = _x - r; y = _y - r; \\\ntimeDerivative = ( \\\nreadBufferedSubpixel(NEXT_IMAGE, vec2(x, y) + d) - \\\nreadBufferedPixel(PREV_IMAGE, ivec2(x, y)) \\\n); \\\nmismatch += derivativesAt(x, y) * timeDerivative; \\\n}\n@unroll\nfor(_y = 0; _y < WINDOW_SIZE; _y++) {\ninnerLoop();\n}\nreturn vec2(mismatch) * FLT_SCALE;\n}\nbool isInsideImage(vec2 position)\n{\nvec2 imageSize = vec2(textureSize(nextPyramid, 0));\nvec2 border = vec2(WINDOW_SIZE);\nreturn all(bvec4(\ngreaterThanEqual(position, border),\nlessThan(position, imageSize - border)\n));\n}\nvoid main()\n{\nvec4 pixel = threadPixel(encodedFlow);\nivec2 thread = threadLocation();\nfloat windowArea = float(WINDOW_SIZE * WINDOW_SIZE);\nconst int r = WINDOW_RADIUS;\nint keypointIndex = thread.x + thread.y * outputSize().x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(prevKeypoints, encoderLength, address);\ncolor = encodeNullPairOfFloat16();\nif(isNullKeypoint(keypoint))\nreturn;\ncolor = encodeDiscardedPairOfFloat16();\nif(isBadKeypoint(keypoint))\nreturn;\nvec2 pyrGuess = (level < depth - 1) ? decodePairOfFloat16(pixel) : vec2(0.0f);\npyrGuess *= 2.0f;\nreadWindow(keypoint.position, float(level));\nivec2 derivatives;\nivec3 harris3i = ivec3(0);\nfor(int j = 0; j < WINDOW_SIZE; j++) {\nfor(int i = 0; i < WINDOW_SIZE; i++) {\nderivatives = computeDerivatives(PREV_IMAGE, ivec2(i-r, j-r));\nharris3i += ivec3(\nderivatives.x * derivatives.x,\nderivatives.x * derivatives.y,\nderivatives.y * derivatives.y\n);\nderivativesAt(i-r, j-r) = derivatives;\n}\n}\nhighp vec3 harris = vec3(harris3i) * FLT_SCALE;\nhighp mat2 invHarris = mat2(harris.z, -harris.y, -harris.y, harris.x);\nhighp float det = harris.x * harris.z - harris.y * harris.y;\nhighp float invDet = abs(det) >= FLT_EPSILON ? 1.0f / det : 0.0f;\nhighp float minEigenvalue = 0.5f * ((harris.x + harris.z) - sqrt(\n(harris.x - harris.z) * (harris.x - harris.z) + 4.0f * (harris.y * harris.y)\n));\nint niceNumbers = int(abs(det) >= FLT_EPSILON && minEigenvalue >= discardThreshold * windowArea);\nbool goodKeypoint = (level > 0) || (niceNumbers != 0);\nhighp float eps2 = epsilon * epsilon;\nhighp vec2 mismatch, delta, localGuess = vec2(0.0f);\nfor(int k = 0; k < numberOfIterations; k++) {\nmismatch = niceNumbers != 0 ? computeMismatch(pyrGuess, localGuess) : vec2(0.0f);\ndelta = mismatch * invHarris * invDet;\nniceNumbers *= int(eps2 <= dot(delta, delta));\nlocalGuess += float(niceNumbers) * delta;\n}\nvec2 opticalFlow = pyrGuess + localGuess;\nbool mustDiscard = (level == 0) && any(bvec2(\n!goodKeypoint,\n!isInsideImage(keypoint.position + opticalFlow)\n));\ncolor = !mustDiscard ? encodePairOfFloat16(opticalFlow) : encodeDiscardedPairOfFloat16();\n}'},3890:e=>{e.exports='#if @FS_USE_CUSTOM_PRECISION@\nprecision mediump int;\nprecision mediump float;\n#endif\n#if !defined(STAGE)\n#error Undefined STAGE\n#elif STAGE == 1\n@include "float16.glsl"\nuniform sampler2D corners;\n#elif STAGE < 1\nuniform mediump usampler2D lookupTable;\n#else\n#define SKIP_TEXTURE_READS 1\n#define DENSITY_FACTOR 0.10\nuniform mediump usampler2D lookupTable;\nuniform int blockSize;\nuniform int width;\nuniform int height;\nin vec2 v_topLeft, v_top, v_topRight,\nv_left, v_center, v_right,\nv_bottomLeft, v_bottom, v_bottomRight;\n#endif\nconst uvec2 NULL_ELEMENT = uvec2(0xFFFFu);\nvoid main()\n{\n#if STAGE == 1\nuvec2 outSize = uvec2(outputSize());\nuvec2 thread = uvec2(threadLocation());\nuvec2 size = uvec2(textureSize(corners, 0));\nuint location = thread.y * outSize.x + thread.x;\nivec2 pos = ivec2(location % size.x, location / size.x);\nvec4 pixel = location < size.x * size.y ? texelFetch(corners, pos, 0) : vec4(0.0f);\nbool isCorner = !isEncodedFloat16Zero(pixel.rb);\ncolor = isCorner ? uvec4(uvec2(pos), 1u, 0u) : uvec4(NULL_ELEMENT, 0u, 0u);\n#elif STAGE > 1\nint dblBlockSize = 2 * blockSize;\nivec2 thread = threadLocation();\nivec2 offset = thread % dblBlockSize;\nivec2 delta = thread - offset;\n#if SKIP_TEXTURE_READS\nif(blockSize >= 8) {\nuint sb = texture(lookupTable, texCoord).z;\nfloat p = max((float(sb) / float(blockSize)) / float(blockSize), DENSITY_FACTOR);\nfloat rowthr = float(dblBlockSize) * p + 3.0f * sqrt(p * (1.0f - p));\ncolor = uvec4(NULL_ELEMENT, 4u * sb, 0u);\nif(offset.y >= max(1, int(ceil(rowthr))))\nreturn;\n}\n#endif\n#define deltaCenter ivec2(0,0)\n#define deltaTop ivec2(0,-blockSize)\n#define deltaTopRight ivec2(blockSize,-blockSize)\n#define deltaRight ivec2(blockSize,0)\n#define deltaBottomRight ivec2(blockSize,blockSize)\n#define deltaBottom ivec2(0,blockSize)\n#define deltaBottomLeft ivec2(-blockSize,blockSize)\n#define deltaLeft ivec2(-blockSize,0)\n#define deltaTopLeft ivec2(-blockSize,-blockSize)\nivec2 boundary = ivec2(width - 1, height - 1) / blockSize;\nivec2 bottomRightPos = thread + deltaBottomRight;\nuvec2 valid = uvec2(\nbottomRightPos.x < width || bottomRightPos.x / blockSize == boundary.x,\nbottomRightPos.y < height || bottomRightPos.y / blockSize == boundary.y\n);\nuvec4 mask[4];\nmask[0] = uvec4(1u, valid.x, valid.y, valid.x * valid.y);\nmask[1] = uvec4(1u, 1u, valid.y, valid.y);\nmask[2] = uvec4(1u, valid.x, 1u, valid.x);\nmask[3] = uvec4(1u);\n#if SKIP_TEXTURE_READS\n#define calcSb(delta) texelFetch(lookupTable, blockSize * ((thread + (delta)) / blockSize), 0).z\nuint center = calcSb(deltaCenter);\nuint top = calcSb(deltaTop);\nuint topRight = calcSb(deltaTopRight);\nuint right = calcSb(deltaRight);\nuint bottomRight = calcSb(deltaBottomRight);\nuint bottom = calcSb(deltaBottom);\nuint bottomLeft = calcSb(deltaBottomLeft);\nuint left = calcSb(deltaLeft);\nuint topLeft = calcSb(deltaTopLeft);\n#else\n#define calcSb(pos) texture(lookupTable, (pos)).z\nuint center = calcSb(v_center);\nuint top = calcSb(v_top);\nuint topRight = calcSb(v_topRight);\nuint right = calcSb(v_right);\nuint bottomRight = calcSb(v_bottomRight);\nuint bottom = calcSb(v_bottom);\nuint bottomLeft = calcSb(v_bottomLeft);\nuint left = calcSb(v_left);\nuint topLeft = calcSb(v_topLeft);\n#endif\nuvec4 sums[4];\nsums[0] = uvec4(center, right, bottom, bottomRight);\nsums[1] = uvec4(left, center, bottomLeft, bottom);\nsums[2] = uvec4(top, topRight, center, right);\nsums[3] = uvec4(topLeft, top, left, center);\nivec2 cmp = ivec2(greaterThanEqual(offset, ivec2(blockSize)));\nint option = 2 * cmp.y + cmp.x;\nuvec4 cdef = sums[option] * mask[option];\nuint c2b = cdef.x, d2b = cdef.y, e2b = cdef.z, f2b = cdef.w;\nuint sb = center;\nuint s2b = c2b + d2b + e2b + f2b;\ns2b = s2b < sb ? 0xFFFFu : min(0xFFFFu, s2b);\nuint w2b = uint(min(dblBlockSize, width - delta.x));\nuvec2 uoffset = uvec2(offset);\nuint ceiling = s2b >= uoffset.x ? (s2b - uoffset.x) / w2b + uint((s2b - uoffset.x) % w2b > 0u) : 0u;\ncolor = uvec4(NULL_ELEMENT, s2b, 0u);\nif(uoffset.y >= ceiling)\nreturn;\nuint i2b = uoffset.y * w2b + uoffset.x;\nuint j2b = i2b >= c2b ? i2b - c2b : 0u;\nuint k2b = j2b >= d2b ? j2b - d2b : 0u;\nuint l2b = k2b >= e2b ? k2b - e2b : 0u;\nuint wl = uint(min(blockSize, width - delta.x));\nuint wr = uint(min(blockSize, width - delta.x - blockSize));\nivec2 magicOffset = (\n(i2b < c2b) ? ivec2(i2b % wl, i2b / wl) : (\n(j2b < d2b) ? ivec2(j2b % wr, j2b / wr) + ivec2(blockSize, 0) : (\n(k2b < e2b) ? ivec2(k2b % wl, k2b / wl) + ivec2(0, blockSize) : (\n(l2b < f2b) ? ivec2(l2b % wr, l2b / wr) + ivec2(blockSize) : ivec2(0)\n))));\nuvec2 a2b = texelFetch(lookupTable, delta + magicOffset, 0).xy;\ncolor = uvec4(a2b, s2b, 0u);\n#else\nuvec4 pix = texture(lookupTable, texCoord);\ncolor = all(equal(pix.xy, NULL_ELEMENT)) ? vec4(0,1,1,1) : vec4(1,0,0,1);\n#endif\n}'},8647:e=>{e.exports="#if !defined(STAGE) || STAGE < 1\n#error Invalid STAGE\n#else\nuniform mediump int blockSize;\nout vec2 v_topLeft, v_top, v_topRight,\nv_left, v_center, v_right,\nv_bottomLeft, v_bottom, v_bottomRight;\nvoid vsmain()\n{\nfloat b = float(blockSize);\n#define V(x,y) (texCoord + (vec2((x),(y)) * b) / texSize)\nv_topLeft = V(-1,-1); v_top = V(0,-1); v_topRight = V(1,-1);\nv_left = V(-1,0); v_center = V(0,0); v_right = V(1,0);\nv_bottomLeft = V(-1,1); v_bottom = V(0,1); v_bottomRight = V(1,1);\n}\n#endif"},4776:e=>{e.exports='@include "keypoints.glsl"\n@include "keypoint-matches.glsl"\n@include "keypoint-descriptors.glsl"\nuniform sampler2D candidates;\nuniform sampler2D filters;\nuniform int matcherLength;\nuniform sampler2D tables;\nuniform sampler2D descriptorDB;\nuniform int tableIndex;\nuniform int bucketCapacity;\nuniform int bucketsPerTable;\nuniform int tablesStride;\nuniform int descriptorDBStride;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#if HASH_SIZE > SEQUENCE_MAXLEN\n#error LSH: invalid HASH_SIZE\n#elif SEQUENCE_COUNT * SEQUENCE_MAXLEN * 4 > 16384\n#error LSH: sequences are too large!\n#elif (SEQUENCE_COUNT * SEQUENCE_MAXLEN) % 4 > 0\n#error LSH: sequences of invalid size!\n#endif\nlayout(std140) uniform LSHSequences\n{\nuvec4 sequences[(SEQUENCE_COUNT * SEQUENCE_MAXLEN) / 4];\n};\n#if HASH_SIZE == 10\nconst int SWAP_COUNT[3] = int[3](1, 11, 56);\nconst int[56] SWAP = int[56](0,1,2,4,8,16,32,64,128,256,512,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768);\n#elif HASH_SIZE == 11\nconst int SWAP_COUNT[3] = int[3](1, 12, 67);\nconst int[67] SWAP = int[67](0,1,2,4,8,16,32,64,128,256,512,1024,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536);\n#elif HASH_SIZE == 12\nconst int SWAP_COUNT[3] = int[3](1, 13, 79);\nconst int[79] SWAP = int[79](0,1,2,4,8,16,32,64,128,256,512,1024,2048,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072);\n#elif HASH_SIZE == 13\nconst int SWAP_COUNT[3] = int[3](1, 14, 92);\nconst int[92] SWAP = int[92](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144);\n#elif HASH_SIZE == 14\nconst int SWAP_COUNT[3] = int[3](1, 15, 106);\nconst int[106] SWAP = int[106](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288);\n#elif HASH_SIZE == 15\nconst int SWAP_COUNT[3] = int[3](1, 16, 121);\nconst int[121] SWAP = int[121](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576);\n#elif HASH_SIZE == 16\nconst int SWAP_COUNT[3] = int[3](1, 17, 137);\nconst int[137] SWAP = int[137](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576,32769,32770,32772,32776,32784,32800,32832,32896,33024,33280,33792,34816,36864,40960,49152);\n#elif HASH_SIZE == 17\nconst int SWAP_COUNT[3] = int[3](1, 18, 154);\nconst int[154] SWAP = int[154](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576,32769,32770,32772,32776,32784,32800,32832,32896,33024,33280,33792,34816,36864,40960,49152,65537,65538,65540,65544,65552,65568,65600,65664,65792,66048,66560,67584,69632,73728,81920,98304);\n#elif HASH_SIZE == 18\nconst int SWAP_COUNT[3] = int[3](1, 19, 172);\nconst int[172] SWAP = int[172](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576,32769,32770,32772,32776,32784,32800,32832,32896,33024,33280,33792,34816,36864,40960,49152,65537,65538,65540,65544,65552,65568,65600,65664,65792,66048,66560,67584,69632,73728,81920,98304,131073,131074,131076,131080,131088,131104,131136,131200,131328,131584,132096,133120,135168,139264,147456,163840,196608);\n#elif HASH_SIZE == 19\nconst int SWAP_COUNT[3] = int[3](1, 20, 191);\nconst int[191] SWAP = int[191](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576,32769,32770,32772,32776,32784,32800,32832,32896,33024,33280,33792,34816,36864,40960,49152,65537,65538,65540,65544,65552,65568,65600,65664,65792,66048,66560,67584,69632,73728,81920,98304,131073,131074,131076,131080,131088,131104,131136,131200,131328,131584,132096,133120,135168,139264,147456,163840,196608,262145,262146,262148,262152,262160,262176,262208,262272,262400,262656,263168,264192,266240,270336,278528,294912,327680,393216);\n#elif HASH_SIZE == 20\nconst int SWAP_COUNT[3] = int[3](1, 21, 211);\nconst int[211] SWAP = int[211](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576,32769,32770,32772,32776,32784,32800,32832,32896,33024,33280,33792,34816,36864,40960,49152,65537,65538,65540,65544,65552,65568,65600,65664,65792,66048,66560,67584,69632,73728,81920,98304,131073,131074,131076,131080,131088,131104,131136,131200,131328,131584,132096,133120,135168,139264,147456,163840,196608,262145,262146,262148,262152,262160,262176,262208,262272,262400,262656,263168,264192,266240,270336,278528,294912,327680,393216,524289,524290,524292,524296,524304,524320,524352,524416,524544,524800,525312,526336,528384,532480,540672,557056,589824,655360,786432);\n#else\n#error Invalid HASH_SIZE\n#endif\n#if LEVEL < 0 || LEVEL > 2\n#error Invalid LEVEL\n#endif\nconst uint END_OF_LIST = 0xFFFFFFFFu;\nconst int NUMBER_OF_HASHES = SWAP_COUNT[LEVEL];\nuint sequenceElement(int sequenceIndex, int elementIndex)\n{\nint offset = (SEQUENCE_MAXLEN) * sequenceIndex + elementIndex;\nuvec4 tuple = sequences[offset / 4];\nreturn tuple[offset & 3];\n}\nint descriptorHash(uint[DESCRIPTOR_SIZE] descriptor, int sequenceIndex)\n{\nuint bit, b, m;\nint hash = 0;\n@unroll\nfor(int i = 0; i < HASH_SIZE; i++) {\nbit = sequenceElement(sequenceIndex, i);\nb = bit >> 3u;\nm = 1u << (bit & 7u);\nhash = (hash << 1) | int((descriptor[b] & m) != 0u);\n}\nreturn hash;\n}\n#define readTableData(tables, tablesStride, rasterIndex) decodeUint32(texelFetch((tables), ivec2((rasterIndex) % (tablesStride), (rasterIndex) / (tablesStride)), 0))\nvoid main()\n{\nivec2 thread = threadLocation();\nint keypointIndex = thread.x + thread.y * matcherLength;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\ncolor = encodeKeypointMatch(MATCH_NOT_FOUND);\nif(isBadKeypoint(keypoint))\nreturn;\nKeypointMatch candidate = decodeKeypointMatch(threadPixel(candidates));\nKeypointMatch mfilter = decodeKeypointMatch(threadPixel(filters));\nuint[DESCRIPTOR_SIZE] candidateDescriptor;\nuint[DESCRIPTOR_SIZE] descriptor = readKeypointDescriptor(encodedKeypoints, descriptorSize, extraSize, encoderLength, address);\nint hash0 = descriptorHash(descriptor, tableIndex);\nfor(int h = 0; h < NUMBER_OF_HASHES; h++) {\nint hash = hash0 ^ SWAP[h];\nint tableAddress = tableIndex * bucketsPerTable * bucketCapacity;\nint bucketAddress = tableAddress + hash * bucketCapacity;\nbool validEntry = true;\nfor(int b = 0; b < bucketCapacity; b++) {\nint entryAddress = bucketAddress + b;\nuint entry = validEntry ? readTableData(tables, tablesStride, entryAddress) : END_OF_LIST;\nvalidEntry = (validEntry && entry != END_OF_LIST);\nint candidateIndex = int(entry);\ncandidateDescriptor = readKeypointDescriptorFromDB(descriptorDB, descriptorDBStride, validEntry ? candidateIndex : -1);\nint descriptorDistance = distanceBetweenKeypointDescriptors(descriptor, candidateDescriptor);\nKeypointMatch match = KeypointMatch(candidateIndex, descriptorDistance);\nbool betterThanCandidate = (match.dist < candidate.dist) || (match.dist == candidate.dist && match.index > candidate.index);\nbool worseThanFilter = (match.dist > mfilter.dist) || (match.dist == mfilter.dist && match.index < mfilter.index);\nbool nicerMatch = (validEntry && betterThanCandidate && worseThanFilter);\nivec2 v = nicerMatch ? ivec2(match.index, match.dist) : ivec2(candidate.index, candidate.dist);\ncandidate = KeypointMatch(v.x, v.y);\n}\n}\ncolor = encodeKeypointMatch(candidate);\n}'},2648:e=>{e.exports='@include "keypoints.glsl"\n@include "int32.glsl"\n#if !defined(STAGE)\n#error Undefined STAGE\n#elif STAGE == 1\nuniform sampler2D encodedKeypointsA;\nuniform sampler2D encodedKeypointsB;\nuniform int encoderLengthA;\nuniform int encoderLengthB;\nuniform int encoderCapacityA;\nuniform int encoderCapacityB;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#elif STAGE == 2\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int maxKeypoints;\n#elif STAGE == 3\nuniform sampler2D array;\nuniform int blockSize;\n#elif STAGE == 4\nuniform sampler2D array;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#elif STAGE == 5\nuniform sampler2D array;\n#else\n#error Invalid STAGE\n#endif\n#define NULL_KEYPOINT_INDEX 0xFFFF\nconst highp uint UNIT = 0x10000u;\nvoid main()\n{\n#if STAGE == 1\nivec2 thread = threadLocation();\nKeypointAddress addr = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint keypointIndex = findKeypointIndex(addr, descriptorSize, extraSize);\nint newKeypointIndex = keypointIndex < encoderCapacityA ? keypointIndex : keypointIndex - encoderCapacityA;\ncolor = encodeNullKeypoint();\nif(newKeypointIndex >= max(encoderCapacityA, encoderCapacityB))\nreturn;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\naddr = KeypointAddress(newKeypointIndex * pixelsPerKeypoint, addr.offset);\nvec4 dataA = readKeypointData(encodedKeypointsA, encoderLengthA, addr);\nvec4 dataB = readKeypointData(encodedKeypointsB, encoderLengthB, addr);\ncolor = keypointIndex < encoderCapacityA ? dataA : dataB;\n#elif STAGE == 2\nivec2 thread = threadLocation();\nint keypointIndex = thread.y * outputSize().x + thread.x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress addr = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, addr);\nbool isValid = !isNullKeypoint(keypoint) && keypointIndex < maxKeypoints;\nkeypointIndex = isValid ? keypointIndex : NULL_KEYPOINT_INDEX;\ncolor = encodeUint32(uint(keypointIndex & 0xFFFF) | (isValid ? UNIT : 0u));\n#elif STAGE == 3\nivec2 thread = threadLocation();\nivec2 size = outputSize();\nint arrayLength = size.x * size.y;\nint arrayIndex = thread.y * size.x + thread.x;\nint arrayIndexLeft = arrayIndex - blockSize;\nint arrayIndexRight = arrayIndex + blockSize;\nint mask = int(arrayIndexRight < arrayLength || arrayIndexRight / blockSize == (arrayLength - 1) / blockSize);\narrayIndexLeft = max(0, arrayIndexLeft);\narrayIndexRight = min(arrayLength - 1, arrayIndexRight);\n#define raster2pos(k) ivec2((k) % size.x, (k) / size.x)\nuvec3 entries32 = uvec3(\ndecodeUint32(threadPixel(array)),\ndecodeUint32(texelFetch(array, raster2pos(arrayIndexLeft), 0)),\ndecodeUint32(texelFetch(array, raster2pos(arrayIndexRight), 0))\n);\nivec3 sb = ivec3((entries32 >> 16u) & 0xFFFFu);\nsb.z *= mask;\nint dblBlockSize = 2 * blockSize;\nint offset = arrayIndex % dblBlockSize;\nint s2b = sb.x + (offset < blockSize ? sb.z : sb.y);\nint l2b = offset < blockSize ? sb.x : sb.y;\nuint keypointIndex = entries32.x & 0xFFFFu;\nuint shiftedS2b = uint(s2b) << 16u;\ncolor = encodeUint32(uint(NULL_KEYPOINT_INDEX) | shiftedS2b);\nif(offset >= s2b)\nreturn;\ncolor = encodeUint32(keypointIndex | shiftedS2b);\nif(offset < l2b)\nreturn;\nvec4 entry = texelFetch(array, raster2pos(arrayIndex + blockSize - l2b), 0);\nkeypointIndex = decodeUint32(entry) & 0xFFFFu;\ncolor = encodeUint32(keypointIndex | shiftedS2b);\n#elif STAGE == 4\nivec2 thread = threadLocation();\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress addr = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint keypointIndex = findKeypointIndex(addr, descriptorSize, extraSize);\n#define raster2pos(k) ivec2((k) % size.x, (k) / size.x)\nivec2 size = textureSize(array, 0);\nuint sortedPair = decodeUint32(texelFetch(array, raster2pos(keypointIndex), 0));\nint newKeypointIndex = int(sortedPair & 0xFFFFu);\ncolor = encodeNullKeypoint();\nif(newKeypointIndex == NULL_KEYPOINT_INDEX || keypointIndex >= size.x * size.y)\nreturn;\nKeypointAddress newAddr = KeypointAddress(newKeypointIndex * pixelsPerKeypoint, addr.offset);\ncolor = readKeypointData(encodedKeypoints, encoderLength, newAddr);\n#elif STAGE == 5\nuint val = decodeUint32(threadPixel(array));\ncolor = (val & 0xFFFFu) == uint(NULL_KEYPOINT_INDEX) ? vec4(0,1,1,1) : vec4(1,0,0,1);\n#endif\n}'},8825:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\n@include "filters.glsl"\n#if !defined(USE_LAPLACIAN)\n#error Undefined USE_LAPLACIAN\n#endif\nuniform sampler2D corners;\nuniform sampler2D pyramid;\nuniform float lodStep;\n#if USE_LAPLACIAN\nuniform sampler2D pyrLaplacian;\n#endif\nvoid main()\n{\nivec2 thread = threadLocation();\nvec4 pixel = threadPixel(corners);\nfloat score = decodeFloat16(pixel.rb);\nfloat myEncodedLod = pixel.a;\nfloat lod = decodeLod(myEncodedLod);\nfloat lodPlus = lod + lodStep;\nfloat lodMinus = lod - lodStep;\nfloat pot = exp2(lod);\nfloat potPlus = exp2(lodPlus);\nfloat potMinus = exp2(lodMinus);\ncolor = pixel;\nif(score == 0.0f)\nreturn;\n#define P(p,u,v) textureLod(corners, texCoord + (p) * vec2((u),(v)) / texSize, 0.0f)\nvec4 pix[18];\n#define D(u,v) P(potMinus,(u),(v))\npix[0] = D(-1,-1); pix[1] = D(0,-1); pix[2] = D(1,-1);\npix[3] = D(-1,0); pix[4] = D(0,0); pix[5] = D(1,0);\npix[6] = D(-1,1); pix[7] = D(0,1); pix[8] = D(1,1);\n#define U(u,v) P(potPlus,(u),(v))\npix[9] = U(-1,-1); pix[10] = U(0,-1); pix[11] = U(1,-1);\npix[12] = U(-1,0); pix[13] = U(0,0); pix[14] = U(1,0);\npix[15] = U(-1,1); pix[16] = U(0,1); pix[17] = U(1,1);\nfloat scores[18];\n#define C(j) decodeFloat16(pix[j].rb)\nscores[0] = C(0); scores[1] = C(1); scores[2] = C(2);\nscores[3] = C(3); scores[4] = C(4); scores[5] = C(5);\nscores[6] = C(6); scores[7] = C(7); scores[8] = C(8);\nscores[9] = C(9); scores[10] = C(10); scores[11] = C(11);\nscores[12] = C(12); scores[13] = C(13); scores[14] = C(14);\nscores[15] = C(15); scores[16] = C(16); scores[17] = C(17);\nfloat lods[18];\n#define E(j) decodeLod(pix[j].a)\nlods[0] = E(0); lods[1] = E(1); lods[2] = E(2);\nlods[3] = E(3); lods[4] = E(4); lods[5] = E(5);\nlods[6] = E(6); lods[7] = E(7); lods[8] = E(8);\nlods[9] = E(9); lods[10] = E(10); lods[11] = E(11);\nlods[12] = E(12); lods[13] = E(13); lods[14] = E(14);\nlods[15] = E(15); lods[16] = E(16); lods[17] = E(17);\n#if USE_LAPLACIAN\n#define L(p,u,v) textureLod(pyrLaplacian, texCoord + (p) * vec2((u),(v)) / texSize, 0.0f)\nmat3 strengths[2];\nstrengths[0] = mat3(\n#define Lm(u,v) abs(decodeFloat16(L(potMinus,(u),(v)).xy))\nLm(-1,-1), Lm(0,-1), Lm(1,-1),\nLm(-1,0), Lm(0,0), Lm(1,0),\nLm(-1,1), Lm(0,1), Lm(1,1)\n);\nstrengths[1] = mat3(\n#define Lp(u,v) abs(decodeFloat16(L(potPlus,(u),(v)).zw))\nLp(-1,-1), Lp(0,-1), Lp(1,-1),\nLp(-1,0), Lp(0,0), Lp(1,0),\nLp(-1,1), Lp(0,1), Lp(1,1)\n);\nfloat myStrength = abs(laplacian(pyramid, vec2(thread), lod));\n#else\n#define L(u,v) (((v)+1)*3 + ((u)+1))\nmat3 strengths[2];\nstrengths[0] = mat3(\n#define Lm(u,v) scores[L((u),(v))]\nLm(-1,-1), Lm(0,-1), Lm(1,-1),\nLm(-1,0), Lm(0,0), Lm(1,0),\nLm(-1,1), Lm(0,1), Lm(1,1)\n);\nstrengths[1] = mat3(\n#define Lp(u,v) scores[9 + L((u),(v))]\nLp(-1,-1), Lp(0,-1), Lp(1,-1),\nLp(-1,0), Lp(0,0), Lp(1,0),\nLp(-1,1), Lp(0,1), Lp(1,1)\n);\nfloat myStrength = score;\n#endif\n#define B(j,lod) float(isSameLod(lods[j], (lod))) * float(scores[j] > 0.0f)\nmat3 nearLod[2];\nnearLod[0] = mat3(\n#define Bm(j) B((j), lodMinus)\nBm(0), Bm(1), Bm(2),\nBm(3), Bm(4), Bm(5),\nBm(6), Bm(7), Bm(8)\n);\nnearLod[1] = mat3(\n#define Bp(j) B((j), lodPlus)\nBp(9), Bp(10), Bp(11),\nBp(12), Bp(13), Bp(14),\nBp(15), Bp(16), Bp(17)\n);\nmat3 upStrengths = matrixCompMult(strengths[1], nearLod[1]);\nmat3 downStrengths = matrixCompMult(strengths[0], nearLod[0]);\nvec3 maxUpStrength3 = max(upStrengths[0], max(upStrengths[1], upStrengths[2]));\nvec3 maxDownStrength3 = max(downStrengths[0], max(downStrengths[1], downStrengths[2]));\nvec3 maxStrength3 = max(maxUpStrength3, maxDownStrength3);\nfloat maxStrength = max(maxStrength3.x, max(maxStrength3.y, maxStrength3.z));\ncolor.rb = encodeFloat16(score * step(maxStrength, myStrength));\n}'},5693:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\nuniform sampler2D corners;\nvoid main()\n{\nivec2 thread = threadLocation();\nvec4 pixel = threadPixel(corners);\nfloat encodedLod = pixel.a;\nfloat score = decodeFloat16(pixel.rb);\nfloat lod = decodeLod(encodedLod);\nfloat pot = exp2(lod);\ncolor = pixel;\nif(score == 0.0f)\nreturn;\n#if 1\nvec2 gridSize = vec2(pot);\nvec2 gridLocation = floor(mod(texCoord * texSize, gridSize));\nvec2 gridDelta = gridLocation / gridSize - vec2(0.5f);\nfloat gridStep = 1.0f / pot;\nconst float adjustment = 1.25f;\ncolor.rb = encodeFloat16(0.0f);\nif(max(abs(gridDelta.x), abs(gridDelta.y)) > adjustment * gridStep)\nreturn;\n#endif\n#define P(x,y) textureLod(corners, texCoord + pot * vec2((x), (y)) / texSize, 0.0f)\nvec4 pix[9];\npix[0] = P(-1,-1); pix[1] = P(0,-1); pix[2] = P(1,-1);\npix[3] = P(-1, 0); pix[4] = pixel; pix[5] = P(1, 0);\npix[6] = P(-1, 1); pix[7] = P(0, 1); pix[8] = P(1, 1);\n#define S(j) decodeFloat16(pix[j].rb)\nmat3 scores = mat3(\nS(0), S(1), S(2),\nS(3), S(4), S(5),\nS(6), S(7), S(8)\n);\n#define B(j) float(isSameLod(decodeLod(pix[j].a), lod))\nmat3 sameLod = mat3(\nB(0), B(1), B(2),\nB(3), B(4), B(5),\nB(6), B(7), B(8)\n);\nmat3 sameLodScores = matrixCompMult(scores, sameLod);\nvec3 maxScore3 = max(sameLodScores[0], max(sameLodScores[1], sameLodScores[2]));\nfloat maxScore = max(maxScore3.x, max(maxScore3.y, maxScore3.z));\ncolor.rb = encodeFloat16(score * step(maxScore, score));\n}'},9280:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\nuniform sampler2D image;\nuniform float lodStep;\n#if !defined(MULTISCALE)\n#error Must define MULTISCALE\n#elif MULTISCALE != 0\n#define LOD_STEP (lodStep)\n#define USE_MIDDLE_RING\n#else\n#define LOD_STEP (0.0f)\n#endif\n#define PIX(x,y) pixelAtShortOffset(image, ivec2((x),(y)))\n#define L2(v,i) bvec2(isSameEncodedLod(v[i].a, alphaMinus), isSameEncodedLod(v[i].a, alphaPlus))\n#define L3(v,i) bvec3(isSameEncodedLod(v[i].a, alpha), isSameEncodedLod(v[i].a, alphaMinus), isSameEncodedLod(v[i].a, alphaPlus))\n#define S3(v,i) decodeFloat16(v[i].rb) * float(any(L3(v,i)))\n#define S2(v,i) decodeFloat16(v[i].rb) * float(any(L2(v,i)))\n#define P(i) S3(p,i)\n#define Q(i) S2(q,i)\n#define R(i) S2(r,i)\nconst vec4 O = vec4(0.0f);\nvoid main()\n{\nvec4 pixel = threadPixel(image);\nfloat lod = decodeLod(pixel.a);\nfloat score = decodeFloat16(pixel.rb);\ncolor = pixel;\nif(score == 0.0f)\nreturn;\nvec4 p[8];\np[0] = PIX(0,1); p[1] = PIX(1,1); p[2] = PIX(1,0); p[3] = PIX(1,-1);\np[4] = PIX(0,-1); p[5] = PIX(-1,-1); p[6] = PIX(-1,0); p[7] = PIX(-1,1);\n#ifdef USE_MIDDLE_RING\nvec4 q[16];\nq[0] = PIX(0,2); q[1] = PIX(1,2); q[2] = PIX(2,2); q[3] = PIX(2,1);\nq[4] = PIX(2,0); q[5] = PIX(2,-1); q[6] = PIX(2,-2); q[7] = PIX(1,-2);\nq[8] = PIX(0,-2); q[9] = PIX(-1,-2); q[10] = PIX(-2,-2); q[11] = PIX(-2,-1);\nq[12] = PIX(-2,0); q[13] = PIX(-2,1); q[14] = PIX(-2,2); q[15] = PIX(-1,2);\n#else\nvec4 q[16];\nq[0] = O; q[1] = O; q[2] = O; q[3] = O;\nq[4] = O; q[5] = O; q[6] = O; q[7] = O;\nq[8] = O; q[9] = O; q[10] = O; q[11] = O;\nq[12] = O; q[13] = O; q[14] = O; q[15] = O;\n#endif\n#ifdef USE_OUTER_RING\nvec4 r[16];\nr[0] = PIX(0,3); r[1] = PIX(1,3); r[2] = PIX(3,1); r[3] = PIX(3,0);\nr[4] = PIX(3,-1); r[5] = PIX(1,-3); r[6] = PIX(0,-3); r[7] = PIX(-1,-3);\nr[8] = PIX(-3,-1); r[9] = PIX(-3,0); r[10] = PIX(-3,1); r[11] = PIX(-1,3);\nr[12] = PIX(0,4); r[13] = PIX(4,0); r[14] = PIX(0,-4); r[15] = PIX(-4,0);\n#else\nvec4 r[16];\nr[0] = O; r[1] = O; r[2] = O; r[3] = O;\nr[4] = O; r[5] = O; r[6] = O; r[7] = O;\nr[8] = O; r[9] = O; r[10] = O; r[11] = O;\nr[12] = O; r[13] = O; r[14] = O; r[15] = O;\n#endif\nfloat alphaPlus = encodeLod(lod + LOD_STEP);\nfloat alphaMinus = encodeLod(lod - LOD_STEP);\nfloat alpha = encodeLod(lod);\nmat3 innerScore = mat3(\nP(0), P(1), P(2), P(3),\nP(4), P(5), P(6), P(7),\n0.0f);\nmat4 middleScore = mat4(\nQ(0), Q(1), Q(2), Q(3),\nQ(4), Q(5), Q(6), Q(7),\nQ(8), Q(9), Q(10), Q(11),\nQ(12), Q(13), Q(14), Q(15)\n);\nmat4 outerScore = mat4(\nR(0), R(1), R(2), R(3),\nR(4), R(5), R(6), R(7),\nR(8), R(9), R(10), R(11),\nR(12), R(13), R(14), R(15)\n);\nvec3 maxInnerScore3 = max(innerScore[0], max(innerScore[1], innerScore[2]));\nvec4 maxMiddleScore4 = max(max(middleScore[0], middleScore[1]), max(middleScore[2], middleScore[3]));\nvec4 maxOuterScore4 = max(max(outerScore[0], outerScore[1]), max(outerScore[2], outerScore[3]));\nfloat maxInnerScore = max(maxInnerScore3.x, max(maxInnerScore3.y, maxInnerScore3.z));\nfloat maxMiddleScore = max(max(maxMiddleScore4.x, maxMiddleScore4.y), max(maxMiddleScore4.z, maxMiddleScore4.w));\nfloat maxOuterScore = max(max(maxOuterScore4.x, maxOuterScore4.y), max(maxOuterScore4.z, maxOuterScore4.w));\nfloat maxScore = max(maxInnerScore, max(maxMiddleScore, maxOuterScore));\nfloat finalScore = step(maxScore, score) * score;\ncolor.rb = encodeFloat16(finalScore);\n}'},9108:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedCorners;\nuniform int encoderLength;\nuniform sampler2D image;\nuniform int extraSize;\nconst int descriptorSize = 32;\n#define P(a,b,c,d) ivec4((a),(b),(c),(d))\nconst ivec4 pat31[256] = ivec4[256](\nP(8,-3,9,5),\nP(4,2,7,-12),\nP(-11,9,-8,2),\nP(7,-12,12,-13),\nP(2,-13,2,12),\nP(1,-7,1,6),\nP(-2,-10,-2,-4),\nP(-13,-13,-11,-8),\nP(-13,-3,-12,-9),\nP(10,4,11,9),\nP(-13,-8,-8,-9),\nP(-11,7,-9,12),\nP(7,7,12,6),\nP(-4,-5,-3,0),\nP(-13,2,-12,-3),\nP(-9,0,-7,5),\nP(12,-6,12,-1),\nP(-3,6,-2,12),\nP(-6,-13,-4,-8),\nP(11,-13,12,-8),\nP(4,7,5,1),\nP(5,-3,10,-3),\nP(3,-7,6,12),\nP(-8,-7,-6,-2),\nP(-2,11,-1,-10),\nP(-13,12,-8,10),\nP(-7,3,-5,-3),\nP(-4,2,-3,7),\nP(-10,-12,-6,11),\nP(5,-12,6,-7),\nP(5,-6,7,-1),\nP(1,0,4,-5),\nP(9,11,11,-13),\nP(4,7,4,12),\nP(2,-1,4,4),\nP(-4,-12,-2,7),\nP(-8,-5,-7,-10),\nP(4,11,9,12),\nP(0,-8,1,-13),\nP(-13,-2,-8,2),\nP(-3,-2,-2,3),\nP(-6,9,-4,-9),\nP(8,12,10,7),\nP(0,9,1,3),\nP(7,-5,11,-10),\nP(-13,-6,-11,0),\nP(10,7,12,1),\nP(-6,-3,-6,12),\nP(10,-9,12,-4),\nP(-13,8,-8,-12),\nP(-13,0,-8,-4),\nP(3,3,7,8),\nP(5,7,10,-7),\nP(-1,7,1,-12),\nP(3,-10,5,6),\nP(2,-4,3,-10),\nP(-13,0,-13,5),\nP(-13,-7,-12,12),\nP(-13,3,-11,8),\nP(-7,12,-4,7),\nP(6,-10,12,8),\nP(-9,-1,-7,-6),\nP(-2,-5,0,12),\nP(-12,5,-7,5),\nP(3,-10,8,-13),\nP(-7,-7,-4,5),\nP(-3,-2,-1,-7),\nP(2,9,5,-11),\nP(-11,-13,-5,-13),\nP(-1,6,0,-1),\nP(5,-3,5,2),\nP(-4,-13,-4,12),\nP(-9,-6,-9,6),\nP(-12,-10,-8,-4),\nP(10,2,12,-3),\nP(7,12,12,12),\nP(-7,-13,-6,5),\nP(-4,9,-3,4),\nP(7,-1,12,2),\nP(-7,6,-5,1),\nP(-13,11,-12,5),\nP(-3,7,-2,-6),\nP(7,-8,12,-7),\nP(-13,-7,-11,-12),\nP(1,-3,12,12),\nP(2,-6,3,0),\nP(-4,3,-2,-13),\nP(-1,-13,1,9),\nP(7,1,8,-6),\nP(1,-1,3,12),\nP(9,1,12,6),\nP(-1,-9,-1,3),\nP(-13,-13,-10,5),\nP(7,7,10,12),\nP(12,-5,12,9),\nP(6,3,7,11),\nP(5,-13,6,10),\nP(2,-12,2,3),\nP(3,8,4,-6),\nP(2,6,12,-13),\nP(9,-12,10,3),\nP(-8,4,-7,9),\nP(-11,12,-4,-6),\nP(1,12,2,-8),\nP(6,-9,7,-4),\nP(2,3,3,-2),\nP(6,3,11,0),\nP(3,-3,8,-8),\nP(7,8,9,3),\nP(-11,-5,-6,-4),\nP(-10,11,-5,10),\nP(-5,-8,-3,12),\nP(-10,5,-9,0),\nP(8,-1,12,-6),\nP(4,-6,6,-11),\nP(-10,12,-8,7),\nP(4,-2,6,7),\nP(-2,0,-2,12),\nP(-5,-8,-5,2),\nP(7,-6,10,12),\nP(-9,-13,-8,-8),\nP(-5,-13,-5,-2),\nP(8,-8,9,-13),\nP(-9,-11,-9,0),\nP(1,-8,1,-2),\nP(7,-4,9,1),\nP(-2,1,-1,-4),\nP(11,-6,12,-11),\nP(-12,-9,-6,4),\nP(3,7,7,12),\nP(5,5,10,8),\nP(0,-4,2,8),\nP(-9,12,-5,-13),\nP(0,7,2,12),\nP(-1,2,1,7),\nP(5,11,7,-9),\nP(3,5,6,-8),\nP(-13,-4,-8,9),\nP(-5,9,-3,-3),\nP(-4,-7,-3,-12),\nP(6,5,8,0),\nP(-7,6,-6,12),\nP(-13,6,-5,-2),\nP(1,-10,3,10),\nP(4,1,8,-4),\nP(-2,-2,2,-13),\nP(2,-12,12,12),\nP(-2,-13,0,-6),\nP(4,1,9,3),\nP(-6,-10,-3,-5),\nP(-3,-13,-1,1),\nP(7,5,12,-11),\nP(4,-2,5,-7),\nP(-13,9,-9,-5),\nP(7,1,8,6),\nP(7,-8,7,6),\nP(-7,-4,-7,1),\nP(-8,11,-7,-8),\nP(-13,6,-12,-8),\nP(2,4,3,9),\nP(10,-5,12,3),\nP(-6,-5,-6,7),\nP(8,-3,9,-8),\nP(2,-12,2,8),\nP(-11,-2,-10,3),\nP(-12,-13,-7,-9),\nP(-11,0,-10,-5),\nP(5,-3,11,8),\nP(-2,-13,-1,12),\nP(-1,-8,0,9),\nP(-13,-11,-12,-5),\nP(-10,-2,-10,11),\nP(-3,9,-2,-13),\nP(2,-3,3,2),\nP(-9,-13,-4,0),\nP(-4,6,-3,-10),\nP(-4,12,-2,-7),\nP(-6,-11,-4,9),\nP(6,-3,6,11),\nP(-13,11,-5,5),\nP(11,11,12,6),\nP(7,-5,12,-2),\nP(-1,12,0,7),\nP(-4,-8,-3,-2),\nP(-7,1,-6,7),\nP(-13,-12,-8,-13),\nP(-7,-2,-6,-8),\nP(-8,5,-6,-9),\nP(-5,-1,-4,5),\nP(-13,7,-8,10),\nP(1,5,5,-13),\nP(1,0,10,-13),\nP(9,12,10,-1),\nP(5,-8,10,-9),\nP(-1,11,1,-13),\nP(-9,-3,-6,2),\nP(-1,-10,1,12),\nP(-13,1,-8,-10),\nP(8,-11,10,-6),\nP(2,-13,3,-6),\nP(7,-13,12,-9),\nP(-10,-10,-5,-7),\nP(-10,-8,-8,-13),\nP(4,-6,8,5),\nP(3,12,8,-13),\nP(-4,2,-3,-3),\nP(5,-13,10,-12),\nP(4,-13,5,-1),\nP(-9,9,-4,3),\nP(0,3,3,-9),\nP(-12,1,-6,1),\nP(3,2,4,-8),\nP(-10,-10,-10,9),\nP(8,-13,12,12),\nP(-8,-12,-6,-5),\nP(2,2,3,7),\nP(10,6,11,-8),\nP(6,8,8,-12),\nP(-7,10,-6,5),\nP(-3,-9,-3,9),\nP(-1,-13,-1,5),\nP(-3,-7,-3,4),\nP(-8,-2,-8,3),\nP(4,2,12,12),\nP(2,-5,3,11),\nP(6,-9,11,-13),\nP(3,-1,7,12),\nP(11,-1,12,4),\nP(-3,0,-3,6),\nP(4,-11,4,12),\nP(2,-4,2,1),\nP(-10,-6,-8,1),\nP(-13,7,-11,1),\nP(-13,12,-11,-13),\nP(6,0,11,-13),\nP(0,-1,1,4),\nP(-13,3,-9,-2),\nP(-9,8,-6,-3),\nP(-13,-6,-8,-2),\nP(5,-9,8,10),\nP(2,7,3,-9),\nP(-1,-6,-1,-1),\nP(9,5,11,-2),\nP(11,-3,12,-8),\nP(3,0,3,5),\nP(-1,4,0,10),\nP(3,-6,4,5),\nP(-13,0,-10,5),\nP(5,8,12,11),\nP(8,9,9,-6),\nP(7,-4,8,-12),\nP(-10,4,-10,9),\nP(7,3,12,4),\nP(9,-7,10,-2),\nP(7,0,12,-2),\nP(-1,-6,0,-11)\n);\nvoid getPair(int index, mat2 rot, out vec2 p, out vec2 q)\n{\nivec4 data = pat31[index];\nvec2 op = vec2(data.xy);\nvec2 oq = vec2(data.zw);\np = rot * op;\nq = rot * oq;\n}\nvoid main()\n{\nvec4 pixel = threadPixel(encodedCorners);\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint descriptorCell = address.offset - sizeofEncodedKeypoint(0, extraSize) / 4;\ncolor = pixel;\nif(descriptorCell < 0)\nreturn;\nKeypoint keypoint = decodeKeypoint(encodedCorners, encoderLength, address);\nif(isBadKeypoint(keypoint))\nreturn;\nfloat degreesOrientation = round(360.0f + degrees(keypoint.orientation));\nfloat orientation = radians(degreesOrientation - mod(degreesOrientation, 12.0f));\nfloat kcos = cos(orientation);\nfloat ksin = sin(orientation);\nmat2 rot = mat2(kcos, ksin, -ksin, kcos);\nfloat pot = exp2(keypoint.lod);\nint patternStart = 32 * descriptorCell;\nuint test[4] = uint[4](0u, 0u, 0u, 0u);\nfor(int t = 0; t < 4; t++) {\nuint bits = 0u;\nvec2 p, q;\nvec4 a, b;\nint i = t * 8;\n@unroll\nfor(int j = 0; j < 8; j++) {\ngetPair(patternStart + i + j, rot, p, q);\na = texelFetch(image, ivec2(round(keypoint.position + pot * p)), 0);\nb = texelFetch(image, ivec2(round(keypoint.position + pot * q)), 0);\nbits |= uint(a.g < b.g) << j;\n}\ntest[t] = bits;\n}\ncolor = vec4(test[0], test[1], test[2], test[3]) / 255.0f;\n}'},7137:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D image;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#define P(x,y) ivec2((x),(y))\nconst int diskPointCount[16] = int[16](0, 4, 12, 28, 48, 80, 112, 148, 196, 252, 316, 376, 440, 528, 612, 708);\nconst ivec2 diskPoint[708] = ivec2[708](\nP(0,-1),P(-1,0),P(1,0),P(0,1),\nP(-1,-1),P(1,-1),P(-1,1),P(1,1),P(0,-2),P(-2,0),P(2,0),P(0,2),\nP(-1,-2),P(1,-2),P(-2,-1),P(2,-1),P(-2,1),P(2,1),P(-1,2),P(1,2),P(-2,-2),P(2,-2),P(-2,2),P(2,2),P(0,-3),P(-3,0),P(3,0),P(0,3),\nP(-1,-3),P(1,-3),P(-3,-1),P(3,-1),P(-3,1),P(3,1),P(-1,3),P(1,3),P(-2,-3),P(2,-3),P(-3,-2),P(3,-2),P(-3,2),P(3,2),P(-2,3),P(2,3),P(0,-4),P(-4,0),P(4,0),P(0,4),\nP(-1,-4),P(1,-4),P(-4,-1),P(4,-1),P(-4,1),P(4,1),P(-1,4),P(1,4),P(-3,-3),P(3,-3),P(-3,3),P(3,3),P(-2,-4),P(2,-4),P(-4,-2),P(4,-2),P(-4,2),P(4,2),P(-2,4),P(2,4),P(0,-5),P(-3,-4),P(3,-4),P(-4,-3),P(4,-3),P(-5,0),P(5,0),P(-4,3),P(4,3),P(-3,4),P(3,4),P(0,5),\nP(-1,-5),P(1,-5),P(-5,-1),P(5,-1),P(-5,1),P(5,1),P(-1,5),P(1,5),P(-2,-5),P(2,-5),P(-5,-2),P(5,-2),P(-5,2),P(5,2),P(-2,5),P(2,5),P(-4,-4),P(4,-4),P(-4,4),P(4,4),P(-3,-5),P(3,-5),P(-5,-3),P(5,-3),P(-5,3),P(5,3),P(-3,5),P(3,5),P(0,-6),P(-6,0),P(6,0),P(0,6),\nP(-1,-6),P(1,-6),P(-6,-1),P(6,-1),P(-6,1),P(6,1),P(-1,6),P(1,6),P(-2,-6),P(2,-6),P(-6,-2),P(6,-2),P(-6,2),P(6,2),P(-2,6),P(2,6),P(-4,-5),P(4,-5),P(-5,-4),P(5,-4),P(-5,4),P(5,4),P(-4,5),P(4,5),P(-3,-6),P(3,-6),P(-6,-3),P(6,-3),P(-6,3),P(6,3),P(-3,6),P(3,6),P(0,-7),P(-7,0),P(7,0),P(0,7),\nP(-1,-7),P(1,-7),P(-5,-5),P(5,-5),P(-7,-1),P(7,-1),P(-7,1),P(7,1),P(-5,5),P(5,5),P(-1,7),P(1,7),P(-4,-6),P(4,-6),P(-6,-4),P(6,-4),P(-6,4),P(6,4),P(-4,6),P(4,6),P(-2,-7),P(2,-7),P(-7,-2),P(7,-2),P(-7,2),P(7,2),P(-2,7),P(2,7),P(-3,-7),P(3,-7),P(-7,-3),P(7,-3),P(-7,3),P(7,3),P(-3,7),P(3,7),P(-5,-6),P(5,-6),P(-6,-5),P(6,-5),P(-6,5),P(6,5),P(-5,6),P(5,6),P(0,-8),P(-8,0),P(8,0),P(0,8),\nP(-1,-8),P(1,-8),P(-4,-7),P(4,-7),P(-7,-4),P(7,-4),P(-8,-1),P(8,-1),P(-8,1),P(8,1),P(-7,4),P(7,4),P(-4,7),P(4,7),P(-1,8),P(1,8),P(-2,-8),P(2,-8),P(-8,-2),P(8,-2),P(-8,2),P(8,2),P(-2,8),P(2,8),P(-6,-6),P(6,-6),P(-6,6),P(6,6),P(-3,-8),P(3,-8),P(-8,-3),P(8,-3),P(-8,3),P(8,3),P(-3,8),P(3,8),P(-5,-7),P(5,-7),P(-7,-5),P(7,-5),P(-7,5),P(7,5),P(-5,7),P(5,7),P(-4,-8),P(4,-8),P(-8,-4),P(8,-4),P(-8,4),P(8,4),P(-4,8),P(4,8),P(0,-9),P(-9,0),P(9,0),P(0,9),\nP(-1,-9),P(1,-9),P(-9,-1),P(9,-1),P(-9,1),P(9,1),P(-1,9),P(1,9),P(-2,-9),P(2,-9),P(-6,-7),P(6,-7),P(-7,-6),P(7,-6),P(-9,-2),P(9,-2),P(-9,2),P(9,2),P(-7,6),P(7,6),P(-6,7),P(6,7),P(-2,9),P(2,9),P(-5,-8),P(5,-8),P(-8,-5),P(8,-5),P(-8,5),P(8,5),P(-5,8),P(5,8),P(-3,-9),P(3,-9),P(-9,-3),P(9,-3),P(-9,3),P(9,3),P(-3,9),P(3,9),P(-4,-9),P(4,-9),P(-9,-4),P(9,-4),P(-9,4),P(9,4),P(-4,9),P(4,9),P(-7,-7),P(7,-7),P(-7,7),P(7,7),P(0,-10),P(-6,-8),P(6,-8),P(-8,-6),P(8,-6),P(-10,0),P(10,0),P(-8,6),P(8,6),P(-6,8),P(6,8),P(0,10),\nP(-1,-10),P(1,-10),P(-10,-1),P(10,-1),P(-10,1),P(10,1),P(-1,10),P(1,10),P(-2,-10),P(2,-10),P(-10,-2),P(10,-2),P(-10,2),P(10,2),P(-2,10),P(2,10),P(-5,-9),P(5,-9),P(-9,-5),P(9,-5),P(-9,5),P(9,5),P(-5,9),P(5,9),P(-3,-10),P(3,-10),P(-10,-3),P(10,-3),P(-10,3),P(10,3),P(-3,10),P(3,10),P(-7,-8),P(7,-8),P(-8,-7),P(8,-7),P(-8,7),P(8,7),P(-7,8),P(7,8),P(-4,-10),P(4,-10),P(-10,-4),P(10,-4),P(-10,4),P(10,4),P(-4,10),P(4,10),P(-6,-9),P(6,-9),P(-9,-6),P(9,-6),P(-9,6),P(9,6),P(-6,9),P(6,9),P(0,-11),P(-11,0),P(11,0),P(0,11),\nP(-1,-11),P(1,-11),P(-11,-1),P(11,-1),P(-11,1),P(11,1),P(-1,11),P(1,11),P(-2,-11),P(2,-11),P(-5,-10),P(5,-10),P(-10,-5),P(10,-5),P(-11,-2),P(11,-2),P(-11,2),P(11,2),P(-10,5),P(10,5),P(-5,10),P(5,10),P(-2,11),P(2,11),P(-8,-8),P(8,-8),P(-8,8),P(8,8),P(-3,-11),P(3,-11),P(-7,-9),P(7,-9),P(-9,-7),P(9,-7),P(-11,-3),P(11,-3),P(-11,3),P(11,3),P(-9,7),P(9,7),P(-7,9),P(7,9),P(-3,11),P(3,11),P(-6,-10),P(6,-10),P(-10,-6),P(10,-6),P(-10,6),P(10,6),P(-6,10),P(6,10),P(-4,-11),P(4,-11),P(-11,-4),P(11,-4),P(-11,4),P(11,4),P(-4,11),P(4,11),P(0,-12),P(-12,0),P(12,0),P(0,12),\nP(-1,-12),P(1,-12),P(-8,-9),P(8,-9),P(-9,-8),P(9,-8),P(-12,-1),P(12,-1),P(-12,1),P(12,1),P(-9,8),P(9,8),P(-8,9),P(8,9),P(-1,12),P(1,12),P(-5,-11),P(5,-11),P(-11,-5),P(11,-5),P(-11,5),P(11,5),P(-5,11),P(5,11),P(-2,-12),P(2,-12),P(-12,-2),P(12,-2),P(-12,2),P(12,2),P(-2,12),P(2,12),P(-7,-10),P(7,-10),P(-10,-7),P(10,-7),P(-10,7),P(10,7),P(-7,10),P(7,10),P(-3,-12),P(3,-12),P(-12,-3),P(12,-3),P(-12,3),P(12,3),P(-3,12),P(3,12),P(-6,-11),P(6,-11),P(-11,-6),P(11,-6),P(-11,6),P(11,6),P(-6,11),P(6,11),P(-4,-12),P(4,-12),P(-12,-4),P(12,-4),P(-12,4),P(12,4),P(-4,12),P(4,12),P(-9,-9),P(9,-9),P(-9,9),P(9,9),P(-8,-10),P(8,-10),P(-10,-8),P(10,-8),P(-10,8),P(10,8),P(-8,10),P(8,10),P(0,-13),P(-5,-12),P(5,-12),P(-12,-5),P(12,-5),P(-13,0),P(13,0),P(-12,5),P(12,5),P(-5,12),P(5,12),P(0,13),\nP(-1,-13),P(1,-13),P(-7,-11),P(7,-11),P(-11,-7),P(11,-7),P(-13,-1),P(13,-1),P(-13,1),P(13,1),P(-11,7),P(11,7),P(-7,11),P(7,11),P(-1,13),P(1,13),P(-2,-13),P(2,-13),P(-13,-2),P(13,-2),P(-13,2),P(13,2),P(-2,13),P(2,13),P(-3,-13),P(3,-13),P(-13,-3),P(13,-3),P(-13,3),P(13,3),P(-3,13),P(3,13),P(-6,-12),P(6,-12),P(-12,-6),P(12,-6),P(-12,6),P(12,6),P(-6,12),P(6,12),P(-9,-10),P(9,-10),P(-10,-9),P(10,-9),P(-10,9),P(10,9),P(-9,10),P(9,10),P(-4,-13),P(4,-13),P(-8,-11),P(8,-11),P(-11,-8),P(11,-8),P(-13,-4),P(13,-4),P(-13,4),P(13,4),P(-11,8),P(11,8),P(-8,11),P(8,11),P(-4,13),P(4,13),P(-7,-12),P(7,-12),P(-12,-7),P(12,-7),P(-12,7),P(12,7),P(-7,12),P(7,12),P(-5,-13),P(5,-13),P(-13,-5),P(13,-5),P(-13,5),P(13,5),P(-5,13),P(5,13),P(0,-14),P(-14,0),P(14,0),P(0,14),\nP(-1,-14),P(1,-14),P(-14,-1),P(14,-1),P(-14,1),P(14,1),P(-1,14),P(1,14),P(-2,-14),P(2,-14),P(-10,-10),P(10,-10),P(-14,-2),P(14,-2),P(-14,2),P(14,2),P(-10,10),P(10,10),P(-2,14),P(2,14),P(-9,-11),P(9,-11),P(-11,-9),P(11,-9),P(-11,9),P(11,9),P(-9,11),P(9,11),P(-3,-14),P(3,-14),P(-6,-13),P(6,-13),P(-13,-6),P(13,-6),P(-14,-3),P(14,-3),P(-14,3),P(14,3),P(-13,6),P(13,6),P(-6,13),P(6,13),P(-3,14),P(3,14),P(-8,-12),P(8,-12),P(-12,-8),P(12,-8),P(-12,8),P(12,8),P(-8,12),P(8,12),P(-4,-14),P(4,-14),P(-14,-4),P(14,-4),P(-14,4),P(14,4),P(-4,14),P(4,14),P(-7,-13),P(7,-13),P(-13,-7),P(13,-7),P(-13,7),P(13,7),P(-7,13),P(7,13),P(-5,-14),P(5,-14),P(-10,-11),P(10,-11),P(-11,-10),P(11,-10),P(-14,-5),P(14,-5),P(-14,5),P(14,5),P(-11,10),P(11,10),P(-10,11),P(10,11),P(-5,14),P(5,14),P(0,-15),P(-9,-12),P(9,-12),P(-12,-9),P(12,-9),P(-15,0),P(15,0),P(-12,9),P(12,9),P(-9,12),P(9,12),P(0,15)\n);\nconst int DEFAULT_PATCH_RADIUS = 15;\nconst int MIN_PATCH_RADIUS = 2;\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nint keypointIndex = thread.x + thread.y * outputSize().x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\nvec2 m = vec2(0.0f);\nfloat pot = exp2(keypoint.lod);\nvec2 imageSize = vec2(textureSize(image, 0));\nint scaledRadius = int(ceil(float(DEFAULT_PATCH_RADIUS) / pot));\nint radius = max(scaledRadius, MIN_PATCH_RADIUS);\nint count = diskPointCount[radius];\nfor(int j = 0; j < count; j++) {\nvec2 offset = vec2(diskPoint[j]);\nvec2 position = keypoint.position + round(pot * offset);\nvec4 patchPixel = texture(image, (position + vec2(0.5f)) / imageSize);\nm += offset * patchPixel.g;\n}\nfloat angle = fastAtan2(m.y, m.x);\nfloat encodedOrientation = encodeKeypointOrientation(angle);\ncolor = vec4(0.0f, encodedOrientation, 0.0f, 0.0f);\n}'},9739:e=>{e.exports='@include "keypoints.glsl"\n@include "filters.glsl"\n#if !defined(METHOD)\n#error Undefined METHOD\n#endif\nuniform sampler2D pyramid;\nuniform float lodStep;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#if METHOD == 1\nuniform int threshold;\n#endif\nconst float eps = 1e-6;\nfloat cornerStrength(vec2 position, float lod)\n{\n#if METHOD == 0\nreturn laplacian(pyramid, position, lod);\n#elif METHOD == 1\nfloat pot = exp2(lod);\nfloat t = float(clamp(threshold, 0, 255)) / 255.0f;\n#define P(x,y) pyrPixelAtOffset(pyramid, lod, pot, ivec2((x),(y))).g\nmat4 mp = mat4(\nP(0,3),P(3,0),P(0,-3),P(-3,0),\nP(1,3),P(2,2),P(3,1),P(3,-1),\nP(2,-2),P(1,-3),P(-1,-3),P(-2,-2),\nP(-3,-1),P(-3,1),P(-2,2),P(-1,3)\n);\nfloat c = P(0,0);\nfloat ct = c + t, c_t = c - t;\nmat4 mct = mp - mat4(ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct);\nmat4 mc_t = mat4(c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t) - mp;\nconst vec4 zeros = vec4(0.0f), ones = vec4(1.0f);\nvec4 bs = max(mct[0], zeros), ds = max(mc_t[0], zeros);\nbs += max(mct[1], zeros); ds += max(mc_t[1], zeros);\nbs += max(mct[2], zeros); ds += max(mc_t[2], zeros);\nbs += max(mct[3], zeros); ds += max(mc_t[3], zeros);\nreturn max(dot(bs, ones), dot(ds, ones)) / 16.0f;\n#else\n#error Invalid method\n#endif\n}\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\ncolor = pixel;\nif(address.offset != 1)\nreturn;\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\nif(isBadKeypoint(keypoint))\nreturn;\nvec3 strength = vec3(\ncornerStrength(keypoint.position, max(0.0f, keypoint.lod - lodStep)),\ncornerStrength(keypoint.position, keypoint.lod),\ncornerStrength(keypoint.position, keypoint.lod + lodStep)\n);\nvec3 p = mat3(\n2, -3, 1,\n-4, 4, 0,\n2, -1, 0\n) * strength;\nfloat maxStrength = max(strength.x, max(strength.y, strength.z));\nvec3 diffStrength = abs(strength - vec3(maxStrength));\nvec3 strengthIndicators = vec3(lessThan(diffStrength, vec3(eps)));\nfloat maxPoint = min(1.0f, dot(vec3(0.0f, 0.5f, 1.0f), strengthIndicators));\nbool hasMax = p.x < -eps;\nfloat pmax = hasMax ? -0.5f * p.y / p.x : maxPoint;\nfloat alpha = abs(pmax - 0.5f) <= 0.5f ? pmax : maxPoint;\nfloat lodOffset = mix(-lodStep, lodStep, alpha);\nfloat lod = keypoint.lod + lodOffset;\ncolor.r = encodeLod(lod);\n}'},8231:e=>{e.exports='@include "float16.glsl"\nuniform sampler2D corners;\nuniform int iterationNumber;\nvoid main()\n{\nivec2 thread = threadLocation();\nivec2 bounds = outputSize();\nint jump = (1 << iterationNumber);\nint clusterLength = jump << 1;\nint clusterMask = clusterLength - 1;\nivec2 clusterPos = ivec2(thread >> (1 + iterationNumber)) << (1 + iterationNumber);\nivec2 next1 = clusterPos + ((thread - clusterPos + ivec2(jump, 0)) & clusterMask);\nivec2 next2 = clusterPos + ((thread - clusterPos + ivec2(0, jump)) & clusterMask);\nivec2 next3 = clusterPos + ((thread - clusterPos + ivec2(jump, jump)) & clusterMask);\nvec4 p0 = threadPixel(corners);\nvec4 p1 = texelFetch(corners, next1 % bounds, 0);\nvec4 p2 = texelFetch(corners, next2 % bounds, 0);\nvec4 p3 = texelFetch(corners, next3 % bounds, 0);\nfloat s0 = decodeFloat16(p0.rb);\nfloat s1 = decodeFloat16(p1.rb);\nfloat s2 = decodeFloat16(p2.rb);\nfloat s3 = decodeFloat16(p3.rb);\nbool b0 = s0 >= s1 && s0 >= s2 && s0 >= s3;\nbool b1 = s1 >= s0 && s1 >= s2 && s1 >= s3;\nbool b2 = s2 >= s0 && s2 >= s1 && s2 >= s3;\ncolor = vec4(0.0f);\ncolor.rb = b0 ? p0.rb : (\nb1 ? p1.rb : (\nb2 ? p2.rb : p3.rb\n)\n);\n}'},2518:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#if PERMUTATION_MAXLEN % 4 > 0 || PERMUTATION_MAXLEN * 4 > 16384\n#error Invalid PERMUTATION_MAXLEN\n#endif\nlayout(std140) uniform Permutation\n{\nivec4 permutation[PERMUTATION_MAXLEN / 4];\n};\nint permutationElement(int index)\n{\nint base = index - (index % PERMUTATION_MAXLEN);\nint offset = index - base;\nivec4 tuple = permutation[offset / 4];\nint newOffset = tuple[offset & 3];\nreturn base + newOffset;\n}\nvoid main()\n{\nivec2 thread = threadLocation();\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress myAddress = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint myIndex = findKeypointIndex(myAddress, descriptorSize, extraSize);\nint otherIndex = permutationElement(myIndex);\nKeypointAddress otherAddress = KeypointAddress(otherIndex * pixelsPerKeypoint, myAddress.offset);\nKeypoint myKeypoint = decodeKeypoint(encodedKeypoints, encoderLength, myAddress);\nKeypoint otherKeypoint = decodeKeypoint(encodedKeypoints, encoderLength, otherAddress);\ncolor = readKeypointData(encodedKeypoints, encoderLength, otherAddress);\n}'},8096:e=>{e.exports='@include "keypoints.glsl"\n#if !defined(STAGE)\n#error Undefined STAGE\n#elif STAGE == 1\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#elif STAGE == 2\nuniform sampler2D permutation;\nuniform int blockSize;\nuniform int dblLog2BlockSize;\n#elif STAGE == 3\nuniform sampler2D permutation;\nuniform int maxKeypoints;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\n#else\n#error Invalid STAGE\n#endif\nstruct PermutationElement\n{\nint keypointIndex;\nfloat score;\nbool valid;\n};\nvec4 encodePermutationElement(PermutationElement element)\n{\nconst vec2 ONES = vec2(1.0f);\nvec2 encodedScore = element.valid ? encodeFloat16(element.score) : ONES;\nvec2 encodedIndex = vec2(element.keypointIndex & 255, (element.keypointIndex >> 8) & 255) / 255.0f;\nreturn vec4(encodedIndex, encodedScore);\n}\nPermutationElement decodePermutationElement(vec4 pixel)\n{\nconst vec2 ONES = vec2(1.0f);\nPermutationElement element;\nelement.keypointIndex = int(pixel.r * 255.0f) | (int(pixel.g * 255.0f) << 8);\nelement.valid = !all(equal(pixel.ba, ONES));\nelement.score = element.valid ? decodeFloat16(pixel.ba) : -1.0f;\nreturn element;\n}\nPermutationElement readPermutationElement(sampler2D permutation, int elementIndex, int stride, int height)\n{\nconst vec4 INVALID_PIXEL = vec4(1.0f);\nivec2 pos = ivec2(elementIndex % stride, elementIndex / stride);\nvec4 pixel = pos.y < height ? pixelAt(permutation, pos) : INVALID_PIXEL;\nreturn decodePermutationElement(pixel);\n}\n#if STAGE == 2\nPermutationElement selectKth(sampler2D permutation, int k, int la, int ra, int lb, int rb)\n{\nfloat scoreA, scoreB;\nint ha, hb, ma, mb;\nbool discard1stHalf, altb;\nbool locked = false;\nint tmp, result = 0;\nint stride = outputSize().x;\nint height = outputSize().y;\nfor(int i = 0; i < dblLog2BlockSize; i++) {\ntmp = (lb > rb && !locked) ? (la+k) : result;\nresult = (la > ra && !locked) ? (lb+k) : tmp;\nlocked = locked || (la > ra) || (lb > rb);\nha = (ra - la + 1) / 2;\nhb = (rb - lb + 1) / 2;\nma = la + ha;\nmb = lb + hb;\nscoreA = readPermutationElement(permutation, ma, stride, height).score;\nscoreB = readPermutationElement(permutation, mb, stride, height).score;\ndiscard1stHalf = (k > ha + hb);\naltb = (-scoreA < -scoreB);\nk -= int(discard1stHalf && altb) * (ha + 1);\nk -= int(discard1stHalf && !altb) * (hb + 1);\nla += int(discard1stHalf && altb) * (ma + 1 - la);\nlb += int(discard1stHalf && !altb) * (mb + 1 - lb);\nra += int(!discard1stHalf && !altb) * (ma - 1 - ra);\nrb += int(!discard1stHalf && altb) * (mb - 1 - rb);\n}\nreturn readPermutationElement(permutation, result, stride, height);\n}\n#endif\nvoid main()\n{\n#if STAGE == 1\nivec2 thread = threadLocation();\nint stride = outputSize().x;\nint keypointIndex = thread.y * stride + thread.x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\nPermutationElement element;\nelement.keypointIndex = keypointIndex;\nelement.score = keypoint.score;\nelement.valid = !isBadKeypoint(keypoint);\ncolor = encodePermutationElement(element);\n#elif STAGE == 2\nivec2 thread = threadLocation();\nint stride = outputSize().x;\nint elementIndex = thread.y * stride + thread.x;\nint blockIndex = elementIndex / blockSize;\nint blockOffset = elementIndex % blockSize;\nint la = blockIndex * blockSize;\nint lb = la + blockSize / 2;\nint ra = lb - 1;\nint rb = (blockIndex + 1) * blockSize - 1;\nint k = blockOffset;\nPermutationElement element = selectKth(permutation, k, la, ra, lb, rb);\ncolor = encodePermutationElement(element);\n#elif STAGE == 3\nivec2 thread = threadLocation();\nint newEncoderLength = outputSize().x;\nKeypointAddress myAddress = findKeypointAddress(thread, newEncoderLength, descriptorSize, extraSize);\nint myKeypointIndex = findKeypointIndex(myAddress, descriptorSize, extraSize);\nivec2 psize = textureSize(permutation, 0);\nPermutationElement element = readPermutationElement(permutation, myKeypointIndex, psize.x, psize.y);\nint oldEncoderLength = textureSize(encodedKeypoints, 0).x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(element.keypointIndex * pixelsPerKeypoint, myAddress.offset);\nvec4 keypointData = readKeypointData(encodedKeypoints, oldEncoderLength, address);\ncolor = myKeypointIndex < maxKeypoints && element.valid ? keypointData : encodeNullKeypoint();\n#endif\n}'},5795:e=>{e.exports='@include "keypoints.glsl"\n@include "float16.glsl"\n#if !defined(METHOD)\n#error Must define METHOD\n#endif\nuniform sampler2D pyramid;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int maxIterations;\nuniform float epsilon;\nconst int PATCH_RADIUS = 1;\nconst int PATCH_SIZE = 2 * PATCH_RADIUS + 1;\nconst int PATCH_SIZE_SQUARED = PATCH_SIZE * PATCH_SIZE;\nconst int LARGE_PATCH_RADIUS = PATCH_RADIUS + 1;\nconst int LARGE_PATCH_SIZE = 2 * LARGE_PATCH_RADIUS + 1;\nconst int LARGE_PATCH_SIZE_SQUARED = LARGE_PATCH_SIZE * LARGE_PATCH_SIZE;\nconst int LARGER_PATCH_RADIUS = LARGE_PATCH_RADIUS + 1;\nconst int LARGER_PATCH_SIZE = 2 * LARGER_PATCH_RADIUS + 1;\nconst int LARGER_PATCH_SIZE_SQUARED = LARGER_PATCH_SIZE * LARGER_PATCH_SIZE;\nconst float EPS = 1e-5;\nfloat smoothPixelBuffer[LARGER_PATCH_SIZE_SQUARED];\nvec2 derivativesBuffer[LARGE_PATCH_SIZE_SQUARED];\nfloat responseBuffer[PATCH_SIZE_SQUARED];\n#define patchPixelAt(u,v) smoothPixelBuffer[((v) + LARGER_PATCH_RADIUS) * LARGER_PATCH_SIZE + ((u) + LARGER_PATCH_RADIUS)]\n#define derivativesAt(u,v) derivativesBuffer[((v) + LARGE_PATCH_RADIUS) * LARGE_PATCH_SIZE + ((u) + LARGE_PATCH_RADIUS)]\n#define responseAt(u,v) responseBuffer[((v) + PATCH_RADIUS) * PATCH_SIZE + ((u) + PATCH_RADIUS)]\nvoid readPixels(vec2 center, float lod)\n{\nivec2 pyrBaseSize = textureSize(pyramid, 0);\nfloat pot = exp2(lod);\nint u, v;\nfor(int j = 0; j < LARGER_PATCH_SIZE; j++) {\nfor(int i = 0; i < LARGER_PATCH_SIZE; i++) {\nu = i - LARGER_PATCH_RADIUS;\nv = j - LARGER_PATCH_RADIUS;\npatchPixelAt(u,v) = pyrSubpixelAtExOffset(pyramid, center, lod, pot, ivec2(u,v), pyrBaseSize).g;\n}\n}\n}\nvoid computeDerivatives()\n{\nconst mat3 dx = mat3(\n-1, 0, 1,\n-2, 0, 2,\n-1, 0, 1\n);\nconst mat3 dy = mat3(\n1, 2, 1,\n0, 0, 0,\n-1,-2,-1\n);\nint u, v;\nmat3 pix, convX, convY;\nconst vec3 ones = vec3(1.0f);\nfor(int j = 0; j < LARGE_PATCH_SIZE; j++) {\nfor(int i = 0; i < LARGE_PATCH_SIZE; i++) {\nu = i - LARGE_PATCH_RADIUS;\nv = j - LARGE_PATCH_RADIUS;\npix = mat3(\npatchPixelAt(u+1,v+1), patchPixelAt(u+0,v+1), patchPixelAt(u-1,v+1),\npatchPixelAt(u+1,v+0), patchPixelAt(u+0,v+0), patchPixelAt(u-1,v+0),\npatchPixelAt(u+1,v-1), patchPixelAt(u+0,v-1), patchPixelAt(u-1,v-1)\n);\nconvX = matrixCompMult(dx, pix);\nconvY = matrixCompMult(dy, pix);\nderivativesAt(u,v) = vec2(\ndot(ones, vec3(\ndot(convX[0], ones),\ndot(convX[1], ones),\ndot(convX[2], ones)\n)),\ndot(ones, vec3(\ndot(convY[0], ones),\ndot(convY[1], ones),\ndot(convY[2], ones)\n))\n);\n}\n}\n}\nvec2 computeResponseMap()\n{\nfloat patchArea = float(PATCH_SIZE * PATCH_SIZE);\nvec3 h; vec2 d, c = vec2(0.0f);\nconst vec3 ones = vec3(1.0f);\nfloat response, sum = 0.0f;\nint u, v;\n#define H(r,s) d = derivativesAt((r),(s)); h += vec3(d.x * d.x, d.x * d.y, d.y * d.y)\nfor(int j = 0; j < PATCH_SIZE; j++) {\nfor(int i = 0; i < PATCH_SIZE; i++) {\nu = i - PATCH_RADIUS;\nv = j - PATCH_RADIUS;\nh = vec3(0.0f);\nH(u-1,v-1); H(u+0,v-1); H(u+1,v-1);\nH(u-1,v+0); H(u+0,v+0); H(u+1,v+0);\nH(u-1,v+1); H(u+0,v+1); H(u+1,v+1);\nresponse = 0.5f * (h.x + h.z - sqrt((h.x - h.z) * (h.x - h.z) + 4.0f * h.y * h.y));\nresponse /= patchArea;\nresponseAt(u,v) = response;\nc += vec2(u,v) * response;\nsum += response;\n}\n}\nreturn abs(sum) > EPS ? c / sum : vec2(0.0f);\n}\n#if METHOD == 0\nvec2 quadratic1d()\n{\nfloat a = 0.5f * (responseAt(-1,0) - 2.0f * responseAt(0,0) + responseAt(1,0));\nfloat b = 0.5f * (responseAt(1,0) - responseAt(-1,0));\nfloat c = responseAt(0,0);\nfloat d = 0.5f * (responseAt(0,-1) - 2.0f * responseAt(0,0) + responseAt(0,1));\nfloat e = 0.5f * (responseAt(0,1) - responseAt(0,-1));\nfloat f = responseAt(0,0);\nbool hasMax = a < -EPS && d < -EPS;\nreturn hasMax ? -0.5f * vec2(b / a, e / d) : vec2(0.0f);\n}\n#endif\n#if METHOD == 1\nvec2 taylor2d()\n{\nfloat dx = (-responseAt(-1,0) + responseAt(1,0)) * 0.5f;\nfloat dy = (-responseAt(0,-1) + responseAt(0,1)) * 0.5f;\nfloat dxx = responseAt(-1,0) - 2.0f * responseAt(0,0) + responseAt(1,0);\nfloat dyy = responseAt(0,-1) - 2.0f * responseAt(0,0) + responseAt(0,1);\nfloat dxy = (responseAt(-1,-1) + responseAt(1,1) - responseAt(1,-1) - responseAt(-1,1)) * 0.25f;\nfloat det = dxx * dyy - dxy * dxy;\nmat2 inv = mat2(dyy, -dxy, -dxy, dxx);\nbool hasMax = det > EPS && dxx < 0.0f;\nreturn hasMax ? inv * vec2(dx, dy) / (-det) : vec2(0.0f);\n}\n#endif\n#if METHOD == 2\nvoid bilinearUpsample(ivec2 patchOffset, vec4 pixelsOfPatch)\n{\nint u, v, i, j;\nvec2 frc, ifrc; vec4 sub;\nconst vec4 ones = vec4(1.0f);\nfloat s = 1.0f / float(PATCH_SIZE - 1);\nint xoff = 2 * patchOffset.x;\nint yoff = 2 * patchOffset.y;\nfor(j = 0; j < PATCH_SIZE; j++) {\nfor(i = 0; i < PATCH_SIZE; i++) {\nu = i - PATCH_RADIUS;\nv = j - PATCH_RADIUS;\nfrc = vec2(i, j) * s;\nifrc = vec2(1.0f) - frc;\nsub = vec4(\nifrc.x * ifrc.y,\nfrc.x * ifrc.y,\nifrc.x * frc.y,\nfrc.x * frc.y\n);\npatchPixelAt(u+xoff,v+yoff) = dot(sub*pixelsOfPatch, ones);\n}\n}\n}\n#endif\n#if METHOD == 3\nvoid bicubicUpsample(ivec2 patchOffset, vec4 pixelsOfPatch, vec4 dx, vec4 dy, vec4 dxy)\n{\nfloat x, y, s = 1.0f / float(PATCH_SIZE - 1);\nint u, v, i, j;\nfloat f00 = pixelsOfPatch.x;\nfloat f10 = pixelsOfPatch.y;\nfloat f01 = pixelsOfPatch.z;\nfloat f11 = pixelsOfPatch.w;\nfloat fx00 = dx.x;\nfloat fx10 = dx.y;\nfloat fx01 = dx.z;\nfloat fx11 = dx.w;\nfloat fy00 = dy.x;\nfloat fy10 = dy.y;\nfloat fy01 = dy.z;\nfloat fy11 = dy.w;\nfloat fxy00 = dxy.x;\nfloat fxy10 = dxy.y;\nfloat fxy01 = dxy.z;\nfloat fxy11 = dxy.w;\nmat4 bicubic = mat4(\n1, 0, -3, 2,\n0, 0, 3, -2,\n0, 1, -2, 1,\n0, 0, -1, 1\n) * mat4(\nf00, f10, fx00, fx10,\nf01, f11, fx01, fx11,\nfy00, fy10, fxy00, fxy10,\nfy01, fy11, fxy01, fxy11\n) * mat4(\n1, 0, 0, 0,\n0, 0, 1, 0,\n-3, 3, -2, -1,\n2, -2, 1, 1\n);\nint xoff = 2 * patchOffset.x;\nint yoff = 2 * patchOffset.y;\nfor(j = 0; j < PATCH_SIZE; j++) {\nfor(i = 0; i < PATCH_SIZE; i++) {\nu = i - PATCH_RADIUS;\nv = j - PATCH_RADIUS;\nx = float(i) * s;\ny = float(j) * s;\npatchPixelAt(u+xoff,v+yoff) = dot(\nvec4(1, x, x*x, x*x*x),\nbicubic * vec4(1, y, y*y, y*y*y)\n);\n}\n}\n}\n#endif\n#if METHOD == 2 || METHOD == 3\nvoid upsamplePatch(int left, int top, int right, int bottom)\n{\nint x, y, k;\nvec4 ptch[9];\nvec2 d00, d10, d01, d11;\nfor(k = 0; k < 9; k++) {\nx = -1 + (k % 3);\ny = -1 + (k / 3);\nptch[k] = vec4(\npatchPixelAt(left+x, top+y),\npatchPixelAt(right+x, top+y),\npatchPixelAt(left+x, bottom+y),\npatchPixelAt(right+x, bottom+y)\n);\n}\nfor(k = 0; k < 9; k++) {\nx = -1 + (k % 3);\ny = -1 + (k / 3);\n#if METHOD == 2\nbilinearUpsample(ivec2(x, y), ptch[k]);\n#elif METHOD == 3\nd00 = derivativesAt(left+x, top+y);\nd10 = derivativesAt(right+x, top+y);\nd01 = derivativesAt(left+x, bottom+y);\nd11 = derivativesAt(right+x, bottom+y);\nbicubicUpsample(ivec2(x, y), ptch[k],\nvec4(d00.x, d10.x, d01.x, d11.x),\nvec4(d00.y, d10.y, d01.y, d11.y),\n0.25f * vec4(\n(patchPixelAt(left+x + 1,top+y + 1) + patchPixelAt(left+x - 1, top+y - 1)) - (patchPixelAt(left+x + 1, top+y - 1) + patchPixelAt(left+x - 1, top+y + 1)),\n(patchPixelAt(right+x + 1,top+y + 1) + patchPixelAt(right+x - 1, top+y - 1)) - (patchPixelAt(right+x + 1, top+y - 1) + patchPixelAt(right+x - 1, top+y + 1)),\n(patchPixelAt(left+x + 1,bottom+y + 1) + patchPixelAt(left+x - 1, bottom+y - 1)) - (patchPixelAt(left+x + 1, bottom+y - 1) + patchPixelAt(left+x - 1, bottom+y + 1)),\n(patchPixelAt(right+x + 1,bottom+y + 1) + patchPixelAt(right+x - 1, bottom+y - 1)) - (patchPixelAt(right+x + 1, bottom+y - 1) + patchPixelAt(right+x - 1, bottom+y + 1))\n)\n);\n#endif\n}\n}\nvec2 upsampleResponseMap(int left, int top, int right, int bottom)\n{\nupsamplePatch(left, top, right, bottom);\ncomputeDerivatives();\nreturn computeResponseMap();\n}\nvec2 iterativeUpsample(vec2 initialGuess)\n{\nint refine = 1;\nfloat scale = 0.5f;\nfloat eps2 = epsilon * epsilon;\nvec2 guess = initialGuess, localGuess = initialGuess;\nfor(int k = 0; k < maxIterations; k++) {\nivec4 quad = ivec4(floor(localGuess.x), floor(localGuess.y), ceil(localGuess.x), ceil(localGuess.y));\nvec2 response = (refine != 0) ? upsampleResponseMap(quad.x, quad.y, quad.z, quad.w) : vec2(0.0f);\nlocalGuess = response * scale;\nguess += localGuess;\nscale *= 0.5f;\nrefine *= int(dot(localGuess, localGuess) >= eps2);\n}\nreturn guess;\n}\n#endif\nvoid main()\n{\nivec2 thread = threadLocation();\nint keypointIndex = thread.x + thread.y * outputSize().x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\ncolor = encodeNullPairOfFloat16();\nif(isNullKeypoint(keypoint))\nreturn;\ncolor = encodeDiscardedPairOfFloat16();\nif(isBadKeypoint(keypoint))\nreturn;\nreadPixels(keypoint.position, keypoint.lod);\ncomputeDerivatives();\nvec2 offset = computeResponseMap();\n#if METHOD == 0\noffset = quadratic1d();\n#elif METHOD == 1\noffset = taylor2d();\n#elif METHOD == 2 || METHOD == 3\noffset = iterativeUpsample(offset);\n#else\n#error Unknown METHOD\n#endif\nfloat pot = exp2(keypoint.lod);\ncolor = encodePairOfFloat16(offset * pot);\n}'},3169:e=>{e.exports='@include "keypoints.glsl"\n@include "float16.glsl"\nuniform sampler2D encodedFlow;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nint len = textureSize(encodedFlow, 0).x;\nKeypointAddress myAddress = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, myAddress);\nint myIndex = findKeypointIndex(myAddress, descriptorSize, extraSize);\ncolor = pixel;\nif(isBadKeypoint(keypoint))\nreturn;\nivec2 location = ivec2(myIndex % len, myIndex / len);\nvec4 encodedFlow = myIndex < len * len ? pixelAt(encodedFlow, location) : encodeDiscardedKeypoint();\nbool discardFlow = isDiscardedPairOfFloat16(encodedFlow);\nvec2 flow = !discardFlow ? decodePairOfFloat16(encodedFlow) : vec2(0.0f);\nvec4 newPosition = encodeKeypointPosition(keypoint.position + flow);\nvec4 newPixel = myAddress.offset == 0 ? newPosition : pixel;\ncolor = !discardFlow ? newPixel : encodeDiscardedKeypoint();\n}'},1337:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedOrientations;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nKeypointAddress myAddress = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint myIndex = findKeypointIndex(myAddress, descriptorSize, extraSize);\nint orientationEncoderLength = textureSize(encodedOrientations, 0).x;\nivec2 location = ivec2(myIndex % orientationEncoderLength, myIndex / orientationEncoderLength);\nvec4 targetPixel = pixelAt(encodedOrientations, location);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, myAddress);\nbool isValid = !isBadKeypoint(keypoint);\nfloat encodedOrientation = targetPixel.g;\ncolor = isValid && myAddress.offset == 1 ? vec4(pixel.r, encodedOrientation, pixel.ba) : pixel;\n}'},6187:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedData;\nuniform int strideOfEncodedData;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvec4 readEncodedData(sampler2D encodedData, int strideOfEncodedData, int elementId, int pixelsPerElement, int pixelOffset)\n{\nint rasterIndex = elementId * pixelsPerElement + pixelOffset;\nivec2 pos = ivec2(rasterIndex % strideOfEncodedData, rasterIndex / strideOfEncodedData);\nreturn texelFetch(encodedData, pos, 0);\n}\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress myAddress = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint myIndex = findKeypointIndex(myAddress, descriptorSize, extraSize);\nint headerSize = sizeofEncodedKeypointHeader();\nint extraCell = myAddress.offset - headerSize / 4;\nint numberOfExtraCells = extraSize / 4;\ncolor = threadPixel(encodedKeypoints);\nif(extraCell < 0 || extraCell >= numberOfExtraCells)\nreturn;\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, myAddress);\nif(isBadKeypoint(keypoint))\nreturn;\ncolor = readEncodedData(encodedData, strideOfEncodedData, myIndex, numberOfExtraCells, extraCell);\n}'},477:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedKeypoints;\nuniform int startIndex;\nuniform int endIndex;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#ifndef BUFFER_SIZE\n#error Undefined BUFFER_SIZE\n#endif\nlayout(std140) uniform KeypointBuffer\n{\nvec4 keypointBuffer[BUFFER_SIZE];\n};\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint index = findKeypointIndex(address, descriptorSize, extraSize);\ncolor = pixel;\nif(index < startIndex)\nreturn;\ncolor = encodeNullKeypoint();\nif(index >= endIndex)\nreturn;\nvec4 data = keypointBuffer[index - startIndex];\nswitch(address.offset) {\ncase 0: {\ncolor = encodeKeypointPosition(data.xy);\nbreak;\n}\ncase 1: {\nvec2 score = encodeKeypointScore(max(data.w, 0.0f));\nfloat scale = encodeLod(data.z);\nfloat rotation = encodeKeypointOrientation(0.0f);\ncolor = vec4(scale, rotation, score);\nbreak;\n}\ndefault: {\ncolor = vec4(0.0f);\nbreak;\n}\n}\n}'},4050:e=>{e.exports="uniform sampler2D image;\nvoid main()\n{\n#if 1\ncolor = texture(image, texCoord);\n#else\nivec2 thread = threadLocation();\nivec2 pos = min(thread * 2, textureSize(image, 0) - ivec2(1));\ncolor = pixelAt(image, pos);\n#endif\n}"},5545:e=>{e.exports="uniform sampler2D image;\nvoid main()\n{\nivec2 thread = threadLocation();\nvec4 pixel = pixelAt(image, thread / 2);\ncolor = (((thread.x + thread.y) & 1) == 0) ? pixel : vec4(0.0f, 0.0f, 0.0f, pixel.a);\n}"},7113:e=>{e.exports='@include "subpixel.glsl"\nuniform sampler2D image0;\nuniform sampler2D image1;\nuniform float alpha;\nuniform float beta;\nuniform float gamma;\nconst vec4 BACKGROUND = vec4(0.0f);\nvoid main()\n{\nivec2 location = threadLocation();\nivec2 size0 = textureSize(image0, 0);\nivec2 size1 = textureSize(image1, 0);\nvec4 pix0 = all(lessThan(location, size0)) ? pixelAt(image0, location) : BACKGROUND;\nvec4 pix1 = all(lessThan(location, size1)) ? pixelAt(image1, location) : BACKGROUND;\nvec4 pix = clamp(alpha * pix0 + beta * pix1 + vec4(gamma), 0.0f, 1.0f);\ncolor = vec4(pix.rgb, 1.0f);\n}'},1202:e=>{e.exports='@include "subpixel.glsl"\nuniform sampler2D image;\nvoid main()\n{\nvec2 imageSize = vec2(textureSize(image, 0));\n#if !defined(INTERPOLATION_METHOD)\n#error Must define INTERPOLATION_METHOD\n#elif INTERPOLATION_METHOD == 0\nvec2 pos = texCoord * imageSize;\ncolor = textureLod(image, (round(pos) + vec2(0.5f)) / imageSize, 0.0f);\n#elif INTERPOLATION_METHOD == 1\ncolor = subpixelAtBI(image, texCoord * imageSize);\n#else\n#error Invalid INTERPOLATION_METHOD\n#endif\n}'},7971:e=>{e.exports='@include "subpixel.glsl"\nuniform sampler2D image;\nuniform mat3 inverseHomography;\nconst vec4 emptyColor = vec4(0.0f, 0.0f, 0.0f, 1.0f);\nvec2 perspectiveWarp(mat3 homography, vec2 p)\n{\nvec3 q = homography * vec3(p, 1.0f);\nreturn q.xy / q.z;\n}\nvoid main()\n{\nivec2 location = threadLocation();\nivec2 size = outputSize();\nconst vec2 zero = vec2(0.0f);\nvec2 target = perspectiveWarp(inverseHomography, vec2(location));\nbool withinBounds = all(bvec4(greaterThanEqual(target, zero), lessThan(target, vec2(size))));\ncolor = withinBounds ? subpixelAtBI(image, target) : emptyColor;\n}'},6122:e=>{e.exports='@include "colors.glsl"\nuniform sampler2D dest, src;\nuniform int destComponents;\nuniform int srcComponentId;\nvoid main()\n{\nvec4 destPixel = threadPixel(dest);\nvec4 srcPixel = threadPixel(src);\nbvec4 flags = bvec4(\n(destComponents & PIXELCOMPONENT_RED) != 0,\n(destComponents & PIXELCOMPONENT_GREEN) != 0,\n(destComponents & PIXELCOMPONENT_BLUE) != 0,\n(destComponents & PIXELCOMPONENT_ALPHA) != 0\n);\ncolor = mix(destPixel, vec4(srcPixel[srcComponentId]), flags);\n}'},371:e=>{e.exports='#if !defined(TYPE)\n#error Undefined TYPE\n#elif TYPE == 1\n@include "keypoints.glsl"\n#define nullPixel() encodeNullKeypoint()\n#elif TYPE == 2\n@include "float16.glsl"\n#define nullPixel() encodeNullPairOfFloat16()\n#else\n#error Invalid TYPE\n#endif\nuniform sampler2D image;\nvoid main()\n{\nivec2 thread = threadLocation();\nivec2 imageSize = textureSize(image, 0);\nint rasterIndex = thread.y * outputSize().x + thread.x;\nbool isValidPixel = rasterIndex < imageSize.x * imageSize.y;\nivec2 pos = ivec2(rasterIndex % imageSize.x, rasterIndex / imageSize.x);\nvec4 nullpix = nullPixel();\ncolor = isValidPixel ? texelFetch(image, pos, 0) : nullpix;\n}'},7307:e=>{e.exports="uniform sampler2D image;\nvoid main()\n{\ncolor = threadPixel(image);\n}"},8614:e=>{e.exports='@include "colors.glsl"\nuniform sampler2D image;\nuniform int pixelComponents;\nuniform float value;\nvoid main()\n{\nvec4 pixel = threadPixel(image);\nbvec4 flags = bvec4(\n(pixelComponents & PIXELCOMPONENT_RED) != 0,\n(pixelComponents & PIXELCOMPONENT_GREEN) != 0,\n(pixelComponents & PIXELCOMPONENT_BLUE) != 0,\n(pixelComponents & PIXELCOMPONENT_ALPHA) != 0\n);\ncolor = mix(pixel, vec4(value), flags);\n}'},6271:e=>{e.exports="uniform float value;\nvoid main()\n{\ncolor = vec4(value);\n}"},3016:e=>{e.exports="void vsmain()\n{\ngl_Position *= vec4(1,-1,1,1);\n}"},3630:e=>{e.exports="uniform sampler2D image;\nuniform int iterationNumber;\nvoid main()\n{\nivec2 thread = threadLocation();\nivec2 last = outputSize() - ivec2(1);\nint jump = (1 << iterationNumber);\nint clusterLength = jump << 1;\nint clusterMask = clusterLength - 1;\nivec2 clusterPos = ivec2(thread >> (1 + iterationNumber)) << (1 + iterationNumber);\nivec2 next1 = clusterPos + ((thread - clusterPos + ivec2(jump, 0)) & clusterMask);\nivec2 next2 = clusterPos + ((thread - clusterPos + ivec2(0, jump)) & clusterMask);\nivec2 next3 = clusterPos + ((thread - clusterPos + ivec2(jump, jump)) & clusterMask);\nvec4 p0 = texelFetch(image, thread, 0);\nvec4 p1 = texelFetch(image, min(next1, last), 0);\nvec4 p2 = texelFetch(image, min(next2, last), 0);\nvec4 p3 = texelFetch(image, min(next3, last), 0);\nvec4 pmax = max(max(p0, p1), max(p2, p3));\nvec4 pmin = min(min(p0, p1), min(p2, p3));\ncolor = vec4(pmax.r, pmin.g, pmax.r - pmin.g, p0.a);\n}"},8508:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\nuniform sampler2D pyramid;\nuniform float lod;\n#define USE_VARYINGS 1\nin vec2 v_pix0, v_pix1, v_pix2,\nv_pix3, v_pix4, v_pix5,\nv_pix6, v_pix7, v_pix8;\nconst mat3 hkern = mat3(\n1.0f, 0.0f,-1.0f,\n2.0f, 0.0f,-2.0f,\n1.0f, 0.0f,-1.0f\n), vkern = mat3(\n1.0f, 2.0f, 1.0f,\n0.0f, 0.0f, 0.0f,\n-1.0f,-2.0f,-1.0f\n);\n#define PIX(x,y) pyrPixelAtOffset(pyramid, lod, pot, ivec2((x),(y))).g\n#define XIP(v) textureLod(pyramid, (v), lod).g\nvoid main()\n{\nconst vec3 ones = vec3(1.0f);\nfloat pot = exp2(lod);\nmat3 win = mat3(\n#if USE_VARYINGS\nXIP(v_pix0), XIP(v_pix1), XIP(v_pix2),\nXIP(v_pix3), XIP(v_pix4), XIP(v_pix5),\nXIP(v_pix6), XIP(v_pix7), XIP(v_pix8)\n#else\nPIX(-1,-1), PIX(0,-1), PIX(1,-1),\nPIX(-1,0), PIX(0,0), PIX(1,0),\nPIX(-1,1), PIX(0,1), PIX(1,1)\n#endif\n);\nmat3 dx = matrixCompMult(hkern, win);\nmat3 dy = matrixCompMult(vkern, win);\nvec2 df = vec2(\ndot(dx[0] + dx[1] + dx[2], ones),\ndot(dy[0] + dy[1] + dy[2], ones)\n);\ncolor = encodePairOfFloat16(df);\n}'},8073:e=>{e.exports="uniform mediump float lod;\nout vec2 v_pix0, v_pix1, v_pix2,\nv_pix3, v_pix4, v_pix5,\nv_pix6, v_pix7, v_pix8;\n#define PIX(x,y) (texCoord + ((pot) * vec2((x),(y))) / texSize)\nvoid vsmain()\n{\nfloat pot = exp2(lod);\nv_pix0 = PIX(-1,-1); v_pix1 = PIX(0,-1); v_pix2 = PIX(1,-1);\nv_pix3 = PIX(-1,0); v_pix4 = PIX(0,0); v_pix5 = PIX(1,0);\nv_pix6 = PIX(-1,1); v_pix7 = PIX(0,1); v_pix8 = PIX(1,1);\n}"},3575:e=>{e.exports="AGFzbQEAAAABiwETYAABfmADf39/AX9gAX8AYAN/f38AYAF9AX9gAX8Bf2ACf38Bf2AFf39/f38B\nf2AFf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oxMDcARG91YmxlIGZyZWUgYXQgcmFuc2FjMzIuYzoy\nMzYARG91YmxlIGZyZWUgYXQgcmFuc2FjMzIuYzoyNDMARG91YmxlIGZyZWUgYXQgcmFuc2FjMzIu\nYzoyNDYARG91YmxlIGZyZWUgYXQgcmFuc2FjMzIuYzoyNDkAQXNzZXJ0aW9uIGZhaWxlZCBhdCBy\nYW5zYWMzMi5jOjI3NQBPdXQgb2YgbWVtb3J5IGF0IHJhbnNhYzMyLmM6Mjg4AE91dCBvZiBtZW1v\ncnkgYXQgcmFuc2FjMzIuYzoyOTIAT3V0IG9mIG1lbW9yeSBhdCByYW5zYWMzMi5jOjI5NwBPdXQg\nb2YgbWVtb3J5IGF0IHJhbnNhYzMyLmM6MzExAERvdWJsZSBmcmVlIGF0IHJhbnNhYzMyLmM6NDM2\nAERvdWJsZSBmcmVlIGF0IHJhbnNhYzMyLmM6NDQzAERvdWJsZSBmcmVlIGF0IHJhbnNhYzMyLmM6\nNDQ2AERvdWJsZSBmcmVlIGF0IHJhbnNhYzMyLmM6NDQ5AEFzc2VydGlvbiBmYWlsZWQgYXQgdHJh\nbnNmb3JtMzIuYzozOQBBc3NlcnRpb24gZmFpbGVkIGF0IHRyYW5zZm9ybTMyLmM6NzcAQXNzZXJ0\naW9uIGZhaWxlZCBhdCB0cmFuc2Zvcm0zMi5jOjExNAAAQbQaCwwIAAAAUA0AAAEAAAAAQcAaCyQA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n"}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{"use strict";n.d(i,{default:()=>Vi});var e=n(1001),t=n(9037),o=n(2199),s=n(9192);const r=[],A=[],a="asap"+Math.random().toString(36).substr(1);function d(e,...t){r.unshift(e),A.unshift(t),window.postMessage(a,"*")}window.addEventListener("message",(e=>{if(e.source!==window||e.data!==a)return;if(e.stopPropagation(),0==r.length)return;const t=r.pop(),n=A.pop();t.apply(void 0,n)}),!0);var c=n(8581);const l=navigator.userAgent.includes("Firefox")?(e,...t)=>setTimeout(e,10,...t):(e,...t)=>requestAnimationFrame((()=>e.apply(void 0,t)));class g{constructor(e=2){t.A.assert(e>0),this._initialized=!1,this._pixelBuffer=new Array(e).fill(null).map((()=>new Uint8Array(0))),this._pbo=new Array(e).fill(null),this._consumerIndex=0,this._producerIndex=e-1,this._promise=Array.from({length:e},(()=>s.i.resolve())),this._busy=new Array(e).fill(!1),this._ready=new Array(e).fill(!0)}init(e){this._allocatePBOs(e),e.subscribe(this._allocatePBOs,this,e),this._initialized=!0}release(e){return e.unsubscribe(this._allocatePBOs,this),this._deallocatePBOs(e),this._initialized=!1,null}readPixelsSync(e,n=0,i=0,o=e.width,s=e.height){t.A.assert(this._initialized);const r=e.gl,A=e.glFbo;o=Math.max(0,Math.min(o,e.width)),s=Math.max(0,Math.min(s,e.height)),n=Math.max(0,Math.min(n,e.width-o)),i=Math.max(0,Math.min(i,e.height-s));const a=o*s*4;return this._reallocate(a),r.isContextLost()||(r.bindFramebuffer(r.FRAMEBUFFER,A),r.readPixels(n,i,o,s,r.RGBA,r.UNSIGNED_BYTE,this._pixelBuffer[0]),r.bindFramebuffer(r.FRAMEBUFFER,null)),this._pixelBuffer[0].subarray(0,a)}readPixelsAsync(e,n=0,i=0,o=e.width,r=e.height,A=!1){t.A.assert(this._initialized);const a=e.gl,d=e.glFbo;o=Math.max(0,Math.min(o,e.width)),r=Math.max(0,Math.min(r,e.height)),n=Math.max(0,Math.min(n,e.width-o)),i=Math.max(0,Math.min(i,e.height-r));const c=o*r*4;if(this._reallocate(c),a.isContextLost())return s.i.resolve(this._pixelBuffer[0].subarray(0,c));if(!A){const e=this._pixelBuffer[0].subarray(0,c);return g._readPixelsViaPBO(a,this._pbo[0],e,d,n,i,o,r).then((()=>e))}const l=this._pixelBuffer.length,h=this._producerIndex;if(!this._busy[h]){const e=this._pbo[h],t=this._pixelBuffer[h].subarray(0,c);this._producerIndex=(h+1)%l,this._ready[h]=!1,this._busy[h]=!0,this._promise[h]=g._readPixelsViaPBO(a,e,t,d,n,i,o,r).then((()=>{this._busy[h]=!1,this._ready[h]=!0}))}const p=this._consumerIndex;return this._consumerIndex=(p+1)%l,this._ready[p]?(this._ready[p]=!1,s.i.resolve(this._pixelBuffer[p])):this._promise[p].then((()=>(this._ready[p]=!1,this._pixelBuffer[p])))}_reallocate(e){if(!(e<=this._pixelBuffer[0].byteLength))for(let t=0;t=0;e--)t.deleteBuffer(this._pbo[e]),this._pbo[e]=null}static _readPixelsViaPBO(e,n,i,r,A,a,h,p){const u=h*p*4;t.A.assert(i.byteLength>=u,"Invalid buffer size"),e.bindBuffer(e.PIXEL_PACK_BUFFER,n),e.bufferData(e.PIXEL_PACK_BUFFER,u,e.DYNAMIC_READ),e.bindFramebuffer(e.FRAMEBUFFER,r),e.readPixels(A,a,h,p,e.RGBA,e.UNSIGNED_BYTE,0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindBuffer(e.PIXEL_PACK_BUFFER,null);const I=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new s.i(((t,n)=>{"asap"!=o.w.gpuPollingMode?l(g._clientWaitAsync,e,I,0,t,n):d(g._clientWaitAsync,e,I,0,t,n)})).then((()=>{e.bindBuffer(e.PIXEL_PACK_BUFFER,n),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,i),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)})).catch((e=>{throw new c.Er("Can't getBufferSubDataAsync(): error in clientWaitAsync()",e)})).finally((()=>{e.deleteSync(I)}))}static _clientWaitAsync(e,t,n,i,s,r=10,A=1e3){!function r(){const a=e.clientWaitSync(t,n,0);A--<=0?s(new c.MU("GPU polling timeout",c.wB.from(e))):a===e.CONDITION_SATISFIED||a===e.ALREADY_SIGNALED?i():"asap"!=o.w.gpuPollingMode?requestAnimationFrame(r):d(r)}()}}var h=n(3816);class p{constructor(e,t,n,i=e.RGBA,o=e.RGBA8,s=e.UNSIGNED_BYTE,r=e.NEAREST,A=e.MIRRORED_REPEAT){this._gl=e,this._width=Math.max(1,0|t),this._height=Math.max(1,0|n),this._hasMipmaps=!1,this._format=i,this._internalFormat=o,this._dataType=s,this._filter=r,this._wrap=A,this._glTexture=p._createTexture(this._gl,this._width,this._height,this._format,this._internalFormat,this._dataType,this._filter,this._wrap)}release(){const e=this._gl;if(null==this._glTexture)throw new c.Er("The SpeedyTexture has already been released");return this.discardMipmaps(),e.deleteTexture(this._glTexture),this._glTexture=null,this._width=this._height=0,null}upload(e,n=this._width,i=this._height){const o=this._gl;return e instanceof HTMLVideoElement&&e.readyState<2||(t.A.assert(n>0&&i>0),this.discardMipmaps(),this._width=n,this._height=i,this._internalFormat=o.RGBA8,this._format=o.RGBA,this._dataType=o.UNSIGNED_BYTE,p._upload(o,this._glTexture,this._width,this._height,e,0,this._format,this._internalFormat,this._dataType)),this}clear(){const e=this._gl;return e.isContextLost()||(e.bindTexture(e.TEXTURE_2D,this._glTexture),e.texImage2D(e.TEXTURE_2D,0,this._internalFormat,this._width,this._height,0,this._format,this._dataType,null),e.bindTexture(e.TEXTURE_2D,null),this.discardMipmaps()),this}resize(e,t){const n=this._gl;if(this._width===e&&this._height===t)return this;if(t|=0,(e|=0)>h.MAX_TEXTURE_LENGTH||t>h.MAX_TEXTURE_LENGTH)throw new c.EM(`Maximum texture size exceeded. Using ${e} x ${t}, expected up to ${h.MAX_TEXTURE_LENGTH} x ${h.MAX_TEXTURE_LENGTH}.`);if(e<1||t<1)throw new c.qw(`Invalid texture size: ${e} x ${t}`);return n.isContextLost()||(this._width=e,this._height=t,n.bindTexture(n.TEXTURE_2D,this._glTexture),n.texImage2D(n.TEXTURE_2D,0,this._internalFormat,this._width,this._height,0,this._format,this._dataType,null),n.bindTexture(n.TEXTURE_2D,null),this.discardMipmaps()),this}generateMipmaps(e=[]){const n=this._gl;if(this._hasMipmaps)return this;if(n.bindTexture(n.TEXTURE_2D,this._glTexture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST_MIPMAP_LINEAR),n.generateMipmap(n.TEXTURE_2D),n.bindTexture(n.TEXTURE_2D,null),e.length>0){const n=this.width,i=this.height,o=1+Math.floor(Math.log2(Math.max(n,i)));t.A.assert(e.length<=o);for(let o=1;o>>o),r=Math.max(1,i>>>o);t.A.assert(e[o].width===s&&e[o].height===r),e[o].copyTo(this,o)}}return this._hasMipmaps=!0,this}discardMipmaps(){const e=this._gl;this._hasMipmaps&&(e.bindTexture(e.TEXTURE_2D,this._glTexture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,this._filter),e.bindTexture(e.TEXTURE_2D,null),this._hasMipmaps=!1)}hasMipmaps(){return this._hasMipmaps}isReleased(){return null==this._glTexture}get glTexture(){return this._glTexture}get width(){return this._width}get height(){return this._height}get gl(){return this._gl}static _createTexture(e,n,i,o,s,r,A,a){t.A.assert(n>0&&i>0);const d=e.createTexture();return e.bindTexture(e.TEXTURE_2D,d),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,A),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,A),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,a),e.texImage2D(e.TEXTURE_2D,0,s,n,i,0,o,r,null),e.bindTexture(e.TEXTURE_2D,null),d}static _upload(e,t,n,i,o,s,r,A,a){return e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,s,A,n,i,0,r,a,o),e.bindTexture(e.TEXTURE_2D,null),t}}class u extends p{constructor(e,t,n,i=void 0,o=void 0,s=void 0,r=void 0,A=void 0){super(e,t,n,i,o,s,r,A),this._glFbo=u._createFramebuffer(e,this._glTexture)}release(){const e=this._gl;if(null==this._glFbo)throw new c.Er("The SpeedyDrawableTexture has already been released");return e.deleteFramebuffer(this._glFbo),this._glFbo=null,super.release()}get glFbo(){return this._glFbo}copyTo(e,n=0){const i=this._gl;if(i.isContextLost())return;const o=1<<(n|=0),s=Math.max(1,Math.floor(e.width/o)),r=Math.max(1,Math.floor(e.height/o));t.A.assert(this._width===s&&this._height===r),u._copyToTexture(i,this._glFbo,e.glTexture,0,0,this._width,this._height,n)}clear(){return this.clearToColor(0,0,0,0)}clearToColor(e,t,n,i){const o=this._gl;return o.isContextLost()||(e=Math.max(0,Math.min(+e,1)),t=Math.max(0,Math.min(+t,1)),n=Math.max(0,Math.min(+n,1)),i=Math.max(0,Math.min(+i,1)),this.discardMipmaps(),o.bindFramebuffer(o.FRAMEBUFFER,this._glFbo),o.viewport(0,0,this._width,this._height),o.clearColor(e,t,n,i),o.clear(o.COLOR_BUFFER_BIT),o.bindFramebuffer(o.FRAMEBUFFER,null)),this}inspect(e,t){if(void 0===t){(t=new g).init(e);const n=t.readPixelsSync(this);return t.release(e),new Uint8Array(n)}{const e=t.readPixelsSync(this);return new Uint8Array(e)}}inspect32(e,n){return t.A.assert(h.LITTLE_ENDIAN),new Uint32Array(this.inspect(e,n).buffer)}static _createFramebuffer(e,t){const n=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,n),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0);const i=e.checkFramebufferStatus(e.FRAMEBUFFER);if(i!=e.FRAMEBUFFER_COMPLETE){const t=["FRAMEBUFFER_UNSUPPORTED","FRAMEBUFFER_INCOMPLETE_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_DIMENSIONS","FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"].filter((t=>e[t]===i))[0]||"unknown error";throw new c.wB(`Can't create framebuffer: ${t} (${i})`)}return e.bindFramebuffer(e.FRAMEBUFFER,null),n}static _copyToTexture(e,t,n,i,o,s,r,A=0){return e.bindTexture(e.TEXTURE_2D,n),e.bindFramebuffer(e.FRAMEBUFFER,t),e.copyTexSubImage2D(e.TEXTURE_2D,A,0,0,i,o,s,r),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),n}}var I=n(9420);const f=Object.freeze({sampler2D:"uniform1i",isampler2D:"uniform1i",usampler2D:"uniform1i",float:"uniform1f",int:"uniform1i",uint:"uniform1ui",bool:"uniform1i",vec2:"uniform2f",vec3:"uniform3f",vec4:"uniform4f",ivec2:"uniform2i",ivec3:"uniform3i",ivec4:"uniform4i",uvec2:"uniform2ui",uvec3:"uniform3ui",uvec4:"uniform4ui",bvec2:"uniform2i",bvec3:"uniform3i",bvec4:"uniform4i",mat2:"uniformMatrix2fv",mat3:"uniformMatrix3fv",mat4:"uniformMatrix4fv"});class m extends Function{constructor(e,t,n={}){return super("...args","return this._self._call(...args)"),this._self=this.bind(this),this._self._init(e,t,n),this._self}_init(e,t,n){if(e.isContextLost())throw new c.Er("Can't initialize SpeedyProgram: lost context");n=Object.assign({renderToTexture:!0,pingpong:!1},n),this._gl=e,this._program=m._compile(e,t.vertexSource,t.fragmentSource),this._geometry=new C(e,{position:t.locationOfAttributes.position,texCoord:t.locationOfAttributes.texCoord}),this._argnames=t.arguments,this._argIsArray=new Array(this._argnames.length).fill(!1),this._ubo=null,this._renderToTexture=Boolean(n.renderToTexture),this._width=1,this._height=1,this._size=[1,1],this._texture=new Array(n.pingpong?2:1).fill(null),this._textureIndex=0,this._uniform=new Map,this._shaderdecl=t,e.useProgram(this._program);for(const n of t.uniforms){const i=t.uniformType(n),o=e.getUniformLocation(this._program,n);this._uniform.set(n,new E(i,o))}for(let e=0;e=0;t--)if(e[t]===i)throw new c.EM("Can't run shader: don't use its output texture as an input to itself. Consider using pingpong rendering!");if(t.isContextLost())return i;t.useProgram(this._program),t.bindVertexArray(this._geometry.vao);const o=this._renderToTexture?i.glFbo:null,s=this._uniform.get("texSize");this._size[0]=this._width,this._size[1]=this._height,s.setValue(t,this._size);for(let i=0,o=0;i0&&n>0),this._width=0|e,this._height=0|n;for(let e=0;e1&&(this._textureIndex=1-this._textureIndex)}static _compile(e,t,n){const i=e.createProgram(),o=e.createShader(e.VERTEX_SHADER),s=e.createShader(e.FRAGMENT_SHADER);if(e.shaderSource(o,t),e.compileShader(o),e.attachShader(i,o),e.shaderSource(s,n),e.compileShader(s),e.attachShader(i,s),e.linkProgram(i),e.validateProgram(i),e.getProgramParameter(i,e.LINK_STATUS))return i;const r=[e.getShaderInfoLog(s),e.getShaderInfoLog(o),e.getProgramInfoLog(i)];e.deleteProgram(i),e.deleteShader(s),e.deleteShader(o);const A=e=>{return new Array((t=e,Math.max(0,2-Math.floor(Math.log10(t))))).fill(" ").join("")+e+". ";var t},a=(r[0]?n:t).split("\n").map(((e,t)=>A(1+t)+e)).join("\n");throw new c.wB("\n\n---------- ERROR ----------\n\n"+r.filter((e=>e)).join("\n")+"\n\n---------- SOURCE CODE ----------\n\n"+a+"\n")}}function C(e,t){return this.vao=e.createVertexArray(),this.vbo=Object.freeze({position:e.createBuffer(),texCoord:e.createBuffer()}),this._gl=e,e.bindVertexArray(this.vao),e.bindBuffer(e.ARRAY_BUFFER,this.vbo.position),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW),e.enableVertexAttribArray(t.position),e.vertexAttribPointer(t.position,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.vbo.texCoord),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),e.STATIC_DRAW),e.enableVertexAttribArray(t.texCoord),e.vertexAttribPointer(t.texCoord,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindVertexArray(null),Object.freeze(this)}function E(e,t){if(this.type=String(e),!Object.prototype.hasOwnProperty.call(f,this.type))throw new c.EM(`Unsupported uniform type: ${this.type}`);this.location=t,this.setter=f[this.type];const n=0|Number(this.setter.match(/^uniform(Matrix)?(\d)/)[2]);this.dim=this.type.startsWith("mat")?2:this.type.indexOf("vec")>=0?1:0,this.length=2==this.dim?n*n:n,this._value=null}function x(e,t){this._gl=e,this._program=t,this._nextIndex=0,this._ubo=Object.create(null)}function y(e,t){const n=y.cache;let i=n.get(e);return void 0===i&&n.set(e,i=[]),void 0===i[t]&&(i[t]=`${e}[${t}]`),i[t]}C.prototype.release=function(){const e=this._gl;return e.deleteVertexArray(this.vao),e.deleteBuffer(this.vbo.position),e.deleteBuffer(this.vbo.texCoord),null},E.prototype.setValue=function(e,t,n=-1){const i=e[this.setter];if("object"==typeof t&&this.type.endsWith("sampler2D")){if(n>=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS)throw new c.EM(`Can't activate texture unit ${n}: max is ${e.MAX_COMBINED_TEXTURE_IMAGE_UNITS}`);if(Array.isArray(t))throw new c.EM("Can't pass arrays of textures to shaders");if(null==t)throw new c.qw(`Can't run shader: cannot use ${t} as an input texture`);if(n<0)throw new c.qw("Missing texNo");const i=t;e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,i.glTexture),e.uniform1i(this.location,n),n++}else if(t===this._value&&"object"!=typeof t);else if("number"==typeof t||"boolean"==typeof t)i.call(e,this.location,t);else{if(!Array.isArray(t))throw new c.qw(`Can't run shader: unrecognized argument "${t}"`);if(t.length!==this.length)throw new c.qw(`Can't run shader: incorrect number of values for ${this.type}: "${t}"`);2==this.dim?i.call(e,this.location,!1,t):i.call(e,this.location,...t)}return this._value=t,n},x.prototype.set=function(e,t){const n=this._gl;void 0===this._ubo[e]&&(this._ubo[e]={buffer:n.createBuffer(),blockBindingIndex:this._nextIndex++,blockIndex:-1,data:null});const i=this._ubo[e];if(i.blockIndex<0){const t=n.getUniformBlockIndex(this._program,e);n.uniformBlockBinding(this._program,t,i.blockBindingIndex),i.blockIndex=t}i.data=t},x.prototype.update=function(){const e=this._gl;for(const t in this._ubo){const n=this._ubo[t];e.bindBuffer(e.UNIFORM_BUFFER,n.buffer),e.bufferData(e.UNIFORM_BUFFER,n.data,e.DYNAMIC_DRAW),e.bindBufferBase(e.UNIFORM_BUFFER,n.blockBindingIndex,n.buffer),e.bindBuffer(e.UNIFORM_BUFFER,null)}},x.prototype.release=function(){const e=this._gl;for(const t in this._ubo){const n=this._ubo[t];e.deleteBuffer(n.buffer),n.data=null}return null},y.cache=new Map;const _=Object.freeze({usesPingpongRendering:()=>({pingpong:!0}),rendersToCanvas:()=>({renderToTexture:!1})});class S{constructor(e){this._gpu=e,this._programs=[]}declare(e,t,n={}){return Object.defineProperty(this,e,{get:(()=>{const i=Symbol(e);return()=>this[i]||(this[i]=this._createProgram(t.build(),n))})()}),this}get program(){return _}release(){for(let e=0;e(e[t]=(0,I.bf)("filters/convolution2d.glsl").withDefines({KERNEL_SIZE_SQUARED:t*t}).withArguments("image","kernel"),e)),{}),N=[3,5,7,9,11,13,15].reduce(((e,t)=>(e[t]=(0,I.bf)("filters/convolution1d.glsl").withDefines({KERNEL_SIZE:t,AXIS:0}).withArguments("image","kernel"),e)),{}),X=[3,5,7,9,11,13,15].reduce(((e,t)=>(e[t]=(0,I.bf)("filters/convolution1d.glsl").withDefines({KERNEL_SIZE:t,AXIS:1}).withArguments("image","kernel"),e)),{}),T=[3,5,7].reduce(((e,t)=>(e[t]=(0,I.bf)("filters/fast-median.glsl").withDefines({KERNEL_SIZE:t}).withArguments("image"),e)),{}),F=(0,I.bf)("filters/normalize-image.glsl").withDefines({GREYSCALE:1}).withArguments("minmax2d","minValue","maxValue"),O=(0,I.bf)("filters/normalize-image.glsl").withDefines({GREYSCALE:0}).withArguments("minmax2dRGB","minValue","maxValue"),U=(0,I.bf)("filters/nightvision.glsl").withDefines({GREYSCALE:0}).withArguments("image","illuminationMap","gain","offset","decay"),G=(0,I.bf)("filters/nightvision.glsl").withDefines({GREYSCALE:1}).withArguments("image","illuminationMap","gain","offset","decay"),q=e=>t.A.gaussianKernel((e=>Math.max(1,e/6))(e),e),H=e=>new Array(e).fill(1/e);class J extends S{constructor(e){super(e),this.declare("rgb2grey",R).declare("median3",T[3]).declare("median5",T[5]).declare("median7",T[7]).declare("convolution3",z[3]).declare("convolution5",z[5]).declare("convolution7",z[7]).declare("convolution3x",N[3]).declare("convolution3y",X[3]).declare("convolution5x",N[5]).declare("convolution5y",X[5]).declare("convolution7x",N[7]).declare("convolution7y",X[7]).declare("convolution9x",N[9]).declare("convolution9y",X[9]).declare("convolution11x",N[11]).declare("convolution11y",X[11]).declare("convolution13x",N[13]).declare("convolution13y",X[13]).declare("convolution15x",N[15]).declare("convolution15y",X[15]).declare("normalizeGreyscale",F).declare("normalizeColored",O).declare("nightvision",U).declare("nightvisionGreyscale",G).declare("illuminationMapLoX",(0,k.convX)(t.A.gaussianKernel(80,31))).declare("illuminationMapLoY",(0,k.convY)(t.A.gaussianKernel(80,31))).declare("illuminationMapX",(0,k.convX)(t.A.gaussianKernel(80,63))).declare("illuminationMapY",(0,k.convY)(t.A.gaussianKernel(80,63))).declare("illuminationMapHiX",(0,k.convX)(t.A.gaussianKernel(80,255))).declare("illuminationMapHiY",(0,k.convY)(t.A.gaussianKernel(80,255))).declare("gaussian3x",(0,k.convX)([.25,.5,.25])).declare("gaussian3y",(0,k.convY)([.25,.5,.25])).declare("gaussian5x",(0,k.convX)([.05,.25,.4,.25,.05])).declare("gaussian5y",(0,k.convY)([.05,.25,.4,.25,.05])).declare("gaussian7x",(0,k.convX)(q(7))).declare("gaussian7y",(0,k.convY)(q(7))).declare("gaussian9x",(0,k.convX)(q(9))).declare("gaussian9y",(0,k.convY)(q(9))).declare("gaussian11x",(0,k.convX)(q(11))).declare("gaussian11y",(0,k.convY)(q(11))).declare("box3x",(0,k.convX)(H(3))).declare("box3y",(0,k.convY)(H(3))).declare("box5x",(0,k.convX)(H(5))).declare("box5y",(0,k.convY)(H(5))).declare("box7x",(0,k.convX)(H(7))).declare("box7y",(0,k.convY)(H(7))).declare("box9x",(0,k.convX)(H(9))).declare("box9y",(0,k.convY)(H(9))).declare("box11x",(0,k.convX)(H(11))).declare("box11y",(0,k.convY)(H(11)))}}var Y=n(6634);class W extends Y.Q{static create(e,n,i){t.A.assert(i%4==0,`Invalid descriptorSize: ${i}`);const o=n.length,s=i/4,r=Math.log2(s*Math.max(o,1))/2,A=1<l)throw new c.EM(`The capacity of the descriptorDB (${l} for ${8*i}-bit descriptors) has been exceeded`);const g=new Uint8Array(a*d*4);for(let e=0;e(t.A.range(ee).forEach((t=>e.subarray(t*V,(t+1)*V).sort())),e),ne=(e,n)=>(t.A.range(ee).forEach((t=>n.subarray((t+1)*V-e,(t+1)*V).fill(195939070))),n),ie=j.reduce(((e,n)=>{return e[n]={32:te(ne(V-(i=n),new Uint32Array([...t.A.shuffle(t.A.range(256)),...t.A.shuffle(t.A.range(256)),...t.A.shuffle(t.A.range(256))].slice(0,ee*V)))),64:te(ne(V-i,new Uint32Array([...t.A.shuffle(t.A.range(512)),...t.A.shuffle(t.A.range(512))].slice(0,ee*V))))},e;var i}),{});class oe{constructor(e,n,i,o=8,s=15,r=.95){const A=i.length,a=A>0?i[0].byteLength:0,d=(c=o,l=s,g=r,j.includes(l)&&Z.includes(c)?[{name:"x-small",bucketCapacity:1,tableCount:c,hashSize:l,capacity:re(l,1,g)},{name:"small",bucketCapacity:2,tableCount:c,hashSize:l,capacity:re(l,2,g)},{name:"small-plus",bucketCapacity:3,tableCount:c,hashSize:l,capacity:re(l,3,g)},{name:"medium",bucketCapacity:4,tableCount:c,hashSize:l,capacity:re(l,4,g)},{name:"medium-plus",bucketCapacity:5,tableCount:c,hashSize:l,capacity:re(l,5,g)},{name:"large",bucketCapacity:6,tableCount:c,hashSize:l,capacity:re(l,6,g)},{name:"x-large",bucketCapacity:8,tableCount:c,hashSize:l,capacity:re(l,8,g)}]:null);var c,l,g;t.A.assert(A>0,"Can't build LSH tables without descriptors!"),t.A.assert($.includes(a),`Can't build LSH tables: unacceptable descriptor size of ${a} bytes`),t.A.assert(i.findIndex((e=>e.byteLength!==a))<0,`Can't build LSH tables: incorrectly sized descriptors. Expected ${a} bytes for each`),t.A.assert(AA<=e.capacity))||d[d.length-1],this._descriptorSize=a,this._descriptorCount=A,this._sequences=this._pickSequences(this._descriptorSize),this._tables=this._createStaticTables(e,this._sequences,i,a),this._descriptorDB=W.create(n,i,a)}get descriptorSize(){return this._descriptorSize}get descriptorCount(){return this._descriptorCount}get sequences(){return this._sequences}get hashSize(){return this._profile.hashSize}get bucketCapacity(){return this._profile.bucketCapacity}get bucketsPerTable(){return 1<1?1<A){const e=100*I/A;t.A.warning(`There are too many descriptors (${I}) for a ${r} LSH table. That's ${e.toFixed(2)}% of its theoretical capacity. Consider increasing the hashSize (currently set to ${l}) or reducing the number of descriptors to avoid degradation.`)}const m=new ArrayBuffer(h*u*4),C=new Uint8Array(m).fill(255),E=new DataView(m),x=t.A.shuffle(t.A.range(I)),y=new Array(a).fill(0);for(let e=0;ee+t),0),S=y.map((e=>100*e/I));return t.A.log(`When building ${a} ${r} LSH tables with ${I} ${8*o}-bit descriptors each and hashSize = ${l} bits, I got the following discard profile: `+S.map((e=>e.toFixed(2)+"%")).join(", ")+". "+`Average: ${(100*_/(a*I)).toFixed(2)}%. `+`Minimum: ${Math.min(...S).toFixed(2)}%. `+`Table capacity: ${A}.`),e.resize(h,u),e.upload(C),e}_hashCodes(e,n){const i=this.tableCount,o=this.hashSize,s=this.bucketsPerTable,r=new Array(i);t.A.assert(o<=V&&n.length>=V*i);for(let A=0;A>>3]&s)}t.A.assert(a>=0&&as?r=a+1:A=a;return a}const Ae=(0,I.bf)("keypoints/fast.glsl","keypoints/fast.vs.glsl").withDefines({FAST_TYPE:916}).withArguments("corners","pyramid","lod","threshold"),ae=[1,3,5,7].reduce(((e,t)=>(e[t]=(0,I.bf)("keypoints/harris.glsl").withDefines({WINDOW_SIZE:t}).withArguments("corners","pyramid","derivatives","lod","lodStep","gaussian"),e)),{}),de=(0,I.bf)("keypoints/score-findmax.glsl").withArguments("corners","iterationNumber"),ce=(0,I.bf)("keypoints/harris-cutoff.glsl").withArguments("corners","maxScore","quality"),le=(0,I.bf)("keypoints/subpixel-refinement.glsl").withDefines({METHOD:0}).withArguments("pyramid","encodedKeypoints","descriptorSize","extraSize","encoderLength","maxIterations","epsilon"),ge=(0,I.bf)("keypoints/subpixel-refinement.glsl").withDefines({METHOD:1}).withArguments("pyramid","encodedKeypoints","descriptorSize","extraSize","encoderLength","maxIterations","epsilon"),he=(0,I.bf)("keypoints/subpixel-refinement.glsl").withDefines({METHOD:2}).withArguments("pyramid","encodedKeypoints","descriptorSize","extraSize","encoderLength","maxIterations","epsilon"),pe=(0,I.bf)("keypoints/subpixel-refinement.glsl").withDefines({METHOD:3}).withArguments("pyramid","encodedKeypoints","descriptorSize","extraSize","encoderLength","maxIterations","epsilon"),ue=(0,I.bf)("keypoints/refine-scale.glsl").withDefines({METHOD:0}).withArguments("pyramid","lodStep","encodedKeypoints","descriptorSize","extraSize","encoderLength"),Ie=(0,I.bf)("keypoints/refine-scale.glsl").withDefines({METHOD:1}).withArguments("pyramid","lodStep","encodedKeypoints","descriptorSize","extraSize","encoderLength","threshold"),fe=(0,I.bf)("keypoints/allocate-descriptors.glsl").withArguments("inputEncodedKeypoints","inputDescriptorSize","inputExtraSize","inputEncoderLength","outputDescriptorSize","outputExtraSize","outputEncoderLength"),me=(0,I.bf)("keypoints/allocate-extra.glsl").withArguments("inputEncodedKeypoints","inputDescriptorSize","inputExtraSize","inputEncoderLength","outputDescriptorSize","outputExtraSize","outputEncoderLength"),Ce=(0,I.bf)("keypoints/transfer-to-extra.glsl").withArguments("encodedData","strideOfEncodedData","encodedKeypoints","descriptorSize","extraSize","encoderLength"),Ee=(0,I.bf)("keypoints/orb-descriptor.glsl").withArguments("image","encodedCorners","extraSize","encoderLength"),xe=(0,I.bf)("keypoints/orb-orientation.glsl").withArguments("image","encodedKeypoints","descriptorSize","extraSize","encoderLength"),ye=(0,I.bf)("keypoints/nonmax-suppression.glsl").withDefines({MULTISCALE:0}).withArguments("image","lodStep"),_e=(0,I.bf)("keypoints/nonmax-suppression.glsl").withDefines({MULTISCALE:1}).withArguments("image","lodStep"),Se=(0,I.bf)("keypoints/nonmax-space.glsl").withArguments("corners"),Pe=(0,I.bf)("keypoints/nonmax-scale.glsl").withDefines({USE_LAPLACIAN:1}).withArguments("corners","pyramid","pyrLaplacian","lodStep"),Be=(0,I.bf)("keypoints/nonmax-scale.glsl").withDefines({USE_LAPLACIAN:0}).withArguments("corners","pyramid","lodStep"),ve=(0,I.bf)("keypoints/laplacian.glsl").withArguments("corners","pyramid","lodStep","lodOffset"),Qe=[3,5,7,9,11,13,15,17,19,21].reduce(((e,t)=>(e[t]=(0,I.bf)("keypoints/lk.glsl").withDefines({WINDOW_SIZE:t}).withArguments("encodedFlow","prevKeypoints","nextPyramid","prevPyramid","level","depth","numberOfIterations","discardThreshold","epsilon","descriptorSize","extraSize","encoderLength"),e)),{}),we=(0,I.bf)("keypoints/transfer-flow.glsl").withArguments("encodedFlow","encodedKeypoints","descriptorSize","extraSize","encoderLength"),be=(0,I.bf)("keypoints/knn-init.glsl").withDefines({ENCODE_FILTERS:0}),De=(0,I.bf)("keypoints/knn-init.glsl").withDefines({ENCODE_FILTERS:1}),Me=(0,I.bf)("keypoints/knn-transfer.glsl").withArguments("encodedMatches","encodedKthMatches","numberOfMatchesPerKeypoint","kthMatch"),Ke=(0,I.bf)("keypoints/bf-knn.glsl").withDefines({DESCRIPTOR_SIZE:32,NUMBER_OF_KEYPOINTS_PER_PASS:16}).withArguments("encodedMatches","encodedFilters","matcherLength","dbEncodedKeypoints","dbDescriptorSize","dbExtraSize","dbEncoderLength","encodedKeypoints","descriptorSize","extraSize","encoderLength","passId"),Le=(0,I.bf)("keypoints/bf-knn.glsl").withDefines({DESCRIPTOR_SIZE:64,NUMBER_OF_KEYPOINTS_PER_PASS:8}).withArguments("encodedMatches","encodedFilters","matcherLength","dbEncodedKeypoints","dbDescriptorSize","dbExtraSize","dbEncoderLength","encodedKeypoints","descriptorSize","extraSize","encoderLength","passId"),ke=(0,I.bf)("keypoints/knn-init.glsl").withDefines({ENCODE_FILTERS:0}),Re=(0,I.bf)("keypoints/knn-init.glsl").withDefines({ENCODE_FILTERS:1}),ze=$.reduce(((e,t)=>(e[t]=j.reduce(((e,n)=>(e[n]=[0,1,2].reduce(((e,i)=>(e[i]=(0,I.bf)("keypoints/lsh-knn.glsl").withDefines({DESCRIPTOR_SIZE:t,HASH_SIZE:n,LEVEL:i,SEQUENCE_MAXLEN:V,SEQUENCE_COUNT:ee}).withArguments("candidates","filters","matcherLength","tables","descriptorDB","tableIndex","bucketCapacity","bucketsPerTable","tablesStride","descriptorDBStride","encodedKeypoints","descriptorSize","extraSize","encoderLength"),e)),{}),e)),{}),e)),{}),Ne=(0,I.bf)("keypoints/knn-transfer.glsl").withArguments("encodedMatches","encodedKthMatches","numberOfMatchesPerKeypoint","kthMatch"),Xe=(0,I.bf)("keypoints/sort-keypoints.glsl").withDefines({STAGE:1}).withArguments("encodedKeypoints","descriptorSize","extraSize","encoderLength"),Te=(0,I.bf)("keypoints/sort-keypoints.glsl").withDefines({STAGE:2}).withArguments("permutation","blockSize","dblLog2BlockSize"),Fe=(0,I.bf)("keypoints/sort-keypoints.glsl").withDefines({STAGE:3}).withArguments("permutation","maxKeypoints","encodedKeypoints","descriptorSize","extraSize"),Oe=(0,I.bf)("keypoints/mix-keypoints.glsl").withDefines({STAGE:1}).withArguments("encodedKeypointsA","encodedKeypointsB","encoderLengthA","encoderLengthB","encoderCapacityA","encoderCapacityB","descriptorSize","extraSize","encoderLength"),Ue=(0,I.bf)("keypoints/mix-keypoints.glsl").withDefines({STAGE:2}).withArguments("encodedKeypoints","descriptorSize","extraSize","encoderLength","maxKeypoints"),Ge=(0,I.bf)("keypoints/mix-keypoints.glsl").withDefines({STAGE:3}).withArguments("array","blockSize"),qe=(0,I.bf)("keypoints/mix-keypoints.glsl").withDefines({STAGE:5}).withArguments("array"),He=(0,I.bf)("keypoints/mix-keypoints.glsl").withDefines({STAGE:4}).withArguments("array","encodedKeypoints","descriptorSize","extraSize","encoderLength"),Je=(0,I.bf)("keypoints/lookup-of-locations.glsl").withDefines({FS_OUTPUT_TYPE:2,STAGE:1}).withArguments("corners"),Ye=(0,I.bf)("keypoints/lookup-of-locations.glsl","keypoints/lookup-of-locations.vs.glsl").withDefines({FS_OUTPUT_TYPE:2,FS_USE_CUSTOM_PRECISION:1,STAGE:2}).withArguments("lookupTable","blockSize","width","height"),We=(0,I.bf)("keypoints/lookup-of-locations.glsl").withDefines({STAGE:-1}).withArguments("lookupTable"),Ze=(0,I.bf)("keypoints/encode-keypoints.glsl").withArguments("corners","lookupTable","stride","descriptorSize","extraSize","encoderLength","encoderCapacity"),je=(0,I.bf)("keypoints/encode-keypoint-offsets.glsl").withArguments("corners","imageSize"),$e=(0,I.bf)("keypoints/encode-keypoint-long-offsets.glsl").withDefines({MAX_ITERATIONS:6}).withArguments("offsetsImage","imageSize"),Ve=(0,I.bf)("keypoints/encode-keypoint-positions.glsl").withArguments("offsetsImage","imageSize","passId","numPasses","keypointLimit","encodedKeypoints","descriptorSize","extraSize","encoderLength"),et=(0,I.bf)("keypoints/encode-keypoint-properties.glsl").withArguments("corners","encodedKeypoints","descriptorSize","extraSize","encoderLength"),tt=(0,I.bf)("keypoints/encode-null-keypoints.glsl").withArguments(),nt=(0,I.bf)("keypoints/transfer-orientation.glsl").withArguments("encodedOrientations","encodedKeypoints","descriptorSize","extraSize","encoderLength"),it=(0,I.bf)("keypoints/upload-keypoints.glsl").withDefines({BUFFER_SIZE:1024}).withArguments("encodedKeypoints","startIndex","endIndex","descriptorSize","extraSize","encoderLength"),ot=(0,I.bf)("keypoints/apply-homography.glsl").withArguments("homography","encodedKeypoints","descriptorSize","extraSize","encoderLength"),st=(0,I.bf)("keypoints/clip-border.glsl").withArguments("imageWidth","imageHeight","borderTop","borderRight","borderBottom","borderLeft","encodedKeypoints","descriptorSize","extraSize","encoderLength"),rt=(0,I.bf)("keypoints/distance-filter.glsl").withArguments("encodedKeypointsA","encoderLengthA","encodedKeypointsB","encoderLengthB","descriptorSize","extraSize","encoderLength","threshold"),At=(0,I.bf)("keypoints/hamming-distance-filter.glsl").withDefines({DESCRIPTOR_SIZE:32}).withArguments("encodedKeypointsA","encoderLengthA","encodedKeypointsB","encoderLengthB","descriptorSize","extraSize","encoderLength","threshold"),at=(0,I.bf)("keypoints/hamming-distance-filter.glsl").withDefines({DESCRIPTOR_SIZE:64}).withArguments("encodedKeypointsA","encoderLengthA","encodedKeypointsB","encoderLengthB","descriptorSize","extraSize","encoderLength","threshold"),dt=(0,I.bf)("keypoints/shuffle.glsl").withDefines({PERMUTATION_MAXLEN:2048}).withArguments("encodedKeypoints","descriptorSize","extraSize","encoderLength"),ct=(0,I.bf)("keypoints/clip.glsl").withArguments("encodedKeypoints","descriptorSize","extraSize","encoderLength","maxKeypoints");class lt extends S{constructor(e){super(e),this.declare("fast9_16",Ae,Object.assign({},this.program.usesPingpongRendering())).declare("harris1",ae[1],Object.assign({},this.program.usesPingpongRendering())).declare("harris3",ae[3],Object.assign({},this.program.usesPingpongRendering())).declare("harris5",ae[5],Object.assign({},this.program.usesPingpongRendering())).declare("harris7",ae[7],Object.assign({},this.program.usesPingpongRendering())).declare("harrisScoreFindMax",de,Object.assign({},this.program.usesPingpongRendering())).declare("harrisScoreCutoff",ce).declare("subpixelQuadratic1d",le).declare("subpixelTaylor2d",ge).declare("subpixelBicubic",pe).declare("subpixelBilinear",he).declare("refineScaleLoG",ue).declare("refineScaleFAST916",Ie).declare("allocateDescriptors",fe).declare("allocateExtra",me).declare("transferToExtra",Ce).declare("orbDescriptor",Ee).declare("orbOrientation",xe).declare("nonmax",ye).declare("pyrnonmax",_e).declare("nonmaxSpace",Se).declare("nonmaxScale",Pe).declare("nonmaxScaleSimple",Be).declare("laplacian",ve).declare("lk21",Qe[21],Object.assign({},this.program.usesPingpongRendering())).declare("lk19",Qe[19],Object.assign({},this.program.usesPingpongRendering())).declare("lk17",Qe[17],Object.assign({},this.program.usesPingpongRendering())).declare("lk15",Qe[15],Object.assign({},this.program.usesPingpongRendering())).declare("lk13",Qe[13],Object.assign({},this.program.usesPingpongRendering())).declare("lk11",Qe[11],Object.assign({},this.program.usesPingpongRendering())).declare("lk9",Qe[9],Object.assign({},this.program.usesPingpongRendering())).declare("lk7",Qe[7],Object.assign({},this.program.usesPingpongRendering())).declare("lk5",Qe[5],Object.assign({},this.program.usesPingpongRendering())).declare("lk3",Qe[3],Object.assign({},this.program.usesPingpongRendering())).declare("transferFlow",we).declare("bfMatcherInitCandidates",be).declare("bfMatcherInitFilters",De).declare("bfMatcherTransfer",Me,Object.assign({},this.program.usesPingpongRendering())).declare("bfMatcher32",Ke,Object.assign({},this.program.usesPingpongRendering())).declare("bfMatcher64",Le,Object.assign({},this.program.usesPingpongRendering())).declare("lshKnnInitCandidates",ke).declare("lshKnnInitFilters",Re).declare("lshKnnTransfer",Ne,Object.assign({},this.program.usesPingpongRendering())).declare("sortCreatePermutation",Xe).declare("sortMergePermutation",Te,Object.assign({},this.program.usesPingpongRendering())).declare("sortApplyPermutation",Fe).declare("mixKeypointsPreInit",Oe).declare("mixKeypointsInit",Ue).declare("mixKeypointsSort",Ge,Object.assign({},this.program.usesPingpongRendering())).declare("mixKeypointsView",qe).declare("mixKeypointsApply",He).declare("encodeNullKeypoints",tt).declare("encodeKeypoints",Ze).declare("initLookupTable",Je).declare("sortLookupTable",Ye,Object.assign({},this.program.usesPingpongRendering())).declare("viewLookupTable",We).declare("encodeKeypointSkipOffsets",je).declare("encodeKeypointLongSkipOffsets",$e,Object.assign({},this.program.usesPingpongRendering())).declare("encodeKeypointPositions",Ve,Object.assign({},this.program.usesPingpongRendering())).declare("encodeKeypointProperties",et).declare("transferOrientation",nt).declare("uploadKeypoints",it,Object.assign({},this.program.usesPingpongRendering())).declare("applyHomography",ot).declare("clipBorder",st).declare("distanceFilter",rt).declare("hammingDistanceFilter32",At).declare("hammingDistanceFilter64",at).declare("shuffle",dt).declare("clip",ct);for(const e of Object.keys(ze))for(const t of Object.keys(ze[e]))for(const n of Object.keys(ze[e][t])){const i=`lshKnn${e}h${t}lv${n}`;this.declare(i,ze[e][t][n],Object.assign({},this.program.usesPingpongRendering()))}}}const gt=(0,I.bf)("pyramids/upsample2.glsl").withArguments("image"),ht=(0,I.bf)("pyramids/downsample2.glsl").withArguments("image");class pt extends S{constructor(e){super(e),this.declare("upsample2",gt).declare("downsample2",ht).declare("smoothX",(0,k.convX)([.05,.25,.4,.25,.05])).declare("smoothY",(0,k.convY)([.05,.25,.4,.25,.05])).declare("smoothX2",(0,k.convX)([.1,.5,.8,.5,.1])).declare("smoothY2",(0,k.convY)([.1,.5,.8,.5,.1],.5))}}const ut=(0,I.bf)("transforms/warp-perspective.glsl").withArguments("image","inverseHomography"),It=(0,I.bf)("transforms/resize.glsl").withDefines({INTERPOLATION_METHOD:0}).withArguments("image"),ft=(0,I.bf)("transforms/resize.glsl").withDefines({INTERPOLATION_METHOD:1}).withArguments("image"),mt=(0,I.bf)("transforms/additive-mix.glsl").withArguments("image0","image1","alpha","beta","gamma");class Ct extends S{constructor(e){super(e),this.declare("warpPerspective",ut).declare("resizeNearest",It).declare("resizeBilinear",ft).declare("additiveMix",mt)}}class Et{constructor(e){this._gpu=e,this._filters=null,this._transforms=null,this._pyramids=null,this._keypoints=null,this._utils=null}get filters(){return this._filters||(this._filters=new J(this._gpu))}get transforms(){return this._transforms||(this._transforms=new Ct(this._gpu))}get pyramids(){return this._pyramids||(this._pyramids=new pt(this._gpu))}get keypoints(){return this._keypoints||(this._keypoints=new lt(this._gpu))}get utils(){return this._utils||(this._utils=new L(this._gpu))}release(){for(const e in this)if(Object.prototype.hasOwnProperty.call(this,e)&&null!=this[e]){const t=this[e];t instanceof S&&t.release()}return null}}const xt=Symbol("Bucket");class yt{constructor(e,t,n){this.texture=e,this.index=t,this.next=n,this.free=!0}}class _t{constructor(e,n=1024){t.A.assert(n>0),this._bucket=Array.from({length:n},((e,t)=>new yt(null,t,t-1))),this._head=n-1,this._gpu=e}allocate(){if(this._head<0)throw new c.l(`Exhausted pool (capacity: ${this._bucket.length})`);const e=this._bucket[this._head];return e.free=!1,this._head=e.next,null==e.texture&&(e.texture=_t._createManagedTexture(this._gpu.gl,e)),e.texture}free(e){const n=e[xt];return t.A.assert(void 0!==n&&!n.free,"Unmanaged texture or double free"),n.next=this._head,n.free=!0,this._head=n.index,null}release(){for(let e=0;e{t.A.log(`Waiting for ${n} to be triggered in ${e}...`);const r=setTimeout((()=>{A(),s(new c.MU(`${n} has not been triggered in ${e}: timeout (${i}ms)`))}),i);function A(){clearTimeout(r),e.removeEventListener("error",a,!1),e.removeEventListener(n,d,!1)}function a(){const t=null!==e.error&&"object"==typeof e.error?e.error:{code:-1,message:""},n=`${t.message} (error code ${t.code})`;A(),s(new c.FJ(`Can't load ${e}. ${n}`))}function d(){A(),o(e)}e.addEventListener("error",a,!1),e.addEventListener(n,d,!1)}))}}class vt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.Image}get width(){return this._data?this._data.naturalWidth:0}get height(){return this._data?this._data.naturalHeight:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");const e=this._data.cloneNode(!0);return vt.load(e)}_load(e){return this.isLoaded()&&this.release(),e.complete&&0!==e.naturalWidth?new s.i((t=>{this._data=e,t(this)})):Bt._waitUntil(e,"load").then((()=>(this._data=e,this)))}static load(e){return new vt(Pt)._load(e)}}class Qt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.Video}get width(){return this._data?this._data.videoWidth:0}get height(){return this._data?this._data.videoHeight:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");const e=this._data.cloneNode(!0);return Qt.load(e)}_load(e){return this.isLoaded()&&this.release(),setTimeout((()=>e.load())),Qt._waitUntilPlayable(e).then((()=>Qt._handleAutoplay(e).then((()=>(this._data=e,this)))))}static load(e){return new Qt(Pt)._load(e)}static _handleAutoplay(e){return e.autoplay?new s.i(((t,n)=>{const i=e.play();void 0!==i?i.then(t,n):t()})):s.i.resolve()}static _waitUntilPlayable(e){return e.readyState>=3?s.i.resolve(e):new s.i(((t,n)=>{let i=0,o=setInterval((()=>{e.readyState>=3?(clearInterval(o),t(e)):(i+=500)>=15e3&&(clearInterval(o),n(new c.MU("The video took too long to load")))}),500)}))}}class wt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.Canvas}get width(){return this._data?this._data.width:0}get height(){return this._data?this._data.height:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");const e=t.A.createCanvas(this.width,this.height);return e.getContext("2d").drawImage(this._data,0,0),wt.load(e)}_load(e){return this.isLoaded()&&this.release(),new s.i((t=>{this._data=e,t(this)}))}static load(e){return new wt(Pt)._load(e)}}class bt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.OffscreenCanvas}get width(){return this._data?this._data.width:0}get height(){return this._data?this._data.height:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");const e=new OffscreenCanvas(this.width,this.height);return e.getContext("2d").drawImage(this._data,0,0),bt.load(e)}_load(e){return this.isLoaded()&&this.release(),new s.i((t=>{this._data=e,t(this)}))}static load(e){return new bt(Pt)._load(e)}}class Dt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.Bitmap}get width(){return this._data?this._data.width:0}get height(){return this._data?this._data.height:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");return new s.i(((e,t)=>{createImageBitmap(this._data).then((n=>{new Dt(Pt)._load(n).then(e,t)}),t)}))}release(){return null!=this._data&&this._data.close(),super.release()}_load(e){return this.isLoaded()&&this.release(),new s.i((t=>{this._data=e,t(this)}))}static load(e){return new Dt(Pt)._load(e)}}class Mt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.Data}get width(){return this._data?this._data.width:0}get height(){return this._data?this._data.height:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");const e=new ImageData(new Uint8ClampedArray(this._data.data),this._data.width,this._data.height);return Mt.load(e)}_load(e){return this.isLoaded()&&this.release(),new s.i((t=>{this._data=e,t(this)}))}static load(e){return new Mt(Pt)._load(e)}}var Kt=n(3211);class Lt extends Kt.c{constructor(){super(),this._speedyGL=e.c.instance,this._programs=new Et(this),this._texturePool=new _t(this),this._speedyGL.subscribe(this._reset,this)}get programs(){return this._programs}get gl(){return this._speedyGL.gl}get canvas(){return this._speedyGL.canvas}get texturePool(){return this._texturePool}renderToCanvas(e){const n=e.width,i=e.height,o=this.canvas;return(n>o.width||i>o.height)&&(t.A.warning(`Resizing the canvas to ${n} x ${i}`),o.width=n,o.height=i),this.programs.utils.renderToCanvas.outputs(n,i,null),this.programs.utils.renderToCanvas(e),o}upload(e,t){return t.upload(e.data,e.width,e.height)}release(){return t.A.assert(!this.isReleased()),this._programs=this._programs.release(),this._texturePool=this._texturePool.release(),this._speedyGL.unsubscribe(this._reset),null}isReleased(){return null==this._programs}loseAndRestoreWebGLContext(){return this._speedyGL.loseAndRestoreContext().then((()=>{}))}_reset(){this.isReleased()||(this._programs=new Et(this),this._texturePool=new _t(this),this._notify())}}class kt{constructor(e,t){this._width=Math.max(0,+e),this._height=Math.max(0,+t)}get width(){return this._width}set width(e){this._width=Math.max(0,+e)}get height(){return this._height}set height(e){this._height=Math.max(0,+e)}toString(){return`SpeedySize(${this.width}, ${this.height})`}equals(e){return this.width===e.width&&this.height===e.height}area(){return this.width*this.height}}const Rt=Symbol();class zt{constructor(e,t,n={}){if(e!==Rt)throw new c.Er;if(this._source=t,this._format=void 0!==n.format?n.format:St.f5.RGBA,this._options=Object.freeze(Object.assign(Object.assign({},n),{},{format:this._format})),!t.isLoaded())throw new c.Er(`Source not loaded: ${t}`);if(this._format!==St.f5.RGBA&&this._format!==St.f5.GREY)throw new c.qw(`Invalid format: ${this._format}`)}static load(e,n={},i=!0){return Bt.load(e).then((o=>{t.A.assert(0!==o.width&&0!==o.height);const s=new zt(Rt,o,n);return i&&t.A.log(`Loaded SpeedyMedia with a ${e}.`),s}))}get source(){return this._source?this._source.data:null}get type(){if(this.isReleased())return"unknown";switch(this._source.type){case St.zu.Image:return"image";case St.zu.Video:return"video";case St.zu.Canvas:return"canvas";case St.zu.OffscreenCanvas:return"offscreen-canvas";case St.zu.Bitmap:return"bitmap";case St.zu.Data:return"data";default:return"unknown"}}get width(){return this._source?this._source.width:0}get height(){return this._source?this._source.height:0}get size(){return this._source?new kt(this._source.width,this._source.height):new kt(0,0)}get options(){return this._options}release(){return this.isReleased()||(t.A.log("Releasing SpeedyMedia object..."),this._source=this._source.release()),null}isReleased(){return null==this._source}clone(){if(this.isReleased())throw new c.Er("Can't clone a SpeedyMedia that has been released");const e=new zt(Rt,this._source,this._options);return s.i.resolve(e)}toBitmap(){if(this.isReleased())throw new c.Er("Can't convert SpeedyMedia to ImageBitmap: the media has been released");if(this._source.isLoaded())return this._source.type==St.zu.Bitmap?s.i.resolve(this._source.data):new s.i(((e,t)=>createImageBitmap(this._source.data).then(e,t)));throw new c.Er("Can't convert SpeedyMedia to bitmap: the media hasn't been loaded")}}class Nt extends Y.Q{static get renderer(){return e.c.instance.renderer}static get vendor(){return e.c.instance.vendor}}class Xt{constructor(e,t){this._x=+e,this._y=+t}get x(){return this._x}set x(e){this._x=+e}get y(){return this._y}set y(e){this._y=+e}toString(){return`SpeedyVector2(${this.x.toFixed(5)}, ${this.y.toFixed(5)})`}equals(e){return this.x===e.x&&this.y===e.y}dot(e){return this.x*e.x+this.y*e.y}distanceTo(e){const t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalized(){const e=this.length();return e>0?new Xt(this.x/e,this.y/e):new Xt(0,0)}plus(e){return new Xt(this.x+e.x,this.y+e.y)}minus(e){return new Xt(this.x-e.x,this.y-e.y)}times(e){return new Xt(this.x*e,this.y*e)}}class Tt{constructor(e,t){this._x=+e,this._y=+t}get x(){return this._x}set x(e){this._x=+e}get y(){return this._y}set y(e){this._y=+e}toString(){return`SpeedyPoint2(${this.x.toFixed(5)}, ${this.y.toFixed(5)})`}plus(e){return new Tt(this.x+e.x,this.y+e.y)}minus(e){return new Xt(this.x-e.x,this.y-e.y)}equals(e){return this.x===e.x&&this.y===e.y}}n(6306);var Ft=n(6465),Ot=n(4188);const Ut=Object.freeze({Nothing:Symbol("Nothing"),Image:Symbol("Image"),Keypoints:Symbol("Keypoints"),Vector2:Symbol("Vector2"),LSHTables:Symbol("LSHTables"),KeypointMatches:Symbol("KeypointMatches")});class Gt{constructor(e){this._type=e}get type(){return this._type}hasType(e){return this._type===e}isEmpty(){return this.hasType(Ut.Nothing)}toString(){return`message of type ${Object.keys(Ut).find((e=>Ut[e]===this.type))}`}inspect(e){throw new c.aQ}set(...e){throw new c.aQ}static create(e){return function(e){return new Ht[e]}(e)}}class qt extends Gt{constructor(){super(Ut.Nothing)}set(){return this}inspect(e){return{type:this.constructor.name}}}const Ht=Object.freeze({[Ut.Nothing]:qt,[Ut.Image]:class extends Gt{constructor(){super(Ut.Image),this._image=null,this._format=St.f5.RGBA}set(e,t=St.f5.RGBA){return this._image=e,this._format=t,this}inspect(e){const t=Object.keys(St.f5).find((e=>St.f5[e]===this.format));return{type:this.constructor.name,format:String(t),imageSize:this.image?`${this.image.width}x${this.image.height}`:"0x0",image:this.image?"":"",hasMipmaps:this.image&&this.image.hasMipmaps()?"yes":"no"}}get image(){return this._image}get format(){return this._format}},[Ut.Keypoints]:class extends Gt{constructor(){super(Ut.Keypoints),this._encodedKeypoints=null,this._descriptorSize=0,this._extraSize=0,this._encoderLength=1}set(e,n,i,o){return this._encodedKeypoints=e,this._descriptorSize=0|n,this._extraSize=0|i,this._encoderLength=0|o,t.A.assert(this._descriptorSize>=0&&this._extraSize>=0),t.A.assert(this._encoderLength===this._encodedKeypoints.width,"Invalid encoderLength"),t.A.assert(this._encodedKeypoints.width===this._encodedKeypoints.height,"Invalid encodedKeypoints texture"),this}inspect(e){return{type:this.constructor.name,descriptorSize:this.descriptorSize,extraSize:this.extraSize,encoderLength:this.encoderLength,encodedKeypointsSize:this.encodedKeypoints?`${this.encodedKeypoints.width}x${this.encodedKeypoints.height}`:"0x0",encodedKeypoints:this.encodedKeypoints?t.A.formatBinaryData(this.encodedKeypoints.inspect(e).buffer):""}}get encodedKeypoints(){return this._encodedKeypoints}get descriptorSize(){return this._descriptorSize}get extraSize(){return this._extraSize}get encoderLength(){return this._encoderLength}},[Ut.Vector2]:class extends Gt{constructor(){super(Ut.Vector2),this._vectors=null}set(e){return this._vectors=e,this}inspect(e){return{type:this.constructor.name,vectorsSize:this.vectors?`${this.vectors.width}x${this.vectors.height}`:"0x0",vectors:this.vectors?t.A.formatBinaryData(this.vectors.inspect(e).buffer):""}}get vectors(){return this._vectors}},[Ut.LSHTables]:class extends Gt{constructor(){super(Ut.LSHTables),this._lsh=null}set(e){return this._lsh=e,this}inspect(e){return{type:this.constructor.name,lsh:""}}get lsh(){return this._lsh}},[Ut.KeypointMatches]:class extends Gt{constructor(){super(Ut.KeypointMatches),this._encodedMatches=null,this._matchesPerKeypoint=1}set(e,n){return this._encodedMatches=e,this._matchesPerKeypoint=0|n,t.A.assert(this._matchesPerKeypoint>0),this}inspect(e){return{type:this.constructor.name,matchesPerKeypoint:this.matchesPerKeypoint,encodedMatchesSize:this.encodedMatches?`${this.encodedMatches.width}x${this.encodedMatches.height}`:"0x0",encodedMatches:this.encodedMatches?t.A.formatBinaryData(this.encodedMatches.inspect(e).buffer):""}}get encodedMatches(){return this._encodedMatches}get matchesPerKeypoint(){return this._matchesPerKeypoint}}});const Jt=e=>!0;class Yt{constructor(e,n=Jt){this._expectedMessageType=e,this._isValidMessage="function"==typeof n?n:Jt,t.A.assert(this._expectedMessageType!=Ut.Nothing)}isCompatibleWith(e){return this._expectedMessageType==e._expectedMessageType}accepts(e){return e.hasType(this._expectedMessageType)&&this._isValidMessage(e)}toString(){return`Port expects ${Object.keys(Ut).find((e=>Ut[e]===this._expectedMessageType))} satisfying ${this._isValidMessage}`}get expectedMessageType(){return this._expectedMessageType}}const Wt=/^[a-z][a-zA-Z0-9]*$/,Zt=new qt;class jt{constructor(e,n,i){this._name=String(e),this._spec=n,this._node=i,this._message=Zt,t.A.assert(Wt.test(this._name),`Port name "${this._name}" is not acceptable`)}get name(){return this._name}get node(){return this._node}connectTo(e){throw new c.aQ}isInputPort(){throw new c.aQ}isOutputPort(){return!this.isInputPort()}clearMessage(){this._message=Zt}hasMessage(){return!this._message.isEmpty()}read(){if(this._message.isEmpty())throw new c.Er(`Can't read from port ${this.name}: nothing to read`);return this._message}write(e){throw new c.EM(`Can't write ${e} to port ${this.name}: unsupported operation`)}inspect(e){return this._message.inspect(e)}static get DEFAULT_NAME(){throw new c.aQ}}class $t extends jt{constructor(e,t,n){super(e,t,n),this._cachedMessage=null}connectTo(e){if(!e.isInputPort())throw new c.qw(`Can't connect output port ${this.name} to port ${e.name}: expected an input port`);e.connectTo(this)}isInputPort(){return!1}write(e){if(!this._spec.accepts(e))throw new c.qw(`Can't write ${e} to port ${this.name}. ${this._spec}`);this._message=e}swrite(...e){null==this._cachedMessage&&(this._cachedMessage=Gt.create(this._spec.expectedMessageType)),this.write(this._cachedMessage.set(...e))}static get DEFAULT_NAME(){return"out"}}class Vt extends jt{constructor(e,t,n){super(e,t,n),this._incomingLink=null}get incomingLink(){return this._incomingLink}connectTo(e){if(!e.isOutputPort())throw new c.qw(`Can't connect input port ${this.name} of "${this.node.fullName}" to input port ${e.name} of "${e.node.fullName}": expected an output port`);if(!this._spec.isCompatibleWith(e._spec))throw new c.qw(`Can't connect port ${this.name} of "${this.node.fullName}" to port ${e.name} of "${e.node.fullName}": incompatible types`);this._incomingLink=e}disconnect(){this._incomingLink=null}isInputPort(){return!0}pullMessage(e=""){const t=e.length>0?`${this.name} of ${e}`:this.name;if(null==this._incomingLink)throw new c.Er(`No incoming link for input port ${t}`);const n=this._incomingLink.read();if(!this._spec.accepts(n))throw new c.qw(`Can't receive ${n} at port ${t}: ${this._spec}`);return this._message=n}static get DEFAULT_NAME(){return"in"}}class en{constructor(e,t){this._class=e,this._name=String(t),this._type=Ut.Nothing,this._messageConstraint=void 0}expects(e){return t.A.assert(this._type==Ut.Nothing),t.A.assert(e!=Ut.Nothing),this._type=e,this}satisfying(e){return t.A.assert(this._type!=Ut.Nothing,"You must first declare what type of message this port expects"),t.A.assert(void 0===this._messageConstraint),t.A.assert("function"==typeof e),this._messageConstraint=e,this}build(e){const t=new Yt(this._type,this._messageConstraint);return Reflect.construct(this._class,[this._name,t,e])}}function tn(e=Vt.DEFAULT_NAME){return new en(Vt,e)}function nn(e=$t.DEFAULT_NAME){return new en($t,e)}function on(e){return e.reduce(((e,t)=>(e[t.name]=t,e)),Object.create(null))}function sn(e){return e.reduce(((e,t)=>(e[t.name]=t,e)),Object.create(null))}let rn=!1;class An{constructor(e=(()=>Math.random().toString(16).substr(2))(),t=0,n=[]){this._name=String(e),this._tex=new Array(t).fill(null);const i=n.map((e=>e.build(this))),o=i.filter((e=>e.isInputPort())),s=i.filter((e=>e.isOutputPort()));if(this._inputPorts=on(o),this._outputPorts=sn(s),0==this._name.length)throw new c.qw(`Invalid name "${this._name}" for node ${this.fullName}`);if(0==n.length)throw new c.qw(`No ports have been found in node ${this.fullName}`)}get name(){return this._name}get fullName(){return`${this.constructor.name}[${this.name}]`}input(e=Vt.DEFAULT_NAME){if(e in this._inputPorts)return this._inputPorts[e];throw new c.qw(`Can't find input port ${e} in node ${this.fullName}`)}output(e=$t.DEFAULT_NAME){if(e in this._outputPorts)return this._outputPorts[e];throw new c.qw(`Can't find output port ${e} in node ${this.fullName}`)}execute(e){let t;for(t in this._outputPorts)this._outputPorts[t].clearMessage();for(t in this._inputPorts)this._inputPorts[t].pullMessage(this.fullName);const n=this._run(e);return void 0===n?void this._finishExecution(e):n.then((()=>this._finishExecution(e)))}_finishExecution(e){for(const e in this._outputPorts)t.A.assert(this._outputPorts[e].hasMessage(),`Did you forget to write data to the output port ${e} of ${this.fullName}?`);if("diagnostic"===o.w.logging){t.A.log(`%c ${this.fullName} `,"font-size:12pt;font-weight:bold;color:white;background:blue");for(const n in this._inputPorts)t.A.log(`%c-> ${n}:`,"font-size:10pt;font-weight:bold",this._inputPorts[n].inspect(e));for(const n in this._outputPorts)t.A.log(`%c<- ${n}:`,"font-size:10pt;font-weight:bold",this._outputPorts[n].inspect(e))}}_run(e){throw new c.aQ}init(e){e.subscribe(this._allocateWorkTextures,this,e),this._allocateWorkTextures(e)}release(e){this._deallocateWorkTextures(e),e.unsubscribe(this._allocateWorkTextures,this)}clearPorts(){let e;for(e in this._inputPorts)this._inputPorts[e].clearMessage();for(e in this._outputPorts)this._outputPorts[e].clearMessage()}inputNodes(){const e=[];for(const t in this._inputPorts){const n=this._inputPorts[t];null!=n.incomingLink&&e.push(n.incomingLink.node)}return e}isSource(){return!1}isSink(){return!1}_allocateWorkTextures(e){for(let t=0;t=0;t--)this._tex[t]=e.texturePool.free(this._tex[t])}_visualize(e,t){const n=e.renderToCanvas(t);rn||(document.body.appendChild(n),rn=!0)}}class an extends An{constructor(e=void 0,n=void 0,i=void 0){super(e,n,i),t.A.assert(0==Object.keys(this._inputPorts).length)}isSource(){return!0}}class dn extends An{constructor(e=void 0,n=void 0,i=void 0){super(e,n,i),t.A.assert(0==Object.keys(this._outputPorts).length)}export(){throw new c.aQ}isSink(){return!0}}class cn{constructor(e,t){const n=t0)throw new c.Er("The pipeline has already been initialized");if(0==e.length)throw new c.qw("Can't initialize the pipeline. Please specify its nodes");0==un++&&(t.A.assert(!pn,"Duplicate SpeedyGPU instance"),pn=new Lt);for(let t=0;t=0;e--)this._sequence[e].release(pn);return this._sequence.length=0,this._nodes.length=0,0==--un&&(pn=pn.release()),null}run(){if(t.A.assert(this._sequence.length>0,"The pipeline has not been initialized or has been released"),this._busy)return new s.i(((e,t)=>{setTimeout((()=>this.run().then(e,t)),0)}));this._busy=!0;const e=this._sequence.filter((e=>e.isSink())),n=In._createOutputTemplate(e);return"diagnostic"===o.w.logging&&t.A.log("%c RUNNING PIPELINE ","background:red;color:white;font-size:28pt;font-weight:bold"),In._runSequence(this._sequence).then((()=>s.i.all(e.map((e=>e.export().turbocharge()))).then((t=>t.reduce(((t,n,i)=>(t[e[i].name]=n,t)),n))))).finally((()=>{for(let e=this._sequence.length-1;e>=0;e--)this._sequence[e].clearPorts();this._busy=!1,"diagnostic"===o.w.logging&&(t.A.log("%c PIPELINE OUTPUT \n","background:green;color:white;font-size:16pt;font-weight:bold"),Object.keys(n).forEach((e=>{t.A.log("%c"+e+":","font-size:10pt;font-weight:bold",n[e])})))})).turbocharge()}get _gpu(){return pn}static _runSequence(e,t=0,n=e.length){for(;tIn._runSequence(e,t+1,n)))}return s.i.resolve()}static _tsort(e){const t=In._outlinks(e),n=e.map((e=>[e,!1])),i=new Set,o=new Array(e.length);let s=o.length;for(;n.length>0;){const[e,r]=n.pop();if(r)o[--s]=e;else if(!i.has(e)){const s=t.get(e);if(i.add(e),n.push([e,!0]),n.push(...s.map((e=>[e,!1]))),s.some((e=>i.has(e)&&!o.includes(e))))throw new c.Er("Pipeline networks cannot have cycles!")}}return o}static _outlinks(e){const t=new Map;for(let n=0;n=0;n--)t[e[n].name]=null;return t}static _validateSequence(e){if(0==e.length)throw new c.Er("Pipeline doesn't have nodes");if(!e[0].isSource())throw new c.Er("Pipeline doesn't have a source");if(!e.find((e=>e.isSink())))throw new c.Er("Pipeline doesn't have a sink")}}class fn extends an{constructor(e=void 0){super(e,2,[nn().expects(Ut.Image)]),this._media=null,this._textureIndex=0}get media(){return this._media}set media(e){if(null!==e&&!(e instanceof zt))throw new c.qw(`Not a SpeedyMedia: ${e}`);this._media=e}_run(e){if(null==this._media)throw new c.Er(`Did you forget to set the media of ${this.fullName}?`);this._textureIndex=(this._textureIndex+1)%this._tex.length;const t=this._tex[this._textureIndex];e.upload(this._media._source,t),this.output().swrite(t,this._media._format)}}class mn extends dn{constructor(e="image"){super(e,0,[tn().expects(Ut.Image)]),this._mediaType="bitmap",this._bitmap=null,this._data=null,this._format=St.f5.RGBA,this._textureReader=new g(1)}get mediaType(){return this._mediaType}set mediaType(e){if("bitmap"!=e&&"data"!=e)throw new c.qw(`Invalid mediaType for ${this.fullName}: "${e}"`);this._mediaType=e}init(e){super.init(e),this._textureReader.init(e)}release(e){this._textureReader.release(e),super.release(e)}export(){const e="data"!=this._mediaType?this._bitmap:this._data;return t.A.assert(null!=e),zt.load(e,{format:this._format},!1)}_run(e){const{image:t,format:n}=this.input().read();return"data"!=this._mediaType?new s.i((i=>{const o=e.renderToCanvas(t);createImageBitmap(o,0,o.height-t.height,t.width,t.height).then((e=>{this._bitmap=e,this._format=n,this._data=null,i()}))})):this._textureReader.readPixelsAsync(t,0,0,t.width,t.height,!1).then((e=>{const i=new Uint8ClampedArray(e.buffer);this._data=new ImageData(i,t.width,t.height),this._format=n,this._bitmap=null}))}}const Cn=["in0","in1"];class En extends An{constructor(e=void 0){super(e,0,[...Cn.map((e=>tn(e).expects(Ut.Image))),nn().expects(Ut.Image)]),this._port=0}get port(){return this._port}set port(e){if(e<0||e>=Cn.length)throw new c.qw(`Invalid port: ${e}`);this._port=0|e}_run(e){const t=this.input(Cn[this._port]).read();this.output().write(t)}}class xn extends An{constructor(e=void 0){super(e,2,[tn().expects(Ut.Image),nn().expects(Ut.Image)]),this._pageIndex=0,this._initialized=!1,this._previousFormat=St.f5.RGBA,this._frozen=!1}get frozen(){return this._frozen}set frozen(e){this._frozen=Boolean(e)}release(e){this._initialized=!1,super.release(e)}_run(e){const{image:t,format:n}=this.input().read(),i=this._previousFormat,o=this._tex,s=o[1-this._pageIndex],r=o[this._pageIndex];if(t.hasMipmaps())throw new c.EM(`${this.fullName} can't bufferize a pyramid`);if(this._frozen&&this._initialized||(this._previousFormat=n,s.resize(t.width,t.height),t.copyTo(s),this._pageIndex=1-this._pageIndex),!this._initialized)return this._initialized=!0,void this.output().swrite(s,n);this.output().swrite(r,i)}}const yn=h.PYRAMID_MAX_LEVELS,_n=2*yn;class Sn extends An{constructor(e=void 0){super(e,_n+1,[tn().expects(Ut.Image),nn().expects(Ut.Image)])}_run(e){const{image:t,format:n}=this.input().read(),i=this._tex[0],o=e.programs.pyramids;let s=t.width,r=t.height;const A=1+Math.floor(Math.log2(Math.max(s,r))),a=new Array(_n+1);for(let e=_n;e>=1;e--)a[e-1]=this._tex[e];a[0].resize(s,r),t.copyTo(a[0]);const d=Math.min(A,yn);for(let t=1;t>>1),i=Math.max(1,r>>>1),A=t-1+yn;o.smoothX.outputs(s,r,a[A])(a[t-1]),o.smoothY.outputs(s,r,a[t-1])(a[A]),o.downsample2.outputs(n,i,a[t])(a[t-1]),e.gl.flush(),s=n,r=i}i.resize(t.width,t.height),i.clear(),t.copyTo(i),i.generateMipmaps(a.slice(0,d)),this.output().swrite(i,n)}}class Pn extends An{constructor(e=void 0){super(e,1,[tn("in0").expects(Ut.Image),tn("in1").expects(Ut.Image),nn().expects(Ut.Image)]),this._alpha=.5,this._beta=.5,this._gamma=0}get alpha(){return this._alpha}set alpha(e){this._alpha=+e}get beta(){return this._beta}set beta(e){this._beta=+e}get gamma(){return this._gamma}set gamma(e){this._gamma=+e}_run(e){const t=this.input("in0").read(),n=this.input("in1").read(),i=t.image,o=n.image,s=t.format,r=n.format,A=Math.max(i.width,o.width),a=Math.max(i.height,o.height),d=this._alpha,l=this._beta,g=this._gamma,h=this._tex[0];if(s!=r)throw new c.EM("Can't mix images of different formats");e.programs.transforms.additiveMix.outputs(A,a,h),e.programs.transforms.additiveMix(i,o,d,l,g),this.output().swrite(h,s)}}class Bn extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Image)]),this._format=St.f5.RGBA,this._initialized=!1}get image(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._tex[0]}get format(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._format}init(e){super.init(e),this._tex[0].resize(1,1).clear(),this._format=St.f5.RGBA,this._initialized=!0}release(e){this._initialized=!1,super.release(e)}_run(e){const{image:t,format:n}=this.input().read(),i=this._tex[0];if(t.hasMipmaps())throw new c.EM(`${this.fullName} can't store a pyramid`);this._format=n,i.resize(t.width,t.height),t.copyTo(i)}}class vn extends an{constructor(e=void 0){super(e,0,[nn().expects(Ut.Image)]),this._source=null}get source(){return this._source}set source(e){if(null!==e&&!(e instanceof Bn))throw new c.qw(`Incompatible source for ${this.fullName}`);this._source=e}_run(e){if(null==this._source)throw new c.Er(`${this.fullName} has no source`);this.output().swrite(this._source.image,this._source.format)}}class Qn extends Y.Q{static Source(e=void 0){return new vn(e)}static Sink(e=void 0){return new Bn(e)}}class wn extends Y.Q{static Source(e=void 0){return new fn(e)}static Sink(e=void 0){return new mn(e)}static Multiplexer(e=void 0){return new En(e)}static Buffer(e=void 0){return new xn(e)}static Pyramid(e=void 0){return new Sn(e)}static Mixer(e=void 0){return new Pn(e)}static get Portal(){return Qn}}class bn extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Image),nn().expects(Ut.Image)])}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._tex[0],r=e.programs.filters;r.rgb2grey.outputs(i,o,s),r.rgb2grey(t),this.output().swrite(s,St.f5.GREY)}}const Dn=Object.freeze({3:[.27901008925473514,.44197982149052983,.27901008925473514],5:[.06135959781344021,.2447701955296099,.3877404133138998,.2447701955296099,.06135959781344021],7:[.03873542500847274,.11308485700794121,.2150068609928349,.26634571398150225,.2150068609928349,.11308485700794121,.03873542500847274],9:[.028532262603370988,.067234535494912,.12400932997922749,.17904386461741617,.20236001461014655,.17904386461741617,.12400932997922749,.067234535494912,.028532262603370988],11:[.022656882730580346,.04610857898527292,.08012661469398517,.11890414969751599,.15067709325491124,.16305336127546846,.15067709325491124,.11890414969751599,.08012661469398517,.04610857898527292,.022656882730580346],13:[.018815730430644363,.03447396964662016,.05657737457255748,.08317258170844948,.10952340502389682,.12918787500405662,.13649812722755,.12918787500405662,.10952340502389682,.08317258170844948,.05657737457255748,.03447396964662016,.018815730430644363],15:[.016100340991695383,.027272329212157102,.042598338587449644,.06135478775568558,.08148767614129326,.09979838342934616,.11270444144735056,.11736740487004466,.11270444144735056,.09979838342934616,.08148767614129326,.06135478775568558,.042598338587449644,.027272329212157102,.016100340991695383]}),Mn=new Xt(0,0),Kn=Object.freeze({3:"convolution3x",5:"convolution5x",7:"convolution7x",9:"convolution9x",11:"convolution11x",13:"convolution13x",15:"convolution15x"}),Ln=Object.freeze({3:"convolution3y",5:"convolution5y",7:"convolution7y",9:"convolution9y",11:"convolution11y",13:"convolution13y",15:"convolution15y"});class kn extends An{constructor(e=void 0){super(e,2,[tn().expects(Ut.Image),nn().expects(Ut.Image)]),this._kernelSize=new kt(5,5),this._sigma=Mn,this._kernel={x:Dn[this._kernelSize.width],y:Dn[this._kernelSize.height]}}get kernelSize(){return this._kernelSize}set kernelSize(e){t.A.assert(e instanceof kt);const n=e.width,i=e.height;if(n<3||i<3||n>15||i>15||n%2==0||i%2==0)throw new c.EM(`Unsupported kernel size: ${n}x${i}`);this._kernelSize=e,this._updateKernel()}get sigma(){return this._sigma}set sigma(e){t.A.assert(e instanceof Xt,"Sigma must be a SpeedyVector2"),t.A.assert(e.x>=0&&e.y>=0),this._sigma=e,this._updateKernel()}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._kernel.x,r=this._kernel.y,A=Kn[this._kernelSize.width],a=Ln[this._kernelSize.height],d=this._tex[0],c=this._tex[1];e.programs.filters[A].outputs(i,o,d)(t,s),e.programs.filters[a].outputs(i,o,c)(d,r),this.output().swrite(c,n)}_updateKernel(){this._sigma.x==Mn.x?this._kernel.x=Dn[this._kernelSize.width]:this._kernel.x=t.A.gaussianKernel(this._sigma.x,this._kernelSize.width,!0),this._sigma.y==Mn.y?this._kernel.y=Dn[this._kernelSize.height]:this._kernel.y=t.A.gaussianKernel(this._sigma.y,this._kernelSize.height,!0)}}const Rn=Object.freeze({3:new Array(3).fill(1/3),5:new Array(5).fill(.2),7:new Array(7).fill(1/7),9:new Array(9).fill(1/9),11:new Array(11).fill(1/11),13:new Array(13).fill(1/13),15:new Array(15).fill(1/15)}),zn=Object.freeze({3:"convolution3x",5:"convolution5x",7:"convolution7x",9:"convolution9x",11:"convolution11x",13:"convolution13x",15:"convolution15x"}),Nn=Object.freeze({3:"convolution3y",5:"convolution5y",7:"convolution7y",9:"convolution9y",11:"convolution11y",13:"convolution13y",15:"convolution15y"});class Xn extends An{constructor(e=void 0){super(e,2,[tn().expects(Ut.Image),nn().expects(Ut.Image)]),this._kernelSize=new kt(5,5),this._kernel={x:Rn[this._kernelSize.width],y:Rn[this._kernelSize.height]}}get kernelSize(){return this._kernelSize}set kernelSize(e){t.A.assert(e instanceof kt);const n=e.width,i=e.height;if(n<3||i<3||n>15||i>15||n%2==0||i%2==0)throw new c.EM(`Unsupported kernel size: ${n}x${i}`);this._kernelSize=e,this._kernel.x=Rn[this._kernelSize.width],this._kernel.y=Rn[this._kernelSize.height]}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._kernel.x,r=this._kernel.y,A=zn[this._kernelSize.width],a=Nn[this._kernelSize.height],d=this._tex[0],c=this._tex[1];e.programs.filters[A].outputs(i,o,d)(t,s),e.programs.filters[a].outputs(i,o,c)(d,r),this.output().swrite(c,n)}}const Tn={3:"median3",5:"median5",7:"median7"};class Fn extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),nn().expects(Ut.Image)]),this._kernelSize=new kt(5,5)}get kernelSize(){return this._kernelSize}set kernelSize(e){t.A.assert(e instanceof kt);const n=e.width;if(3!=n&&5!=n&&7!=n)throw new c.EM("Supported kernel sizes: 3x3, 5x5, 7x7");if(e.width!=e.height)throw new c.EM("Use a square kernel");this._kernelSize=e}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._kernelSize.width,r=Tn[s],A=this._tex[0];e.programs.filters[r].outputs(i,o,A)(t),this.output().swrite(A,n)}}const On={3:"convolution3",5:"convolution5",7:"convolution7"};class Un extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Image),nn().expects(Ut.Image)]),this._kernel=Ot.SpeedyMatrix.Create(3,3,[0,0,0,0,1,0,0,0,0])}get kernel(){return this._kernel}set kernel(e){if(e.rows!=e.columns)throw new c.EM("Use a square kernel");if(3!=e.rows&&5!=e.rows&&7!=e.rows)throw new c.EM("Invalid kernel size. Supported sizes: 3x3, 5x5, 7x7");this._kernel=e}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._tex[0],r=this._kernel.rows,A=On[r],a=this._kernel.read();e.programs.filters[A].outputs(i,o,s)(t,a),this.output().swrite(s,n)}}class Gn extends An{constructor(e=void 0){super(e,3,[tn().expects(Ut.Image).satisfying((e=>e.format===St.f5.RGBA||e.format===St.f5.GREY)),nn().expects(Ut.Image)]),this._gain=.5,this._offset=.5,this._decay=0,this._quality="medium"}get gain(){return this._gain}set gain(e){this._gain=+e}get offset(){return this._offset}set offset(e){this._offset=+e}get decay(){return this._decay}set decay(e){this._decay=Math.max(0,Math.min(+e,1))}get quality(){return this._quality}set quality(e){if("high"!==e&&"medium"!==e&&"low"!==e)throw new c.qw(`Invalid quality level for the Nightvision filter: "${e}"`);this._quality=e}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._gain,r=this._offset,A=this._decay,a=this._quality,d=e.programs.filters,c=this._tex[0],l=this._tex[1],g=this._tex[2];"medium"==a?(d.illuminationMapX.outputs(i,o,c),d.illuminationMapY.outputs(i,o,l),d.illuminationMapX(t),d.illuminationMapY(c)):"high"==a?(d.illuminationMapHiX.outputs(i,o,c),d.illuminationMapHiY.outputs(i,o,l),d.illuminationMapHiX(t),d.illuminationMapHiY(c)):"low"==a&&(d.illuminationMapLoX.outputs(i,o,c),d.illuminationMapLoY.outputs(i,o,l),d.illuminationMapLoX(t),d.illuminationMapLoY(c)),n===St.f5.GREY?(d.nightvisionGreyscale.outputs(i,o,g),d.nightvisionGreyscale(t,l,s,r,A)):n===St.f5.RGBA&&(d.nightvision.outputs(i,o,g),d.nightvision(t,l,s,r,A)),this.output().swrite(g,n)}}class qn extends An{constructor(e=void 0){super(e,4,[tn().expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),nn().expects(Ut.Image)]),this._minValue=0,this._maxValue=255}get minValue(){return this._minValue}set minValue(e){this._minValue=Math.max(0,Math.min(+e,255))}get maxValue(){return this._maxValue}set maxValue(e){this._maxValue=Math.max(0,Math.min(+e,255))}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._tex[3];let r=this._minValue,A=this._maxValue;r>A&&(r=A=(r+A)/2);const a=this._scanMinMax(e,t,St.kQ.GREEN);e.programs.filters.normalizeGreyscale.outputs(i,o,s),e.programs.filters.normalizeGreyscale(a,r,A),this.output().swrite(s,n)}_scanMinMax(e,n,i){const o=this._tex,s=e.programs.utils,r=n.width,A=n.height,a=0|Math.ceil(Math.log2(Math.max(r,A)));t.A.assert(void 0!==St.kg[i]),s.copyComponents.outputs(r,A,o[2]),s.scanMinMax2D.outputs(r,A,o[0],o[1]);let d=s.copyComponents(n,n,St.kQ.ALL,St.kg[i]);for(let e=0;e>>1),a=Math.ceil(t.width*t.height/A),d=Math.max(A,a),c=e.programs.keypoints;c.initLookupTable.outputs(A,a,this._tex16[1]),c.sortLookupTable.outputs(A,a,this._tex16[0],this._tex16[1]),c.encodeKeypoints.outputs(r,r,n);let l=c.initLookupTable(t);for(let e=1;e1?1<{this._keypoints=this._decode(e,n,i,r,a)}))}_decode(e,n,i,o,s){const r=h.MIN_KEYPOINT_SIZE+n+i,A=h.LOG2_PYRAMID_MAX_SCALE,a=h.PYRAMID_MAX_LEVELS,d=Math.PI/255,l=[],g=this._includeDiscarded;let p,u,I,f,m,C,E,x,y=si,_=si;if(n%4!=0||i%4!=0)throw new c.qw(`Invalid descriptorSize (${n}) / extraSize (${i})`);const S=o*s*4,P=e.byteLength;P!=S&&t.A.warning(`Expected ${S} bytes when decoding a set of keypoints, found ${P}`),n+i>0&&(e=new Uint8Array(e));for(let o=0;o0&&(_=e.subarray(8+o,8+o+i),_.byteLength0&&(y=e.subarray(8+o+i,8+o+i+n),y.byteLength0&&A%4==0);const a=i.width,d=Vn.encoderCapacity(o,s,a),c=Vn.encoderLength(d,r,A);return e.programs.keypoints.allocateExtra.outputs(c,c,n)(i,o,s,a,r,A,c)}}class Ai extends ri{constructor(e="keypoints"){super(e,0,[tn().expects(Ut.Keypoints)])}_createKeypoint(e,t,n,i,o,s,r){const A=s.byteLength>0?new oi(s):null;return new ln(e,t,n,i,o,A)}}class ai extends ri{constructor(e="keypoints"){super(e,2,[tn().expects(Ut.Keypoints).satisfying((e=>0==e.extraSize)),tn("flow").expects(Ut.Vector2)])}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input().read(),{vectors:s}=this.input("flow").read(),r=n,A=this._allocateExtra(e,this._tex[0],t,n,i,r,4),a=A.width,d=e.programs.keypoints.transferToExtra.outputs(a,a,this._tex[1])(s,s.width,A,r,4,a);return this._download(e,d,r,4,a)}_createKeypoint(e,n,i,o,s,r,A){const a=r.byteLength,d=(A.byteLength,a>0?new oi(r):null),c=t.A.decodeFloat16(A[1]<<8|A[0]),l=t.A.decodeFloat16(A[3]<<8|A[2]),g=new Xt(c,l);return new gn(e,n,i,o,s,d,g)}}class di extends ri{constructor(e="keypoints"){super(e,2,[tn().expects(Ut.Keypoints).satisfying((e=>0==e.extraSize)),tn("matches").expects(Ut.KeypointMatches)])}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input().read(),{encodedMatches:s,matchesPerKeypoint:r}=this.input("matches").read(),A=n,a=4*r,d=this._allocateExtra(e,this._tex[0],t,n,i,A,a),c=d.width,l=e.programs.keypoints.transferToExtra.outputs(c,c,this._tex[1])(s,s.width,d,A,a,c);return this._download(e,l,A,a,c)}_createKeypoint(e,t,n,i,o,s,r){const A=s.byteLength,a=r.byteLength,d=A>0?new oi(s):null,c=a/4,l=new Array(c);for(let e=0;e>>h.MATCH_INDEX_BITS);l[e]=i}return new hn(e,t,n,i,o,d,l)}}const ci=h.MAX_ENCODER_CAPACITY;class li extends An{constructor(e=void 0){super(e,4,[tn().expects(Ut.Keypoints),nn().expects(Ut.Keypoints)]),this._size=ci}get size(){return this._size}set size(e){this._size=Math.max(0,Math.min(0|e,ci))}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input().read(),s=e.programs.keypoints,r=this._size,A=this._tex,a=this._tex[3],d=Vn.encoderCapacity(n,i,o),c=Math.ceil(d/32),l=32*c,g=Math.min(d,r),h=Vn.encoderLength(g,n,i);s.sortCreatePermutation.outputs(32,c,A[0]);let p=s.sortCreatePermutation(t,n,i,o);const u=Math.ceil(Math.log2(l));s.sortMergePermutation.outputs(32,c,A[1],A[2]);for(let e=1;e<=u;e++){const t=1<tn(e).expects(Ut.Keypoints))),nn().expects(Ut.Keypoints)]),this._port=0}get port(){return this._port}set port(e){if(e<0||e>=Ii.length)throw new c.qw(`Invalid port: ${e}`);this._port=0|e}_run(e){const t=this.input(Ii[this._port]).read();this.output().write(t)}}class mi extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Keypoints),nn().expects(Ut.Keypoints)]),this._transform=Ot.SpeedyMatrix.Create(3,3,[1,0,0,0,1,0,0,0,1])}get transform(){return this._transform}set transform(e){if(3!=e.rows||3!=e.columns)throw new c.qw(`Not a 3x3 transformation matrix: ${e}`);this._transform=e}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input().read(),s=this._tex[0],r=this._transform.read();e.programs.keypoints.applyHomography.outputs(t.width,t.height,s)(r,t,n,i,o),this.output().swrite(s,n,i,o)}}const Ci=Object.freeze({quadratic1d:"subpixelQuadratic1d",taylor2d:"subpixelTaylor2d","bicubic-upsample":"subpixelBicubic","bilinear-upsample":"subpixelBilinear"});class Ei extends An{constructor(e=void 0){super(e,2,[tn("image").expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),tn("keypoints").expects(Ut.Keypoints),nn().expects(Ut.Keypoints),nn("displacements").expects(Ut.Vector2)]),this._method="quadratic1d",this._maxIterations=6,this._epsilon=.1}get method(){return this._method}set method(e){if(!Object.prototype.hasOwnProperty.call(Ci,e))throw new c.qw(`Invalid method: "${e}"`);this._method=e}get maxIterations(){return this._maxIterations}set maxIterations(e){this._maxIterations=Math.max(0,+e)}get epsilon(){return this._epsilon}set epsilon(e){this._epsilon=Math.max(0,+e)}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input("keypoints").read(),{image:s,format:r}=this.input("image").read(),A=this._tex,a=Ci[this._method],d=this._maxIterations,c=this._epsilon,l=Vn.encoderCapacity(n,i,o),g=Math.max(1,Math.ceil(Math.sqrt(l))),h=e.programs.keypoints[a].outputs(g,g,A[0])(s,t,n,i,o,d,c),p=e.programs.keypoints.transferFlow.outputs(o,o,A[1])(h,t,n,i,o);this.output().swrite(p,n,i,o),this.output("displacements").swrite(h)}}class xi extends ei{constructor(e=void 0){super(e,5,[tn().expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),nn().expects(Ut.Keypoints)]),this._threshold=20}get threshold(){return this._threshold}set threshold(e){this._threshold=Math.max(0,Math.min(0|e,255))}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._tex,r=this._capacity,A=this._threshold,a=Math.log2(this.scaleFactor),d=this.levels;if(1!=d&&!t.hasMipmaps())throw new c.Er(`Expected a pyramid in ${this.fullName}`);if(0==r){const t=this._encodeZeroKeypoints(e,s[4]),n=t.width;return void this.output().swrite(t,0,0,n)}e.programs.keypoints.fast9_16.outputs(i,o,s[0],s[1]),e.programs.keypoints.nonmaxSpace.outputs(i,o,s[2]);let l=s[1].clear(),g=Math.max(1,Math.min(d,h.PYRAMID_MAX_LEVELS/a|0));for(let n=a*(g-1);g-- >0;n-=a)l=e.programs.keypoints.fast9_16(l,t,n,A);l=e.programs.keypoints.nonmaxSpace(l),d>1&&(l=e.programs.keypoints.nonmaxScaleSimple.outputs(i,o,s[1])(l,t,a));let p=this._encodeKeypoints(e,l,s[3]);const u=p.width;d>1&&(p=e.programs.keypoints.refineScaleFAST916.outputs(u,u,s[4])(t,a,p,0,0,u,A)),this.output().swrite(p,0,0,u)}}const yi=Object.freeze({1:"harris1",3:"harris3",5:"harris5",7:"harris7"});class _i extends ei{constructor(e=void 0){super(e,6,[tn().expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),nn().expects(Ut.Keypoints)]),this._windowSize=new kt(3,3),this._quality=.1}get quality(){return this._quality}set quality(e){this._quality=Math.max(0,Math.min(+e,1))}get windowSize(){return this._windowSize}set windowSize(e){const t=e.width;if(t!=e.height||1!=t&&3!=t&&5!=t&&7!=t)throw new c.qw(`Invalid window: ${e}. Acceptable sizes: 1x1, 3x3, 5x5, 7x7`);this._windowSize=e}_run(e){const{image:n,format:i}=this.input().read(),o=n.width,s=n.height,r=this._capacity,A=this._quality,a=this._windowSize.width,d=this.levels,l=Math.log2(this.scaleFactor),g=d>1?this.scaleFactor:1,p=e.programs.keypoints[yi[a]],u=this._tex;if(1!=d&&!n.hasMipmaps())throw new c.Er(`Expected a pyramid in ${this.fullName}`);if(0==r){const t=this._encodeZeroKeypoints(e,u[5]),n=t.width;return void this.output().swrite(t,0,0,n)}p.outputs(o,s,u[0],u[1]),e.programs.utils.sobelDerivatives.outputs(o,s,u[2]),e.programs.keypoints.nonmaxSpace.outputs(o,s,u[3]);let I=u[1].clear(),f=Math.max(1,Math.min(d,h.PYRAMID_MAX_LEVELS/l|0));for(let i=l*(f-1);f-- >0;i-=l){const o=t.A.gaussianKernel(g*(1+i),a);I=p(I,n,e.programs.utils.sobelDerivatives(n,i),i,l,o),I=e.programs.keypoints.nonmaxSpace(I)}if(d>1){const t=e.programs.keypoints.laplacian.outputs(o,s,u[0])(I,n,l,0);I=e.programs.keypoints.nonmaxScale.outputs(o,s,u[2])(I,n,t,l)}e.programs.keypoints.harrisScoreFindMax.outputs(o,s,u[0],u[1]),f=Math.ceil(Math.log2(Math.max(o,s)));let m=I;for(let t=0;t1&&(C=e.programs.keypoints.refineScaleLoG.outputs(E,E,u[5])(n,l,C,0,0,E)),this.output().swrite(C,0,0,E)}}class Si extends An{constructor(e=void 0,t=0,n=void 0){super(e,t+1,n)}_allocateDescriptors(e,n,i,o,s,r){t.A.assert(n>=0&&i>=0),t.A.assert(o>=0&&o%4==0&&s===i);const A=r.width,a=Vn.encoderCapacity(n,i,A),d=Vn.encoderLength(a,o,s),c=this._tex[this._tex.length-1];return e.programs.keypoints.allocateDescriptors.outputs(d,d,c)(r,n,i,A,o,s,d)}}class Pi extends Si{constructor(e=void 0){super(e,3,[tn("image").expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),tn("keypoints").expects(Ut.Keypoints),nn().expects(Ut.Keypoints)])}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input("keypoints").read(),s=this.input("image").read().image,r=this._tex,A=this._tex[2],a=Vn.encoderCapacity(n,i,o),d=Math.max(1,Math.ceil(Math.sqrt(a))),c=e.programs.keypoints.orbOrientation.outputs(d,d,r[0])(s,t,n,i,o),l=e.programs.keypoints.transferOrientation.outputs(o,o,r[1])(c,t,n,i,o),g=this._allocateDescriptors(e,n,i,32,i,l),h=g.width,p=e.programs.keypoints.orbDescriptor.outputs(h,h,A)(s,g,i,h);this.output().swrite(p,32,i,h)}}const Bi=new kt(11,11),vi=Math.min(3,h.PYRAMID_MAX_LEVELS),Qi={3:"lk3",5:"lk5",7:"lk7",9:"lk9",11:"lk11",13:"lk13",15:"lk15",17:"lk17",19:"lk19",21:"lk21"};class wi extends An{constructor(e=void 0){super(e,3,[tn("previousImage").expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),tn("nextImage").expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),tn("previousKeypoints").expects(Ut.Keypoints),nn().expects(Ut.Keypoints),nn("flow").expects(Ut.Vector2)]),this._windowSize=Bi,this._levels=vi,this._discardThreshold=1e-4,this._numberOfIterations=30,this._epsilon=.01}get windowSize(){return this._windowSize}set windowSize(e){if(e.width!=e.height)throw new c.EM(`LK: window ${this._windowSize.toString()} is not square!`);if(!Object.prototype.hasOwnProperty.call(Qi,e.width)){const e=Object.keys(Qi).sort(((e,t)=>e-t)).map((e=>e+"x"+e)).join(", ");throw new c.EM(`LK: window of size ${this._windowSize.toString()} is not supported! Supported sizes: ${e}`)}this._windowSize=e}get levels(){return this._levels}set levels(e){t.A.assert(e>=1&&e<=h.PYRAMID_MAX_LEVELS),this._levels=0|e}get discardThreshold(){return this._discardThreshold}set discardThreshold(e){t.A.assert(e>=0),this._discardThreshold=+e}get numberOfIterations(){return this._numberOfIterations}set numberOfIterations(e){t.A.assert(e>=1),this._numberOfIterations=0|e}get epsilon(){return this._epsilon}set epsilon(e){t.A.assert(e>=0),this._epsilon=+e}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input("previousKeypoints").read(),s=this.input("previousImage").read().image,r=this.input("nextImage").read().image,A=t,a=this._levels,d=this._windowSize.width,l=this._numberOfIterations,g=this._discardThreshold,h=this._epsilon,p=e.programs.keypoints,u=this._tex;if(!(1==a||s.hasMipmaps()&&r.hasMipmaps()))throw new c.Er("LK: a pyramid is required if levels > 1");if(s.width!==r.width||s.height!==r.height)throw new c.Er("LK: can't use input images of different size");const I=p[Qi[d]],f=Vn.encoderCapacity(n,i,o),m=Math.max(1,Math.ceil(Math.sqrt(f)));I.outputs(m,m,u[0],u[1]);let C=I.clear();for(let e=a-1;e>=0;e--)C=I(C,A,r,s,e,a,l,g,h,n,i,o);p.transferFlow.outputs(o,o,u[2]);const E=p.transferFlow(C,A,n,i,o);this.output().swrite(E,n,i,o),this.output("flow").swrite(C)}}class bi extends an{constructor(e=void 0){super(e,2,[nn().expects(Ut.LSHTables)]),this._keypoints=[],this._keypointsCopy=[],this._numberOfTables=8,this._hashSize=15,this._lsh=null}get keypoints(){return this._keypoints}set keypoints(e){if(!Array.isArray(e)||e.find((e=>!(e instanceof ln))))throw new c.qw("Static LSH tables: an invalid set of keypoints has been provided");this._keypoints!==e&&(this._keypoints=e,this._keypointsCopy=e.slice(0),this._lsh=null)}get numberOfTables(){return this._numberOfTables}set numberOfTables(e){if(!Z.includes(e))throw new c.qw(`Invalid number of tables: ${e}. Acceptable values: ${Z.join(", ")}`);e!==this._numberOfTables&&(this._numberOfTables=0|e,this._lsh=null)}get hashSize(){return this._hashSize}set hashSize(e){if(!j.includes(e))throw new c.qw(`Invalid hash size: ${e}. Acceptable values: ${j.join(", ")}`);e!==this._hashSize&&(this._hashSize=0|e,this._lsh=null)}_run(e){null==this._lsh&&(this._lsh=this._train()),this.output().swrite(this._lsh)}_train(){const e=this._keypointsCopy,t=this._numberOfTables,n=this._hashSize;if(e.find((e=>null==e.descriptor)))throw new c.Er("Static LSH tables: can't train the model with no keypoint descriptors!");const i=e.map((e=>e.descriptor.data)),o=this._tex[0],s=this._tex[1];return new oe(o,s,i,t,n)}}const Di={fastest:0,default:1,demanding:2},Mi=$.reduce(((e,t)=>(e[t]=(e=>{return t=t=>{return n=n=>`lshKnn${e}h${t}lv${n}`,[0,1,2].reduce(((e,t)=>(e[t]=n(t),e)),{});var n},j.reduce(((e,n)=>(e[n]=t(n),e)),{});var t})(t),e)),{});class Ki extends An{constructor(e=void 0){super(e,6,[tn("keypoints").expects(Ut.Keypoints).satisfying((e=>e.descriptorSize>0)),tn("lsh").expects(Ut.LSHTables),nn().expects(Ut.KeypointMatches)]),this._k=1,this._quality="default"}get k(){return this._k}set k(e){this._k=Math.max(1,0|e)}get quality(){return this._quality}set quality(e){if(!Object.prototype.hasOwnProperty.call(Di,e))throw new c.qw(`Invalid quality level: "${e}"`);this._quality=e}_run(e){const{encodedKeypoints:n,descriptorSize:i,extraSize:o,encoderLength:s}=this.input("keypoints").read(),r=this.input("lsh").read().lsh,A=e.programs.keypoints,a=r.tables,d=r.descriptorDB,l=a.width,g=d.width,h=r.tableCount,p=r.hashSize,u=r.bucketCapacity,I=r.bucketsPerTable,f=r.sequences,m=this._tex[0],C=this._tex[1],E=this._tex[2],x=this._tex[3],y=this._tex[4],_=this._tex[5],S=Di[this._quality],P=this._k;if(i!==r.descriptorSize)throw new c.qw(`Can't match different types of descriptors in ${this.fullName}`);t.A.assert(null!=Mi[i]),t.A.assert(null!=Mi[i][p]),t.A.assert(null!=Mi[i][p][S]);const B=Vn.encoderCapacity(i,o,s),v=Math.max(1,Math.ceil(Math.sqrt(B*P)));let Q=_;A.lshKnnTransfer.outputs(v,v,y,_);const w=Math.max(1,Math.ceil(Math.sqrt(B)));A.lshKnnInitCandidates.outputs(w,w,m),A.lshKnnInitFilters.outputs(w,w,x);const b=A[Mi[i][p][S]];b.outputs(w,w,C,E),b.setUBO("LSHSequences",f),Q.clear(),A.lshKnnInitFilters();for(let t=0;te.descriptorSize>0)),tn("database").expects(Ut.Keypoints).satisfying((e=>e.descriptorSize>0)),nn().expects(Ut.KeypointMatches)]),this._matchesPerKeypoint=1}get k(){return this._matchesPerKeypoint}set k(e){this._matchesPerKeypoint=Math.max(1,0|e)}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input("keypoints").read(),s=this.input("database").read(),r=this._tex[0],A=this._tex[1],a=this._tex[2],d=this._tex[3],l=this._tex[4],g=this._tex[5],h=this._matchesPerKeypoint,p=e.programs.keypoints;if(n!==s.descriptorSize)throw new c.qw(`Incompatible descriptors in ${this.fullName}`);if(!Object.prototype.hasOwnProperty.call(Li,n))throw new c.EM(`Unsupported descriptor size (${n}) in ${this.fullName}`);const u=p[Li[n]],I=Vn.encoderCapacity(n,i,o),f=Vn.encoderCapacity(s.descriptorSize,s.extraSize,s.encoderLength),m=u.definedConstant("NUMBER_OF_KEYPOINTS_PER_PASS"),C=Math.ceil(f/m),E=Math.max(1,Math.ceil(Math.sqrt(I))),x=Math.max(1,Math.ceil(Math.sqrt(I*h)));p.bfMatcherTransfer.outputs(x,x,l,g),p.bfMatcherInitCandidates.outputs(E,E,a),p.bfMatcherInitFilters.outputs(E,E,d),u.outputs(E,E,r,A);let y=g.clear(),_=p.bfMatcherInitFilters();for(let r=0;r1&&A.copyTo(_),y=p.bfMatcherTransfer(y,A,h,r)}this.output().swrite(y,h)}}class Ri extends An{constructor(e=void 0){super(e,1,[tn("in").expects(Ut.Keypoints),tn("reference").expects(Ut.Keypoints),nn().expects(Ut.Keypoints)]),this._threshold=h.MAX_TEXTURE_LENGTH+1}get threshold(){return this._threshold}set threshold(e){this._threshold=Math.max(0,+e)}_run(e){const t=this.input("in").read(),n=this.input("reference").read(),i=this._threshold;if(t.descriptorSize!=n.descriptorSize||t.extraSize!=n.extraSize)throw new c.Er("The distance filter requires two compatible shapes of keypoint streams");const o=this._tex[0],s=Math.max(t.encoderLength,n.encoderLength),r=t.descriptorSize,A=t.extraSize;e.programs.keypoints.distanceFilter.outputs(s,s,o)(t.encodedKeypoints,t.encoderLength,n.encodedKeypoints,n.encoderLength,r,A,s,i),this.output().swrite(o,r,A,s)}}const zi={32:"hammingDistanceFilter32",64:"hammingDistanceFilter64"};class Ni extends An{constructor(e=void 0){super(e,1,[tn("in").expects(Ut.Keypoints).satisfying((e=>e.descriptorSize>0)),tn("reference").expects(Ut.Keypoints).satisfying((e=>e.descriptorSize>0)),nn().expects(Ut.Keypoints)]),this._threshold=8*h.MAX_DESCRIPTOR_SIZE}get threshold(){return this._threshold}set threshold(e){this._threshold=Math.max(0,0|e)}_run(e){const t=this.input("in").read(),n=this.input("reference").read(),i=this._threshold;if(t.descriptorSize!=n.descriptorSize||t.extraSize!=n.extraSize)throw new c.Er("The Hamming distance filter requires two compatible shapes of keypoint streams");if(!Object.prototype.hasOwnProperty.call(zi,t.descriptorSize))throw new c.EM(`Hamming distance filter - invalid descriptor size: ${t.descriptorSize}`);const o=this._tex[0],s=Math.max(t.encoderLength,n.encoderLength),r=t.descriptorSize,A=t.extraSize,a=zi[t.descriptorSize];e.programs.keypoints[a].outputs(s,s,o)(t.encodedKeypoints,t.encoderLength,n.encodedKeypoints,n.encoderLength,r,A,s,i),this.output().swrite(o,r,A,s)}}class Xi extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Keypoints)]),this._descriptorSize=0,this._extraSize=0,this._encoderLength=0,this._initialized=!1}get encodedKeypoints(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._tex[0]}get descriptorSize(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._descriptorSize}get extraSize(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._extraSize}get encoderLength(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._encoderLength}init(e){super.init(e);const t=Vn.encoderLength(0,0,0);this._tex[0].resize(t,t).clearToColor(1,1,1,1),this._descriptorSize=this._extraSize=0,this._encoderLength=t,this._initialized=!0}release(e){this._initialized=!1,super.release(e)}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input().read(),s=this._tex[0];s.resize(t.width,t.height),t.copyTo(s),this._descriptorSize=n,this._extraSize=i,this._encoderLength=o}}class Ti extends an{constructor(e=void 0){super(e,0,[nn().expects(Ut.Keypoints)]),this._source=null}get source(){return this._source}set source(e){if(null!==e&&!(e instanceof Xi))throw new c.qw(`Incompatible source for ${this.fullName}`);this._source=e}_run(e){if(null==this._source)throw new c.Er(`${this.fullName} has no source`);this.output().swrite(this._source.encodedKeypoints,this._source.descriptorSize,this._source.extraSize,this._source.encoderLength)}}class Fi extends Y.Q{static FAST(e=void 0){return new xi(e)}static Harris(e=void 0){return new _i(e)}}class Oi extends Y.Q{static ORB(e=void 0){return new Pi(e)}}class Ui extends Y.Q{static LK(e=void 0){return new wi(e)}}class Gi extends Y.Q{static StaticLSHTables(e=void 0){return new bi(e)}static LSHKNN(e=void 0){return new Ki(e)}static BFKNN(e=void 0){return new ki(e)}}class qi extends Y.Q{static Source(e=void 0){return new Ti(e)}static Sink(e=void 0){return new Xi(e)}}class Hi extends Y.Q{static get Detector(){return Fi}static get Descriptor(){return Oi}static get Tracker(){return Ui}static get Matcher(){return Gi}static get Portal(){return qi}static Source(e=void 0){return new ii(e)}static Sink(e=void 0){return new Ai(e)}static SinkOfTrackedKeypoints(e=void 0){return new ai(e)}static SinkOfMatchedKeypoints(e=void 0){return new di(e)}static Clipper(e=void 0){return new li(e)}static BorderClipper(e=void 0){return new gi(e)}static Buffer(e=void 0){return new hi(e)}static Mixer(e=void 0){return new pi(e)}static Shuffler(e=void 0){return new ui(e)}static Multiplexer(e=void 0){return new fi(e)}static Transformer(e=void 0){return new mi(e)}static SubpixelRefiner(e=void 0){return new Ei(e)}static DistanceFilter(e=void 0){return new Ri(e)}static HammingDistanceFilter(e=void 0){return new Ni(e)}}const Ji=e=>e>1?1<{this._vectors=Yi._decode(e,o,s)}))}static _decode(e,n,i){const o=[];let s=0,r=0,A=0,a=0;const d=n*i*4,c=Math.min(e.length,d);for(let n=0;n=this._updateInterval&&(this._fps=Math.round(this._frames/(.001*t)),this._frames=0,this._lastUpdate=e),this._frames++,requestAnimationFrame(this._boundUpdate)}}const ji=new class extends Function{constructor(){return super("...args","return args.length > 1 ? this._create(...args) : this._from(args[0])"),this.bind(this)}_create(e,t=e,n=[]){return Ot.SpeedyMatrix.Create(e,t,n)}_from(e){return Ot.SpeedyMatrix.From(e)}Zeros(e,t=e){return Ot.SpeedyMatrix.Zeros(e,t)}Ones(e,t=e){return Ot.SpeedyMatrix.Ones(e,t)}Eye(e,t=e){return Ot.SpeedyMatrix.Eye(e,t)}ready(){return Ot.SpeedyMatrix.ready()}qr(e,t,n,{mode:i="reduced"}={}){const o=n,s=n.rows,r=n.columns;if("reduced"==i){if(e.rows!=s||e.columns!=r||t.rows!=r||t.columns!=r)throw new c.qw("Invalid shape for reduced QR")}else{if("full"!=i)throw new c.qw(`Invalid mode for QR: "${i}"`);if(e.rows!=s||e.columns!=s||t.rows!=s||t.columns!=r)throw new c.qw("Invalid shape for full QR")}return Ft.U.ready().then((({wasm:n,memory:s})=>{const r=Ft.U.allocateMat32(n,s,e),A=Ft.U.allocateMat32(n,s,t),a=Ft.U.allocateMat32(n,s,o);return Ft.U.copyToMat32(n,s,a,o),"reduced"==i?n.exports.Mat32_qr_reduced(r,A,a):n.exports.Mat32_qr_full(r,A,a),Ft.U.copyFromMat32(n,s,r,e),Ft.U.copyFromMat32(n,s,A,t),Ft.U.deallocateMat32(n,s,a),Ft.U.deallocateMat32(n,s,A),Ft.U.deallocateMat32(n,s,r),[e,t]}))}ols(e,t,n,{method:i="qr"}={}){const o=t.rows,s=t.columns,r=e;if(o{const A=Ft.U.allocateMat32(o,s,t),a=Ft.U.allocateMat32(o,s,n),d=Ft.U.allocateMat32(o,s,r);if(Ft.U.copyToMat32(o,s,A,t),Ft.U.copyToMat32(o,s,a,n),"qr"!==i)throw new c.qw(`Invalid method: "${i}"`);return o.exports.Mat32_qr_ols(d,A,a,2),Ft.U.copyFromMat32(o,s,d,r),Ft.U.deallocateMat32(o,s,d),Ft.U.deallocateMat32(o,s,a),Ft.U.deallocateMat32(o,s,A),e}))}solve(e,t,n,{method:i="qr"}={}){const o=t.rows,s=t.columns,r=e;if(o!=s)throw new c.qw("Can't solve an over or underdetermined system of equations");if(n.rows!=o||1!=n.columns||r.rows!=o||1!=r.columns)throw new c.qw("Invalid shapes");return Ft.U.ready().then((({wasm:e,memory:o})=>{if("qr"===i)return this.ols(r,t,n,{method:i});throw new c.qw(`Invalid method: "${i}"`)}))}perspective(e,t,n){if(2!=t.rows||4!=t.columns||2!=n.rows||4!=n.columns)throw new c.qw("You need two 2x4 input matrices to compute a perspective transformation");if(3!=e.rows||3!=e.columns)throw new c.qw("The output of perspective() is a 3x3 homography");return Ft.U.ready().then((({wasm:i,memory:o})=>{const s=Ft.U.allocateMat32(i,o,e),r=Ft.U.allocateMat32(i,o,t),A=Ft.U.allocateMat32(i,o,n);return Ft.U.copyToMat32(i,o,r,t),Ft.U.copyToMat32(i,o,A,n),i.exports.Mat32_homography_ndlt4(s,r,A),Ft.U.copyFromMat32(i,o,s,e),Ft.U.deallocateMat32(i,o,A),Ft.U.deallocateMat32(i,o,r),Ft.U.deallocateMat32(i,o,s),e}))}findHomography(e,n,i,{method:o="default",mask:s=null,reprojectionError:r=3,numberOfHypotheses:A=512,bundleSize:a=128}={}){if(2!=n.rows||n.columns<4||2!=i.rows||i.columns!=n.columns)throw new c.qw("You need two 2 x n (n >= 4) input matrices to compute a homography");if(3!=e.rows||3!=e.columns)throw new c.qw("The output of findHomography() is a 3x3 homography");if(null!=s&&(1!=s.rows||s.columns!=n.columns))throw new c.qw("Invalid shape of the inliers mask");return Ft.U.ready().then((({wasm:d,memory:l})=>{const g=Ft.U.allocateMat32(d,l,e),h=Ft.U.allocateMat32(d,l,n),p=Ft.U.allocateMat32(d,l,i),u=null!=s?Ft.U.allocateMat32(d,l,s):0;switch(Ft.U.copyToMat32(d,l,h,n),Ft.U.copyToMat32(d,l,p,i),o){case"pransac":t.A.assert(r>=0&&A>0&&a>0),d.exports.Mat32_pransac_homography(g,u,h,p,A,a,r);break;case"default":case"dlt":d.exports.Mat32_homography_ndlt(g,h,p);break;default:throw new c.qw(`Illegal method for findHomography(): "${o}"`)}return Ft.U.copyFromMat32(d,l,g,e),null!=s&&Ft.U.copyFromMat32(d,l,u,s),null!=s&&Ft.U.deallocateMat32(d,l,u),Ft.U.deallocateMat32(d,l,p),Ft.U.deallocateMat32(d,l,h),Ft.U.deallocateMat32(d,l,g),e}))}applyPerspectiveTransform(e,t,n){if(2!=t.rows||2!=e.rows||t.columns!=e.columns)throw new c.qw("Invalid shapes");if(3!=n.rows||3!=n.columns)throw new c.qw("The perspective transformation must be a 3x3 matrix");return Ft.U.ready().then((({wasm:i,memory:o})=>{const s=Ft.U.allocateMat32(i,o,n),r=Ft.U.allocateMat32(i,o,t),A=Ft.U.allocateMat32(i,o,e);return Ft.U.copyToMat32(i,o,r,t),Ft.U.copyToMat32(i,o,s,n),i.exports.Mat32_transform_perspective(A,r,s),Ft.U.copyFromMat32(i,o,A,e),Ft.U.deallocateMat32(i,o,A),Ft.U.deallocateMat32(i,o,r),Ft.U.deallocateMat32(i,o,s),e}))}affine(e,t,n){if(2!=t.rows||3!=t.columns||2!=n.rows||3!=n.columns)throw new c.qw("You need two 2x3 input matrices to compute an affine transform");if(2!=e.rows||3!=e.columns)throw new c.qw("The output of affine() is a 2x3 matrix");return Ft.U.ready().then((({wasm:i,memory:o})=>{const s=Ft.U.allocateMat32(i,o,e),r=Ft.U.allocateMat32(i,o,t),A=Ft.U.allocateMat32(i,o,n);return Ft.U.copyToMat32(i,o,r,t),Ft.U.copyToMat32(i,o,A,n),i.exports.Mat32_affine_direct3(s,r,A),Ft.U.copyFromMat32(i,o,s,e),Ft.U.deallocateMat32(i,o,A),Ft.U.deallocateMat32(i,o,r),Ft.U.deallocateMat32(i,o,s),e}))}findAffineTransform(e,n,i,{method:o="default",mask:s=null,reprojectionError:r=3,numberOfHypotheses:A=512,bundleSize:a=128}={}){if(2!=n.rows||n.columns<3||2!=i.rows||i.columns!=n.columns)throw new c.qw("You need two 2 x n (n >= 3) input matrices to compute an affine transform");if(2!=e.rows||3!=e.columns)throw new c.qw("The output of findAffineTransform() is a 2x3 matrix");if(null!=s&&(1!=s.rows||s.columns!=n.columns))throw new c.qw("Invalid shape of the inliers mask");return Ft.U.ready().then((({wasm:d,memory:l})=>{const g=Ft.U.allocateMat32(d,l,e),h=Ft.U.allocateMat32(d,l,n),p=Ft.U.allocateMat32(d,l,i),u=null!=s?Ft.U.allocateMat32(d,l,s):0;switch(Ft.U.copyToMat32(d,l,h,n),Ft.U.copyToMat32(d,l,p,i),o){case"pransac":t.A.assert(r>=0&&A>0&&a>0),d.exports.Mat32_pransac_affine(g,u,h,p,A,a,r);break;case"default":d.exports.Mat32_affine_direct(g,h,p);break;default:throw new c.qw(`Illegal method for findAffineTransform(): "${o}"`)}return Ft.U.copyFromMat32(d,l,g,e),null!=s&&Ft.U.copyFromMat32(d,l,u,s),null!=s&&Ft.U.deallocateMat32(d,l,u),Ft.U.deallocateMat32(d,l,p),Ft.U.deallocateMat32(d,l,h),Ft.U.deallocateMat32(d,l,g),e}))}applyAffineTransform(e,t,n){if(2!=t.rows||2!=e.rows||t.columns!=e.columns)throw new c.qw("Invalid shapes");if(2!=n.rows||3!=n.columns)throw new c.qw("The affine transformation must be a 2x3 matrix");return Ft.U.ready().then((({wasm:i,memory:o})=>{const s=Ft.U.allocateMat32(i,o,n),r=Ft.U.allocateMat32(i,o,t),A=Ft.U.allocateMat32(i,o,e);return Ft.U.copyToMat32(i,o,r,t),Ft.U.copyToMat32(i,o,s,n),i.exports.Mat32_transform_affine(A,r,s),Ft.U.copyFromMat32(i,o,A,e),Ft.U.deallocateMat32(i,o,A),Ft.U.deallocateMat32(i,o,r),Ft.U.deallocateMat32(i,o,s),e}))}},$i=new class extends Function{constructor(){return super("...args","return this._create(...args)"),this.bind(this)}_create(e,t){return new Xt(e,t)}Sink(e=void 0){return new Yi(e)}};class Vi{static get version(){return"0.9.1"}static isSupported(){return"undefined"!=typeof WebAssembly&&"undefined"!=typeof WebGL2RenderingContext&&null!=e.c.instance.gl}static get Settings(){return o.w}static get Vector2(){return $i}static Point2(e,t){return new Tt(e,t)}static Size(e,t){return new kt(e,t)}static get Matrix(){return ji}static get Promise(){return s.i}static Pipeline(){return new In}static get Image(){return wn}static get Filter(){return Hn}static get Transform(){return Zn}static get Keypoint(){return Hi}static load(e,t={}){return zt.load(e,t)}static camera(e=640,n=360){const i="object"==typeof e?e:{audio:!1,video:{width:0|e,height:0|n}};return t.A.requestCameraStream(i).then((e=>zt.load(e)))}static get Platform(){return Nt}static get fps(){return Zi.instance.fps}}Object.freeze(Vi),t.A.log(`Speedy Vision version ${Vi.version}. GPU-accelerated Computer Vision for JavaScript by Alexandre Martins. https://github.com/alemart/speedy-vision`),h.LITTLE_ENDIAN||t.A.warning("Running on a big-endian machine")})(),i=i.default})())); \ No newline at end of file +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Speedy=t():e.Speedy=t()}(self,(()=>(()=>{var e={2199:(e,t,n)=>{"use strict";n.d(t,{w:()=>d});var i=n(6634),o=n(1001),s=n(9037),r=n(8581);let A="raf",a="default";class d extends i.Q{static get powerPreference(){return o.c.powerPreference}static set powerPreference(e){o.c.powerPreference=e}static get gpuPollingMode(){return A}static set gpuPollingMode(e){if("raf"!==e&&"asap"!==e)throw new r.qw(`Invalid GPU polling mode: "${e}"`);A=e}static get logging(){return a}static set logging(e){if("default"!==e&&"none"!==e&&"diagnostic"!==e)throw new r.qw(`Invalid logging mode: "${e}"`);"diagnostic"===e&&s.A.log("%c DIAGNOSTIC MODE ","background:red;color:white;font-size:36pt;font-weight:bold"),a=e}}},6306:(e,t,n)=>{"use strict";n.d(t,{r:()=>A});var i=n(6465),o=n(9037),s=n(8581);const r=Object.freeze({float32:Float32Array});class A{constructor(e,t,n){o.A.assert(e>0&&t>0),o.A.assert(n===A.DEFAULT_DTYPE),this._rows=0|e,this._columns=0|t,this._dtype=n}get rows(){return this._rows}get columns(){return this._columns}get dtype(){return this._dtype}static get DEFAULT_DTYPE(){return"float32"}static get BUFFER_TYPE(){return r}plus(e){return new u(this,e)}minus(e){return new I(this,e)}times(e){return"number"==typeof e?new p(this,e):new f(this,e)}transpose(){return new g(this)}inverse(){return new h(this)}compMult(e){return new m(this,e)}ldiv(e){return new C(this,e)}toString(){return`SpeedyMatrixExpr(rows=${this.rows}, columns=${this.columns})`}_evaluate(e,t){throw new s.aQ}}const{SpeedyMatrix:a}=n(4188);class d extends A{constructor(e,t,n){super(e,t,n),this._tempMatrix=a.Zeros(this.rows,this.columns,this.dtype)}}class c extends d{constructor(e,t,n){super(e,t,n.dtype),this._operand=n}_evaluate(e,t){const n=this._operand._evaluate(e,t),o=this._tempMatrix,s=i.U.allocateMat32(e,t,o),r=i.U.allocateMat32(e,t,n);return i.U.copyToMat32(e,t,r,n),this._compute(e,t,s,r),i.U.copyFromMat32(e,t,s,o),i.U.deallocateMat32(e,t,r),i.U.deallocateMat32(e,t,s),o}_compute(e,t,n,i){throw new s.aQ}}class l extends d{constructor(e,t,n,i){o.A.assert(n.dtype===i.dtype),super(e,t,n.dtype),this._left=n,this._right=i}_evaluate(e,t){const n=this._left._evaluate(e,t),o=this._right._evaluate(e,t),s=this._tempMatrix,r=i.U.allocateMat32(e,t,s),A=i.U.allocateMat32(e,t,n),a=i.U.allocateMat32(e,t,o);return i.U.copyToMat32(e,t,A,n),i.U.copyToMat32(e,t,a,o),this._compute(e,t,r,A,a),i.U.copyFromMat32(e,t,r,s),i.U.deallocateMat32(e,t,a),i.U.deallocateMat32(e,t,A),i.U.deallocateMat32(e,t,r),s}_compute(e,t,n,i,o){throw new s.aQ}}class g extends c{constructor(e){super(e.columns,e.rows,e)}_compute(e,t,n,i){e.exports.Mat32_transpose(n,i)}}class h extends c{constructor(e){o.A.assert(e.rows===e.columns),super(e.rows,e.columns,e),this._size=e.rows}_compute(e,t,n,i){switch(this._size){case 0:break;case 1:e.exports.Mat32_inverse1(n,i);break;case 2:e.exports.Mat32_inverse2(n,i);break;case 3:e.exports.Mat32_inverse3(n,i);break;default:e.exports.Mat32_qr_inverse(n,i)}}}class p extends c{constructor(e,t){super(e.rows,e.columns,e),this._scalar=+t}_compute(e,t,n,i){e.exports.Mat32_scale(n,i,this._scalar)}}class u extends l{constructor(e,t){o.A.assert(e.rows===t.rows&&e.columns===t.columns),super(e.rows,e.columns,e,t)}_compute(e,t,n,i,o){e.exports.Mat32_add(n,i,o)}}class I extends l{constructor(e,t){o.A.assert(e.rows===t.rows&&e.columns===t.columns),super(e.rows,e.columns,e,t)}_compute(e,t,n,i,o){e.exports.Mat32_subtract(n,i,o)}}class f extends l{constructor(e,t){o.A.assert(e.columns===t.rows),super(e.rows,t.columns,e,t)}_compute(e,t,n,i,o){e.exports.Mat32_multiply(n,i,o)}}class m extends l{constructor(e,t){o.A.assert(e.rows===t.rows&&e.columns===t.columns),super(t.rows,t.columns,e,t)}_compute(e,t,n,i,o){e.exports.Mat32_compmult(n,i,o)}}class C extends l{constructor(e,t){const n=e.rows,i=e.columns;o.A.assert(n>=i&&t.rows===n&&1===t.columns),super(i,1,e,t)}_compute(e,t,n,i,o){e.exports.Mat32_qr_ols(n,i,o,2)}}},6465:(e,t,n)=>{"use strict";n.d(t,{U:()=>h});var i=n(9192),o=n(8581),s=n(9037),r=n(3816);const A=n(3575);let a=null,d=null;const c={as:{object:l="undefined"==typeof WebAssembly?new Uint8Array(1024):new WebAssembly.Memory({initial:16,maximum:256}),uint8:new Uint8Array(l.buffer),int32:new Int32Array(l.buffer),uint32:new Uint32Array(l.buffer),float32:new Float32Array(l.buffer),float64:new Float64Array(l.buffer)}};var l,g;class h{static ready(){return"undefined"==typeof WebAssembly?i.i.reject(new o.EM("This application requires WebAssembly. Please update your system.")):r.LITTLE_ENDIAN?new i.i(((e,t)=>{h._ready(e,t)})):i.i.reject(new o.EM("Can't run WebAssembly code: not in a little-endian machine!"))}static get handle(){if(!a||!d)throw new o.NO("Can't get WASM handle: routines not yet loaded");return{wasm:a,memory:c,module:d}}static imports(e){const t=new p(e);return Object.getOwnPropertyNames(p.prototype).filter((e=>"function"==typeof t[e]&&"constructor"!==e)).reduce(((e,n)=>(e[n]=t[n],e)),Object.create(null))}static allocateMat32(e,t,n){const i=e.exports.malloc(n.data.byteLength);return e.exports.Mat32_create(n.rows,n.columns,n.step0,n.step1,n._data.length,i)}static deallocateMat32(e,t,n){const i=e.exports.Mat32_data(n);return e.exports.free(n),e.exports.free(i),0}static copyToMat32(e,t,n,i){s.A.assert(i.data.byteLength===e.exports.Mat32_dataSize(n));const o=e.exports.Mat32_data(n);return t.as.float32.set(i.data,o/Float32Array.BYTES_PER_ELEMENT),n}static copyFromMat32(e,t,n,i){s.A.assert(i.data.byteLength===e.exports.Mat32_dataSize(n));const o=e.exports.Mat32_data(n)/Float32Array.BYTES_PER_ELEMENT;for(let e=i.data.length-1;e>=0;e--)i.data[e]=t.as.float32[o+e];return n}static _ready(e,t,n=1e3){null!==a&&null!==d?e({wasm:a,memory:c,module:d}):n<=0?t(new o.MU("Can't load WASM routines")):setTimeout(h._ready,0,e,t,n-1)}}class p{constructor(e){return Object.getOwnPropertyNames(this.constructor.prototype).filter((e=>"function"==typeof this[e])).filter((e=>"constructor"!==e)).forEach((e=>{this[e]=this[e].bind(this)})),this.memory=e,this.cstring=new u(e),Object.freeze(this)}print(e){s.A.log(this.cstring.get(e))}fatal(e){throw new o.NO(this.cstring.get(e))}bytefill(e,t,n){this.memory.as.uint8.fill(e,t,n)}copyWithin(e,t,n){this.memory.as.uint8.copyWithin(e,t,n)}}class u{constructor(e){this._decoder=new TextDecoder("utf-8"),this._memory=e}get(e){const t=this._memory.as.uint8,n=this._memory.as.uint8.byteLength;let i=e;for(;i(e=>Uint8Array.from(atob(e),(e=>e.charCodeAt(0))))(e))).then((e=>WebAssembly.instantiate(e,{env:Object.assign({memory:g.as.object},h.imports(g))}))).then((e=>{a=e.instance,d=e.module,e.instance.exports.srand(.001*Date.now()&4294967295),s.A.log("The WebAssembly routines have been loaded!")})).catch((e=>{throw new o.NO(`Can't load the WebAssembly routines: ${e}`,e)}))},4188:(e,t,n)=>{"use strict";n.r(t),n.d(t,{SpeedyMatrix:()=>A});var i=n(6306),o=n(6465),s=n(9192),r=n(9037);class A extends i.r{constructor(e,t,n,o,s){super(e,t,i.r.DEFAULT_DTYPE),r.A.assert(s.constructor===i.r.BUFFER_TYPE[this.dtype]),r.A.assert(n>0&&o>=n),r.A.assert(s.length+e*t===0||s.length===1+n*(e-1)+o*(t-1)),this._step0=0|n,this._step1=0|o,this._data=s}static Create(e,t,n,o=i.r.DEFAULT_DTYPE){return r.A.assert(e*t>0,"Can't create a matrix without a shape"),r.A.assert(e*t===n.length,`Can't create matrix: expected ${e*t} entries, but found ${n.length}`),r.A.assert(Object.prototype.hasOwnProperty.call(i.r.BUFFER_TYPE,o),`Invalid dtype: "${o}"`),new A(e,t,1,e,Reflect.construct(i.r.BUFFER_TYPE[o],[n]))}static Zeros(e,t=e,n=i.r.DEFAULT_DTYPE){return r.A.assert(e*t>0,"Can't create a matrix without a shape"),r.A.assert(Object.prototype.hasOwnProperty.call(i.r.BUFFER_TYPE,n),`Invalid dtype: "${n}"`),new A(e,t,1,e,Reflect.construct(i.r.BUFFER_TYPE[n],[e*t]))}static Ones(e,t=e,n=i.r.DEFAULT_DTYPE){return r.A.assert(e*t>0,"Can't create a matrix without a shape"),r.A.assert(Object.prototype.hasOwnProperty.call(i.r.BUFFER_TYPE,n),`Invalid dtype: "${n}"`),new A(e,t,1,e,Reflect.construct(i.r.BUFFER_TYPE[n],[e*t]).fill(1))}static Eye(e,t=e,n=i.r.DEFAULT_DTYPE){r.A.assert(e*t>0,"Can't create a matrix without a shape"),r.A.assert(Object.prototype.hasOwnProperty.call(i.r.BUFFER_TYPE,n),`Invalid dtype: "${n}"`);const o=Reflect.construct(i.r.BUFFER_TYPE[n],[e*t]);for(let n=Math.min(e,t)-1;n>=0;n--)o[n*e+n]=1;return new A(e,t,1,e,o)}static From(e){return A.Zeros(e.rows,e.columns,e.dtype).setToSync(e)}static ready(){return o.U.ready().then((e=>{}))}get data(){return this._data}get step0(){return this._step0}get step1(){return this._step1}block(e,t,n,i){r.A.assert(e<=t&&n<=i,`Invalid indices: [${e}:${t},${n}:${i}]`),e=Math.max(e,0),t=Math.min(t,this._rows-1),n=Math.max(n,0);const o=t-e+1,s=(i=Math.min(i,this._columns-1))-n+1,a=this._step0,d=this._step1,c=e*a+n*d,l=1+t*a+i*d;return new A(o,s,a,d,this._data.subarray(c,l))}row(e){return this.block(e,e,0,this._columns-1)}column(e){return this.block(0,this._rows-1,e,e)}diagonal(){const e=Math.min(this._rows,this._columns),t=e,n=this._step0+this._step1,i=1+(e-1)*n;return new A(t,1,n,n,this._data.subarray(0,i))}at(e,t){return e>=0&&e=0&&te.toFixed(5);return`SpeedyMatrix(rows=${e}, columns=${t}, data=[\n${i.map((e=>" "+e.map(o).join(", "))).join(",\n")}\n])`}setTo(e){return o.U.ready().then((t=>this.setToSync(e)))}setToSync(e){const{wasm:t,memory:n}=o.U.handle,i=e._evaluate(t,n);r.A.assert(this._rows===i._rows&&this._columns===i._columns&&this.dtype===i.dtype,`Can't set the values of a ${this.rows} x ${this.columns} ${this.dtype} matrix to those of a ${i.rows} x ${i.columns} ${i.dtype} matrix`);const s=this._step0,A=this._step1,a=i._step0,d=i._step1;if(s===a&&A===d&&this._data.length===i._data.length)this._data.set(i._data);else for(let e=this._columns-1;e>=0;e--)for(let t=this._rows-1;t>=0;t--)this._data[t*s+e*A]=i._data[t*a+e*d];return this}fill(e){return this.fillSync(e),s.i.resolve(this)}fillSync(e){if(e=+e,this._rows*this._columns===this._data.length)return this._data.fill(e),this;for(let t=0;t{"use strict";n.d(t,{Q:()=>o});var i=n(8581);class o{constructor(){throw new i.aQ("Namespaces can't be instantiated")}}},9192:(e,t,n)=>{"use strict";n.d(t,{i:()=>o});const i="undefined"!=typeof queueMicrotask&&queueMicrotask||"undefined"!=typeof process&&process.nextTick||(e=>Promise.resolve().then((()=>e())));class o{constructor(e){this._state=0,this._value=void 0,this._onFulfillment=null,this._onRejection=null,this._children=0,this[0]=this,this._parent=void 0,this._flags=0,this._fulfill=this._fulfill.bind(this),this._reject=this._reject.bind(this),this._resolve=this._resolve.bind(this),this._broadcastIfAsync=this._broadcastIfAsync.bind(this),e(this._fulfill,this._reject)}then(e,t=null){const n=new o(this._nop);return n._onFulfillment="function"==typeof e&&e,n._onRejection="function"==typeof t&&t,n._parent=this,this[this._children++]=n,this._flags&=-2,this._notify(),n}catch(e){return this.then(null,e)}finally(e){const t=t=>(e(),t);return this.then(t,t)}turbocharge(){let e=this;for(this._flags|=1;void 0!==e._parent;)e=e._parent,e._flags|=1;return e._notify(),this}toString(){switch(this._state){case 0:return"SpeedyPromise { }";case 1:return`SpeedyPromise { ${this._value} }`;case 2:return`SpeedyPromise { ${this._value} }`;default:return""}}get[Symbol.toStringTag](){return"SpeedyPromise"}static resolve(e){const t=new o(this._snop);return"object"==typeof e&&null!==e&&"then"in e||"function"==typeof e&&"then"in e?t._resolve(e):(t._value=e,t._state=1),t}static reject(e){const t=new o(this._snop);return t._value=e,t._state=2,t}static all(e){return new o(((t,n)=>{const i=[];for(const t of e)i.push(t);const s=i.length;if(0==s)return void t([]);let r=s;const A=new Array(s),a=e=>n=>{A[e]=n,0==--r&&t(A)};for(let e=0;e{const i=[];for(const t of e)i.push(t);const s=i.length;for(let e=0;e{n(e),n=i=this._nop}),(e=>{i(e),n=i=this._nop}))}catch(e){n!==this._nop&&i!==this._nop&&this._reject(e)}}else this._fulfill(e)}catch(e){this._reject(e)}else e.then(this._resolve,this._reject)}}_nop(){}static _snop(){}}},9420:(e,t,n)=>{"use strict";n.d(t,{gx:()=>D,bf:()=>b});var i=n(1001),o=n(9037),s=n(6049),r=n(8581);function A(){A=function(e,t){return new n(e,void 0,t)};var e=RegExp.prototype,t=new WeakMap;function n(e,i,o){var s=RegExp(e,i);return t.set(s,o||t.get(e)),a(s,n.prototype)}function i(e,n){var i=t.get(n);return Object.keys(i).reduce((function(t,n){var o=i[n];if("number"==typeof o)t[n]=e[o];else{for(var s=0;void 0===e[o[s]]&&s+1]+)>/g,(function(e,t){var n=s[t];return"$"+(Array.isArray(n)?n.join("$"):n)})))}if("function"==typeof o){var r=this;return e[Symbol.replace].call(this,n,(function(){var e=arguments;return"object"!=typeof e[e.length-1]&&(e=[].slice.call(e)).push(i(e,r)),o.apply(this,e)}))}return e[Symbol.replace].call(this,n,o)},A.apply(this,arguments)}function a(e,t){return a=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},a(e,t)}const d=n(3816),c=Object.keys(d).filter((e=>"number"==typeof d[e])).reduce(((e,t)=>(e[t]=d[t],e)),{}),l=Object.freeze(Object.assign(Object.assign({},c),{},{FS_USE_CUSTOM_PRECISION:0,FS_OUTPUT_TYPE:0,PIXELCOMPONENT_RED:s.kQ.RED,PIXELCOMPONENT_GREEN:s.kQ.GREEN,PIXELCOMPONENT_BLUE:s.kQ.BLUE,PIXELCOMPONENT_ALPHA:s.kQ.ALPHA})),g=[/\/\*(.|\s)*?\*\//g,/\/\/.*$/gm],h=/^\s*@\s*include\s+"(.*?)"/gm,p=/@(\w+)@/g,u=[A(/@\s*unroll\s+?for\s*\(\s*(int|)\s*(\w+)\s*=\s*(\x2D?\d+|\w+)\s*;\s*\2\s*(<=?)\s*(\x2D?\d+|\w+)\s*;\s*\2\s*\+\+()\s*\)\s*\{\s*([\s\S]+?)\s*\}/g,{counter:2}),A(/@\s*unroll\s+?for\s*\(\s*(int|)\s*(\w+)\s*=\s*(\x2D?\d+|\w+)\s*;\s*\2\s*(<=?)\s*(\x2D?\d+|\w+)\s*;\s*\2\s*\+=\s*(\x2D?\d+)\s*\)\s*\{\s*([\s\S]+?)\s*\}/g,{counter:2})];class I{static generateGLSL(e,t,n=null,s=null){const r=[],A=function(e){o.A.assert(i.c.isInitialized());const t=new Map,n=Object.assign(Object.create(null),l,(s=o.A.platformString(),r=i.c.instance.renderer,Object.freeze({APPLE:0|/(Mac|iOS|iPhone|iPad|iPod)/i.test(s),APPLE_GPU:0|/Apple/.test(r),INTEL_GRAPHICS:0|/Intel.*Graphics/.test(r)})));var s,r;for(const e in n)t.set(e,n[e]);for(const[n,i]of e)t.set(n,i);return t}(e),a=function(e,t,n=null,i=null){const o=[];null!==n&&o.push(n);for(const[t,n]of e)o.push(`#define ${t} ${Number(n)}`);o.push(t),null!==i&&o.push(i);return o.join("\n")}(e,t,n,s);return function(e,t){const n=m.bind(t),i=u.length;for(let t=0;tString(A.has(t)?Number(A.get(t)):(r.push(`Undefined constant ${t}`),0)))).replace(h,((t,n)=>I.generateGLSL(e,f(n)))),e)+r.map((e=>`\n#error ${e}\n`)).join("")}}function f(e){if(String(e).match(/^[a-zA-Z0-9_-]+\.glsl$/))return n(5235)("./"+e);throw new r.kG(`Shader preprocessor: can't read file "${e}"`)}function m(e,t,n,i,s,A,a,d){const c=this,l=Number.isFinite(+i)||c.has(i),g=Number.isFinite(+A)||c.has(A);if(!l||!g){if(c.size>0)throw new r.mB(`Can't unroll loop: unknown limits (start=${i}, end=${A}). Code:\n\n${e}`);return e}let h=c.has(i)?c.get(i):parseInt(i),p=c.has(A)?c.get(A):parseInt(A),u=0==a.length?1:parseInt(a);o.A.assert(h<=p&&u>0);let I=null!==d.match(/\bbreak\s*;/)?"switch(1) { default:\n":"{\n";I+=`${t} ${n};\n`,p+="<="==s?1:0;for(let e=h;ee.trim())).filter((e=>e));for(const n of t)if(n.endsWith("]")){if(!(o=n.match(/(\w+)\s*\[\s*(\d+)\s*\]$/)))throw new r.mB(`Unspecified array length for uniform "${n}" in the shader`);const[t,s]=[o[1],Number(o[2])];for(let n=0;n0)throw new r.Er("Redefinition of shader arguments");for(let t=0;t0)throw new r.Er("Redefinition of externally defined constants of a shader");const t=Object.keys(e);for(const n of t){const t=Number(e[n]);this._defines.set(n,t)}return this}build(){throw new r.aQ}}class Q extends v{constructor(e,t,n){super(e),this._fsSource=String(t),this._vsSource=void 0!==n?String(n):void 0}build(){return new P(_,this._arguments,this._defines,this._fsSource,this._vsSource)}}class w extends v{constructor(e,t,n){super(e),this._fsFilepath=String(t),this._vsFilepath=void 0!==n?String(n):void 0}build(){return new B(_,this._arguments,this._defines,this._fsFilepath,this._vsFilepath)}}function b(e,t=void 0){return new w(_,e,t)}function D(e,t=void 0){return new Q(_,e,t)}},1672:(e,t,n)=>{"use strict";n.r(t),n.d(t,{conv2D:()=>r,convX:()=>A,convY:()=>a});var i=n(9420),o=n(9037),s=n(8581);function r(e,t=1){const n=new Float32Array(e.map((e=>+e*+t))),r=0|Math.sqrt(n.length),A=r>>1;if(r<1||r%2==0)throw new s.qw(`Can't perform a 2D convolution with an invalid kSize of ${r}`);if(r*r!=n.length)throw new s.qw(`Invalid 2D convolution kernel of ${n.length} elements (expected: square)`);const a=A<=7?"pixelAtShortOffset":"pixelAtLongOffset",d=`\n uniform sampler2D image;\n\n void main()\n {\n float alpha = threadPixel(image).a;\n vec4 result = vec4(0.0f);\n\n ${c=(e,t,n)=>`\n result += ${a}(image, ivec2(${0|-n}, ${0|-t})) * float(${+e});\n `,o.A.cartesian(o.A.symmetricRange(A),o.A.symmetricRange(A)).map((e=>c(n[(e[0]+A)*r+(e[1]+A)],e[0],e[1]))).join("\n")}\n\n color = vec4(result.rgb, alpha);\n }\n `;var c;return(0,i.gx)(d).withArguments("image")}function A(e,t=1){return d("x",e,t)}function a(e,t=1){return d("y",e,t)}function d(e,t,n=1){const r=new Float32Array(t.map((e=>+e*+n))),A=r.length,a=A>>1;if(A<1||A%2==0)throw new s.qw(`Can't perform a 1D convolution with an invalid kSize of ${A}`);if("x"!=e&&"y"!=e)throw new s.qw(`Can't perform 1D convolution: invalid axis "${e}"`);const d=a<=7?"pixelAtShortOffset":"pixelAtLongOffset",c=`\n uniform sampler2D image;\n\n void main()\n {\n float alpha = threadPixel(image).a;\n vec4 pixel = vec4(0.0f);\n\n ${l=(t,n)=>"x"==e?`\n pixel += ${d}(image, ivec2(${0|-n}, 0)) * float(${+t});\n `:`\n pixel += ${d}(image, ivec2(0, ${0|-n})) * float(${+t});\n `,o.A.symmetricRange(a).reduce(((e,t)=>e+l(r[t+a],t)),"")}\n\n color = vec4(pixel.rgb, alpha);\n }\n `;var l;return(0,i.gx)(c).withArguments("image")}},1001:(e,t,n)=>{"use strict";n.d(t,{c:()=>l});var i=n(9037),o=n(2199),s=n(3211),r=n(9192),A=n(8581);const a=Symbol();let d=null,c="default";class l extends s.c{constructor(e){i.A.assert(e===a),super(),this._reinitializeOnContextLoss=!0,this._canvas=this._createCanvas(this._reinitialize.bind(this)),this._gl=this._createContext(this._canvas),this._vendor="",this._renderer="",this._readDriverInfo(),"diagnostic"===o.w.logging&&this._logDriverInfo()}static get instance(){return d||(d=new l(a))}get gl(){return this._gl}get canvas(){return this._canvas}get renderer(){return this._renderer}get vendor(){return this._vendor}_createCanvas(e){const t=i.A.createCanvas(16,16);return t.addEventListener("webglcontextlost",(t=>{i.A.warning("Lost WebGL2 context"),setTimeout(e,0),t.preventDefault()}),!1),t}_createContext(e){if(i.A.log(`Creating a ${c} WebGL2 rendering context...`),"undefined"==typeof WebGL2RenderingContext)throw new A.EM("This application requires WebGL2. Please update your system.");const t=e.getContext("webgl2",{premultipliedAlpha:!1,preserveDrawingBuffer:!1,powerPreference:c,alpha:!0,antialias:!1,depth:!1,stencil:!1,desynchronized:!0});if(!t)throw new A.EM("Can't create a WebGL2 Rendering Context. Try a different browser!");return t}_reinitialize(){this._reinitializeOnContextLoss&&(i.A.warning("Reinitializing WebGL2..."),this._canvas.remove(),this._canvas=this._createCanvas(this._reinitialize.bind(this)),this._gl=this._createContext(this._canvas),this._readDriverInfo(),this._notify())}_readDriverInfo(){const e=this._gl;let t=null;navigator.userAgent.includes("Firefox")?(this._vendor="",this._renderer=e.getParameter(e.RENDERER)):null!=(t=e.getExtension("WEBGL_debug_renderer_info"))?(this._vendor=e.getParameter(t.UNMASKED_VENDOR_WEBGL),this._renderer=e.getParameter(t.UNMASKED_RENDERER_WEBGL)):(this._vendor="",this._renderer="")}_logDriverInfo(){i.A.log("Platform: "+i.A.platformString()),i.A.log("GL vendor: "+this.vendor),i.A.log("GL renderer: "+this.renderer)}loseContext(){const e=this._gl,t=e.getExtension("WEBGL_lose_context");if(!t)throw new A.EM("WEBGL_lose_context extension is unavailable");return e.isContextLost()||(this._reinitializeOnContextLoss=!1,t.loseContext()),t}loseAndRestoreContext(e=1){const t=1e3*Math.max(e,0),n=this.loseContext();return new r.i((e=>{setTimeout((()=>{this._reinitializeOnContextLoss=!0,this._reinitialize(),setTimeout((()=>e(n)),0)}),t)}))}static get powerPreference(){return c}static set powerPreference(e){if("default"!==e&&"low-power"!==e&&"high-performance"!==e)throw new A.qw(`Invalid powerPreference: "${e}"`);null!=d&&c===e||(c=e,null!=d&&d.loseAndRestoreContext())}static isInitialized(){return null!=d}}},8581:(e,t,n)=>{"use strict";n.d(t,{EM:()=>o,Er:()=>a,FJ:()=>l,MU:()=>g,NO:()=>I,Uk:()=>u,aQ:()=>r,kG:()=>c,l:()=>d,mB:()=>h,pf:()=>p,qw:()=>A,wB:()=>s,xB:()=>i});class i extends Error{constructor(e,t=null){super([e,t?t.toString():"[speedy-vision.js]"].join("\n-> ")),this._cause=t}get name(){return this.constructor.name}set name(e){}get cause(){return this._cause}}class o extends i{constructor(e="",t=null){super(`Unsupported operation. ${e}`,t)}}class s extends i{constructor(e="",t=null){super(`WebGL error. ${e}`,t)}static from(e){const t=e.getError(),n=["NO_ERROR","INVALID_ENUM","INVALID_VALUE","INVALID_OPERATION","INVALID_FRAMEBUFFER_OPERATION","OUT_OF_MEMORY","CONTEXT_LOST_WEBGL"].find((n=>e[n]==t))||"Unknown";return new s(n)}}class r extends i{constructor(e="",t=null){super(`Can't call abstract method. ${e}`,t)}}class A extends i{constructor(e="",t=null){super(`Illegal argument. ${e}`,t)}}class a extends i{constructor(e="",t=null){super(`Illegal operation. ${e}`,t)}}class d extends i{constructor(e="",t=null){super(`Out of memory. ${e}`,t)}}class c extends i{constructor(e="",t=null){super(`File not found. ${e}`,t)}}class l extends i{constructor(e="",t=null){super(`Resource not loaded. ${e}`,t)}}class g extends i{constructor(e="",t=null){super(`Timeout error. ${e}`,t)}}class h extends i{constructor(e="",t=null){super(`Parse error. ${e}`,t)}}class p extends i{constructor(e="",t=null){super(`Assertion failed. ${e}`,t)}}class u extends i{constructor(e="",t=null){super(`Access denied. ${e}`,t)}}class I extends i{constructor(e="",t=null){super(`WebAssembly error. ${e}`,t)}}},3816:(e,t,n)=>{"use strict";n.r(t),n.d(t,{DEFAULT_ENCODER_CAPACITY:()=>g,FIX_BITS:()=>r,FIX_RESOLUTION:()=>A,LITTLE_ENDIAN:()=>C,LOG2_MAX_DESCRIPTOR_SIZE:()=>h,LOG2_PYRAMID_MAX_SCALE:()=>o,MATCH_INDEX_BITS:()=>u,MATCH_INDEX_MASK:()=>I,MATCH_MAX_DISTANCE:()=>m,MATCH_MAX_INDEX:()=>f,MAX_DESCRIPTOR_SIZE:()=>p,MAX_ENCODER_CAPACITY:()=>l,MAX_TEXTURE_LENGTH:()=>a,MIN_ENCODER_LENGTH:()=>c,MIN_KEYPOINT_SIZE:()=>d,PYRAMID_MAX_LEVELS:()=>i,PYRAMID_MAX_SCALE:()=>s});const i=8,o=0,s=1<{"use strict";n.d(t,{c:()=>i});class i{constructor(){this._subscribers=[],this._thisptr=[],this._args=[]}subscribe(e,t,...n){this._subscribers.push(e),this._thisptr.push(t),this._args.push(n)}unsubscribe(e,t){for(let n=this._subscribers.length-1;n>=0;n--)if(this._subscribers[n]===e&&this._thisptr[n]===t){this._subscribers.splice(n,1),this._thisptr.splice(n,1),this._args.splice(n,1);break}}_notify(){for(let e=0;e{"use strict";n.d(t,{f5:()=>o,kQ:()=>s,kg:()=>r,zu:()=>i});const i=Object.freeze({Image:Symbol("Image"),Video:Symbol("Video"),Canvas:Symbol("Canvas"),OffscreenCanvas:Symbol("OffscreenCanvas"),Bitmap:Symbol("Bitmap"),Data:Symbol("Data")}),o=Object.freeze({RGBA:Symbol("RGBA"),GREY:Symbol("GREY")}),s=Object.freeze({RED:1,GREEN:2,BLUE:4,ALPHA:8,ALL:15}),r=Object.freeze({[s.RED]:0,[s.GREEN]:1,[s.BLUE]:2,[s.ALPHA]:3})},9037:(e,t,n)=>{"use strict";n.d(t,{A:()=>r});var i=n(8581),o=n(9192),s=n(2199);class r{static warning(e,...t){"none"!==s.w.logging&&console.warn("[speedy-vision] "+e,...t)}static log(e,...t){"none"!==s.w.logging&&console.log("[speedy-vision] "+e,...t)}static assert(e,t=""){if(!e)throw new i.pf(t)}static functionArguments(e){const t=e.toString(),n=t.startsWith("function")?"function\\s.*\\(([^)]*)\\)":t.startsWith("(")?"\\(([^)]*)\\).*=>":"([^=]+).*=>",o=new RegExp(n).exec(t);if(null!==o){return o[1].replace(/\/\*.*?\*\//g,"").split(",").map((e=>e.replace(/=.*$/,"").trim())).filter((e=>e))}throw new i.mB(`Can't detect function arguments of ${t}`)}static getAllPropertyDescriptors(e){if(e){const t=Object.getPrototypeOf(e);return Object.assign(Object.assign({},r.getAllPropertyDescriptors(t)),Object.getOwnPropertyDescriptors(e))}return Object.create(null)}static createCanvas(e,t){const n=document.createElement("canvas");return n.width=e,n.height=t,n}static gaussianKernel(e,t=0,n=!0){if(0==t&&(t=0|Math.ceil(5*e),t+=1-t%2),(t|=0)<1||t%2==0)throw new i.qw(`Invalid kernel size given to gaussianKernel: ${t} x 1`);if(e<=0)throw new i.qw(`Invalid sigma given to gaussianKernel: ${e}`);const o=new Array(t),s=t>>1,r=1.4142135623730951*+e,A=.3275911,a=.254829592,d=-.284496736,c=1.421413741,l=-1.453152027,g=1.061405429;let h=0;for(let e=0;e=1&&n%2==1);let i=new Array(n*n),o=0;for(let s=0;st.map((t=>[e,t])))))}static symmetricRange(e){if((e|=0)<0)throw new i.qw("Expected a non-negative integer as input");return[...Array(2*e+1).keys()].map((t=>t-e))}static range(e){if((e|=0)<=0)throw new i.qw("Expected a positive integer as input");return[...Array(e).keys()]}static shuffle(e){const t=e.length,n=t-1;for(let i=0;i>10,n=1023&e,i=1-2*((65535&e)>>15);if(0==t)return 0==n?0*i:i*n*5.960464477539063e-8;if(31==t)return 0==n?i*Number.POSITIVE_INFINITY:Number.NaN;return i*(t>=15?1<{navigator.mediaDevices.getUserMedia(e).then((n=>{const i=document.createElement("video");i.onloadedmetadata=()=>{i.play(),r.log(`The camera is on! Resolution: ${i.videoWidth} x ${i.videoHeight}`),t(i)},i.setAttribute("playsinline",""),i.setAttribute("autoplay",""),!1!==e.audio&&void 0!==e.audio||i.setAttribute("muted",""),i.srcObject=n})).catch((t=>{"NotAllowedError"===t.name?n(new i.Uk("Please give access to the camera and reload the page.",t)):"OverconstrainedError"===t.name||"NotFoundError"===t.name?n(new i.EM(`Can't access the webcam with the requested constraints: ${JSON.stringify(e)}.`,t)):n(new i.xB("Can't access the webcam.",t))}))}))}static formatBinaryData(e){const t=new Uint8Array(e);return Array.from(t,(e=>e.toString(16).padStart(2,"0"))).join(" ")}static platformString(){return"object"==typeof navigator.userAgentData?navigator.userAgentData.platform:navigator.platform}}},5235:(e,t,n)=>{var i={"./colors.glsl":8609,"./filters.glsl":4672,"./fixed-point.glsl":9778,"./float16.glsl":8710,"./global.glsl":2434,"./int32.glsl":439,"./keypoint-descriptors.glsl":8545,"./keypoint-matches.glsl":6762,"./keypoints.glsl":7639,"./math.glsl":431,"./platform.glsl":6822,"./pyramids.glsl":2728,"./subpixel.glsl":6823};function o(e){var t=s(e);return n(t)}function s(e){if(!n.o(i,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return i[e]}o.keys=function(){return Object.keys(i)},o.resolve=s,e.exports=o,o.id=5235},4606:(e,t,n)=>{var i={"./filters/convolution":1672,"./filters/convolution.js":1672,"./filters/convolution1d.glsl":8211,"./filters/convolution2d.glsl":7360,"./filters/fast-median.glsl":8191,"./filters/nightvision.glsl":4438,"./filters/normalize-image.glsl":5867,"./filters/rgb2grey.glsl":9252,"./include/colors.glsl":8609,"./include/filters.glsl":4672,"./include/fixed-point.glsl":9778,"./include/float16.glsl":8710,"./include/global.glsl":2434,"./include/int32.glsl":439,"./include/keypoint-descriptors.glsl":8545,"./include/keypoint-matches.glsl":6762,"./include/keypoints.glsl":7639,"./include/math.glsl":431,"./include/platform.glsl":6822,"./include/pyramids.glsl":2728,"./include/subpixel.glsl":6823,"./keypoints/allocate-descriptors.glsl":1341,"./keypoints/allocate-extra.glsl":7833,"./keypoints/apply-homography.glsl":2352,"./keypoints/bf-knn.glsl":7541,"./keypoints/clip-border.glsl":4868,"./keypoints/clip.glsl":5591,"./keypoints/distance-filter.glsl":191,"./keypoints/encode-keypoint-long-offsets.glsl":5467,"./keypoints/encode-keypoint-offsets.glsl":336,"./keypoints/encode-keypoint-positions.glsl":8968,"./keypoints/encode-keypoint-properties.glsl":1733,"./keypoints/encode-keypoints.glsl":9674,"./keypoints/encode-null-keypoints.glsl":2090,"./keypoints/fast.glsl":1855,"./keypoints/fast.vs.glsl":4824,"./keypoints/hamming-distance-filter.glsl":2381,"./keypoints/harris-cutoff.glsl":6060,"./keypoints/harris.glsl":9974,"./keypoints/knn-init.glsl":3047,"./keypoints/knn-transfer.glsl":3266,"./keypoints/laplacian.glsl":8018,"./keypoints/lk.glsl":3168,"./keypoints/lookup-of-locations.glsl":3890,"./keypoints/lookup-of-locations.vs.glsl":8647,"./keypoints/lsh-knn.glsl":4776,"./keypoints/mix-keypoints.glsl":2648,"./keypoints/nonmax-scale.glsl":8825,"./keypoints/nonmax-space.glsl":5693,"./keypoints/nonmax-suppression.glsl":9280,"./keypoints/orb-descriptor.glsl":9108,"./keypoints/orb-orientation.glsl":7137,"./keypoints/refine-scale.glsl":9739,"./keypoints/score-findmax.glsl":8231,"./keypoints/shuffle.glsl":2518,"./keypoints/sort-keypoints.glsl":8096,"./keypoints/subpixel-refinement.glsl":5795,"./keypoints/transfer-flow.glsl":3169,"./keypoints/transfer-orientation.glsl":1337,"./keypoints/transfer-to-extra.glsl":6187,"./keypoints/upload-keypoints.glsl":477,"./pyramids/downsample2.glsl":4050,"./pyramids/upsample2.glsl":5545,"./transforms/additive-mix.glsl":7113,"./transforms/resize.glsl":1202,"./transforms/warp-perspective.glsl":7971,"./utils/copy-components.glsl":6122,"./utils/copy-raster.glsl":371,"./utils/copy.glsl":7307,"./utils/fill-components.glsl":8614,"./utils/fill.glsl":6271,"./utils/flip-y.vs.glsl":3016,"./utils/scan-minmax2d.glsl":3630,"./utils/sobel-derivatives.glsl":8508,"./utils/sobel-derivatives.vs.glsl":8073};function o(e){var t=s(e);return n(t)}function s(e){if(!n.o(i,e)){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}return i[e]}o.keys=function(){return Object.keys(i)},o.resolve=s,e.exports=o,o.id=4606},8211:e=>{e.exports="#if !defined(KERNEL_SIZE) || !defined(AXIS) || (AXIS != 0 && AXIS != 1)\n#error Undefined KERNEL_SIZE / AXIS\n#endif\nuniform sampler2D image;\nuniform float kernel[@KERNEL_SIZE@];\nconst ivec2 axis = ivec2(1-AXIS, AXIS);\n#define S(x,k) result += pixelAtShortOffset(image, ivec2((x),(x)) * axis) * kernel[k]\nvoid main()\n{\nvec4 result = vec4(0.0f);\n#if KERNEL_SIZE == 3\nS(-1, 2);\nS( 0, 1);\nS( 1, 0);\n#elif KERNEL_SIZE == 5\nS(-2, 4);\nS(-1, 3);\nS( 0, 2);\nS( 1, 1);\nS( 2, 0);\n#elif KERNEL_SIZE == 7\nS(-3, 6);\nS(-2, 5);\nS(-1, 4);\nS( 0, 3);\nS( 1, 2);\nS( 2, 1);\nS( 3, 0);\n#elif KERNEL_SIZE == 9\nS(-4, 8);\nS(-3, 7);\nS(-2, 6);\nS(-1, 5);\nS( 0, 4);\nS( 1, 3);\nS( 2, 2);\nS( 3, 1);\nS( 4, 0);\n#elif KERNEL_SIZE == 11\nS(-5, 10);\nS(-4, 9);\nS(-3, 8);\nS(-2, 7);\nS(-1, 6);\nS( 0, 5);\nS( 1, 4);\nS( 2, 3);\nS( 3, 2);\nS( 4, 1);\nS( 5, 0);\n#elif KERNEL_SIZE == 13\nS(-6, 12);\nS(-5, 11);\nS(-4, 10);\nS(-3, 9);\nS(-2, 8);\nS(-1, 7);\nS( 0, 6);\nS( 1, 5);\nS( 2, 4);\nS( 3, 3);\nS( 4, 2);\nS( 5, 1);\nS( 6, 0);\n#elif KERNEL_SIZE == 15\nS(-7, 14);\nS(-6, 13);\nS(-5, 12);\nS(-4, 11);\nS(-3, 10);\nS(-2, 9);\nS(-1, 8);\nS( 0, 7);\nS( 1, 6);\nS( 2, 5);\nS( 3, 4);\nS( 4, 3);\nS( 5, 2);\nS( 6, 1);\nS( 7, 0);\n#else\n#error Invalid parameters\n#endif\ncolor = vec4(result.rgb, 1.0f);\n}"},7360:e=>{e.exports="#ifndef KERNEL_SIZE_SQUARED\n#error Must define KERNEL_SIZE_SQUARED\n#endif\nuniform sampler2D image;\nuniform float kernel[@KERNEL_SIZE_SQUARED@];\n#define S(x,y,k) result += pixelAtShortOffset(image, ivec2((x),(y))) * kernel[k]\nvoid main()\n{\nvec4 result = vec4(0.0f);\n#if KERNEL_SIZE_SQUARED == 9\nS(-1,-1, 8);\nS(-1, 0, 7);\nS(-1, 1, 6);\nS( 0,-1, 5);\nS( 0, 0, 4);\nS( 0, 1, 3);\nS( 1,-1, 2);\nS( 1, 0, 1);\nS( 1, 1, 0);\n#elif KERNEL_SIZE_SQUARED == 25\nS(-2,-2, 24);\nS(-2,-1, 23);\nS(-2, 0, 22);\nS(-2, 1, 21);\nS(-2, 2, 20);\nS(-1,-2, 19);\nS(-1,-1, 18);\nS(-1, 0, 17);\nS(-1, 1, 16);\nS(-1, 2, 15);\nS( 0,-2, 14);\nS( 0,-1, 13);\nS( 0, 0, 12);\nS( 0, 1, 11);\nS( 0, 2, 10);\nS( 1,-2, 9);\nS( 1,-1, 8);\nS( 1, 0, 7);\nS( 1, 1, 6);\nS( 1, 2, 5);\nS( 2,-2, 4);\nS( 2,-1, 3);\nS( 2, 0, 2);\nS( 2, 1, 1);\nS( 2, 2, 0);\n#elif KERNEL_SIZE_SQUARED == 49\nS(-3,-3, 48);\nS(-3,-2, 47);\nS(-3,-1, 46);\nS(-3, 0, 45);\nS(-3, 1, 44);\nS(-3, 2, 43);\nS(-3, 3, 42);\nS(-2,-3, 41);\nS(-2,-2, 40);\nS(-2,-1, 39);\nS(-2, 0, 38);\nS(-2, 1, 37);\nS(-2, 2, 36);\nS(-2, 3, 35);\nS(-1,-3, 34);\nS(-1,-2, 33);\nS(-1,-1, 32);\nS(-1, 0, 31);\nS(-1, 1, 30);\nS(-1, 2, 29);\nS(-1, 3, 28);\nS( 0,-3, 27);\nS( 0,-2, 26);\nS( 0,-1, 25);\nS( 0, 0, 24);\nS( 0, 1, 23);\nS( 0, 2, 22);\nS( 0, 3, 21);\nS( 1,-3, 20);\nS( 1,-2, 19);\nS( 1,-1, 18);\nS( 1, 0, 17);\nS( 1, 1, 16);\nS( 1, 2, 15);\nS( 1, 3, 14);\nS( 2,-3, 13);\nS( 2,-2, 12);\nS( 2,-1, 11);\nS( 2, 0, 10);\nS( 2, 1, 9);\nS( 2, 2, 8);\nS( 2, 3, 7);\nS( 3,-3, 6);\nS( 3,-2, 5);\nS( 3,-1, 4);\nS( 3, 0, 3);\nS( 3, 1, 2);\nS( 3, 2, 1);\nS( 3, 3, 0);\n#else\n#error Invalid KERNEL_SIZE_SQUARED\n#endif\ncolor = vec4(result.rgb, 1.0f);\n}"},8191:e=>{e.exports="uniform sampler2D image;\n#define X(i,j) t = vec2(min(p[i], p[j]), max(p[i], p[j])); p[i] = t.x; p[j] = t.y;\n#define S(i,x,y) p[i] = pixelAtShortOffset(image, ivec2((x),(y))).g\nvoid main()\n{\nfloat median;\nvec2 t;\n#if !defined(KERNEL_SIZE)\n#error Must define KERNEL_SIZE\n#elif KERNEL_SIZE == 3\nfloat p[9];\nS(0,-1,-1);\nS(1, 0,-1);\nS(2, 1,-1);\nS(3,-1, 0);\nS(4, 0, 0);\nS(5, 1, 0);\nS(6,-1, 1);\nS(7, 0, 1);\nS(8, 1, 1);\nX(1,2);X(4,5);X(7,8);X(0,1);X(3,4);X(6,7);X(1,2);X(4,5);X(7,8);X(0,3);X(5,8);X(4,7);X(3,6);X(1,4);X(2,5);X(4,7);X(4,2);X(6,4);X(4,2);\nmedian = p[4];\n#elif KERNEL_SIZE == 5\nfloat p[25];\nS( 0,-2,-2);\nS( 1,-1,-2);\nS( 2, 0,-2);\nS( 3, 1,-2);\nS( 4, 2,-2);\nS( 5,-2,-1);\nS( 6,-1,-1);\nS( 7, 0,-1);\nS( 8, 1,-1);\nS( 9, 2,-1);\nS(10,-2, 0);\nS(11,-1, 0);\nS(12, 0, 0);\nS(13, 1, 0);\nS(14, 2, 0);\nS(15,-2, 1);\nS(16,-1, 1);\nS(17, 0, 1);\nS(18, 1, 1);\nS(19, 2, 1);\nS(20,-2, 2);\nS(21,-1, 2);\nS(22, 0, 2);\nS(23, 1, 2);\nS(24, 2, 2);\nX(0,1);X(3,4);X(2,4);X(2,3);X(6,7);X(5,7);X(5,6);X(9,10);X(8,10);X(8,9);X(12,13);X(11,13);X(11,12);X(15,16);X(14,16);X(14,15);X(18,19);X(17,19);X(17,18);X(21,22);X(20,22);X(20,21);X(23,24);X(2,5);X(3,6);X(0,6);X(0,3);X(4,7);X(1,7);X(1,4);X(11,14);X(8,14);X(8,11);X(12,15);X(9,15);X(9,12);X(13,16);X(10,16);X(10,13);X(20,23);X(17,23);X(17,20);X(21,24);X(18,24);X(18,21);X(19,22);X(8,17);X(9,18);X(0,18);X(0,9);X(10,19);X(1,19);X(1,10);X(11,20);X(2,20);X(2,11);X(12,21);X(3,21);X(3,12);X(13,22);X(4,22);X(4,13);X(14,23);X(5,23);X(5,14);X(15,24);X(6,24);X(6,15);X(7,16);X(7,19);X(13,21);X(15,23);X(7,13);X(7,15);X(1,9);X(3,11);X(5,17);X(11,17);X(9,17);X(4,10);X(6,12);X(7,14);X(4,6);X(4,7);X(12,14);X(10,14);X(6,7);X(10,12);X(6,10);X(6,17);X(12,17);X(7,17);X(7,10);X(12,18);X(7,12);X(10,18);X(12,20);X(10,20);X(10,12);\nmedian = p[12];\n#elif KERNEL_SIZE == 7\nfloat p[49];\nS( 0,-3,-3);\nS( 1,-2,-3);\nS( 2,-1,-3);\nS( 3, 0,-3);\nS( 4, 1,-3);\nS( 5, 2,-3);\nS( 6, 3,-3);\nS( 7,-3,-2);\nS( 8,-2,-2);\nS( 9,-1,-2);\nS(10, 0,-2);\nS(11, 1,-2);\nS(12, 2,-2);\nS(13, 3,-2);\nS(14,-3,-1);\nS(15,-2,-1);\nS(16,-1,-1);\nS(17, 0,-1);\nS(18, 1,-1);\nS(19, 2,-1);\nS(20, 3,-1);\nS(21,-3, 0);\nS(22,-2, 0);\nS(23,-1, 0);\nS(24, 0, 0);\nS(25, 1, 0);\nS(26, 2, 0);\nS(27, 3, 0);\nS(28,-3, 1);\nS(29,-2, 1);\nS(30,-1, 1);\nS(31, 0, 1);\nS(32, 1, 1);\nS(33, 2, 1);\nS(34, 3, 1);\nS(35,-3, 2);\nS(36,-2, 2);\nS(37,-1, 2);\nS(38, 0, 2);\nS(39, 1, 2);\nS(40, 2, 2);\nS(41, 3, 2);\nS(42,-3, 3);\nS(43,-2, 3);\nS(44,-1, 3);\nS(45, 0, 3);\nS(46, 1, 3);\nS(47, 2, 3);\nS(48, 3, 3);\nX(0,1);X(2,3);X(0,2);X(1,3);X(1,2);X(4,5);X(6,7);X(4,6);X(5,7);X(5,6);X(0,4);X(2,6);X(2,4);X(1,5);X(3,7);X(3,5);X(1,2);X(3,4);X(5,6);X(8,9);X(10,11);X(8,10);X(9,11);X(9,10);X(12,13);X(14,15);X(12,14);X(13,15);X(13,14);X(8,12);X(10,14);X(10,12);X(9,13);X(11,15);X(11,13);X(9,10);X(11,12);X(13,14);X(0,8);X(4,12);X(4,8);X(2,10);X(6,14);X(6,10);X(2,4);X(6,8);X(10,12);X(1,9);X(5,13);X(5,9);X(3,11);X(7,15);X(7,11);X(3,5);X(7,9);X(11,13);X(1,2);X(3,4);X(5,6);X(7,8);X(9,10);X(11,12);X(13,14);X(16,17);X(18,19);X(16,18);X(17,19);X(17,18);X(20,21);X(22,23);X(20,22);X(21,23);X(21,22);X(16,20);X(18,22);X(18,20);X(17,21);X(19,23);X(19,21);X(17,18);X(19,20);X(21,22);X(24,25);X(26,27);X(24,26);X(25,27);X(25,26);X(28,29);X(30,31);X(28,30);X(29,31);X(29,30);X(24,28);X(26,30);X(26,28);X(25,29);X(27,31);X(27,29);X(25,26);X(27,28);X(29,30);X(16,24);X(20,28);X(20,24);X(18,26);X(22,30);X(22,26);X(18,20);X(22,24);X(26,28);X(17,25);X(21,29);X(21,25);X(19,27);X(23,31);X(23,27);X(19,21);X(23,25);X(27,29);X(17,18);X(19,20);X(21,22);X(23,24);X(25,26);X(27,28);X(29,30);X(0,16);X(8,24);X(8,16);X(4,20);X(12,28);X(12,20);X(4,8);X(12,16);X(20,24);X(2,18);X(10,26);X(10,18);X(6,22);X(14,30);X(14,22);X(6,10);X(14,18);X(22,26);X(2,4);X(6,8);X(10,12);X(14,16);X(18,20);X(22,24);X(26,28);X(1,17);X(9,25);X(9,17);X(5,21);X(13,29);X(13,21);X(5,9);X(13,17);X(21,25);X(3,19);X(11,27);X(11,19);X(7,23);X(15,31);X(15,23);X(7,11);X(15,19);X(23,27);X(3,5);X(7,9);X(11,13);X(15,17);X(19,21);X(23,25);X(27,29);X(1,2);X(3,4);X(5,6);X(7,8);X(9,10);X(11,12);X(13,14);X(15,16);X(17,18);X(19,20);X(21,22);X(23,24);X(25,26);X(27,28);X(29,30);X(32,33);X(34,35);X(32,34);X(33,35);X(33,34);X(36,37);X(38,39);X(36,38);X(37,39);X(37,38);X(32,36);X(34,38);X(34,36);X(33,37);X(35,39);X(35,37);X(33,34);X(35,36);X(37,38);X(40,41);X(42,43);X(40,42);X(41,43);X(41,42);X(44,45);X(46,47);X(44,46);X(45,47);X(45,46);X(40,44);X(42,46);X(42,44);X(41,45);X(43,47);X(43,45);X(41,42);X(43,44);X(45,46);X(32,40);X(36,44);X(36,40);X(34,42);X(38,46);X(38,42);X(34,36);X(38,40);X(42,44);X(33,41);X(37,45);X(37,41);X(35,43);X(39,47);X(39,43);X(35,37);X(39,41);X(43,45);X(33,34);X(35,36);X(37,38);X(39,40);X(41,42);X(43,44);X(45,46);X(32,48);X(40,48);X(36,40);X(44,48);X(38,42);X(34,36);X(38,40);X(42,44);X(46,48);X(37,41);X(39,43);X(35,37);X(39,41);X(43,45);X(33,34);X(35,36);X(37,38);X(39,40);X(41,42);X(43,44);X(45,46);X(47,48);X(0,32);X(16,48);X(16,32);X(8,40);X(24,40);X(8,16);X(24,32);X(40,48);X(4,36);X(20,36);X(12,44);X(28,44);X(12,20);X(28,36);X(4,8);X(12,16);X(20,24);X(28,32);X(36,40);X(44,48);X(2,34);X(18,34);X(10,42);X(26,42);X(10,18);X(26,34);X(6,38);X(22,38);X(14,46);X(30,46);X(14,22);X(30,38);X(6,10);X(14,18);X(22,26);X(30,34);X(38,42);X(2,4);X(6,8);X(10,12);X(14,16);X(18,20);X(22,24);X(26,28);X(30,32);X(34,36);X(38,40);X(42,44);X(46,48);X(1,33);X(17,33);X(9,41);X(25,41);X(9,17);X(25,33);X(5,37);X(21,37);X(13,45);X(29,45);X(13,21);X(29,37);X(5,9);X(13,17);X(21,25);X(29,33);X(37,41);X(3,35);X(19,35);X(11,43);X(27,43);X(11,19);X(27,35);X(7,39);X(23,39);X(15,47);X(31,47);X(15,23);X(31,39);X(7,11);X(15,19);X(23,27);X(31,35);X(39,43);X(3,5);X(7,9);X(11,13);X(15,17);X(19,21);X(23,25);X(27,29);X(31,33);X(35,37);X(39,41);X(43,45);X(1,2);X(3,4);X(5,6);X(7,8);X(9,10);X(11,12);X(13,14);X(15,16);X(17,18);X(19,20);X(21,22);X(23,24);\nmedian = p[24];\n#else\n#error Unsupported kernel size\n#endif\ncolor = vec4(median, median, median, 1.0f);\n}"},4438:e=>{e.exports="uniform sampler2D image;\nuniform sampler2D illuminationMap;\nuniform float gain;\nuniform float offset;\nuniform float decay;\n#ifndef GREYSCALE\n#error Must define GREYSCALE\n#endif\n#if GREYSCALE == 0\nconst mat3 rgb2yuv = mat3(\n0.299f, -0.14713f, 0.615f,\n0.587f, -0.28886f, -0.51499f,\n0.114f, 0.436f, -0.10001f\n);\nconst mat3 yuv2rgb = mat3(\n1.0f, 1.0f, 1.0f,\n0.0f, -0.39465f, 2.03211f,\n1.13983f, -0.58060f, 0.0f\n);\n#endif\nconst float eps = 0.0001f;\nconst float sqrt2 = 1.4142135623730951f;\nconst float magic = 20.0f;\nconst vec2 center = vec2(0.5f);\nvoid main()\n{\nvec4 pixel = threadPixel(image);\nvec4 imapPixel = threadPixel(illuminationMap);\nfloat lambda = -sqrt2 * log(max(1.0f - decay, eps));\nfloat dist = length(texCoord - center);\nfloat vgain = gain * exp(-lambda * dist);\nfloat normalizedGain = 2.0f * vgain;\nfloat normalizedOffset = 2.0f * offset - 1.0f;\n#if GREYSCALE != 0\nfloat luma = 1.0 / (1.0 + exp(-normalizedGain * magic * (pixel.g - imapPixel.g)));\nluma = clamp(luma + normalizedOffset, 0.0f, 1.0f);\ncolor = vec4(luma, luma, luma, 1.0f);\n#else\nvec3 yuvPixel = rgb2yuv * pixel.rgb;\nvec3 yuvImapPixel = rgb2yuv * imapPixel.rgb;\nfloat luma = 1.0 / (1.0 + exp(-normalizedGain * magic * (yuvPixel.r - yuvImapPixel.r)));\nluma += normalizedOffset;\nvec3 rgbCorrectedPixel = yuv2rgb * vec3(luma, yuvPixel.gb);\nrgbCorrectedPixel = clamp(rgbCorrectedPixel, 0.0f, 1.0f);\ncolor = vec4(rgbCorrectedPixel, 1.0f);\n#endif\n}"},5867:e=>{e.exports="#ifndef GREYSCALE\n#error Must define GREYSCALE\n#endif\n#if GREYSCALE != 0\nuniform sampler2D minmax2d;\n#else\nuniform sampler2D minmax2dRGB[3];\n#endif\nuniform float minValue;\nuniform float maxValue;\nconst float eps = 1.0f / 255.0f;\nvoid main()\n{\nvec2 minmax = clamp(vec2(minValue, maxValue), 0.0f, 255.0f) / 255.0f;\nvec4 newMin = vec4(minmax.x);\nvec4 newRange = vec4(minmax.y - minmax.x);\nvec4 alpha = vec4(1.0f, newMin.x, newRange.x, 1.0f);\n#if GREYSCALE != 0\nvec4 pixel = threadPixel(minmax2d);\nmat4 channel = mat4(pixel, pixel, pixel, alpha);\n#else\nmat4 channel = mat4(\nthreadPixel(minmax2dRGB[0]),\nthreadPixel(minmax2dRGB[1]),\nthreadPixel(minmax2dRGB[2]),\nalpha\n);\n#endif\nvec4 oldMin = vec4(channel[0].g, channel[1].g, channel[2].g, channel[3].g);\nvec4 oldRange = max(vec4(channel[0].b, channel[1].b, channel[2].b, channel[3].b), eps);\nvec4 oldIntensity = vec4(channel[0].a, channel[1].a, channel[2].a, channel[3].a);\nvec4 newIntensity = (oldIntensity - oldMin) * newRange / oldRange + newMin;\ncolor = newIntensity;\n}"},9252:e=>{e.exports="const vec4 grey = vec4(0.299f, 0.587f, 0.114f, 0.0f);\nuniform sampler2D image;\nvoid main()\n{\nvec4 pixel = threadPixel(image);\nfloat g = dot(pixel, grey);\ncolor = vec4(g, g, g, 1.0f);\n}"},8609:e=>{e.exports="#ifndef _COLORS_GLSL\n#define _COLORS_GLSL\n#define PIXELCOMPONENT_RED @PIXELCOMPONENT_RED@\n#define PIXELCOMPONENT_GREEN @PIXELCOMPONENT_GREEN@\n#define PIXELCOMPONENT_BLUE @PIXELCOMPONENT_BLUE@\n#define PIXELCOMPONENT_ALPHA @PIXELCOMPONENT_ALPHA@\n#endif"},4672:e=>{e.exports="#ifndef _FILTERS_GLSL\n#define _FILTERS_GLSL\nfloat laplacian(sampler2D pyramid, vec2 position, float lod)\n{\nfloat pot = exp2(lod);\nivec2 pyrBaseSize = textureSize(pyramid, 0);\nconst vec3 ones = vec3(1.0f);\nconst mat3 kernel = mat3(\n0,-1, 0,\n-1, 4,-1,\n0,-1, 0\n);\n#define LPC(x,y) pyrSubpixelAtExOffset(pyramid, position, lod, pot, ivec2((x),(y)), pyrBaseSize).g\nmat3 neighborhood = mat3(\n0.0f, LPC(0,-1), 0.0f,\nLPC(-1,0), LPC(0,0), LPC(1,0),\n0.0f, LPC(0,1), 0.0f\n);\nmat3 m = matrixCompMult(neighborhood, kernel);\nreturn dot(ones, vec3(\ndot(m[0], ones),\ndot(m[1], ones),\ndot(m[2], ones)\n)) * (1.0f + lod);\n}\n#endif"},9778:e=>{e.exports="#ifndef _FIXEDPOINT_GLSL\n#define _FIXEDPOINT_GLSL\n#define fixed_t int\n#define fixed2_t ivec2\nconst int FIX_BITS = int(@FIX_BITS@);\nconst float FIX_RESOLUTION = float(@FIX_RESOLUTION@);\n#define itofix(x) fixed_t((x) << FIX_BITS)\n#define fixtoi(f) int((x) >> FIX_BITS)\n#define ftofix(x) fixed_t((x) * FIX_RESOLUTION + 0.5f)\n#define fixtof(f) (float(f) / FIX_RESOLUTION)\n#define ivec2tofix(x) fixed2_t((x) << FIX_BITS)\n#define fixtoivec2(f) ivec2((f) >> FIX_BITS)\n#define vec2tofix(v) fixed2_t((v) * FIX_RESOLUTION + vec2(0.5f))\n#define fixtovec2(f) (vec2(f) / FIX_RESOLUTION)\n#endif"},8710:e=>{e.exports="#ifndef _FLOAT16_GLSL\n#define _FLOAT16_GLSL\n#define encodeFloat16(f) (vec2(packf16(f)) / 255.0f)\n#define decodeFloat16(v) unpackf16(uvec2((v) * 255.0f))\n#define encodePairOfFloat16(f) vec4(encodeFloat16((f).x), encodeFloat16((f).y))\n#define decodePairOfFloat16(v) vec2(decodeFloat16((v).rg), decodeFloat16((v).ba))\n#define encodeNullPairOfFloat16() vec4(1.0f)\n#define isNullPairOfFloat16(v) all(equal((v), encodeNullPairOfFloat16()))\n#define encodeDiscardedPairOfFloat16() vec4(0.0f, 1.0f, 0.0f, 1.0f)\n#define isDiscardedPairOfFloat16(v) all(equal((v), encodeDiscardedPairOfFloat16()))\n#define encodeFloat16NaN() vec2(0.5f, 1.0f)\n#define isEncodedFloat16NaN(v) all(equal((v), encodeFloat16NaN()))\nuvec2 packf16( float f)\n{\nuint y = packHalf2x16(vec2(f, 0.0f));\nreturn uvec2(y, y >> 8u) & 0xFFu;\n}\nfloat unpackf16(uvec2 v)\n{\nv &= 0xFFu;\nreturn unpackHalf2x16(v.x | (v.y << 8u)).x;\n}\nbool isEncodedFloat16Zero(vec2 v)\n{\nuvec2 w = uvec2(v * 255.0f);\nreturn 0u == w.x + w.y * (0x80u - w.y);\n}\n#endif"},2434:e=>{e.exports="#ifndef _GLOBAL_GLSL\n#define _GLOBAL_GLSL\n#define threadLocation() ivec2(texCoord * texSize)\n#define outputSize() ivec2(texSize)\n#define threadPixel(img) textureLod((img), texCoord, 0.0f)\n#define pixelAt(img, pos) texelFetch((img), (pos), 0)\n#define pixelAtShortOffset(img, offset) textureLodOffset((img), texCoord, 0.0f, (offset))\n#define pixelAtLongOffset(img, offset) textureLod((img), texCoord + vec2(offset) / texSize, 0.0f)\n#endif"},439:e=>{e.exports='#ifndef _INT32_GLSL\n#define _INT32_GLSL\n@include "platform.glsl"\nuint decodeUint32(vec4 rgba)\n{\nuvec4 v = uvec4(rgba * 255.0f) & 255u;\nreturn v.x | (v.y << 8u) | (v.z << 16u) | (v.w << 24u);\n}\nvec4 encodeUint32(uint value)\n{\n#if defined(APPLE_GPU) || (defined(APPLE) && defined(INTEL_GRAPHICS))\nuvec4 v = uvec4(value, value / 256u, value / 65536u, value / 16777216u) % 256u;\nreturn vec4(v) / 255.0f;\n#else\nuvec4 v = uvec4(value, value >> 8u, value >> 16u, value >> 24u) & 255u;\nreturn vec4(v) / 255.0f;\n#endif\n}\n#endif'},8545:e=>{e.exports="#ifndef _KEYPOINT_DESCRIPTORS_GLSL\n#define _KEYPOINT_DESCRIPTORS_GLSL\n#if !defined(DESCRIPTOR_SIZE)\n#error Must define DESCRIPTOR_SIZE\n#elif !defined(_KEYPOINTS_GLSL)\n#error Must include keypoints.glsl\n#endif\nuint[DESCRIPTOR_SIZE] readKeypointDescriptor(sampler2D encodedKeypoints, int descriptorSize, int extraSize, int encoderLength, KeypointAddress address)\n{\nint descriptorOffset = sizeofEncodedKeypoint(0, extraSize) / 4;\nKeypointAddress descriptorAddress = KeypointAddress(address.base, descriptorOffset);\nuint[DESCRIPTOR_SIZE] descriptor;\nvec4 pixel; uvec4 bytes;\n@unroll\nfor(int i = 0; i < DESCRIPTOR_SIZE; i += 4) {\npixel = readKeypointData(encodedKeypoints, encoderLength, descriptorAddress);\nbytes = uvec4(pixel * 255.0f);\ndescriptor[i] = bytes.r;\ndescriptor[i+1] = bytes.g;\ndescriptor[i+2] = bytes.b;\ndescriptor[i+3] = bytes.a;\ndescriptorAddress.offset++;\n}\nreturn descriptor;\n}\nuint[DESCRIPTOR_SIZE] readKeypointDescriptorFromDB(sampler2D descriptorDB, int descriptorDBStride, int index)\n{\nuint[DESCRIPTOR_SIZE] descriptor;\nint rasterIndex = index * (DESCRIPTOR_SIZE / 4) * int(index >= 0);\nvec4 pixel; uvec4 bytes; ivec2 pos;\n@unroll\nfor(int i = 0; i < DESCRIPTOR_SIZE; i += 4) {\npos = ivec2(rasterIndex % descriptorDBStride, rasterIndex / descriptorDBStride);\npixel = (index >= 0) ? texelFetch(descriptorDB, pos, 0) : vec4(0.0f);\nbytes = uvec4(pixel * 255.0f);\ndescriptor[i] = bytes.r;\ndescriptor[i+1] = bytes.g;\ndescriptor[i+2] = bytes.b;\ndescriptor[i+3] = bytes.a;\nrasterIndex++;\n}\nreturn descriptor;\n}\nint distanceBetweenKeypointDescriptors(uint[DESCRIPTOR_SIZE] a, uint[DESCRIPTOR_SIZE] b)\n{\nconst int[256] POPCNT = int[256](0,1,1,2,1,2,2,3,1,2,2,3,2,3,3,4,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,1,2,2,3,2,3,3,4,2,3,3,4,3,4,4,5,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,2,3,3,4,3,4,4,5,3,4,4,5,4,5,5,6,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,3,4,4,5,4,5,5,6,4,5,5,6,5,6,6,7,4,5,5,6,5,6,6,7,5,6,6,7,6,7,7,8);\nuvec4 xor, u, v;\nint dist = 0;\nivec4 bits;\n@unroll\nfor(int i = 0; i < DESCRIPTOR_SIZE; i += 4) {\nu = uvec4(a[i], a[i+1], a[i+2], a[i+3]);\nv = uvec4(b[i], b[i+1], b[i+2], b[i+3]);\nxor = (u ^ v) & 255u;\nbits = ivec4(POPCNT[xor.x], POPCNT[xor.y], POPCNT[xor.z], POPCNT[xor.w]);\ndist += bits.x + bits.y + bits.z + bits.w;\n}\nreturn dist;\n}\n#endif"},6762:e=>{e.exports='#ifndef _KEYPOINT_MATCHES_GLSL\n#define _KEYPOINT_MATCHES_GLSL\n@include "int32.glsl"\nconst int MATCH_INDEX_BITS = int(@MATCH_INDEX_BITS@);\nconst int MATCH_INDEX_MASK = int(@MATCH_INDEX_MASK@);\nconst int MATCH_MAX_INDEX = int(@MATCH_MAX_INDEX@);\nconst int MATCH_MAX_DISTANCE = int(@MATCH_MAX_DISTANCE@);\nstruct KeypointMatch\n{\nint index;\nint dist;\n};\nvec4 encodeKeypointMatch(KeypointMatch candidate)\n{\nuint index = uint(candidate.index) & uint(MATCH_INDEX_MASK);\nuint dist = uint(clamp(candidate.dist, 0, MATCH_MAX_DISTANCE));\nuint u32 = index | (dist << MATCH_INDEX_BITS);\nreturn encodeUint32(u32);\n}\nKeypointMatch decodeKeypointMatch(vec4 rgba)\n{\nuint u32 = decodeUint32(rgba);\nint dist = int(u32 >> MATCH_INDEX_BITS);\nint index = int(u32 & uint(MATCH_INDEX_MASK));\nreturn KeypointMatch(index, dist);\n}\nconst KeypointMatch MATCH_NOT_FOUND = KeypointMatch(MATCH_MAX_INDEX, MATCH_MAX_DISTANCE);\n#endif'},7639:e=>{e.exports='#ifndef _KEYPOINTS_GLSL\n#define _KEYPOINTS_GLSL\n@include "math.glsl"\n@include "fixed-point.glsl"\n@include "float16.glsl"\n@include "pyramids.glsl"\nstruct Keypoint\n{\nvec2 position;\nfloat lod;\nfloat orientation;\nfloat score;\nuint flags;\n};\nstruct KeypointAddress\n{\nint base;\nint offset;\n};\nconst int MIN_KEYPOINT_SIZE = int(@MIN_KEYPOINT_SIZE@);\nconst int MAX_DESCRIPTOR_SIZE = int(@MAX_DESCRIPTOR_SIZE@);\nconst uint KPF_NONE = 0u;\nconst uint KPF_NULL = 1u;\nconst uint KPF_DISCARDED = 2u;\n#define encodeKeypointScore(score) encodeFloat16(score)\n#define decodeKeypointScore(encodedScore) decodeFloat16(encodedScore)\n#define encodeKeypointOrientation(angle) ((angle) * INV_PI_OVER_2 + 0.5f)\n#define decodeKeypointOrientation(value) ((value) * TWO_PI - PI)\n#define encodeNullKeypoint() (vec4(1.0f))\n#define encodeDiscardedKeypoint() (vec4(0.0f))\n#define isNullKeypoint(keypoint) ((((keypoint).flags) & KPF_NULL) != 0u)\n#define isDiscardedKeypoint(keypoint) ((((keypoint).flags) & KPF_DISCARDED) != 0u)\n#define isBadKeypoint(keypoint) ((keypoint).score < 0.0f)\n#define sizeofEncodedKeypoint(descriptorSize, extraSize) (MIN_KEYPOINT_SIZE + (descriptorSize) + (extraSize))\n#define sizeofEncodedKeypointHeader() sizeofEncodedKeypoint(0,0)\n#define findKeypointIndex(address, descriptorSize, extraSize) ((address).base / ((sizeofEncodedKeypoint((descriptorSize), (extraSize))) / 4))\nvec4 readKeypointData(sampler2D encodedKeypoints, int encoderLength, KeypointAddress address)\n{\nint rasterIndex = address.base + address.offset;\nvec4 data = pixelAt(encodedKeypoints, ivec2(rasterIndex % encoderLength, rasterIndex / encoderLength));\nreturn rasterIndex < encoderLength * encoderLength ? data : encodeNullKeypoint();\n}\nKeypointAddress findKeypointAddress(ivec2 thread, int encoderLength, int descriptorSize, int extraSize)\n{\nint threadRaster = thread.y * encoderLength + thread.x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nint keypointIndex = int(threadRaster / pixelsPerKeypoint);\nKeypointAddress address = KeypointAddress(\nkeypointIndex * pixelsPerKeypoint,\nthreadRaster % pixelsPerKeypoint\n);\nreturn address;\n}\nKeypoint decodeKeypoint(sampler2D encodedKeypoints, int encoderLength, KeypointAddress address)\n{\nKeypoint keypoint;\nKeypointAddress positionAddress = KeypointAddress(address.base, 0);\nKeypointAddress propertiesAddress = KeypointAddress(address.base, 1);\nvec4 rawEncodedPosition = readKeypointData(encodedKeypoints, encoderLength, positionAddress);\nivec4 encodedPosition = ivec4(rawEncodedPosition * 255.0f);\nkeypoint.position = fixtovec2(fixed2_t(\nencodedPosition.r | (encodedPosition.g << 8),\nencodedPosition.b | (encodedPosition.a << 8)\n));\nvec4 rawEncodedProperties = readKeypointData(encodedKeypoints, encoderLength, propertiesAddress);\nkeypoint.lod = decodeLod(rawEncodedProperties.r);\nkeypoint.orientation = decodeKeypointOrientation(rawEncodedProperties.g);\nkeypoint.score = decodeKeypointScore(rawEncodedProperties.ba);\nbool isNull = all(equal(rawEncodedPosition, vec4(1)));\nbool isDiscarded = all(equal(rawEncodedPosition + rawEncodedProperties, vec4(0)));\nkeypoint.score = (isNull || isDiscarded) ? -1.0f : keypoint.score;\nkeypoint.flags = KPF_NONE;\nkeypoint.flags |= KPF_NULL * uint(isNull);\nkeypoint.flags |= KPF_DISCARDED * uint(isDiscarded);\nreturn keypoint;\n}\nvec4 encodeKeypointPosition(vec2 position)\n{\nconst vec2 zeros = vec2(0.0f);\nfixed2_t pos = vec2tofix(max(position, zeros));\nfixed2_t lo = pos & 255;\nfixed2_t hi = (pos >> 8) & 255;\nreturn vec4(lo.x, hi.x, lo.y, hi.y) / 255.0f;\n}\n#endif'},431:e=>{e.exports="#ifndef _MATH_GLSL\n#define _MATH_GLSL\n#define TWO_PI 6.28318530718f\n#define PI 3.14159265359f\n#define PI_OVER_2 1.57079632679f\n#define PI_OVER_4 0.78539816339f\n#define INV_PI 0.3183098861837907f\n#define INV_PI_OVER_2 0.15915494309189535f\nconst highp float INFINITY = 1.0f / 0.0f;\nfloat fastAtan(float x)\n{\nfloat w = 1.0f - abs(x);\nreturn (w >= 0.0f) ? ((PI_OVER_4 + 0.273f * w) * x) :\n(sign(x) * PI_OVER_2 - (PI_OVER_4 + 0.273f * (1.0f - abs(1.0f / x))) / x);\n}\nfloat fastAtan2(float y, float x)\n{\nreturn (x == 0.0f) ? PI_OVER_2 * sign(y) : fastAtan(y / x) + float(x < 0.0f) * PI * sign(y);\n}\n#endif"},6822:e=>{e.exports="#ifndef _PLATFORM_GLSL\n#define _PLATFORM_GLSL\n#if @APPLE@\n#define APPLE 1\n#endif\n#if @APPLE_GPU@\n#define APPLE_GPU 1\n#endif\n#if @INTEL_GRAPHICS@\n#define INTEL_GRAPHICS 1\n#endif\n#endif"},2728:e=>{e.exports="#ifndef _PYRAMIDS_GLSL\n#define _PYRAMIDS_GLSL\n#define pyrPixel(pyr, lod) textureLod((pyr), texCoord, (lod))\n#define pyrPixelAtOffset(pyr, lod, pot, offset) textureLod((pyr), texCoord + ((pot) * vec2(offset)) / texSize, (lod))\n#define pyrPixelAt(pyr, pos, lod) textureLod((pyr), (vec2(pos) + vec2(0.5f)) / texSize, (lod))\n#define pyrPixelAtEx(pyr, pos, lod, pyrBaseSize) textureLod((pyr), (vec2(pos) + vec2(0.5f)) / vec2(pyrBaseSize), (lod))\n#define pyrSubpixelAtEx(pyr, pos, lod, pyrBaseSize) textureLod((pyr), ((pos) + vec2(0.5f)) / vec2(pyrBaseSize), (lod))\n#define pyrSubpixelAtExOffset(pyr, pos, lod, pot, offset, pyrBaseSize) textureLod((pyr), (((pos) + vec2(0.5f)) + ((pot) * vec2(offset))) / vec2(pyrBaseSize), (lod))\nconst int PYRAMID_MAX_LEVELS = int(@PYRAMID_MAX_LEVELS@);\nconst float F_PYRAMID_MAX_LEVELS = float(@PYRAMID_MAX_LEVELS@);\nconst float LOG2_PYRAMID_MAX_SCALE = float(@LOG2_PYRAMID_MAX_SCALE@);\n#define encodeLod(lod) ((LOG2_PYRAMID_MAX_SCALE + (lod)) / (LOG2_PYRAMID_MAX_SCALE + F_PYRAMID_MAX_LEVELS))\nfloat decodeLod(float encodedLod)\n{\nfloat lod = encodedLod * (LOG2_PYRAMID_MAX_SCALE + F_PYRAMID_MAX_LEVELS) - LOG2_PYRAMID_MAX_SCALE;\nreturn lod - lod * step(1.0f, encodedLod);\n}\n#define LOD_EPS 0.0625f\nconst float ENCODED_LOD_EPS = (LOD_EPS / (LOG2_PYRAMID_MAX_SCALE + F_PYRAMID_MAX_LEVELS));\n#define isSameLod(lod1, lod2) (abs((lod1) - (lod2)) < LOD_EPS)\n#define isSameEncodedLod(alpha1, alpha2) (abs((alpha1) - (alpha2)) < ENCODED_LOD_EPS)\n#endif"},6823:e=>{e.exports="#ifndef _SUBPIXEL_GLSL\n#define _SUBPIXEL_GLSL\n#define subpixelAt(image, pos) textureLod((image), ((pos) + vec2(0.5f)) / texSize, 0.0f)\nvec4 subpixelAtBI(sampler2D image, vec2 pos)\n{\nvec2 frc = fract(pos);\nvec2 ifrc = vec2(1.0f) - frc;\nvec2 p = (floor(pos) + vec2(0.5f)) / vec2(textureSize(image, 0));\nvec4 pix00 = textureLod(image, p, 0.0f);\nvec4 pix10 = textureLodOffset(image, p, 0.0f, ivec2(1,0));\nvec4 pix01 = textureLodOffset(image, p, 0.0f, ivec2(0,1));\nvec4 pix11 = textureLodOffset(image, p, 0.0f, ivec2(1,1));\nmat4 pix = mat4(pix00, pix10, pix01, pix11);\nvec4 mul = vec4(ifrc.x * ifrc.y, frc.x * ifrc.y, ifrc.x * frc.y, frc.x * frc.y);\nreturn pix * mul;\n}\n#endif"},1341:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D inputEncodedKeypoints;\nuniform int inputDescriptorSize;\nuniform int inputExtraSize;\nuniform int inputEncoderLength;\nuniform int outputDescriptorSize;\nuniform int outputExtraSize;\nuniform int outputEncoderLength;\nconst vec4 EMPTY_DESCRIPTOR = vec4(0.0f);\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress myAddress = findKeypointAddress(thread, outputEncoderLength, outputDescriptorSize, outputExtraSize);\nint myIndex = findKeypointIndex(myAddress, outputDescriptorSize, outputExtraSize);\nint headerSize = sizeofEncodedKeypointHeader();\nbool isDescriptor = (myAddress.offset >= (headerSize + outputExtraSize) / 4);\nint addressOffset = myAddress.offset;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(inputDescriptorSize, inputExtraSize) / 4;\nKeypointAddress otherAddress = KeypointAddress(myIndex * pixelsPerKeypoint, addressOffset);\ncolor = isDescriptor ? EMPTY_DESCRIPTOR : readKeypointData(inputEncodedKeypoints, inputEncoderLength, otherAddress);\n}'},7833:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D inputEncodedKeypoints;\nuniform int inputDescriptorSize;\nuniform int inputExtraSize;\nuniform int inputEncoderLength;\nuniform int outputDescriptorSize;\nuniform int outputExtraSize;\nuniform int outputEncoderLength;\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress myAddress = findKeypointAddress(thread, outputEncoderLength, outputDescriptorSize, outputExtraSize);\nint myIndex = findKeypointIndex(myAddress, outputDescriptorSize, outputExtraSize);\nint headerSize = sizeofEncodedKeypointHeader();\nbool isHead = (myAddress.offset < headerSize / 4);\nbool isDescriptor = (myAddress.offset >= (headerSize + outputExtraSize) / 4);\nbool isExtra = (!isHead && !isDescriptor);\nint numberOfExtraPixels = outputExtraSize / 4;\nint addressOffset = myAddress.offset - int(isDescriptor) * numberOfExtraPixels;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(inputDescriptorSize, inputExtraSize) / 4;\nKeypointAddress otherAddress = KeypointAddress(myIndex * pixelsPerKeypoint, addressOffset);\ncolor = isExtra ? vec4(0.0f) : readKeypointData(inputEncodedKeypoints, inputEncoderLength, otherAddress);\n}'},2352:e=>{e.exports='@include "keypoints.glsl"\nuniform mat3 homography;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\ncolor = pixel;\nif(address.offset != 0)\nreturn;\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\nif(isBadKeypoint(keypoint))\nreturn;\nvec3 pos3 = homography * vec3(keypoint.position, 1.0f);\ncolor = encodeKeypointPosition(pos3.xy / pos3.z);\n}'},7541:e=>{e.exports='@include "keypoints.glsl"\n@include "keypoint-descriptors.glsl"\n@include "keypoint-matches.glsl"\nuniform sampler2D encodedMatches;\nuniform sampler2D encodedFilters;\nuniform int matcherLength;\nuniform sampler2D dbEncodedKeypoints;\nuniform int dbDescriptorSize;\nuniform int dbExtraSize;\nuniform int dbEncoderLength;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int passId;\n#ifndef NUMBER_OF_KEYPOINTS_PER_PASS\n#error Undefined NUMBER_OF_KEYPOINTS_PER_PASS\n#endif\nconst int INFINITE_DISTANCE = MATCH_MAX_DISTANCE + 1;\nvoid main()\n{\nivec2 thread = threadLocation();\nint keypointIndex = thread.x + thread.y * matcherLength;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\ncolor = encodeKeypointMatch(MATCH_NOT_FOUND);\nif(isBadKeypoint(keypoint))\nreturn;\nKeypointMatch bestMatch = decodeKeypointMatch(threadPixel(encodedMatches));\nKeypointMatch filterMatch = decodeKeypointMatch(threadPixel(encodedFilters));\nuint[DESCRIPTOR_SIZE] descriptor = readKeypointDescriptor(encodedKeypoints, descriptorSize, extraSize, encoderLength, address);\nuint[DESCRIPTOR_SIZE] dbDescriptor;\nint dbPixelsPerKeypoint = sizeofEncodedKeypoint(dbDescriptorSize, dbExtraSize) / 4;\nfor(int i = 0; i < NUMBER_OF_KEYPOINTS_PER_PASS; i++) {\nint dbKeypointIndex = passId * NUMBER_OF_KEYPOINTS_PER_PASS + i;\nKeypointAddress dbAddress = KeypointAddress(dbKeypointIndex * dbPixelsPerKeypoint, 0);\nKeypoint dbKeypoint = decodeKeypoint(dbEncodedKeypoints, dbEncoderLength, dbAddress);\ndbDescriptor = readKeypointDescriptor(dbEncodedKeypoints, dbDescriptorSize, dbExtraSize, dbEncoderLength, dbAddress);\nint dist = !isBadKeypoint(dbKeypoint) ? distanceBetweenKeypointDescriptors(descriptor, dbDescriptor) : INFINITE_DISTANCE;\nbestMatch.index = all(bvec2(\ndist < bestMatch.dist || (dist == bestMatch.dist && dbKeypointIndex > bestMatch.index),\ndist > filterMatch.dist || (dist == filterMatch.dist && dbKeypointIndex < filterMatch.index)\n)) ? dbKeypointIndex : bestMatch.index;\nbestMatch.dist = dbKeypointIndex == bestMatch.index ? dist : bestMatch.dist;\n}\ncolor = encodeKeypointMatch(bestMatch);\n}'},4868:e=>{e.exports='@include "keypoints.glsl"\nuniform int imageWidth;\nuniform int imageHeight;\nuniform int borderTop;\nuniform int borderRight;\nuniform int borderBottom;\nuniform int borderLeft;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress addr = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, addr);\nvec2 p = keypoint.position;\nbool withinBorder = any(lessThan(\nvec4(p.x, p.y, -p.x, -p.y),\nvec4(borderLeft, borderTop, borderRight - (imageWidth - 1), borderBottom - (imageHeight - 1))\n));\nvec4 pixel = threadPixel(encodedKeypoints);\nvec4 nullPixel = encodeNullKeypoint();\ncolor = withinBorder ? nullPixel : pixel;\n}'},5591:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int maxKeypoints;\nvoid main()\n{\nivec2 thread = threadLocation();\nint newEncoderLength = outputSize().x;\nKeypointAddress address = findKeypointAddress(thread, newEncoderLength, descriptorSize, extraSize);\nint index = findKeypointIndex(address, descriptorSize, extraSize);\nvec4 pixel = readKeypointData(encodedKeypoints, encoderLength, address);\ncolor = index < maxKeypoints ? pixel : encodeNullKeypoint();\n}'},191:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedKeypointsA;\nuniform int encoderLengthA;\nuniform sampler2D encodedKeypointsB;\nuniform int encoderLengthB;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform float threshold;\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint index = findKeypointIndex(address, descriptorSize, extraSize);\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nvec4 data = readKeypointData(encodedKeypointsA, encoderLengthA, address);\ncolor = data;\nif(address.offset >= sizeofEncodedKeypointHeader() / 4)\nreturn;\nKeypoint keypointA = decodeKeypoint(encodedKeypointsA, encoderLengthA, address);\nKeypoint keypointB = decodeKeypoint(encodedKeypointsB, encoderLengthB, address);\ncolor = encodeNullKeypoint();\nif(isNullKeypoint(keypointA) && isNullKeypoint(keypointB))\nreturn;\ncolor = encodeDiscardedKeypoint();\nif(isDiscardedKeypoint(keypointA) || isDiscardedKeypoint(keypointB))\nreturn;\ncolor = encodeDiscardedKeypoint();\nif(isNullKeypoint(keypointA) || isNullKeypoint(keypointB))\nreturn;\nvec2 delta = keypointA.position - keypointB.position;\nbool shouldKeep = (dot(delta, delta) <= threshold * threshold);\ncolor = shouldKeep ? data : encodeDiscardedKeypoint();\n}'},5467:e=>{e.exports='@include "float16.glsl"\nuniform sampler2D offsetsImage;\nuniform ivec2 imageSize;\n#ifndef MAX_ITERATIONS\n#error Undefined MAX_ITERATIONS\n#endif\n#define decodeSkipOffset(pixel) (int((pixel).g * 255.0f) | (int((pixel).a * 255.0f) << 8))\n#define encodeSkipOffset(offset) (vec2((offset) & 255, (offset) >> 8) / 255.0f)\nvoid main()\n{\nvec4 pixel = threadPixel(offsetsImage);\nivec2 thread = threadLocation();\nint rasterIndex = thread.y * imageSize.x + thread.x;\nint offset = decodeSkipOffset(pixel);\nint totalOffset = offset;\nvec2 encodedScore = pixel.rb;\nivec2 pos = thread; int allow = 1;\n@unroll\nfor(int i = 0; i < MAX_ITERATIONS; i++) {\nallow *= int(pos.y < imageSize.y) * int(isEncodedFloat16Zero(pixel.rb));\nrasterIndex += allow * offset;\npos = ivec2(rasterIndex % imageSize.x, rasterIndex / imageSize.x);\npixel = pixelAt(offsetsImage, pos);\noffset = decodeSkipOffset(pixel);\ntotalOffset += allow * offset;\n}\ntotalOffset = min(totalOffset, 65535);\ncolor.rb = encodedScore;\ncolor.ga = encodeSkipOffset(totalOffset);\n}'},336:e=>{e.exports='@include "float16.glsl"\nuniform sampler2D corners;\nuniform ivec2 imageSize;\nvoid main()\n{\nvec4 pixel = threadPixel(corners);\nivec2 pos = threadLocation();\nvec2 encodedScore = pixel.rb;\nint offset = 0, allow = 1, jumped = 0;\n#define READ(j) ; \\\nallow *= int(pos.y < imageSize.y) * int(isEncodedFloat16Zero(pixel.rb)); \\\noffset += allow; \\\npos.x = (pos.x + 1) % imageSize.x; \\\npos.y += int(pos.x == 0); \\\npixel = (0 != (jumped |= int(pos.x == 0))) ? pixelAtShortOffset(corners, ivec2((j),1)) : pixelAtShortOffset(corners, ivec2((j),0))\nREAD(1); READ(2); READ(3); READ(4); READ(5); READ(6); READ(7);\ncolor.rb = encodedScore;\ncolor.ga = vec2(offset, 0) / 255.0f;\n}'},8968:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D offsetsImage;\nuniform ivec2 imageSize;\nuniform int passId;\nuniform int numPasses;\nuniform int keypointLimit;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#define decodeSkipOffset(pixel) (int((pixel).g * 255.0f) | (int((pixel).a * 255.0f) << 8))\nbool findQthKeypoint(int q, int p, inout ivec2 position, out vec4 pixel)\n{\nint notFirstPass = int(passId > 0);\nposition *= notFirstPass;\np |= -(1 - notFirstPass);\np -= notFirstPass;\nint rasterIndex = position.y * imageSize.x + position.x;\nwhile(position.y < imageSize.y && p != q) {\nposition = ivec2(rasterIndex % imageSize.x, rasterIndex / imageSize.x);\npixel = texelFetch(offsetsImage, position, 0);\np += int(!isEncodedFloat16Zero(pixel.rb));\nrasterIndex += max(1, decodeSkipOffset(pixel));\n}\nreturn (p == q);\n}\nvoid main()\n{\nivec2 thread = threadLocation();\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint q = findKeypointIndex(address, descriptorSize, extraSize);\ncolor = vec4(0.0f);\nif(address.offset != 0)\nreturn;\ncolor = threadPixel(encodedKeypoints);\nint numPixels = encoderLength * encoderLength;\nint maxKeypoints = numPixels / pixelsPerKeypoint;\nint maxKeypointsPerPass = maxKeypoints / numPasses + int(maxKeypoints % numPasses != 0);\nint targetPassId = q / maxKeypointsPerPass;\nif(passId != targetPassId)\nreturn;\nint lastIndexFromPrevPass = passId * maxKeypointsPerPass - 1;\nKeypointAddress lastAddressFromPrevPass = KeypointAddress(max(0, lastIndexFromPrevPass) * pixelsPerKeypoint, 0);\nKeypoint lastKeypointFromPrevPass = decodeKeypoint(encodedKeypoints, encoderLength, lastAddressFromPrevPass);\nivec2 position = passId > 0 ? ivec2(lastKeypointFromPrevPass.position) : ivec2(0);\nvec4 pixel;\ncolor = encodeNullKeypoint();\nif(q >= min(maxKeypoints, keypointLimit) || !findQthKeypoint(q, lastIndexFromPrevPass, position, pixel))\nreturn;\ncolor = encodeKeypointPosition(vec2(position));\n}'},1733:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D corners;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvoid main()\n{\nivec2 thread = threadLocation();\nvec4 pixel = threadPixel(encodedKeypoints);\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint q = findKeypointIndex(address, descriptorSize, extraSize);\ncolor = pixel;\nif(address.offset != 1)\nreturn;\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\nvec4 kpix = pixelAt(corners, ivec2(keypoint.position));\nkeypoint.score = decodeFloat16(kpix.rb);\ncolor.r = kpix.a;\ncolor.g = encodeKeypointOrientation(0.0f);\ncolor.ba = encodeKeypointScore(keypoint.score);\n}'},9674:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D corners;\nuniform mediump usampler2D lookupTable;\nuniform int stride;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int encoderCapacity;\nconst uvec2 NULL_ELEMENT = uvec2(0xFFFFu);\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint index = findKeypointIndex(address, descriptorSize, extraSize);\nivec2 pos = ivec2(index % stride, index / stride);\nuvec4 entry = texelFetch(lookupTable, pos, 0);\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nint rasterIndex = address.base + address.offset;\nint numberOfPixels = encoderLength * encoderLength;\nint numberOfValidPixels = numberOfPixels - (numberOfPixels % pixelsPerKeypoint);\nint maxEncoderCapacity = numberOfValidPixels / pixelsPerKeypoint;\ncolor = encodeNullKeypoint();\nif(all(equal(entry.xy, NULL_ELEMENT)) || index >= min(encoderCapacity, maxEncoderCapacity))\nreturn;\ncolor = encodeKeypointPosition(vec2(entry.xy));\nif(address.offset == 0)\nreturn;\ncolor = vec4(0.0f);\nif(address.offset >= sizeofEncodedKeypointHeader() / 4)\nreturn;\nvec4 pixel = texelFetch(corners, ivec2(entry.xy), 0);\nvec2 encodedScore = encodeKeypointScore(decodeFloat16(pixel.rb));\nfloat encodedOrientation = encodeKeypointOrientation(0.0f);\nfloat encodedLod = pixel.a;\ncolor = vec4(encodedLod, encodedOrientation, encodedScore);\n}'},2090:e=>{e.exports='@include "keypoints.glsl"\nvoid main()\n{\ncolor = encodeNullKeypoint();\n}'},1855:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\nuniform sampler2D corners;\nuniform sampler2D pyramid;\nuniform float lod;\nuniform int threshold;\n#define USE_VARYINGS 1\n#if !defined(FAST_TYPE)\n#error Undefined FAST_TYPE\n#elif FAST_TYPE == 916\nin vec2 v_pix0, v_pix1, v_pix2, v_pix3, v_pix4, v_pix5, v_pix6, v_pix7,\nv_pix8, v_pix9, v_pix10,v_pix11,v_pix12,v_pix13,v_pix14,v_pix15;\n#else\n#error Invalid FAST_TYPE\n#endif\n#define PIX(x,y) pyrPixelAtOffset(pyramid, lod, pot, ivec2((x),(y))).g\n#define XIP(v) textureLod(pyramid, (v), lod).g\nvoid main()\n{\nfloat pixel = threadPixel(pyramid).g;\nvec4 prev = threadPixel(corners);\nivec2 thread = threadLocation();\nivec2 size = outputSize();\nfloat pot = exp2(lod);\nfloat t = float(clamp(threshold, 0, 255)) / 255.0f;\nfloat ct = pixel + t, c_t = pixel - t;\ncolor = vec4(prev.r, pixel, prev.ba);\n#if FAST_TYPE == 916\nconst ivec4 margin = ivec4(3, 3, 4, 4);\nif(any(lessThan(ivec4(thread, size - thread), margin)))\nreturn;\n#if USE_VARYINGS\nfloat p0 = XIP(v_pix0), p4 = XIP(v_pix4), p8 = XIP(v_pix8), p12 = XIP(v_pix12);\n#else\nfloat p0 = PIX(0,3), p4 = PIX(3,0), p8 = PIX(0,-3), p12 = PIX(-3,0);\n#endif\nbvec4 brighter = bvec4(p0 > ct, p4 > ct, p8 > ct, p12 > ct);\nbvec4 darker = bvec4(p0 < c_t, p4 < c_t, p8 < c_t, p12 < c_t);\nbvec4 bpairs = bvec4(all(brighter.xy), all(brighter.yz), all(brighter.zw), all(brighter.wx));\nbvec4 dpairs = bvec4(all(darker.xy), all(darker.yz), all(darker.zw), all(darker.wx));\nif(!(any(bpairs) || any(dpairs)))\nreturn;\n#if USE_VARYINGS\nfloat p1 = XIP(v_pix1), p2 = XIP(v_pix2), p3 = XIP(v_pix3),\np5 = XIP(v_pix5), p6 = XIP(v_pix6), p7 = XIP(v_pix7),\np9 = XIP(v_pix9), p10 = XIP(v_pix10), p11 = XIP(v_pix11),\np13 = XIP(v_pix13), p14 = XIP(v_pix14), p15 = XIP(v_pix15);\n#else\nfloat p1 = PIX(1,3), p2 = PIX(2,2), p3 = PIX(3,1),\np5 = PIX(3,-1), p6 = PIX(2,-2), p7 = PIX(1,-3),\np9 = PIX(-1,-3), p10 = PIX(-2,-2), p11 = PIX(-3,-1),\np13 = PIX(-3,1), p14 = PIX(-2,2), p15 = PIX(-1,3);\n#endif\nbool A=(p0>ct),B=(p1>ct),C=(p2>ct),D=(p3>ct),E=(p4>ct),F=(p5>ct),G=(p6>ct),H=(p7>ct),I=(p8>ct),J=(p9>ct),K=(p10>ct),L=(p11>ct),M=(p12>ct),N=(p13>ct),O=(p14>ct),P=(p15>ct),a=(p0 prevScore ? thisResult : color.rba;\n#endif\n}'},4824:e=>{e.exports="uniform mediump float lod;\n#if !defined(FAST_TYPE)\n#error Undefined FAST_TYPE\n#elif FAST_TYPE == 916\nout vec2 v_pix0, v_pix1, v_pix2, v_pix3, v_pix4, v_pix5, v_pix6, v_pix7,\nv_pix8, v_pix9, v_pix10,v_pix11,v_pix12,v_pix13,v_pix14,v_pix15;\n#else\n#error Invalid FAST_TYPE\n#endif\n#define PIX(x,y) (texCoord + ((pot) * vec2((x),(y))) / texSize)\nvoid vsmain()\n{\nfloat pot = exp2(lod);\n#if FAST_TYPE == 916\nv_pix0 = PIX(0,3); v_pix1 = PIX(1,3), v_pix2 = PIX(2,2), v_pix3 = PIX(3,1);\nv_pix4 = PIX(3,0); v_pix5 = PIX(3,-1), v_pix6 = PIX(2,-2), v_pix7 = PIX(1,-3);\nv_pix8 = PIX(0,-3); v_pix9 = PIX(-1,-3), v_pix10 = PIX(-2,-2), v_pix11 = PIX(-3,-1);\nv_pix12 = PIX(-3,0); v_pix13 = PIX(-3,1), v_pix14 = PIX(-2,2), v_pix15 = PIX(-1,3);\n#endif\n}"},2381:e=>{e.exports='@include "keypoints.glsl"\n@include "keypoint-descriptors.glsl"\nuniform sampler2D encodedKeypointsA;\nuniform int encoderLengthA;\nuniform sampler2D encodedKeypointsB;\nuniform int encoderLengthB;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int threshold;\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint index = findKeypointIndex(address, descriptorSize, extraSize);\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nvec4 data = readKeypointData(encodedKeypointsA, encoderLengthA, address);\ncolor = data;\nif(address.offset >= sizeofEncodedKeypointHeader() / 4)\nreturn;\nKeypoint keypointA = decodeKeypoint(encodedKeypointsA, encoderLengthA, address);\nKeypoint keypointB = decodeKeypoint(encodedKeypointsB, encoderLengthB, address);\ncolor = encodeNullKeypoint();\nif(isNullKeypoint(keypointA) && isNullKeypoint(keypointB))\nreturn;\ncolor = encodeDiscardedKeypoint();\nif(isDiscardedKeypoint(keypointA) || isDiscardedKeypoint(keypointB))\nreturn;\ncolor = encodeDiscardedKeypoint();\nif(isNullKeypoint(keypointA) || isNullKeypoint(keypointB))\nreturn;\nuint[DESCRIPTOR_SIZE] descriptorA, descriptorB;\ndescriptorA = readKeypointDescriptor(encodedKeypointsA, descriptorSize, extraSize, encoderLengthA, address);\ndescriptorB = readKeypointDescriptor(encodedKeypointsB, descriptorSize, extraSize, encoderLengthB, address);\nint dist = distanceBetweenKeypointDescriptors(descriptorA, descriptorB);\nbool shouldKeep = (dist <= threshold);\ncolor = shouldKeep ? data : encodeDiscardedKeypoint();\n}'},6060:e=>{e.exports='@include "float16.glsl"\nuniform sampler2D corners;\nuniform sampler2D maxScore;\nuniform float quality;\nvoid main()\n{\nvec4 pixel = threadPixel(corners);\nfloat score = decodeFloat16(pixel.rb);\nfloat maxval = decodeFloat16(threadPixel(maxScore).rb);\nfloat threshold = maxval * clamp(quality, 0.0f, 1.0f);\ncolor = pixel;\ncolor.rb = score >= threshold ? color.rb : encodeFloat16(0.0f);\n}'},9974:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\n@include "filters.glsl"\n#if !defined(WINDOW_SIZE)\n#error Undefined WINDOW_SIZE\n#endif\n#define WINDOW_RADIUS ((WINDOW_SIZE - 1) / 2)\nuniform sampler2D corners;\nuniform sampler2D pyramid;\nuniform sampler2D derivatives;\nuniform float lod;\nuniform float lodStep;\nuniform float gaussian[@WINDOW_SIZE@];\n#define G(x) gaussian[(x) + WINDOW_RADIUS]\n#define W(x,y) (G(x) * G(y))\n#define H(ox,oy) dpix = pixelAtShortOffset(derivatives, ivec2((ox),(oy))); \\\ndf = (1.0f + lod) * decodePairOfFloat16(dpix); \\\nh += vec3(df.x * df.x, df.x * df.y, df.y * df.y) * W((ox),(oy))\nvoid main()\n{\nfloat intensity = 0.0f;\nivec2 thread = threadLocation();\nvec4 pixel = threadPixel(corners);\nvec4 dpix = vec4(0.0f);\nvec2 df = vec2(0.0f);\nvec3 h = vec3(0.0f);\ncolor = pixel;\n#if WINDOW_SIZE == 1\nH(0,0);\n#elif WINDOW_SIZE == 3\nH(-1,-1); H(0,-1); H(1,-1);\nH(-1,0); H(0,0); H(1,0);\nH(-1,1); H(0,1); H(1,1);\n#elif WINDOW_SIZE == 5\nH(-2,-2); H(-1,-2); H(0,-2); H(1,-2); H(2,-2);\nH(-2,-1); H(-1,-1); H(0,-1); H(1,-1); H(2,-1);\nH(-2,0); H(-1,0); H(0,0); H(1,0); H(2,0);\nH(-2,1); H(-1,1); H(0,1); H(1,1); H(2,1);\nH(-2,2); H(-1,2); H(0,2); H(1,2); H(2,2);\n#elif WINDOW_SIZE == 7\nH(-3,-3); H(-2,-3); H(-1,-3); H(0,-3); H(1,-3); H(2,-3); H(3,-3);\nH(-3,-2); H(-2,-2); H(-1,-2); H(0,-2); H(1,-2); H(2,-2); H(3,-2);\nH(-3,-1); H(-2,-1); H(-1,-1); H(0,-1); H(1,-1); H(2,-1); H(3,-1);\nH(-3,0); H(-2,0); H(-1,0); H(0,0); H(1,0); H(2,0); H(3,0);\nH(-3,1); H(-2,1); H(-1,1); H(0,1); H(1,1); H(2,1); H(3,1);\nH(-3,2); H(-2,2); H(-1,2); H(0,2); H(1,2); H(2,2); H(3,2);\nH(-3,3); H(-2,3); H(-1,3); H(0,3); H(1,3); H(2,3); H(3,3);\n#else\n#error Invalid WINDOW_SIZE\n#endif\nfloat response = 0.5f * (h.x + h.z - sqrt((h.x - h.z) * (h.x - h.z) + 4.0f * h.y * h.y));\nresponse /= float(WINDOW_SIZE * WINDOW_SIZE);\nfloat lodPlus = min(float(PYRAMID_MAX_LEVELS - 1), lod + lodStep);\nfloat currentScaleStrength = abs(laplacian(pyramid, vec2(thread), lod));\nfloat previousScaleStrength = abs(laplacian(pyramid, vec2(thread), lodPlus));\nfloat previousResponse = decodeFloat16(pixel.rb);\nvec4 result = vec4(encodeFloat16(response), encodeLod(lod), intensity);\ncolor.rbag = (currentScaleStrength >= previousScaleStrength || previousResponse == 0.0f) ? result : pixel.rbag;\n}'},3047:e=>{e.exports='@include "keypoint-matches.glsl"\nvoid main()\n{\n#if ENCODE_FILTERS != 0\nKeypointMatch initial = KeypointMatch(MATCH_MAX_INDEX, 0);\n#else\nKeypointMatch initial = KeypointMatch(MATCH_MAX_INDEX, MATCH_MAX_DISTANCE);\n#endif\ncolor = encodeKeypointMatch(initial);\n}'},3266:e=>{e.exports='@include "keypoint-matches.glsl"\nuniform sampler2D encodedMatches;\nuniform sampler2D encodedKthMatches;\nuniform int numberOfMatchesPerKeypoint;\nuniform int kthMatch;\nvoid main()\n{\nivec2 thread = threadLocation();\nivec2 matcherSize = textureSize(encodedMatches, 0);\nivec2 kthMatcherSize = textureSize(encodedKthMatches, 0);\nint rasterIndex = thread.y * matcherSize.x + thread.x;\nint matchIndex = rasterIndex / numberOfMatchesPerKeypoint;\nint matchCell = rasterIndex % numberOfMatchesPerKeypoint;\ncolor = threadPixel(encodedMatches);\nif(matchCell != kthMatch)\nreturn;\ncolor = encodeKeypointMatch(MATCH_NOT_FOUND);\nif(matchIndex >= kthMatcherSize.x * kthMatcherSize.y)\nreturn;\nivec2 pos = ivec2(matchIndex % kthMatcherSize.x, matchIndex / kthMatcherSize.x);\ncolor = texelFetch(encodedKthMatches, pos, 0);\n}'},8018:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\n@include "filters.glsl"\nuniform sampler2D corners;\nuniform sampler2D pyramid;\nuniform float lodStep;\nuniform float lodOffset;\nvoid main()\n{\nivec2 thread = threadLocation();\nvec4 pixel = threadPixel(corners);\nfloat lod = decodeLod(pixel.a);\nfloat lodMinus = max(0.0f, lod - lodStep + lodOffset);\nfloat lodPlus = min(float(PYRAMID_MAX_LEVELS - 1), lod + lodStep + lodOffset);\nfloat lapMinus = laplacian(pyramid, vec2(thread), lodMinus);\nfloat lapPlus = abs(lodPlus - lodMinus) < 1e-5 ? lapMinus : laplacian(pyramid, vec2(thread), lodPlus);\ncolor = encodePairOfFloat16(vec2(lapMinus, lapPlus));\n}'},3168:e=>{e.exports='@include "keypoints.glsl"\n@include "float16.glsl"\nuniform sampler2D nextPyramid;\nuniform sampler2D prevPyramid;\nuniform sampler2D encodedFlow;\nuniform sampler2D prevKeypoints;\nuniform int level;\nuniform int depth;\nuniform int numberOfIterations;\nuniform float discardThreshold;\nuniform float epsilon;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#ifndef WINDOW_SIZE\n#error Undefined WINDOW_SIZE\n#endif\n#define NEXT_IMAGE 1\n#define PREV_IMAGE 0\nconst int WINDOW_RADIUS = (WINDOW_SIZE - 1) / 2;\nconst int WINDOW_SIZE_SQUARED = (WINDOW_SIZE) * (WINDOW_SIZE);\nconst int WINDOW_SIZE_PLUS = (WINDOW_SIZE) + 2;\nconst int WINDOW_SIZE_PLUS_SQUARED = WINDOW_SIZE_PLUS * WINDOW_SIZE_PLUS;\nconst int DBL_WINDOW_SIZE_PLUS_SQUARED = 2 * WINDOW_SIZE_PLUS_SQUARED;\nconst int WINDOW_RADIUS_PLUS = (WINDOW_SIZE_PLUS - 1) / 2;\nconst highp float FLT_SCALE = 9.5367431640625e-7;\nconst highp float FLT_EPSILON = 0.00000011920929f;\nint pixelBuffer[DBL_WINDOW_SIZE_PLUS_SQUARED];\n#define prevPixel(index) pixelBuffer[(index)]\n#define nextPixel(index) pixelBuffer[WINDOW_SIZE_PLUS_SQUARED + (index)]\n#define pixelIndex(i, j) (((j) + WINDOW_RADIUS_PLUS) * WINDOW_SIZE_PLUS + ((i) + WINDOW_RADIUS_PLUS))\nivec2 derivBuffer[WINDOW_SIZE_SQUARED];\n#define derivativesAt(x, y) derivBuffer[((y) + WINDOW_RADIUS) * WINDOW_SIZE + ((x) + WINDOW_RADIUS)]\nvoid readWindow(vec2 center, float lod)\n{\nconst int r = WINDOW_RADIUS;\nivec2 pyrBaseSize = textureSize(prevPyramid, 0);\nfloat pot = exp2(lod);\nivec2 offset; int idx;\n#define readPixelsAt(ox, oy) offset = ivec2((ox), (oy)); \\\nidx = pixelIndex(offset.x, offset.y); \\\nnextPixel(idx) = int(255.0f * pyrSubpixelAtExOffset(nextPyramid, center, lod, pot, offset, pyrBaseSize).g); \\\nprevPixel(idx) = int(255.0f * pyrSubpixelAtExOffset(prevPyramid, center, lod, pot, offset, pyrBaseSize).g)\nfor(int j = 0; j < WINDOW_SIZE; j++) {\nfor(int i = 0; i < WINDOW_SIZE; i++) {\nreadPixelsAt(i-r, j-r);\n}\n}\nint r1 = r+1;\nfor(int k = 0; k < WINDOW_SIZE; k++) {\nreadPixelsAt(-r1, k-r);\nreadPixelsAt( r1, k-r);\nreadPixelsAt(k-r,-r1);\nreadPixelsAt(k-r, r1);\n}\nreadPixelsAt(-r1,-r1);\nreadPixelsAt( r1,-r1);\nreadPixelsAt(-r1, r1);\nreadPixelsAt( r1, r1);\n}\nivec2 computeDerivatives(int imageCode, ivec2 offset)\n{\nconst mat3 dx = mat3(\n3, 0, -3,\n10, 0, -10,\n3, 0, -3\n);\nconst mat3 dy = mat3(\n3, 10, 3,\n0, 0, 0,\n-3, -10, -3\n);\nint indexOffset = imageCode * WINDOW_SIZE_PLUS_SQUARED;\nmat3 window = mat3(\npixelBuffer[indexOffset + pixelIndex(offset.x-1, offset.y-1)],\npixelBuffer[indexOffset + pixelIndex(offset.x+0, offset.y-1)],\npixelBuffer[indexOffset + pixelIndex(offset.x+1, offset.y-1)],\npixelBuffer[indexOffset + pixelIndex(offset.x-1, offset.y+0)],\n0.0f,\npixelBuffer[indexOffset + pixelIndex(offset.x+1, offset.y+0)],\npixelBuffer[indexOffset + pixelIndex(offset.x-1, offset.y+1)],\npixelBuffer[indexOffset + pixelIndex(offset.x+0, offset.y+1)],\npixelBuffer[indexOffset + pixelIndex(offset.x+1, offset.y+1)]\n);\nmat3 fx = matrixCompMult(dx, window);\nmat3 fy = matrixCompMult(dy, window);\nconst vec3 ones = vec3(1.0f);\nreturn ivec2(\ndot(fx[0], ones) + dot(fx[1], ones) + dot(fx[2], ones),\ndot(fy[0], ones) + dot(fy[1], ones) + dot(fy[2], ones)\n);\n}\nint readBufferedPixel(int imageCode, ivec2 offset)\n{\nconst int r = WINDOW_RADIUS;\noffset = clamp(offset, -r, r);\nint indexOffset = imageCode * WINDOW_SIZE_PLUS_SQUARED;\nreturn pixelBuffer[indexOffset + pixelIndex(offset.x, offset.y)];\n}\nint readBufferedSubpixel(int imageCode, vec2 offset)\n{\nivec2 p = ivec2(floor(offset));\nvec2 frc = fract(offset);\nvec2 ifrc = vec2(1.0f) - frc;\nvec4 pix = vec4(\nreadBufferedPixel(imageCode, p),\nreadBufferedPixel(imageCode, p + ivec2(1,0)),\nreadBufferedPixel(imageCode, p + ivec2(0,1)),\nreadBufferedPixel(imageCode, p + ivec2(1,1))\n);\nvec4 sub = vec4(\nifrc.x * ifrc.y,\nfrc.x * ifrc.y,\nifrc.x * frc.y,\nfrc.x * frc.y\n);\nreturn int(0.5f + dot(sub*pix, vec4(1.0f)));\n}\nvec2 computeMismatch(vec2 pyrGuess, vec2 localGuess)\n{\nconst int r = WINDOW_RADIUS;\nint timeDerivative;\nivec2 mismatch = ivec2(0);\nint x, y, _x, _y;\nvec2 d = pyrGuess + localGuess;\n#define innerLoop() \\\nfor(_x = 0; _x < WINDOW_SIZE; _x++) { \\\nx = _x - r; y = _y - r; \\\ntimeDerivative = ( \\\nreadBufferedSubpixel(NEXT_IMAGE, vec2(x, y) + d) - \\\nreadBufferedPixel(PREV_IMAGE, ivec2(x, y)) \\\n); \\\nmismatch += derivativesAt(x, y) * timeDerivative; \\\n}\n@unroll\nfor(_y = 0; _y < WINDOW_SIZE; _y++) {\ninnerLoop();\n}\nreturn vec2(mismatch) * FLT_SCALE;\n}\nbool isInsideImage(vec2 position)\n{\nvec2 imageSize = vec2(textureSize(nextPyramid, 0));\nvec2 border = vec2(WINDOW_SIZE);\nreturn all(bvec4(\ngreaterThanEqual(position, border),\nlessThan(position, imageSize - border)\n));\n}\nvoid main()\n{\nvec4 pixel = threadPixel(encodedFlow);\nivec2 thread = threadLocation();\nfloat windowArea = float(WINDOW_SIZE * WINDOW_SIZE);\nconst int r = WINDOW_RADIUS;\nint keypointIndex = thread.x + thread.y * outputSize().x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(prevKeypoints, encoderLength, address);\ncolor = encodeNullPairOfFloat16();\nif(isNullKeypoint(keypoint))\nreturn;\ncolor = encodeDiscardedPairOfFloat16();\nif(isBadKeypoint(keypoint))\nreturn;\nvec2 pyrGuess = (level < depth - 1) ? decodePairOfFloat16(pixel) : vec2(0.0f);\npyrGuess *= 2.0f;\nreadWindow(keypoint.position, float(level));\nivec2 derivatives;\nivec3 harris3i = ivec3(0);\nfor(int j = 0; j < WINDOW_SIZE; j++) {\nfor(int i = 0; i < WINDOW_SIZE; i++) {\nderivatives = computeDerivatives(PREV_IMAGE, ivec2(i-r, j-r));\nharris3i += ivec3(\nderivatives.x * derivatives.x,\nderivatives.x * derivatives.y,\nderivatives.y * derivatives.y\n);\nderivativesAt(i-r, j-r) = derivatives;\n}\n}\nhighp vec3 harris = vec3(harris3i) * FLT_SCALE;\nhighp mat2 invHarris = mat2(harris.z, -harris.y, -harris.y, harris.x);\nhighp float det = harris.x * harris.z - harris.y * harris.y;\nhighp float invDet = abs(det) >= FLT_EPSILON ? 1.0f / det : 0.0f;\nhighp float minEigenvalue = 0.5f * ((harris.x + harris.z) - sqrt(\n(harris.x - harris.z) * (harris.x - harris.z) + 4.0f * (harris.y * harris.y)\n));\nint niceNumbers = int(abs(det) >= FLT_EPSILON && minEigenvalue >= discardThreshold * windowArea);\nbool goodKeypoint = (level > 0) || (niceNumbers != 0);\nhighp float eps2 = epsilon * epsilon;\nhighp vec2 mismatch, delta, localGuess = vec2(0.0f);\nfor(int k = 0; k < numberOfIterations; k++) {\nmismatch = niceNumbers != 0 ? computeMismatch(pyrGuess, localGuess) : vec2(0.0f);\ndelta = mismatch * invHarris * invDet;\nniceNumbers *= int(eps2 <= dot(delta, delta));\nlocalGuess += float(niceNumbers) * delta;\n}\nvec2 opticalFlow = pyrGuess + localGuess;\nbool mustDiscard = (level == 0) && any(bvec2(\n!goodKeypoint,\n!isInsideImage(keypoint.position + opticalFlow)\n));\ncolor = !mustDiscard ? encodePairOfFloat16(opticalFlow) : encodeDiscardedPairOfFloat16();\n}'},3890:e=>{e.exports='#if @FS_USE_CUSTOM_PRECISION@\nprecision mediump int;\nprecision mediump float;\n#endif\n#if !defined(STAGE)\n#error Undefined STAGE\n#elif STAGE == 1\n@include "float16.glsl"\nuniform sampler2D corners;\n#elif STAGE < 1\nuniform mediump usampler2D lookupTable;\n#else\n#define SKIP_TEXTURE_READS 1\n#define DENSITY_FACTOR 0.10\nuniform mediump usampler2D lookupTable;\nuniform int blockSize;\nuniform int width;\nuniform int height;\nin vec2 v_topLeft, v_top, v_topRight,\nv_left, v_center, v_right,\nv_bottomLeft, v_bottom, v_bottomRight;\n#endif\nconst uvec2 NULL_ELEMENT = uvec2(0xFFFFu);\nvoid main()\n{\n#if STAGE == 1\nuvec2 outSize = uvec2(outputSize());\nuvec2 thread = uvec2(threadLocation());\nuvec2 size = uvec2(textureSize(corners, 0));\nuint location = thread.y * outSize.x + thread.x;\nivec2 pos = ivec2(location % size.x, location / size.x);\nvec4 pixel = location < size.x * size.y ? texelFetch(corners, pos, 0) : vec4(0.0f);\nbool isCorner = !isEncodedFloat16Zero(pixel.rb);\ncolor = isCorner ? uvec4(uvec2(pos), 1u, 0u) : uvec4(NULL_ELEMENT, 0u, 0u);\n#elif STAGE > 1\nint dblBlockSize = 2 * blockSize;\nivec2 thread = threadLocation();\nivec2 offset = thread % dblBlockSize;\nivec2 delta = thread - offset;\n#if SKIP_TEXTURE_READS\nif(blockSize >= 8) {\nuint sb = texture(lookupTable, texCoord).z;\nfloat p = max((float(sb) / float(blockSize)) / float(blockSize), DENSITY_FACTOR);\nfloat rowthr = float(dblBlockSize) * p + 3.0f * sqrt(p * (1.0f - p));\ncolor = uvec4(NULL_ELEMENT, 4u * sb, 0u);\nif(offset.y >= max(1, int(ceil(rowthr))))\nreturn;\n}\n#endif\n#define deltaCenter ivec2(0,0)\n#define deltaTop ivec2(0,-blockSize)\n#define deltaTopRight ivec2(blockSize,-blockSize)\n#define deltaRight ivec2(blockSize,0)\n#define deltaBottomRight ivec2(blockSize,blockSize)\n#define deltaBottom ivec2(0,blockSize)\n#define deltaBottomLeft ivec2(-blockSize,blockSize)\n#define deltaLeft ivec2(-blockSize,0)\n#define deltaTopLeft ivec2(-blockSize,-blockSize)\nivec2 boundary = ivec2(width - 1, height - 1) / blockSize;\nivec2 bottomRightPos = thread + deltaBottomRight;\nuvec2 valid = uvec2(\nbottomRightPos.x < width || bottomRightPos.x / blockSize == boundary.x,\nbottomRightPos.y < height || bottomRightPos.y / blockSize == boundary.y\n);\nuvec4 mask[4];\nmask[0] = uvec4(1u, valid.x, valid.y, valid.x * valid.y);\nmask[1] = uvec4(1u, 1u, valid.y, valid.y);\nmask[2] = uvec4(1u, valid.x, 1u, valid.x);\nmask[3] = uvec4(1u);\n#if SKIP_TEXTURE_READS\n#define calcSb(delta) texelFetch(lookupTable, blockSize * ((thread + (delta)) / blockSize), 0).z\nuint center = calcSb(deltaCenter);\nuint top = calcSb(deltaTop);\nuint topRight = calcSb(deltaTopRight);\nuint right = calcSb(deltaRight);\nuint bottomRight = calcSb(deltaBottomRight);\nuint bottom = calcSb(deltaBottom);\nuint bottomLeft = calcSb(deltaBottomLeft);\nuint left = calcSb(deltaLeft);\nuint topLeft = calcSb(deltaTopLeft);\n#else\n#define calcSb(pos) texture(lookupTable, (pos)).z\nuint center = calcSb(v_center);\nuint top = calcSb(v_top);\nuint topRight = calcSb(v_topRight);\nuint right = calcSb(v_right);\nuint bottomRight = calcSb(v_bottomRight);\nuint bottom = calcSb(v_bottom);\nuint bottomLeft = calcSb(v_bottomLeft);\nuint left = calcSb(v_left);\nuint topLeft = calcSb(v_topLeft);\n#endif\nuvec4 sums[4];\nsums[0] = uvec4(center, right, bottom, bottomRight);\nsums[1] = uvec4(left, center, bottomLeft, bottom);\nsums[2] = uvec4(top, topRight, center, right);\nsums[3] = uvec4(topLeft, top, left, center);\nivec2 cmp = ivec2(greaterThanEqual(offset, ivec2(blockSize)));\nint option = 2 * cmp.y + cmp.x;\nuvec4 cdef = sums[option] * mask[option];\nuint c2b = cdef.x, d2b = cdef.y, e2b = cdef.z, f2b = cdef.w;\nuint sb = center;\nuint s2b = c2b + d2b + e2b + f2b;\ns2b = s2b < sb ? 0xFFFFu : min(0xFFFFu, s2b);\nuint w2b = uint(min(dblBlockSize, width - delta.x));\nuvec2 uoffset = uvec2(offset);\nuint ceiling = s2b >= uoffset.x ? (s2b - uoffset.x) / w2b + uint((s2b - uoffset.x) % w2b > 0u) : 0u;\ncolor = uvec4(NULL_ELEMENT, s2b, 0u);\nif(uoffset.y >= ceiling)\nreturn;\nuint i2b = uoffset.y * w2b + uoffset.x;\nuint j2b = i2b >= c2b ? i2b - c2b : 0u;\nuint k2b = j2b >= d2b ? j2b - d2b : 0u;\nuint l2b = k2b >= e2b ? k2b - e2b : 0u;\nuint wl = uint(min(blockSize, width - delta.x));\nuint wr = uint(min(blockSize, width - delta.x - blockSize));\nivec2 magicOffset = (\n(i2b < c2b) ? ivec2(i2b % wl, i2b / wl) : (\n(j2b < d2b) ? ivec2(j2b % wr, j2b / wr) + ivec2(blockSize, 0) : (\n(k2b < e2b) ? ivec2(k2b % wl, k2b / wl) + ivec2(0, blockSize) : (\n(l2b < f2b) ? ivec2(l2b % wr, l2b / wr) + ivec2(blockSize) : ivec2(0)\n))));\nuvec2 a2b = texelFetch(lookupTable, delta + magicOffset, 0).xy;\ncolor = uvec4(a2b, s2b, 0u);\n#else\nuvec4 pix = texture(lookupTable, texCoord);\ncolor = all(equal(pix.xy, NULL_ELEMENT)) ? vec4(0,1,1,1) : vec4(1,0,0,1);\n#endif\n}'},8647:e=>{e.exports="#if !defined(STAGE) || STAGE < 1\n#error Invalid STAGE\n#else\nuniform mediump int blockSize;\nout vec2 v_topLeft, v_top, v_topRight,\nv_left, v_center, v_right,\nv_bottomLeft, v_bottom, v_bottomRight;\nvoid vsmain()\n{\nfloat b = float(blockSize);\n#define V(x,y) (texCoord + (vec2((x),(y)) * b) / texSize)\nv_topLeft = V(-1,-1); v_top = V(0,-1); v_topRight = V(1,-1);\nv_left = V(-1,0); v_center = V(0,0); v_right = V(1,0);\nv_bottomLeft = V(-1,1); v_bottom = V(0,1); v_bottomRight = V(1,1);\n}\n#endif"},4776:e=>{e.exports='@include "keypoints.glsl"\n@include "keypoint-matches.glsl"\n@include "keypoint-descriptors.glsl"\nuniform sampler2D candidates;\nuniform sampler2D filters;\nuniform int matcherLength;\nuniform sampler2D tables;\nuniform sampler2D descriptorDB;\nuniform int tableIndex;\nuniform int bucketCapacity;\nuniform int bucketsPerTable;\nuniform int tablesStride;\nuniform int descriptorDBStride;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#if HASH_SIZE > SEQUENCE_MAXLEN\n#error LSH: invalid HASH_SIZE\n#elif SEQUENCE_COUNT * SEQUENCE_MAXLEN * 4 > 16384\n#error LSH: sequences are too large!\n#elif (SEQUENCE_COUNT * SEQUENCE_MAXLEN) % 4 > 0\n#error LSH: sequences of invalid size!\n#endif\nlayout(std140) uniform LSHSequences\n{\nuvec4 sequences[(SEQUENCE_COUNT * SEQUENCE_MAXLEN) / 4];\n};\n#if HASH_SIZE == 10\nconst int SWAP_COUNT[3] = int[3](1, 11, 56);\nconst int[56] SWAP = int[56](0,1,2,4,8,16,32,64,128,256,512,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768);\n#elif HASH_SIZE == 11\nconst int SWAP_COUNT[3] = int[3](1, 12, 67);\nconst int[67] SWAP = int[67](0,1,2,4,8,16,32,64,128,256,512,1024,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536);\n#elif HASH_SIZE == 12\nconst int SWAP_COUNT[3] = int[3](1, 13, 79);\nconst int[79] SWAP = int[79](0,1,2,4,8,16,32,64,128,256,512,1024,2048,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072);\n#elif HASH_SIZE == 13\nconst int SWAP_COUNT[3] = int[3](1, 14, 92);\nconst int[92] SWAP = int[92](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144);\n#elif HASH_SIZE == 14\nconst int SWAP_COUNT[3] = int[3](1, 15, 106);\nconst int[106] SWAP = int[106](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288);\n#elif HASH_SIZE == 15\nconst int SWAP_COUNT[3] = int[3](1, 16, 121);\nconst int[121] SWAP = int[121](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576);\n#elif HASH_SIZE == 16\nconst int SWAP_COUNT[3] = int[3](1, 17, 137);\nconst int[137] SWAP = int[137](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576,32769,32770,32772,32776,32784,32800,32832,32896,33024,33280,33792,34816,36864,40960,49152);\n#elif HASH_SIZE == 17\nconst int SWAP_COUNT[3] = int[3](1, 18, 154);\nconst int[154] SWAP = int[154](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576,32769,32770,32772,32776,32784,32800,32832,32896,33024,33280,33792,34816,36864,40960,49152,65537,65538,65540,65544,65552,65568,65600,65664,65792,66048,66560,67584,69632,73728,81920,98304);\n#elif HASH_SIZE == 18\nconst int SWAP_COUNT[3] = int[3](1, 19, 172);\nconst int[172] SWAP = int[172](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576,32769,32770,32772,32776,32784,32800,32832,32896,33024,33280,33792,34816,36864,40960,49152,65537,65538,65540,65544,65552,65568,65600,65664,65792,66048,66560,67584,69632,73728,81920,98304,131073,131074,131076,131080,131088,131104,131136,131200,131328,131584,132096,133120,135168,139264,147456,163840,196608);\n#elif HASH_SIZE == 19\nconst int SWAP_COUNT[3] = int[3](1, 20, 191);\nconst int[191] SWAP = int[191](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576,32769,32770,32772,32776,32784,32800,32832,32896,33024,33280,33792,34816,36864,40960,49152,65537,65538,65540,65544,65552,65568,65600,65664,65792,66048,66560,67584,69632,73728,81920,98304,131073,131074,131076,131080,131088,131104,131136,131200,131328,131584,132096,133120,135168,139264,147456,163840,196608,262145,262146,262148,262152,262160,262176,262208,262272,262400,262656,263168,264192,266240,270336,278528,294912,327680,393216);\n#elif HASH_SIZE == 20\nconst int SWAP_COUNT[3] = int[3](1, 21, 211);\nconst int[211] SWAP = int[211](0,1,2,4,8,16,32,64,128,256,512,1024,2048,4096,8192,16384,32768,65536,131072,262144,524288,3,5,6,9,10,12,17,18,20,24,33,34,36,40,48,65,66,68,72,80,96,129,130,132,136,144,160,192,257,258,260,264,272,288,320,384,513,514,516,520,528,544,576,640,768,1025,1026,1028,1032,1040,1056,1088,1152,1280,1536,2049,2050,2052,2056,2064,2080,2112,2176,2304,2560,3072,4097,4098,4100,4104,4112,4128,4160,4224,4352,4608,5120,6144,8193,8194,8196,8200,8208,8224,8256,8320,8448,8704,9216,10240,12288,16385,16386,16388,16392,16400,16416,16448,16512,16640,16896,17408,18432,20480,24576,32769,32770,32772,32776,32784,32800,32832,32896,33024,33280,33792,34816,36864,40960,49152,65537,65538,65540,65544,65552,65568,65600,65664,65792,66048,66560,67584,69632,73728,81920,98304,131073,131074,131076,131080,131088,131104,131136,131200,131328,131584,132096,133120,135168,139264,147456,163840,196608,262145,262146,262148,262152,262160,262176,262208,262272,262400,262656,263168,264192,266240,270336,278528,294912,327680,393216,524289,524290,524292,524296,524304,524320,524352,524416,524544,524800,525312,526336,528384,532480,540672,557056,589824,655360,786432);\n#else\n#error Invalid HASH_SIZE\n#endif\n#if LEVEL < 0 || LEVEL > 2\n#error Invalid LEVEL\n#endif\nconst uint END_OF_LIST = 0xFFFFFFFFu;\nconst int NUMBER_OF_HASHES = SWAP_COUNT[LEVEL];\nuint sequenceElement(int sequenceIndex, int elementIndex)\n{\nint offset = (SEQUENCE_MAXLEN) * sequenceIndex + elementIndex;\nuvec4 tuple = sequences[offset / 4];\nreturn tuple[offset & 3];\n}\nint descriptorHash(uint[DESCRIPTOR_SIZE] descriptor, int sequenceIndex)\n{\nuint bit, b, m;\nint hash = 0;\n@unroll\nfor(int i = 0; i < HASH_SIZE; i++) {\nbit = sequenceElement(sequenceIndex, i);\nb = bit >> 3u;\nm = 1u << (bit & 7u);\nhash = (hash << 1) | int((descriptor[b] & m) != 0u);\n}\nreturn hash;\n}\n#define readTableData(tables, tablesStride, rasterIndex) decodeUint32(texelFetch((tables), ivec2((rasterIndex) % (tablesStride), (rasterIndex) / (tablesStride)), 0))\nvoid main()\n{\nivec2 thread = threadLocation();\nint keypointIndex = thread.x + thread.y * matcherLength;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\ncolor = encodeKeypointMatch(MATCH_NOT_FOUND);\nif(isBadKeypoint(keypoint))\nreturn;\nKeypointMatch candidate = decodeKeypointMatch(threadPixel(candidates));\nKeypointMatch mfilter = decodeKeypointMatch(threadPixel(filters));\nuint[DESCRIPTOR_SIZE] candidateDescriptor;\nuint[DESCRIPTOR_SIZE] descriptor = readKeypointDescriptor(encodedKeypoints, descriptorSize, extraSize, encoderLength, address);\nint hash0 = descriptorHash(descriptor, tableIndex);\nfor(int h = 0; h < NUMBER_OF_HASHES; h++) {\nint hash = hash0 ^ SWAP[h];\nint tableAddress = tableIndex * bucketsPerTable * bucketCapacity;\nint bucketAddress = tableAddress + hash * bucketCapacity;\nbool validEntry = true;\nfor(int b = 0; b < bucketCapacity; b++) {\nint entryAddress = bucketAddress + b;\nuint entry = validEntry ? readTableData(tables, tablesStride, entryAddress) : END_OF_LIST;\nvalidEntry = (validEntry && entry != END_OF_LIST);\nint candidateIndex = int(entry);\ncandidateDescriptor = readKeypointDescriptorFromDB(descriptorDB, descriptorDBStride, validEntry ? candidateIndex : -1);\nint descriptorDistance = distanceBetweenKeypointDescriptors(descriptor, candidateDescriptor);\nKeypointMatch match = KeypointMatch(candidateIndex, descriptorDistance);\nbool betterThanCandidate = (match.dist < candidate.dist) || (match.dist == candidate.dist && match.index > candidate.index);\nbool worseThanFilter = (match.dist > mfilter.dist) || (match.dist == mfilter.dist && match.index < mfilter.index);\nbool nicerMatch = (validEntry && betterThanCandidate && worseThanFilter);\nivec2 v = nicerMatch ? ivec2(match.index, match.dist) : ivec2(candidate.index, candidate.dist);\ncandidate = KeypointMatch(v.x, v.y);\n}\n}\ncolor = encodeKeypointMatch(candidate);\n}'},2648:e=>{e.exports='@include "keypoints.glsl"\n@include "int32.glsl"\n#if !defined(STAGE)\n#error Undefined STAGE\n#elif STAGE == 1\nuniform sampler2D encodedKeypointsA;\nuniform sampler2D encodedKeypointsB;\nuniform int encoderLengthA;\nuniform int encoderLengthB;\nuniform int encoderCapacityA;\nuniform int encoderCapacityB;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#elif STAGE == 2\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int maxKeypoints;\n#elif STAGE == 3\nuniform sampler2D array;\nuniform int blockSize;\n#elif STAGE == 4\nuniform sampler2D array;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#elif STAGE == 5\nuniform sampler2D array;\n#else\n#error Invalid STAGE\n#endif\n#define NULL_KEYPOINT_INDEX 0xFFFF\nconst highp uint UNIT = 0x10000u;\nvoid main()\n{\n#if STAGE == 1\nivec2 thread = threadLocation();\nKeypointAddress addr = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint keypointIndex = findKeypointIndex(addr, descriptorSize, extraSize);\nint newKeypointIndex = keypointIndex < encoderCapacityA ? keypointIndex : keypointIndex - encoderCapacityA;\ncolor = encodeNullKeypoint();\nif(newKeypointIndex >= max(encoderCapacityA, encoderCapacityB))\nreturn;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\naddr = KeypointAddress(newKeypointIndex * pixelsPerKeypoint, addr.offset);\nvec4 dataA = readKeypointData(encodedKeypointsA, encoderLengthA, addr);\nvec4 dataB = readKeypointData(encodedKeypointsB, encoderLengthB, addr);\ncolor = keypointIndex < encoderCapacityA ? dataA : dataB;\n#elif STAGE == 2\nivec2 thread = threadLocation();\nint keypointIndex = thread.y * outputSize().x + thread.x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress addr = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, addr);\nbool isValid = !isNullKeypoint(keypoint) && keypointIndex < maxKeypoints;\nkeypointIndex = isValid ? keypointIndex : NULL_KEYPOINT_INDEX;\ncolor = encodeUint32(uint(keypointIndex & 0xFFFF) | (isValid ? UNIT : 0u));\n#elif STAGE == 3\nivec2 thread = threadLocation();\nivec2 size = outputSize();\nint arrayLength = size.x * size.y;\nint arrayIndex = thread.y * size.x + thread.x;\nint arrayIndexLeft = arrayIndex - blockSize;\nint arrayIndexRight = arrayIndex + blockSize;\nint mask = int(arrayIndexRight < arrayLength || arrayIndexRight / blockSize == (arrayLength - 1) / blockSize);\narrayIndexLeft = max(0, arrayIndexLeft);\narrayIndexRight = min(arrayLength - 1, arrayIndexRight);\n#define raster2pos(k) ivec2((k) % size.x, (k) / size.x)\nuvec3 entries32 = uvec3(\ndecodeUint32(threadPixel(array)),\ndecodeUint32(texelFetch(array, raster2pos(arrayIndexLeft), 0)),\ndecodeUint32(texelFetch(array, raster2pos(arrayIndexRight), 0))\n);\nivec3 sb = ivec3((entries32 >> 16u) & 0xFFFFu);\nsb.z *= mask;\nint dblBlockSize = 2 * blockSize;\nint offset = arrayIndex % dblBlockSize;\nint s2b = sb.x + (offset < blockSize ? sb.z : sb.y);\nint l2b = offset < blockSize ? sb.x : sb.y;\nuint keypointIndex = entries32.x & 0xFFFFu;\nuint shiftedS2b = uint(s2b) << 16u;\ncolor = encodeUint32(uint(NULL_KEYPOINT_INDEX) | shiftedS2b);\nif(offset >= s2b)\nreturn;\ncolor = encodeUint32(keypointIndex | shiftedS2b);\nif(offset < l2b)\nreturn;\nvec4 entry = texelFetch(array, raster2pos(arrayIndex + blockSize - l2b), 0);\nkeypointIndex = decodeUint32(entry) & 0xFFFFu;\ncolor = encodeUint32(keypointIndex | shiftedS2b);\n#elif STAGE == 4\nivec2 thread = threadLocation();\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress addr = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint keypointIndex = findKeypointIndex(addr, descriptorSize, extraSize);\n#define raster2pos(k) ivec2((k) % size.x, (k) / size.x)\nivec2 size = textureSize(array, 0);\nuint sortedPair = decodeUint32(texelFetch(array, raster2pos(keypointIndex), 0));\nint newKeypointIndex = int(sortedPair & 0xFFFFu);\ncolor = encodeNullKeypoint();\nif(newKeypointIndex == NULL_KEYPOINT_INDEX || keypointIndex >= size.x * size.y)\nreturn;\nKeypointAddress newAddr = KeypointAddress(newKeypointIndex * pixelsPerKeypoint, addr.offset);\ncolor = readKeypointData(encodedKeypoints, encoderLength, newAddr);\n#elif STAGE == 5\nuint val = decodeUint32(threadPixel(array));\ncolor = (val & 0xFFFFu) == uint(NULL_KEYPOINT_INDEX) ? vec4(0,1,1,1) : vec4(1,0,0,1);\n#endif\n}'},8825:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\n@include "filters.glsl"\n#if !defined(USE_LAPLACIAN)\n#error Undefined USE_LAPLACIAN\n#endif\nuniform sampler2D corners;\nuniform sampler2D pyramid;\nuniform float lodStep;\n#if USE_LAPLACIAN\nuniform sampler2D pyrLaplacian;\n#endif\nvoid main()\n{\nivec2 thread = threadLocation();\nvec4 pixel = threadPixel(corners);\nfloat score = decodeFloat16(pixel.rb);\nfloat myEncodedLod = pixel.a;\nfloat lod = decodeLod(myEncodedLod);\nfloat lodPlus = lod + lodStep;\nfloat lodMinus = lod - lodStep;\nfloat pot = exp2(lod);\nfloat potPlus = exp2(lodPlus);\nfloat potMinus = exp2(lodMinus);\ncolor = pixel;\nif(score == 0.0f)\nreturn;\n#define P(p,u,v) textureLod(corners, texCoord + (p) * vec2((u),(v)) / texSize, 0.0f)\nvec4 pix[18];\n#define D(u,v) P(potMinus,(u),(v))\npix[0] = D(-1,-1); pix[1] = D(0,-1); pix[2] = D(1,-1);\npix[3] = D(-1,0); pix[4] = D(0,0); pix[5] = D(1,0);\npix[6] = D(-1,1); pix[7] = D(0,1); pix[8] = D(1,1);\n#define U(u,v) P(potPlus,(u),(v))\npix[9] = U(-1,-1); pix[10] = U(0,-1); pix[11] = U(1,-1);\npix[12] = U(-1,0); pix[13] = U(0,0); pix[14] = U(1,0);\npix[15] = U(-1,1); pix[16] = U(0,1); pix[17] = U(1,1);\nfloat scores[18];\n#define C(j) decodeFloat16(pix[j].rb)\nscores[0] = C(0); scores[1] = C(1); scores[2] = C(2);\nscores[3] = C(3); scores[4] = C(4); scores[5] = C(5);\nscores[6] = C(6); scores[7] = C(7); scores[8] = C(8);\nscores[9] = C(9); scores[10] = C(10); scores[11] = C(11);\nscores[12] = C(12); scores[13] = C(13); scores[14] = C(14);\nscores[15] = C(15); scores[16] = C(16); scores[17] = C(17);\nfloat lods[18];\n#define E(j) decodeLod(pix[j].a)\nlods[0] = E(0); lods[1] = E(1); lods[2] = E(2);\nlods[3] = E(3); lods[4] = E(4); lods[5] = E(5);\nlods[6] = E(6); lods[7] = E(7); lods[8] = E(8);\nlods[9] = E(9); lods[10] = E(10); lods[11] = E(11);\nlods[12] = E(12); lods[13] = E(13); lods[14] = E(14);\nlods[15] = E(15); lods[16] = E(16); lods[17] = E(17);\n#if USE_LAPLACIAN\n#define L(p,u,v) textureLod(pyrLaplacian, texCoord + (p) * vec2((u),(v)) / texSize, 0.0f)\nmat3 strengths[2];\nstrengths[0] = mat3(\n#define Lm(u,v) abs(decodeFloat16(L(potMinus,(u),(v)).xy))\nLm(-1,-1), Lm(0,-1), Lm(1,-1),\nLm(-1,0), Lm(0,0), Lm(1,0),\nLm(-1,1), Lm(0,1), Lm(1,1)\n);\nstrengths[1] = mat3(\n#define Lp(u,v) abs(decodeFloat16(L(potPlus,(u),(v)).zw))\nLp(-1,-1), Lp(0,-1), Lp(1,-1),\nLp(-1,0), Lp(0,0), Lp(1,0),\nLp(-1,1), Lp(0,1), Lp(1,1)\n);\nfloat myStrength = abs(laplacian(pyramid, vec2(thread), lod));\n#else\n#define L(u,v) (((v)+1)*3 + ((u)+1))\nmat3 strengths[2];\nstrengths[0] = mat3(\n#define Lm(u,v) scores[L((u),(v))]\nLm(-1,-1), Lm(0,-1), Lm(1,-1),\nLm(-1,0), Lm(0,0), Lm(1,0),\nLm(-1,1), Lm(0,1), Lm(1,1)\n);\nstrengths[1] = mat3(\n#define Lp(u,v) scores[9 + L((u),(v))]\nLp(-1,-1), Lp(0,-1), Lp(1,-1),\nLp(-1,0), Lp(0,0), Lp(1,0),\nLp(-1,1), Lp(0,1), Lp(1,1)\n);\nfloat myStrength = score;\n#endif\n#define B(j,lod) float(isSameLod(lods[j], (lod))) * float(scores[j] > 0.0f)\nmat3 nearLod[2];\nnearLod[0] = mat3(\n#define Bm(j) B((j), lodMinus)\nBm(0), Bm(1), Bm(2),\nBm(3), Bm(4), Bm(5),\nBm(6), Bm(7), Bm(8)\n);\nnearLod[1] = mat3(\n#define Bp(j) B((j), lodPlus)\nBp(9), Bp(10), Bp(11),\nBp(12), Bp(13), Bp(14),\nBp(15), Bp(16), Bp(17)\n);\nmat3 upStrengths = matrixCompMult(strengths[1], nearLod[1]);\nmat3 downStrengths = matrixCompMult(strengths[0], nearLod[0]);\nvec3 maxUpStrength3 = max(upStrengths[0], max(upStrengths[1], upStrengths[2]));\nvec3 maxDownStrength3 = max(downStrengths[0], max(downStrengths[1], downStrengths[2]));\nvec3 maxStrength3 = max(maxUpStrength3, maxDownStrength3);\nfloat maxStrength = max(maxStrength3.x, max(maxStrength3.y, maxStrength3.z));\ncolor.rb = encodeFloat16(score * step(maxStrength, myStrength));\n}'},5693:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\nuniform sampler2D corners;\nvoid main()\n{\nivec2 thread = threadLocation();\nvec4 pixel = threadPixel(corners);\nfloat encodedLod = pixel.a;\nfloat score = decodeFloat16(pixel.rb);\nfloat lod = decodeLod(encodedLod);\nfloat pot = exp2(lod);\ncolor = pixel;\nif(score == 0.0f)\nreturn;\n#if 1\nvec2 gridSize = vec2(pot);\nvec2 gridLocation = floor(mod(texCoord * texSize, gridSize));\nvec2 gridDelta = gridLocation / gridSize - vec2(0.5f);\nfloat gridStep = 1.0f / pot;\nconst float adjustment = 1.25f;\ncolor.rb = encodeFloat16(0.0f);\nif(max(abs(gridDelta.x), abs(gridDelta.y)) > adjustment * gridStep)\nreturn;\n#endif\n#define P(x,y) textureLod(corners, texCoord + pot * vec2((x), (y)) / texSize, 0.0f)\nvec4 pix[9];\npix[0] = P(-1,-1); pix[1] = P(0,-1); pix[2] = P(1,-1);\npix[3] = P(-1, 0); pix[4] = pixel; pix[5] = P(1, 0);\npix[6] = P(-1, 1); pix[7] = P(0, 1); pix[8] = P(1, 1);\n#define S(j) decodeFloat16(pix[j].rb)\nmat3 scores = mat3(\nS(0), S(1), S(2),\nS(3), S(4), S(5),\nS(6), S(7), S(8)\n);\n#define B(j) float(isSameLod(decodeLod(pix[j].a), lod))\nmat3 sameLod = mat3(\nB(0), B(1), B(2),\nB(3), B(4), B(5),\nB(6), B(7), B(8)\n);\nmat3 sameLodScores = matrixCompMult(scores, sameLod);\nvec3 maxScore3 = max(sameLodScores[0], max(sameLodScores[1], sameLodScores[2]));\nfloat maxScore = max(maxScore3.x, max(maxScore3.y, maxScore3.z));\ncolor.rb = encodeFloat16(score * step(maxScore, score));\n}'},9280:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\nuniform sampler2D image;\nuniform float lodStep;\n#if !defined(MULTISCALE)\n#error Must define MULTISCALE\n#elif MULTISCALE != 0\n#define LOD_STEP (lodStep)\n#define USE_MIDDLE_RING\n#else\n#define LOD_STEP (0.0f)\n#endif\n#define PIX(x,y) pixelAtShortOffset(image, ivec2((x),(y)))\n#define L2(v,i) bvec2(isSameEncodedLod(v[i].a, alphaMinus), isSameEncodedLod(v[i].a, alphaPlus))\n#define L3(v,i) bvec3(isSameEncodedLod(v[i].a, alpha), isSameEncodedLod(v[i].a, alphaMinus), isSameEncodedLod(v[i].a, alphaPlus))\n#define S3(v,i) decodeFloat16(v[i].rb) * float(any(L3(v,i)))\n#define S2(v,i) decodeFloat16(v[i].rb) * float(any(L2(v,i)))\n#define P(i) S3(p,i)\n#define Q(i) S2(q,i)\n#define R(i) S2(r,i)\nconst vec4 O = vec4(0.0f);\nvoid main()\n{\nvec4 pixel = threadPixel(image);\nfloat lod = decodeLod(pixel.a);\nfloat score = decodeFloat16(pixel.rb);\ncolor = pixel;\nif(score == 0.0f)\nreturn;\nvec4 p[8];\np[0] = PIX(0,1); p[1] = PIX(1,1); p[2] = PIX(1,0); p[3] = PIX(1,-1);\np[4] = PIX(0,-1); p[5] = PIX(-1,-1); p[6] = PIX(-1,0); p[7] = PIX(-1,1);\n#ifdef USE_MIDDLE_RING\nvec4 q[16];\nq[0] = PIX(0,2); q[1] = PIX(1,2); q[2] = PIX(2,2); q[3] = PIX(2,1);\nq[4] = PIX(2,0); q[5] = PIX(2,-1); q[6] = PIX(2,-2); q[7] = PIX(1,-2);\nq[8] = PIX(0,-2); q[9] = PIX(-1,-2); q[10] = PIX(-2,-2); q[11] = PIX(-2,-1);\nq[12] = PIX(-2,0); q[13] = PIX(-2,1); q[14] = PIX(-2,2); q[15] = PIX(-1,2);\n#else\nvec4 q[16];\nq[0] = O; q[1] = O; q[2] = O; q[3] = O;\nq[4] = O; q[5] = O; q[6] = O; q[7] = O;\nq[8] = O; q[9] = O; q[10] = O; q[11] = O;\nq[12] = O; q[13] = O; q[14] = O; q[15] = O;\n#endif\n#ifdef USE_OUTER_RING\nvec4 r[16];\nr[0] = PIX(0,3); r[1] = PIX(1,3); r[2] = PIX(3,1); r[3] = PIX(3,0);\nr[4] = PIX(3,-1); r[5] = PIX(1,-3); r[6] = PIX(0,-3); r[7] = PIX(-1,-3);\nr[8] = PIX(-3,-1); r[9] = PIX(-3,0); r[10] = PIX(-3,1); r[11] = PIX(-1,3);\nr[12] = PIX(0,4); r[13] = PIX(4,0); r[14] = PIX(0,-4); r[15] = PIX(-4,0);\n#else\nvec4 r[16];\nr[0] = O; r[1] = O; r[2] = O; r[3] = O;\nr[4] = O; r[5] = O; r[6] = O; r[7] = O;\nr[8] = O; r[9] = O; r[10] = O; r[11] = O;\nr[12] = O; r[13] = O; r[14] = O; r[15] = O;\n#endif\nfloat alphaPlus = encodeLod(lod + LOD_STEP);\nfloat alphaMinus = encodeLod(lod - LOD_STEP);\nfloat alpha = encodeLod(lod);\nmat3 innerScore = mat3(\nP(0), P(1), P(2), P(3),\nP(4), P(5), P(6), P(7),\n0.0f);\nmat4 middleScore = mat4(\nQ(0), Q(1), Q(2), Q(3),\nQ(4), Q(5), Q(6), Q(7),\nQ(8), Q(9), Q(10), Q(11),\nQ(12), Q(13), Q(14), Q(15)\n);\nmat4 outerScore = mat4(\nR(0), R(1), R(2), R(3),\nR(4), R(5), R(6), R(7),\nR(8), R(9), R(10), R(11),\nR(12), R(13), R(14), R(15)\n);\nvec3 maxInnerScore3 = max(innerScore[0], max(innerScore[1], innerScore[2]));\nvec4 maxMiddleScore4 = max(max(middleScore[0], middleScore[1]), max(middleScore[2], middleScore[3]));\nvec4 maxOuterScore4 = max(max(outerScore[0], outerScore[1]), max(outerScore[2], outerScore[3]));\nfloat maxInnerScore = max(maxInnerScore3.x, max(maxInnerScore3.y, maxInnerScore3.z));\nfloat maxMiddleScore = max(max(maxMiddleScore4.x, maxMiddleScore4.y), max(maxMiddleScore4.z, maxMiddleScore4.w));\nfloat maxOuterScore = max(max(maxOuterScore4.x, maxOuterScore4.y), max(maxOuterScore4.z, maxOuterScore4.w));\nfloat maxScore = max(maxInnerScore, max(maxMiddleScore, maxOuterScore));\nfloat finalScore = step(maxScore, score) * score;\ncolor.rb = encodeFloat16(finalScore);\n}'},9108:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedCorners;\nuniform int encoderLength;\nuniform sampler2D image;\nuniform int extraSize;\nconst int descriptorSize = 32;\n#define P(a,b,c,d) ivec4((a),(b),(c),(d))\nconst ivec4 pat31[256] = ivec4[256](\nP(8,-3,9,5),\nP(4,2,7,-12),\nP(-11,9,-8,2),\nP(7,-12,12,-13),\nP(2,-13,2,12),\nP(1,-7,1,6),\nP(-2,-10,-2,-4),\nP(-13,-13,-11,-8),\nP(-13,-3,-12,-9),\nP(10,4,11,9),\nP(-13,-8,-8,-9),\nP(-11,7,-9,12),\nP(7,7,12,6),\nP(-4,-5,-3,0),\nP(-13,2,-12,-3),\nP(-9,0,-7,5),\nP(12,-6,12,-1),\nP(-3,6,-2,12),\nP(-6,-13,-4,-8),\nP(11,-13,12,-8),\nP(4,7,5,1),\nP(5,-3,10,-3),\nP(3,-7,6,12),\nP(-8,-7,-6,-2),\nP(-2,11,-1,-10),\nP(-13,12,-8,10),\nP(-7,3,-5,-3),\nP(-4,2,-3,7),\nP(-10,-12,-6,11),\nP(5,-12,6,-7),\nP(5,-6,7,-1),\nP(1,0,4,-5),\nP(9,11,11,-13),\nP(4,7,4,12),\nP(2,-1,4,4),\nP(-4,-12,-2,7),\nP(-8,-5,-7,-10),\nP(4,11,9,12),\nP(0,-8,1,-13),\nP(-13,-2,-8,2),\nP(-3,-2,-2,3),\nP(-6,9,-4,-9),\nP(8,12,10,7),\nP(0,9,1,3),\nP(7,-5,11,-10),\nP(-13,-6,-11,0),\nP(10,7,12,1),\nP(-6,-3,-6,12),\nP(10,-9,12,-4),\nP(-13,8,-8,-12),\nP(-13,0,-8,-4),\nP(3,3,7,8),\nP(5,7,10,-7),\nP(-1,7,1,-12),\nP(3,-10,5,6),\nP(2,-4,3,-10),\nP(-13,0,-13,5),\nP(-13,-7,-12,12),\nP(-13,3,-11,8),\nP(-7,12,-4,7),\nP(6,-10,12,8),\nP(-9,-1,-7,-6),\nP(-2,-5,0,12),\nP(-12,5,-7,5),\nP(3,-10,8,-13),\nP(-7,-7,-4,5),\nP(-3,-2,-1,-7),\nP(2,9,5,-11),\nP(-11,-13,-5,-13),\nP(-1,6,0,-1),\nP(5,-3,5,2),\nP(-4,-13,-4,12),\nP(-9,-6,-9,6),\nP(-12,-10,-8,-4),\nP(10,2,12,-3),\nP(7,12,12,12),\nP(-7,-13,-6,5),\nP(-4,9,-3,4),\nP(7,-1,12,2),\nP(-7,6,-5,1),\nP(-13,11,-12,5),\nP(-3,7,-2,-6),\nP(7,-8,12,-7),\nP(-13,-7,-11,-12),\nP(1,-3,12,12),\nP(2,-6,3,0),\nP(-4,3,-2,-13),\nP(-1,-13,1,9),\nP(7,1,8,-6),\nP(1,-1,3,12),\nP(9,1,12,6),\nP(-1,-9,-1,3),\nP(-13,-13,-10,5),\nP(7,7,10,12),\nP(12,-5,12,9),\nP(6,3,7,11),\nP(5,-13,6,10),\nP(2,-12,2,3),\nP(3,8,4,-6),\nP(2,6,12,-13),\nP(9,-12,10,3),\nP(-8,4,-7,9),\nP(-11,12,-4,-6),\nP(1,12,2,-8),\nP(6,-9,7,-4),\nP(2,3,3,-2),\nP(6,3,11,0),\nP(3,-3,8,-8),\nP(7,8,9,3),\nP(-11,-5,-6,-4),\nP(-10,11,-5,10),\nP(-5,-8,-3,12),\nP(-10,5,-9,0),\nP(8,-1,12,-6),\nP(4,-6,6,-11),\nP(-10,12,-8,7),\nP(4,-2,6,7),\nP(-2,0,-2,12),\nP(-5,-8,-5,2),\nP(7,-6,10,12),\nP(-9,-13,-8,-8),\nP(-5,-13,-5,-2),\nP(8,-8,9,-13),\nP(-9,-11,-9,0),\nP(1,-8,1,-2),\nP(7,-4,9,1),\nP(-2,1,-1,-4),\nP(11,-6,12,-11),\nP(-12,-9,-6,4),\nP(3,7,7,12),\nP(5,5,10,8),\nP(0,-4,2,8),\nP(-9,12,-5,-13),\nP(0,7,2,12),\nP(-1,2,1,7),\nP(5,11,7,-9),\nP(3,5,6,-8),\nP(-13,-4,-8,9),\nP(-5,9,-3,-3),\nP(-4,-7,-3,-12),\nP(6,5,8,0),\nP(-7,6,-6,12),\nP(-13,6,-5,-2),\nP(1,-10,3,10),\nP(4,1,8,-4),\nP(-2,-2,2,-13),\nP(2,-12,12,12),\nP(-2,-13,0,-6),\nP(4,1,9,3),\nP(-6,-10,-3,-5),\nP(-3,-13,-1,1),\nP(7,5,12,-11),\nP(4,-2,5,-7),\nP(-13,9,-9,-5),\nP(7,1,8,6),\nP(7,-8,7,6),\nP(-7,-4,-7,1),\nP(-8,11,-7,-8),\nP(-13,6,-12,-8),\nP(2,4,3,9),\nP(10,-5,12,3),\nP(-6,-5,-6,7),\nP(8,-3,9,-8),\nP(2,-12,2,8),\nP(-11,-2,-10,3),\nP(-12,-13,-7,-9),\nP(-11,0,-10,-5),\nP(5,-3,11,8),\nP(-2,-13,-1,12),\nP(-1,-8,0,9),\nP(-13,-11,-12,-5),\nP(-10,-2,-10,11),\nP(-3,9,-2,-13),\nP(2,-3,3,2),\nP(-9,-13,-4,0),\nP(-4,6,-3,-10),\nP(-4,12,-2,-7),\nP(-6,-11,-4,9),\nP(6,-3,6,11),\nP(-13,11,-5,5),\nP(11,11,12,6),\nP(7,-5,12,-2),\nP(-1,12,0,7),\nP(-4,-8,-3,-2),\nP(-7,1,-6,7),\nP(-13,-12,-8,-13),\nP(-7,-2,-6,-8),\nP(-8,5,-6,-9),\nP(-5,-1,-4,5),\nP(-13,7,-8,10),\nP(1,5,5,-13),\nP(1,0,10,-13),\nP(9,12,10,-1),\nP(5,-8,10,-9),\nP(-1,11,1,-13),\nP(-9,-3,-6,2),\nP(-1,-10,1,12),\nP(-13,1,-8,-10),\nP(8,-11,10,-6),\nP(2,-13,3,-6),\nP(7,-13,12,-9),\nP(-10,-10,-5,-7),\nP(-10,-8,-8,-13),\nP(4,-6,8,5),\nP(3,12,8,-13),\nP(-4,2,-3,-3),\nP(5,-13,10,-12),\nP(4,-13,5,-1),\nP(-9,9,-4,3),\nP(0,3,3,-9),\nP(-12,1,-6,1),\nP(3,2,4,-8),\nP(-10,-10,-10,9),\nP(8,-13,12,12),\nP(-8,-12,-6,-5),\nP(2,2,3,7),\nP(10,6,11,-8),\nP(6,8,8,-12),\nP(-7,10,-6,5),\nP(-3,-9,-3,9),\nP(-1,-13,-1,5),\nP(-3,-7,-3,4),\nP(-8,-2,-8,3),\nP(4,2,12,12),\nP(2,-5,3,11),\nP(6,-9,11,-13),\nP(3,-1,7,12),\nP(11,-1,12,4),\nP(-3,0,-3,6),\nP(4,-11,4,12),\nP(2,-4,2,1),\nP(-10,-6,-8,1),\nP(-13,7,-11,1),\nP(-13,12,-11,-13),\nP(6,0,11,-13),\nP(0,-1,1,4),\nP(-13,3,-9,-2),\nP(-9,8,-6,-3),\nP(-13,-6,-8,-2),\nP(5,-9,8,10),\nP(2,7,3,-9),\nP(-1,-6,-1,-1),\nP(9,5,11,-2),\nP(11,-3,12,-8),\nP(3,0,3,5),\nP(-1,4,0,10),\nP(3,-6,4,5),\nP(-13,0,-10,5),\nP(5,8,12,11),\nP(8,9,9,-6),\nP(7,-4,8,-12),\nP(-10,4,-10,9),\nP(7,3,12,4),\nP(9,-7,10,-2),\nP(7,0,12,-2),\nP(-1,-6,0,-11)\n);\nvoid getPair(int index, mat2 rot, out vec2 p, out vec2 q)\n{\nivec4 data = pat31[index];\nvec2 op = vec2(data.xy);\nvec2 oq = vec2(data.zw);\np = rot * op;\nq = rot * oq;\n}\nvoid main()\n{\nvec4 pixel = threadPixel(encodedCorners);\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint descriptorCell = address.offset - sizeofEncodedKeypoint(0, extraSize) / 4;\ncolor = pixel;\nif(descriptorCell < 0)\nreturn;\nKeypoint keypoint = decodeKeypoint(encodedCorners, encoderLength, address);\nif(isBadKeypoint(keypoint))\nreturn;\nfloat degreesOrientation = round(360.0f + degrees(keypoint.orientation));\nfloat orientation = radians(degreesOrientation - mod(degreesOrientation, 12.0f));\nfloat kcos = cos(orientation);\nfloat ksin = sin(orientation);\nmat2 rot = mat2(kcos, ksin, -ksin, kcos);\nfloat pot = exp2(keypoint.lod);\nint patternStart = 32 * descriptorCell;\nuint test[4] = uint[4](0u, 0u, 0u, 0u);\nfor(int t = 0; t < 4; t++) {\nuint bits = 0u;\nvec2 p, q;\nvec4 a, b;\nint i = t * 8;\n@unroll\nfor(int j = 0; j < 8; j++) {\ngetPair(patternStart + i + j, rot, p, q);\na = texelFetch(image, ivec2(round(keypoint.position + pot * p)), 0);\nb = texelFetch(image, ivec2(round(keypoint.position + pot * q)), 0);\nbits |= uint(a.g < b.g) << j;\n}\ntest[t] = bits;\n}\ncolor = vec4(test[0], test[1], test[2], test[3]) / 255.0f;\n}'},7137:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D image;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#define P(x,y) ivec2((x),(y))\nconst int diskPointCount[16] = int[16](0, 4, 12, 28, 48, 80, 112, 148, 196, 252, 316, 376, 440, 528, 612, 708);\nconst ivec2 diskPoint[708] = ivec2[708](\nP(0,-1),P(-1,0),P(1,0),P(0,1),\nP(-1,-1),P(1,-1),P(-1,1),P(1,1),P(0,-2),P(-2,0),P(2,0),P(0,2),\nP(-1,-2),P(1,-2),P(-2,-1),P(2,-1),P(-2,1),P(2,1),P(-1,2),P(1,2),P(-2,-2),P(2,-2),P(-2,2),P(2,2),P(0,-3),P(-3,0),P(3,0),P(0,3),\nP(-1,-3),P(1,-3),P(-3,-1),P(3,-1),P(-3,1),P(3,1),P(-1,3),P(1,3),P(-2,-3),P(2,-3),P(-3,-2),P(3,-2),P(-3,2),P(3,2),P(-2,3),P(2,3),P(0,-4),P(-4,0),P(4,0),P(0,4),\nP(-1,-4),P(1,-4),P(-4,-1),P(4,-1),P(-4,1),P(4,1),P(-1,4),P(1,4),P(-3,-3),P(3,-3),P(-3,3),P(3,3),P(-2,-4),P(2,-4),P(-4,-2),P(4,-2),P(-4,2),P(4,2),P(-2,4),P(2,4),P(0,-5),P(-3,-4),P(3,-4),P(-4,-3),P(4,-3),P(-5,0),P(5,0),P(-4,3),P(4,3),P(-3,4),P(3,4),P(0,5),\nP(-1,-5),P(1,-5),P(-5,-1),P(5,-1),P(-5,1),P(5,1),P(-1,5),P(1,5),P(-2,-5),P(2,-5),P(-5,-2),P(5,-2),P(-5,2),P(5,2),P(-2,5),P(2,5),P(-4,-4),P(4,-4),P(-4,4),P(4,4),P(-3,-5),P(3,-5),P(-5,-3),P(5,-3),P(-5,3),P(5,3),P(-3,5),P(3,5),P(0,-6),P(-6,0),P(6,0),P(0,6),\nP(-1,-6),P(1,-6),P(-6,-1),P(6,-1),P(-6,1),P(6,1),P(-1,6),P(1,6),P(-2,-6),P(2,-6),P(-6,-2),P(6,-2),P(-6,2),P(6,2),P(-2,6),P(2,6),P(-4,-5),P(4,-5),P(-5,-4),P(5,-4),P(-5,4),P(5,4),P(-4,5),P(4,5),P(-3,-6),P(3,-6),P(-6,-3),P(6,-3),P(-6,3),P(6,3),P(-3,6),P(3,6),P(0,-7),P(-7,0),P(7,0),P(0,7),\nP(-1,-7),P(1,-7),P(-5,-5),P(5,-5),P(-7,-1),P(7,-1),P(-7,1),P(7,1),P(-5,5),P(5,5),P(-1,7),P(1,7),P(-4,-6),P(4,-6),P(-6,-4),P(6,-4),P(-6,4),P(6,4),P(-4,6),P(4,6),P(-2,-7),P(2,-7),P(-7,-2),P(7,-2),P(-7,2),P(7,2),P(-2,7),P(2,7),P(-3,-7),P(3,-7),P(-7,-3),P(7,-3),P(-7,3),P(7,3),P(-3,7),P(3,7),P(-5,-6),P(5,-6),P(-6,-5),P(6,-5),P(-6,5),P(6,5),P(-5,6),P(5,6),P(0,-8),P(-8,0),P(8,0),P(0,8),\nP(-1,-8),P(1,-8),P(-4,-7),P(4,-7),P(-7,-4),P(7,-4),P(-8,-1),P(8,-1),P(-8,1),P(8,1),P(-7,4),P(7,4),P(-4,7),P(4,7),P(-1,8),P(1,8),P(-2,-8),P(2,-8),P(-8,-2),P(8,-2),P(-8,2),P(8,2),P(-2,8),P(2,8),P(-6,-6),P(6,-6),P(-6,6),P(6,6),P(-3,-8),P(3,-8),P(-8,-3),P(8,-3),P(-8,3),P(8,3),P(-3,8),P(3,8),P(-5,-7),P(5,-7),P(-7,-5),P(7,-5),P(-7,5),P(7,5),P(-5,7),P(5,7),P(-4,-8),P(4,-8),P(-8,-4),P(8,-4),P(-8,4),P(8,4),P(-4,8),P(4,8),P(0,-9),P(-9,0),P(9,0),P(0,9),\nP(-1,-9),P(1,-9),P(-9,-1),P(9,-1),P(-9,1),P(9,1),P(-1,9),P(1,9),P(-2,-9),P(2,-9),P(-6,-7),P(6,-7),P(-7,-6),P(7,-6),P(-9,-2),P(9,-2),P(-9,2),P(9,2),P(-7,6),P(7,6),P(-6,7),P(6,7),P(-2,9),P(2,9),P(-5,-8),P(5,-8),P(-8,-5),P(8,-5),P(-8,5),P(8,5),P(-5,8),P(5,8),P(-3,-9),P(3,-9),P(-9,-3),P(9,-3),P(-9,3),P(9,3),P(-3,9),P(3,9),P(-4,-9),P(4,-9),P(-9,-4),P(9,-4),P(-9,4),P(9,4),P(-4,9),P(4,9),P(-7,-7),P(7,-7),P(-7,7),P(7,7),P(0,-10),P(-6,-8),P(6,-8),P(-8,-6),P(8,-6),P(-10,0),P(10,0),P(-8,6),P(8,6),P(-6,8),P(6,8),P(0,10),\nP(-1,-10),P(1,-10),P(-10,-1),P(10,-1),P(-10,1),P(10,1),P(-1,10),P(1,10),P(-2,-10),P(2,-10),P(-10,-2),P(10,-2),P(-10,2),P(10,2),P(-2,10),P(2,10),P(-5,-9),P(5,-9),P(-9,-5),P(9,-5),P(-9,5),P(9,5),P(-5,9),P(5,9),P(-3,-10),P(3,-10),P(-10,-3),P(10,-3),P(-10,3),P(10,3),P(-3,10),P(3,10),P(-7,-8),P(7,-8),P(-8,-7),P(8,-7),P(-8,7),P(8,7),P(-7,8),P(7,8),P(-4,-10),P(4,-10),P(-10,-4),P(10,-4),P(-10,4),P(10,4),P(-4,10),P(4,10),P(-6,-9),P(6,-9),P(-9,-6),P(9,-6),P(-9,6),P(9,6),P(-6,9),P(6,9),P(0,-11),P(-11,0),P(11,0),P(0,11),\nP(-1,-11),P(1,-11),P(-11,-1),P(11,-1),P(-11,1),P(11,1),P(-1,11),P(1,11),P(-2,-11),P(2,-11),P(-5,-10),P(5,-10),P(-10,-5),P(10,-5),P(-11,-2),P(11,-2),P(-11,2),P(11,2),P(-10,5),P(10,5),P(-5,10),P(5,10),P(-2,11),P(2,11),P(-8,-8),P(8,-8),P(-8,8),P(8,8),P(-3,-11),P(3,-11),P(-7,-9),P(7,-9),P(-9,-7),P(9,-7),P(-11,-3),P(11,-3),P(-11,3),P(11,3),P(-9,7),P(9,7),P(-7,9),P(7,9),P(-3,11),P(3,11),P(-6,-10),P(6,-10),P(-10,-6),P(10,-6),P(-10,6),P(10,6),P(-6,10),P(6,10),P(-4,-11),P(4,-11),P(-11,-4),P(11,-4),P(-11,4),P(11,4),P(-4,11),P(4,11),P(0,-12),P(-12,0),P(12,0),P(0,12),\nP(-1,-12),P(1,-12),P(-8,-9),P(8,-9),P(-9,-8),P(9,-8),P(-12,-1),P(12,-1),P(-12,1),P(12,1),P(-9,8),P(9,8),P(-8,9),P(8,9),P(-1,12),P(1,12),P(-5,-11),P(5,-11),P(-11,-5),P(11,-5),P(-11,5),P(11,5),P(-5,11),P(5,11),P(-2,-12),P(2,-12),P(-12,-2),P(12,-2),P(-12,2),P(12,2),P(-2,12),P(2,12),P(-7,-10),P(7,-10),P(-10,-7),P(10,-7),P(-10,7),P(10,7),P(-7,10),P(7,10),P(-3,-12),P(3,-12),P(-12,-3),P(12,-3),P(-12,3),P(12,3),P(-3,12),P(3,12),P(-6,-11),P(6,-11),P(-11,-6),P(11,-6),P(-11,6),P(11,6),P(-6,11),P(6,11),P(-4,-12),P(4,-12),P(-12,-4),P(12,-4),P(-12,4),P(12,4),P(-4,12),P(4,12),P(-9,-9),P(9,-9),P(-9,9),P(9,9),P(-8,-10),P(8,-10),P(-10,-8),P(10,-8),P(-10,8),P(10,8),P(-8,10),P(8,10),P(0,-13),P(-5,-12),P(5,-12),P(-12,-5),P(12,-5),P(-13,0),P(13,0),P(-12,5),P(12,5),P(-5,12),P(5,12),P(0,13),\nP(-1,-13),P(1,-13),P(-7,-11),P(7,-11),P(-11,-7),P(11,-7),P(-13,-1),P(13,-1),P(-13,1),P(13,1),P(-11,7),P(11,7),P(-7,11),P(7,11),P(-1,13),P(1,13),P(-2,-13),P(2,-13),P(-13,-2),P(13,-2),P(-13,2),P(13,2),P(-2,13),P(2,13),P(-3,-13),P(3,-13),P(-13,-3),P(13,-3),P(-13,3),P(13,3),P(-3,13),P(3,13),P(-6,-12),P(6,-12),P(-12,-6),P(12,-6),P(-12,6),P(12,6),P(-6,12),P(6,12),P(-9,-10),P(9,-10),P(-10,-9),P(10,-9),P(-10,9),P(10,9),P(-9,10),P(9,10),P(-4,-13),P(4,-13),P(-8,-11),P(8,-11),P(-11,-8),P(11,-8),P(-13,-4),P(13,-4),P(-13,4),P(13,4),P(-11,8),P(11,8),P(-8,11),P(8,11),P(-4,13),P(4,13),P(-7,-12),P(7,-12),P(-12,-7),P(12,-7),P(-12,7),P(12,7),P(-7,12),P(7,12),P(-5,-13),P(5,-13),P(-13,-5),P(13,-5),P(-13,5),P(13,5),P(-5,13),P(5,13),P(0,-14),P(-14,0),P(14,0),P(0,14),\nP(-1,-14),P(1,-14),P(-14,-1),P(14,-1),P(-14,1),P(14,1),P(-1,14),P(1,14),P(-2,-14),P(2,-14),P(-10,-10),P(10,-10),P(-14,-2),P(14,-2),P(-14,2),P(14,2),P(-10,10),P(10,10),P(-2,14),P(2,14),P(-9,-11),P(9,-11),P(-11,-9),P(11,-9),P(-11,9),P(11,9),P(-9,11),P(9,11),P(-3,-14),P(3,-14),P(-6,-13),P(6,-13),P(-13,-6),P(13,-6),P(-14,-3),P(14,-3),P(-14,3),P(14,3),P(-13,6),P(13,6),P(-6,13),P(6,13),P(-3,14),P(3,14),P(-8,-12),P(8,-12),P(-12,-8),P(12,-8),P(-12,8),P(12,8),P(-8,12),P(8,12),P(-4,-14),P(4,-14),P(-14,-4),P(14,-4),P(-14,4),P(14,4),P(-4,14),P(4,14),P(-7,-13),P(7,-13),P(-13,-7),P(13,-7),P(-13,7),P(13,7),P(-7,13),P(7,13),P(-5,-14),P(5,-14),P(-10,-11),P(10,-11),P(-11,-10),P(11,-10),P(-14,-5),P(14,-5),P(-14,5),P(14,5),P(-11,10),P(11,10),P(-10,11),P(10,11),P(-5,14),P(5,14),P(0,-15),P(-9,-12),P(9,-12),P(-12,-9),P(12,-9),P(-15,0),P(15,0),P(-12,9),P(12,9),P(-9,12),P(9,12),P(0,15)\n);\nconst int DEFAULT_PATCH_RADIUS = 15;\nconst int MIN_PATCH_RADIUS = 2;\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nint keypointIndex = thread.x + thread.y * outputSize().x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\nvec2 m = vec2(0.0f);\nfloat pot = exp2(keypoint.lod);\nvec2 imageSize = vec2(textureSize(image, 0));\nint scaledRadius = int(ceil(float(DEFAULT_PATCH_RADIUS) / pot));\nint radius = max(scaledRadius, MIN_PATCH_RADIUS);\nint count = diskPointCount[radius];\nfor(int j = 0; j < count; j++) {\nvec2 offset = vec2(diskPoint[j]);\nvec2 position = keypoint.position + round(pot * offset);\nvec4 patchPixel = texture(image, (position + vec2(0.5f)) / imageSize);\nm += offset * patchPixel.g;\n}\nfloat angle = fastAtan2(m.y, m.x);\nfloat encodedOrientation = encodeKeypointOrientation(angle);\ncolor = vec4(0.0f, encodedOrientation, 0.0f, 0.0f);\n}'},9739:e=>{e.exports='@include "keypoints.glsl"\n@include "filters.glsl"\n#if !defined(METHOD)\n#error Undefined METHOD\n#endif\nuniform sampler2D pyramid;\nuniform float lodStep;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#if METHOD == 1\nuniform int threshold;\n#endif\nconst float eps = 1e-6;\nfloat cornerStrength(vec2 position, float lod)\n{\n#if METHOD == 0\nreturn laplacian(pyramid, position, lod);\n#elif METHOD == 1\nfloat pot = exp2(lod);\nfloat t = float(clamp(threshold, 0, 255)) / 255.0f;\n#define P(x,y) pyrPixelAtOffset(pyramid, lod, pot, ivec2((x),(y))).g\nmat4 mp = mat4(\nP(0,3),P(3,0),P(0,-3),P(-3,0),\nP(1,3),P(2,2),P(3,1),P(3,-1),\nP(2,-2),P(1,-3),P(-1,-3),P(-2,-2),\nP(-3,-1),P(-3,1),P(-2,2),P(-1,3)\n);\nfloat c = P(0,0);\nfloat ct = c + t, c_t = c - t;\nmat4 mct = mp - mat4(ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct,ct);\nmat4 mc_t = mat4(c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t,c_t) - mp;\nconst vec4 zeros = vec4(0.0f), ones = vec4(1.0f);\nvec4 bs = max(mct[0], zeros), ds = max(mc_t[0], zeros);\nbs += max(mct[1], zeros); ds += max(mc_t[1], zeros);\nbs += max(mct[2], zeros); ds += max(mc_t[2], zeros);\nbs += max(mct[3], zeros); ds += max(mc_t[3], zeros);\nreturn max(dot(bs, ones), dot(ds, ones)) / 16.0f;\n#else\n#error Invalid method\n#endif\n}\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\ncolor = pixel;\nif(address.offset != 1)\nreturn;\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\nif(isBadKeypoint(keypoint))\nreturn;\nvec3 strength = vec3(\ncornerStrength(keypoint.position, max(0.0f, keypoint.lod - lodStep)),\ncornerStrength(keypoint.position, keypoint.lod),\ncornerStrength(keypoint.position, keypoint.lod + lodStep)\n);\nvec3 p = mat3(\n2, -3, 1,\n-4, 4, 0,\n2, -1, 0\n) * strength;\nfloat maxStrength = max(strength.x, max(strength.y, strength.z));\nvec3 diffStrength = abs(strength - vec3(maxStrength));\nvec3 strengthIndicators = vec3(lessThan(diffStrength, vec3(eps)));\nfloat maxPoint = min(1.0f, dot(vec3(0.0f, 0.5f, 1.0f), strengthIndicators));\nbool hasMax = p.x < -eps;\nfloat pmax = hasMax ? -0.5f * p.y / p.x : maxPoint;\nfloat alpha = abs(pmax - 0.5f) <= 0.5f ? pmax : maxPoint;\nfloat lodOffset = mix(-lodStep, lodStep, alpha);\nfloat lod = keypoint.lod + lodOffset;\ncolor.r = encodeLod(lod);\n}'},8231:e=>{e.exports='@include "float16.glsl"\nuniform sampler2D corners;\nuniform int iterationNumber;\nvoid main()\n{\nivec2 thread = threadLocation();\nivec2 bounds = outputSize();\nint jump = (1 << iterationNumber);\nint clusterLength = jump << 1;\nint clusterMask = clusterLength - 1;\nivec2 clusterPos = ivec2(thread >> (1 + iterationNumber)) << (1 + iterationNumber);\nivec2 next1 = clusterPos + ((thread - clusterPos + ivec2(jump, 0)) & clusterMask);\nivec2 next2 = clusterPos + ((thread - clusterPos + ivec2(0, jump)) & clusterMask);\nivec2 next3 = clusterPos + ((thread - clusterPos + ivec2(jump, jump)) & clusterMask);\nvec4 p0 = threadPixel(corners);\nvec4 p1 = texelFetch(corners, next1 % bounds, 0);\nvec4 p2 = texelFetch(corners, next2 % bounds, 0);\nvec4 p3 = texelFetch(corners, next3 % bounds, 0);\nfloat s0 = decodeFloat16(p0.rb);\nfloat s1 = decodeFloat16(p1.rb);\nfloat s2 = decodeFloat16(p2.rb);\nfloat s3 = decodeFloat16(p3.rb);\nbool b0 = s0 >= s1 && s0 >= s2 && s0 >= s3;\nbool b1 = s1 >= s0 && s1 >= s2 && s1 >= s3;\nbool b2 = s2 >= s0 && s2 >= s1 && s2 >= s3;\ncolor = vec4(0.0f);\ncolor.rb = b0 ? p0.rb : (\nb1 ? p1.rb : (\nb2 ? p2.rb : p3.rb\n)\n);\n}'},2518:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#if PERMUTATION_MAXLEN % 4 > 0 || PERMUTATION_MAXLEN * 4 > 16384\n#error Invalid PERMUTATION_MAXLEN\n#endif\nlayout(std140) uniform Permutation\n{\nivec4 permutation[PERMUTATION_MAXLEN / 4];\n};\nint permutationElement(int index)\n{\nint base = index - (index % PERMUTATION_MAXLEN);\nint offset = index - base;\nivec4 tuple = permutation[offset / 4];\nint newOffset = tuple[offset & 3];\nreturn base + newOffset;\n}\nvoid main()\n{\nivec2 thread = threadLocation();\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress myAddress = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint myIndex = findKeypointIndex(myAddress, descriptorSize, extraSize);\nint otherIndex = permutationElement(myIndex);\nKeypointAddress otherAddress = KeypointAddress(otherIndex * pixelsPerKeypoint, myAddress.offset);\nKeypoint myKeypoint = decodeKeypoint(encodedKeypoints, encoderLength, myAddress);\nKeypoint otherKeypoint = decodeKeypoint(encodedKeypoints, encoderLength, otherAddress);\ncolor = readKeypointData(encodedKeypoints, encoderLength, otherAddress);\n}'},8096:e=>{e.exports='@include "keypoints.glsl"\n#if !defined(STAGE)\n#error Undefined STAGE\n#elif STAGE == 1\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#elif STAGE == 2\nuniform sampler2D permutation;\nuniform int blockSize;\nuniform int dblLog2BlockSize;\n#elif STAGE == 3\nuniform sampler2D permutation;\nuniform int maxKeypoints;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\n#else\n#error Invalid STAGE\n#endif\nstruct PermutationElement\n{\nint keypointIndex;\nfloat score;\nbool valid;\n};\nvec4 encodePermutationElement(PermutationElement element)\n{\nconst vec2 ONES = vec2(1.0f);\nvec2 encodedScore = element.valid ? encodeFloat16(element.score) : ONES;\nvec2 encodedIndex = vec2(element.keypointIndex & 255, (element.keypointIndex >> 8) & 255) / 255.0f;\nreturn vec4(encodedIndex, encodedScore);\n}\nPermutationElement decodePermutationElement(vec4 pixel)\n{\nconst vec2 ONES = vec2(1.0f);\nPermutationElement element;\nelement.keypointIndex = int(pixel.r * 255.0f) | (int(pixel.g * 255.0f) << 8);\nelement.valid = !all(equal(pixel.ba, ONES));\nelement.score = element.valid ? decodeFloat16(pixel.ba) : -1.0f;\nreturn element;\n}\nPermutationElement readPermutationElement(sampler2D permutation, int elementIndex, int stride, int height)\n{\nconst vec4 INVALID_PIXEL = vec4(1.0f);\nivec2 pos = ivec2(elementIndex % stride, elementIndex / stride);\nvec4 pixel = pos.y < height ? pixelAt(permutation, pos) : INVALID_PIXEL;\nreturn decodePermutationElement(pixel);\n}\n#if STAGE == 2\nPermutationElement selectKth(sampler2D permutation, int k, int la, int ra, int lb, int rb)\n{\nfloat scoreA, scoreB;\nint ha, hb, ma, mb;\nbool discard1stHalf, altb;\nbool locked = false;\nint tmp, result = 0;\nint stride = outputSize().x;\nint height = outputSize().y;\nfor(int i = 0; i < dblLog2BlockSize; i++) {\ntmp = (lb > rb && !locked) ? (la+k) : result;\nresult = (la > ra && !locked) ? (lb+k) : tmp;\nlocked = locked || (la > ra) || (lb > rb);\nha = (ra - la + 1) / 2;\nhb = (rb - lb + 1) / 2;\nma = la + ha;\nmb = lb + hb;\nscoreA = readPermutationElement(permutation, ma, stride, height).score;\nscoreB = readPermutationElement(permutation, mb, stride, height).score;\ndiscard1stHalf = (k > ha + hb);\naltb = (-scoreA < -scoreB);\nk -= int(discard1stHalf && altb) * (ha + 1);\nk -= int(discard1stHalf && !altb) * (hb + 1);\nla += int(discard1stHalf && altb) * (ma + 1 - la);\nlb += int(discard1stHalf && !altb) * (mb + 1 - lb);\nra += int(!discard1stHalf && !altb) * (ma - 1 - ra);\nrb += int(!discard1stHalf && altb) * (mb - 1 - rb);\n}\nreturn readPermutationElement(permutation, result, stride, height);\n}\n#endif\nvoid main()\n{\n#if STAGE == 1\nivec2 thread = threadLocation();\nint stride = outputSize().x;\nint keypointIndex = thread.y * stride + thread.x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\nPermutationElement element;\nelement.keypointIndex = keypointIndex;\nelement.score = keypoint.score;\nelement.valid = !isBadKeypoint(keypoint);\ncolor = encodePermutationElement(element);\n#elif STAGE == 2\nivec2 thread = threadLocation();\nint stride = outputSize().x;\nint elementIndex = thread.y * stride + thread.x;\nint blockIndex = elementIndex / blockSize;\nint blockOffset = elementIndex % blockSize;\nint la = blockIndex * blockSize;\nint lb = la + blockSize / 2;\nint ra = lb - 1;\nint rb = (blockIndex + 1) * blockSize - 1;\nint k = blockOffset;\nPermutationElement element = selectKth(permutation, k, la, ra, lb, rb);\ncolor = encodePermutationElement(element);\n#elif STAGE == 3\nivec2 thread = threadLocation();\nint newEncoderLength = outputSize().x;\nKeypointAddress myAddress = findKeypointAddress(thread, newEncoderLength, descriptorSize, extraSize);\nint myKeypointIndex = findKeypointIndex(myAddress, descriptorSize, extraSize);\nivec2 psize = textureSize(permutation, 0);\nPermutationElement element = readPermutationElement(permutation, myKeypointIndex, psize.x, psize.y);\nint oldEncoderLength = textureSize(encodedKeypoints, 0).x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(element.keypointIndex * pixelsPerKeypoint, myAddress.offset);\nvec4 keypointData = readKeypointData(encodedKeypoints, oldEncoderLength, address);\ncolor = myKeypointIndex < maxKeypoints && element.valid ? keypointData : encodeNullKeypoint();\n#endif\n}'},5795:e=>{e.exports='@include "keypoints.glsl"\n@include "float16.glsl"\n#if !defined(METHOD)\n#error Must define METHOD\n#endif\nuniform sampler2D pyramid;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nuniform int maxIterations;\nuniform float epsilon;\nconst int PATCH_RADIUS = 1;\nconst int PATCH_SIZE = 2 * PATCH_RADIUS + 1;\nconst int PATCH_SIZE_SQUARED = PATCH_SIZE * PATCH_SIZE;\nconst int LARGE_PATCH_RADIUS = PATCH_RADIUS + 1;\nconst int LARGE_PATCH_SIZE = 2 * LARGE_PATCH_RADIUS + 1;\nconst int LARGE_PATCH_SIZE_SQUARED = LARGE_PATCH_SIZE * LARGE_PATCH_SIZE;\nconst int LARGER_PATCH_RADIUS = LARGE_PATCH_RADIUS + 1;\nconst int LARGER_PATCH_SIZE = 2 * LARGER_PATCH_RADIUS + 1;\nconst int LARGER_PATCH_SIZE_SQUARED = LARGER_PATCH_SIZE * LARGER_PATCH_SIZE;\nconst float EPS = 1e-5;\nfloat smoothPixelBuffer[LARGER_PATCH_SIZE_SQUARED];\nvec2 derivativesBuffer[LARGE_PATCH_SIZE_SQUARED];\nfloat responseBuffer[PATCH_SIZE_SQUARED];\n#define patchPixelAt(u,v) smoothPixelBuffer[((v) + LARGER_PATCH_RADIUS) * LARGER_PATCH_SIZE + ((u) + LARGER_PATCH_RADIUS)]\n#define derivativesAt(u,v) derivativesBuffer[((v) + LARGE_PATCH_RADIUS) * LARGE_PATCH_SIZE + ((u) + LARGE_PATCH_RADIUS)]\n#define responseAt(u,v) responseBuffer[((v) + PATCH_RADIUS) * PATCH_SIZE + ((u) + PATCH_RADIUS)]\nvoid readPixels(vec2 center, float lod)\n{\nivec2 pyrBaseSize = textureSize(pyramid, 0);\nfloat pot = exp2(lod);\nint u, v;\nfor(int j = 0; j < LARGER_PATCH_SIZE; j++) {\nfor(int i = 0; i < LARGER_PATCH_SIZE; i++) {\nu = i - LARGER_PATCH_RADIUS;\nv = j - LARGER_PATCH_RADIUS;\npatchPixelAt(u,v) = pyrSubpixelAtExOffset(pyramid, center, lod, pot, ivec2(u,v), pyrBaseSize).g;\n}\n}\n}\nvoid computeDerivatives()\n{\nconst mat3 dx = mat3(\n-1, 0, 1,\n-2, 0, 2,\n-1, 0, 1\n);\nconst mat3 dy = mat3(\n1, 2, 1,\n0, 0, 0,\n-1,-2,-1\n);\nint u, v;\nmat3 pix, convX, convY;\nconst vec3 ones = vec3(1.0f);\nfor(int j = 0; j < LARGE_PATCH_SIZE; j++) {\nfor(int i = 0; i < LARGE_PATCH_SIZE; i++) {\nu = i - LARGE_PATCH_RADIUS;\nv = j - LARGE_PATCH_RADIUS;\npix = mat3(\npatchPixelAt(u+1,v+1), patchPixelAt(u+0,v+1), patchPixelAt(u-1,v+1),\npatchPixelAt(u+1,v+0), patchPixelAt(u+0,v+0), patchPixelAt(u-1,v+0),\npatchPixelAt(u+1,v-1), patchPixelAt(u+0,v-1), patchPixelAt(u-1,v-1)\n);\nconvX = matrixCompMult(dx, pix);\nconvY = matrixCompMult(dy, pix);\nderivativesAt(u,v) = vec2(\ndot(ones, vec3(\ndot(convX[0], ones),\ndot(convX[1], ones),\ndot(convX[2], ones)\n)),\ndot(ones, vec3(\ndot(convY[0], ones),\ndot(convY[1], ones),\ndot(convY[2], ones)\n))\n);\n}\n}\n}\nvec2 computeResponseMap()\n{\nfloat patchArea = float(PATCH_SIZE * PATCH_SIZE);\nvec3 h; vec2 d, c = vec2(0.0f);\nconst vec3 ones = vec3(1.0f);\nfloat response, sum = 0.0f;\nint u, v;\n#define H(r,s) d = derivativesAt((r),(s)); h += vec3(d.x * d.x, d.x * d.y, d.y * d.y)\nfor(int j = 0; j < PATCH_SIZE; j++) {\nfor(int i = 0; i < PATCH_SIZE; i++) {\nu = i - PATCH_RADIUS;\nv = j - PATCH_RADIUS;\nh = vec3(0.0f);\nH(u-1,v-1); H(u+0,v-1); H(u+1,v-1);\nH(u-1,v+0); H(u+0,v+0); H(u+1,v+0);\nH(u-1,v+1); H(u+0,v+1); H(u+1,v+1);\nresponse = 0.5f * (h.x + h.z - sqrt((h.x - h.z) * (h.x - h.z) + 4.0f * h.y * h.y));\nresponse /= patchArea;\nresponseAt(u,v) = response;\nc += vec2(u,v) * response;\nsum += response;\n}\n}\nreturn abs(sum) > EPS ? c / sum : vec2(0.0f);\n}\n#if METHOD == 0\nvec2 quadratic1d()\n{\nfloat a = 0.5f * (responseAt(-1,0) - 2.0f * responseAt(0,0) + responseAt(1,0));\nfloat b = 0.5f * (responseAt(1,0) - responseAt(-1,0));\nfloat c = responseAt(0,0);\nfloat d = 0.5f * (responseAt(0,-1) - 2.0f * responseAt(0,0) + responseAt(0,1));\nfloat e = 0.5f * (responseAt(0,1) - responseAt(0,-1));\nfloat f = responseAt(0,0);\nbool hasMax = a < -EPS && d < -EPS;\nreturn hasMax ? -0.5f * vec2(b / a, e / d) : vec2(0.0f);\n}\n#endif\n#if METHOD == 1\nvec2 taylor2d()\n{\nfloat dx = (-responseAt(-1,0) + responseAt(1,0)) * 0.5f;\nfloat dy = (-responseAt(0,-1) + responseAt(0,1)) * 0.5f;\nfloat dxx = responseAt(-1,0) - 2.0f * responseAt(0,0) + responseAt(1,0);\nfloat dyy = responseAt(0,-1) - 2.0f * responseAt(0,0) + responseAt(0,1);\nfloat dxy = (responseAt(-1,-1) + responseAt(1,1) - responseAt(1,-1) - responseAt(-1,1)) * 0.25f;\nfloat det = dxx * dyy - dxy * dxy;\nmat2 inv = mat2(dyy, -dxy, -dxy, dxx);\nbool hasMax = det > EPS && dxx < 0.0f;\nreturn hasMax ? inv * vec2(dx, dy) / (-det) : vec2(0.0f);\n}\n#endif\n#if METHOD == 2\nvoid bilinearUpsample(ivec2 patchOffset, vec4 pixelsOfPatch)\n{\nint u, v, i, j;\nvec2 frc, ifrc; vec4 sub;\nconst vec4 ones = vec4(1.0f);\nfloat s = 1.0f / float(PATCH_SIZE - 1);\nint xoff = 2 * patchOffset.x;\nint yoff = 2 * patchOffset.y;\nfor(j = 0; j < PATCH_SIZE; j++) {\nfor(i = 0; i < PATCH_SIZE; i++) {\nu = i - PATCH_RADIUS;\nv = j - PATCH_RADIUS;\nfrc = vec2(i, j) * s;\nifrc = vec2(1.0f) - frc;\nsub = vec4(\nifrc.x * ifrc.y,\nfrc.x * ifrc.y,\nifrc.x * frc.y,\nfrc.x * frc.y\n);\npatchPixelAt(u+xoff,v+yoff) = dot(sub*pixelsOfPatch, ones);\n}\n}\n}\n#endif\n#if METHOD == 3\nvoid bicubicUpsample(ivec2 patchOffset, vec4 pixelsOfPatch, vec4 dx, vec4 dy, vec4 dxy)\n{\nfloat x, y, s = 1.0f / float(PATCH_SIZE - 1);\nint u, v, i, j;\nfloat f00 = pixelsOfPatch.x;\nfloat f10 = pixelsOfPatch.y;\nfloat f01 = pixelsOfPatch.z;\nfloat f11 = pixelsOfPatch.w;\nfloat fx00 = dx.x;\nfloat fx10 = dx.y;\nfloat fx01 = dx.z;\nfloat fx11 = dx.w;\nfloat fy00 = dy.x;\nfloat fy10 = dy.y;\nfloat fy01 = dy.z;\nfloat fy11 = dy.w;\nfloat fxy00 = dxy.x;\nfloat fxy10 = dxy.y;\nfloat fxy01 = dxy.z;\nfloat fxy11 = dxy.w;\nmat4 bicubic = mat4(\n1, 0, -3, 2,\n0, 0, 3, -2,\n0, 1, -2, 1,\n0, 0, -1, 1\n) * mat4(\nf00, f10, fx00, fx10,\nf01, f11, fx01, fx11,\nfy00, fy10, fxy00, fxy10,\nfy01, fy11, fxy01, fxy11\n) * mat4(\n1, 0, 0, 0,\n0, 0, 1, 0,\n-3, 3, -2, -1,\n2, -2, 1, 1\n);\nint xoff = 2 * patchOffset.x;\nint yoff = 2 * patchOffset.y;\nfor(j = 0; j < PATCH_SIZE; j++) {\nfor(i = 0; i < PATCH_SIZE; i++) {\nu = i - PATCH_RADIUS;\nv = j - PATCH_RADIUS;\nx = float(i) * s;\ny = float(j) * s;\npatchPixelAt(u+xoff,v+yoff) = dot(\nvec4(1, x, x*x, x*x*x),\nbicubic * vec4(1, y, y*y, y*y*y)\n);\n}\n}\n}\n#endif\n#if METHOD == 2 || METHOD == 3\nvoid upsamplePatch(int left, int top, int right, int bottom)\n{\nint x, y, k;\nvec4 ptch[9];\nvec2 d00, d10, d01, d11;\nfor(k = 0; k < 9; k++) {\nx = -1 + (k % 3);\ny = -1 + (k / 3);\nptch[k] = vec4(\npatchPixelAt(left+x, top+y),\npatchPixelAt(right+x, top+y),\npatchPixelAt(left+x, bottom+y),\npatchPixelAt(right+x, bottom+y)\n);\n}\nfor(k = 0; k < 9; k++) {\nx = -1 + (k % 3);\ny = -1 + (k / 3);\n#if METHOD == 2\nbilinearUpsample(ivec2(x, y), ptch[k]);\n#elif METHOD == 3\nd00 = derivativesAt(left+x, top+y);\nd10 = derivativesAt(right+x, top+y);\nd01 = derivativesAt(left+x, bottom+y);\nd11 = derivativesAt(right+x, bottom+y);\nbicubicUpsample(ivec2(x, y), ptch[k],\nvec4(d00.x, d10.x, d01.x, d11.x),\nvec4(d00.y, d10.y, d01.y, d11.y),\n0.25f * vec4(\n(patchPixelAt(left+x + 1,top+y + 1) + patchPixelAt(left+x - 1, top+y - 1)) - (patchPixelAt(left+x + 1, top+y - 1) + patchPixelAt(left+x - 1, top+y + 1)),\n(patchPixelAt(right+x + 1,top+y + 1) + patchPixelAt(right+x - 1, top+y - 1)) - (patchPixelAt(right+x + 1, top+y - 1) + patchPixelAt(right+x - 1, top+y + 1)),\n(patchPixelAt(left+x + 1,bottom+y + 1) + patchPixelAt(left+x - 1, bottom+y - 1)) - (patchPixelAt(left+x + 1, bottom+y - 1) + patchPixelAt(left+x - 1, bottom+y + 1)),\n(patchPixelAt(right+x + 1,bottom+y + 1) + patchPixelAt(right+x - 1, bottom+y - 1)) - (patchPixelAt(right+x + 1, bottom+y - 1) + patchPixelAt(right+x - 1, bottom+y + 1))\n)\n);\n#endif\n}\n}\nvec2 upsampleResponseMap(int left, int top, int right, int bottom)\n{\nupsamplePatch(left, top, right, bottom);\ncomputeDerivatives();\nreturn computeResponseMap();\n}\nvec2 iterativeUpsample(vec2 initialGuess)\n{\nint refine = 1;\nfloat scale = 0.5f;\nfloat eps2 = epsilon * epsilon;\nvec2 guess = initialGuess, localGuess = initialGuess;\nfor(int k = 0; k < maxIterations; k++) {\nivec4 quad = ivec4(floor(localGuess.x), floor(localGuess.y), ceil(localGuess.x), ceil(localGuess.y));\nvec2 response = (refine != 0) ? upsampleResponseMap(quad.x, quad.y, quad.z, quad.w) : vec2(0.0f);\nlocalGuess = response * scale;\nguess += localGuess;\nscale *= 0.5f;\nrefine *= int(dot(localGuess, localGuess) >= eps2);\n}\nreturn guess;\n}\n#endif\nvoid main()\n{\nivec2 thread = threadLocation();\nint keypointIndex = thread.x + thread.y * outputSize().x;\nint pixelsPerKeypoint = sizeofEncodedKeypoint(descriptorSize, extraSize) / 4;\nKeypointAddress address = KeypointAddress(keypointIndex * pixelsPerKeypoint, 0);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, address);\ncolor = encodeNullPairOfFloat16();\nif(isNullKeypoint(keypoint))\nreturn;\ncolor = encodeDiscardedPairOfFloat16();\nif(isBadKeypoint(keypoint))\nreturn;\nreadPixels(keypoint.position, keypoint.lod);\ncomputeDerivatives();\nvec2 offset = computeResponseMap();\n#if METHOD == 0\noffset = quadratic1d();\n#elif METHOD == 1\noffset = taylor2d();\n#elif METHOD == 2 || METHOD == 3\noffset = iterativeUpsample(offset);\n#else\n#error Unknown METHOD\n#endif\nfloat pot = exp2(keypoint.lod);\ncolor = encodePairOfFloat16(offset * pot);\n}'},3169:e=>{e.exports='@include "keypoints.glsl"\n@include "float16.glsl"\nuniform sampler2D encodedFlow;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nint len = textureSize(encodedFlow, 0).x;\nKeypointAddress myAddress = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, myAddress);\nint myIndex = findKeypointIndex(myAddress, descriptorSize, extraSize);\ncolor = pixel;\nif(isBadKeypoint(keypoint))\nreturn;\nivec2 location = ivec2(myIndex % len, myIndex / len);\nvec4 encodedFlow = myIndex < len * len ? pixelAt(encodedFlow, location) : encodeDiscardedKeypoint();\nbool discardFlow = isDiscardedPairOfFloat16(encodedFlow);\nvec2 flow = !discardFlow ? decodePairOfFloat16(encodedFlow) : vec2(0.0f);\nvec4 newPosition = encodeKeypointPosition(keypoint.position + flow);\nvec4 newPixel = myAddress.offset == 0 ? newPosition : pixel;\ncolor = !discardFlow ? newPixel : encodeDiscardedKeypoint();\n}'},1337:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedOrientations;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nKeypointAddress myAddress = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint myIndex = findKeypointIndex(myAddress, descriptorSize, extraSize);\nint orientationEncoderLength = textureSize(encodedOrientations, 0).x;\nivec2 location = ivec2(myIndex % orientationEncoderLength, myIndex / orientationEncoderLength);\nvec4 targetPixel = pixelAt(encodedOrientations, location);\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, myAddress);\nbool isValid = !isBadKeypoint(keypoint);\nfloat encodedOrientation = targetPixel.g;\ncolor = isValid && myAddress.offset == 1 ? vec4(pixel.r, encodedOrientation, pixel.ba) : pixel;\n}'},6187:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedData;\nuniform int strideOfEncodedData;\nuniform sampler2D encodedKeypoints;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\nvec4 readEncodedData(sampler2D encodedData, int strideOfEncodedData, int elementId, int pixelsPerElement, int pixelOffset)\n{\nint rasterIndex = elementId * pixelsPerElement + pixelOffset;\nivec2 pos = ivec2(rasterIndex % strideOfEncodedData, rasterIndex / strideOfEncodedData);\nreturn texelFetch(encodedData, pos, 0);\n}\nvoid main()\n{\nivec2 thread = threadLocation();\nKeypointAddress myAddress = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint myIndex = findKeypointIndex(myAddress, descriptorSize, extraSize);\nint headerSize = sizeofEncodedKeypointHeader();\nint extraCell = myAddress.offset - headerSize / 4;\nint numberOfExtraCells = extraSize / 4;\ncolor = threadPixel(encodedKeypoints);\nif(extraCell < 0 || extraCell >= numberOfExtraCells)\nreturn;\nKeypoint keypoint = decodeKeypoint(encodedKeypoints, encoderLength, myAddress);\nif(isBadKeypoint(keypoint))\nreturn;\ncolor = readEncodedData(encodedData, strideOfEncodedData, myIndex, numberOfExtraCells, extraCell);\n}'},477:e=>{e.exports='@include "keypoints.glsl"\nuniform sampler2D encodedKeypoints;\nuniform int startIndex;\nuniform int endIndex;\nuniform int descriptorSize;\nuniform int extraSize;\nuniform int encoderLength;\n#ifndef BUFFER_SIZE\n#error Undefined BUFFER_SIZE\n#endif\nlayout(std140) uniform KeypointBuffer\n{\nvec4 keypointBuffer[BUFFER_SIZE];\n};\nvoid main()\n{\nvec4 pixel = threadPixel(encodedKeypoints);\nivec2 thread = threadLocation();\nKeypointAddress address = findKeypointAddress(thread, encoderLength, descriptorSize, extraSize);\nint index = findKeypointIndex(address, descriptorSize, extraSize);\ncolor = pixel;\nif(index < startIndex)\nreturn;\ncolor = encodeNullKeypoint();\nif(index >= endIndex)\nreturn;\nvec4 data = keypointBuffer[index - startIndex];\nswitch(address.offset) {\ncase 0: {\ncolor = encodeKeypointPosition(data.xy);\nbreak;\n}\ncase 1: {\nvec2 score = encodeKeypointScore(max(data.w, 0.0f));\nfloat scale = encodeLod(data.z);\nfloat rotation = encodeKeypointOrientation(0.0f);\ncolor = vec4(scale, rotation, score);\nbreak;\n}\ndefault: {\ncolor = vec4(0.0f);\nbreak;\n}\n}\n}'},4050:e=>{e.exports="uniform sampler2D image;\nvoid main()\n{\n#if 1\ncolor = texture(image, texCoord);\n#else\nivec2 thread = threadLocation();\nivec2 pos = min(thread * 2, textureSize(image, 0) - ivec2(1));\ncolor = pixelAt(image, pos);\n#endif\n}"},5545:e=>{e.exports="uniform sampler2D image;\nvoid main()\n{\nivec2 thread = threadLocation();\nvec4 pixel = pixelAt(image, thread / 2);\ncolor = (((thread.x + thread.y) & 1) == 0) ? pixel : vec4(0.0f, 0.0f, 0.0f, pixel.a);\n}"},7113:e=>{e.exports='@include "subpixel.glsl"\nuniform sampler2D image0;\nuniform sampler2D image1;\nuniform float alpha;\nuniform float beta;\nuniform float gamma;\nconst vec4 BACKGROUND = vec4(0.0f);\nvoid main()\n{\nivec2 location = threadLocation();\nivec2 size0 = textureSize(image0, 0);\nivec2 size1 = textureSize(image1, 0);\nvec4 pix0 = all(lessThan(location, size0)) ? pixelAt(image0, location) : BACKGROUND;\nvec4 pix1 = all(lessThan(location, size1)) ? pixelAt(image1, location) : BACKGROUND;\nvec4 pix = clamp(alpha * pix0 + beta * pix1 + vec4(gamma), 0.0f, 1.0f);\ncolor = vec4(pix.rgb, 1.0f);\n}'},1202:e=>{e.exports='@include "subpixel.glsl"\nuniform sampler2D image;\nvoid main()\n{\nvec2 imageSize = vec2(textureSize(image, 0));\n#if !defined(INTERPOLATION_METHOD)\n#error Must define INTERPOLATION_METHOD\n#elif INTERPOLATION_METHOD == 0\nvec2 pos = texCoord * imageSize;\ncolor = textureLod(image, (round(pos) + vec2(0.5f)) / imageSize, 0.0f);\n#elif INTERPOLATION_METHOD == 1\ncolor = subpixelAtBI(image, texCoord * imageSize);\n#else\n#error Invalid INTERPOLATION_METHOD\n#endif\n}'},7971:e=>{e.exports='@include "subpixel.glsl"\nuniform sampler2D image;\nuniform mat3 inverseHomography;\nconst vec4 emptyColor = vec4(0.0f, 0.0f, 0.0f, 1.0f);\nvec2 perspectiveWarp(mat3 homography, vec2 p)\n{\nvec3 q = homography * vec3(p, 1.0f);\nreturn q.xy / q.z;\n}\nvoid main()\n{\nivec2 location = threadLocation();\nivec2 size = outputSize();\nconst vec2 zero = vec2(0.0f);\nvec2 target = perspectiveWarp(inverseHomography, vec2(location));\nbool withinBounds = all(bvec4(greaterThanEqual(target, zero), lessThan(target, vec2(size))));\ncolor = withinBounds ? subpixelAtBI(image, target) : emptyColor;\n}'},6122:e=>{e.exports='@include "colors.glsl"\nuniform sampler2D dest, src;\nuniform int destComponents;\nuniform int srcComponentId;\nvoid main()\n{\nvec4 destPixel = threadPixel(dest);\nvec4 srcPixel = threadPixel(src);\nbvec4 flags = bvec4(\n(destComponents & PIXELCOMPONENT_RED) != 0,\n(destComponents & PIXELCOMPONENT_GREEN) != 0,\n(destComponents & PIXELCOMPONENT_BLUE) != 0,\n(destComponents & PIXELCOMPONENT_ALPHA) != 0\n);\ncolor = mix(destPixel, vec4(srcPixel[srcComponentId]), flags);\n}'},371:e=>{e.exports='#if !defined(TYPE)\n#error Undefined TYPE\n#elif TYPE == 1\n@include "keypoints.glsl"\n#define nullPixel() encodeNullKeypoint()\n#elif TYPE == 2\n@include "float16.glsl"\n#define nullPixel() encodeNullPairOfFloat16()\n#else\n#error Invalid TYPE\n#endif\nuniform sampler2D image;\nvoid main()\n{\nivec2 thread = threadLocation();\nivec2 imageSize = textureSize(image, 0);\nint rasterIndex = thread.y * outputSize().x + thread.x;\nbool isValidPixel = rasterIndex < imageSize.x * imageSize.y;\nivec2 pos = ivec2(rasterIndex % imageSize.x, rasterIndex / imageSize.x);\nvec4 nullpix = nullPixel();\ncolor = isValidPixel ? texelFetch(image, pos, 0) : nullpix;\n}'},7307:e=>{e.exports="uniform sampler2D image;\nvoid main()\n{\ncolor = threadPixel(image);\n}"},8614:e=>{e.exports='@include "colors.glsl"\nuniform sampler2D image;\nuniform int pixelComponents;\nuniform float value;\nvoid main()\n{\nvec4 pixel = threadPixel(image);\nbvec4 flags = bvec4(\n(pixelComponents & PIXELCOMPONENT_RED) != 0,\n(pixelComponents & PIXELCOMPONENT_GREEN) != 0,\n(pixelComponents & PIXELCOMPONENT_BLUE) != 0,\n(pixelComponents & PIXELCOMPONENT_ALPHA) != 0\n);\ncolor = mix(pixel, vec4(value), flags);\n}'},6271:e=>{e.exports="uniform float value;\nvoid main()\n{\ncolor = vec4(value);\n}"},3016:e=>{e.exports="void vsmain()\n{\ngl_Position *= vec4(1,-1,1,1);\n}"},3630:e=>{e.exports="uniform sampler2D image;\nuniform int iterationNumber;\nvoid main()\n{\nivec2 thread = threadLocation();\nivec2 last = outputSize() - ivec2(1);\nint jump = (1 << iterationNumber);\nint clusterLength = jump << 1;\nint clusterMask = clusterLength - 1;\nivec2 clusterPos = ivec2(thread >> (1 + iterationNumber)) << (1 + iterationNumber);\nivec2 next1 = clusterPos + ((thread - clusterPos + ivec2(jump, 0)) & clusterMask);\nivec2 next2 = clusterPos + ((thread - clusterPos + ivec2(0, jump)) & clusterMask);\nivec2 next3 = clusterPos + ((thread - clusterPos + ivec2(jump, jump)) & clusterMask);\nvec4 p0 = texelFetch(image, thread, 0);\nvec4 p1 = texelFetch(image, min(next1, last), 0);\nvec4 p2 = texelFetch(image, min(next2, last), 0);\nvec4 p3 = texelFetch(image, min(next3, last), 0);\nvec4 pmax = max(max(p0, p1), max(p2, p3));\nvec4 pmin = min(min(p0, p1), min(p2, p3));\ncolor = vec4(pmax.r, pmin.g, pmax.r - pmin.g, p0.a);\n}"},8508:e=>{e.exports='@include "pyramids.glsl"\n@include "float16.glsl"\nuniform sampler2D pyramid;\nuniform float lod;\n#define USE_VARYINGS 1\nin vec2 v_pix0, v_pix1, v_pix2,\nv_pix3, v_pix4, v_pix5,\nv_pix6, v_pix7, v_pix8;\nconst mat3 hkern = mat3(\n1.0f, 0.0f,-1.0f,\n2.0f, 0.0f,-2.0f,\n1.0f, 0.0f,-1.0f\n), vkern = mat3(\n1.0f, 2.0f, 1.0f,\n0.0f, 0.0f, 0.0f,\n-1.0f,-2.0f,-1.0f\n);\n#define PIX(x,y) pyrPixelAtOffset(pyramid, lod, pot, ivec2((x),(y))).g\n#define XIP(v) textureLod(pyramid, (v), lod).g\nvoid main()\n{\nconst vec3 ones = vec3(1.0f);\nfloat pot = exp2(lod);\nmat3 win = mat3(\n#if USE_VARYINGS\nXIP(v_pix0), XIP(v_pix1), XIP(v_pix2),\nXIP(v_pix3), XIP(v_pix4), XIP(v_pix5),\nXIP(v_pix6), XIP(v_pix7), XIP(v_pix8)\n#else\nPIX(-1,-1), PIX(0,-1), PIX(1,-1),\nPIX(-1,0), PIX(0,0), PIX(1,0),\nPIX(-1,1), PIX(0,1), PIX(1,1)\n#endif\n);\nmat3 dx = matrixCompMult(hkern, win);\nmat3 dy = matrixCompMult(vkern, win);\nvec2 df = vec2(\ndot(dx[0] + dx[1] + dx[2], ones),\ndot(dy[0] + dy[1] + dy[2], ones)\n);\ncolor = encodePairOfFloat16(df);\n}'},8073:e=>{e.exports="uniform mediump float lod;\nout vec2 v_pix0, v_pix1, v_pix2,\nv_pix3, v_pix4, v_pix5,\nv_pix6, v_pix7, v_pix8;\n#define PIX(x,y) (texCoord + ((pot) * vec2((x),(y))) / texSize)\nvoid vsmain()\n{\nfloat pot = exp2(lod);\nv_pix0 = PIX(-1,-1); v_pix1 = PIX(0,-1); v_pix2 = PIX(1,-1);\nv_pix3 = PIX(-1,0); v_pix4 = PIX(0,0); v_pix5 = PIX(1,0);\nv_pix6 = PIX(-1,1); v_pix7 = PIX(0,1); v_pix8 = PIX(1,1);\n}"},3575:e=>{e.exports="AGFzbQEAAAABiwETYAABfmADf39/AX9gAX8AYAN/f38AYAF9AX9gAX8Bf2ACf38Bf2AFf39/f38B\nf2AFf39/f38AYAZ/f39/f38Bf2AAAX9gAn99AX9gA39/fQF/YAJ/fwF9YAF/AX1gBH9/f38AYAR/\nf39/AX9gEX98fHx8fHx8fHx8fHx8fHx8AGAHf39/f39/fQF/AjsEA2VudgZtZW1vcnkCAAIDZW52\nBWZhdGFsAAIDZW52CGJ5dGVmaWxsAAMDZW52CmNvcHlXaXRoaW4AAwNAPwQFBgIGAQECBwgGAwAJ\nAgYCBgYKBQUFCQsFBgEBDAEBBgYGAQEMAQ0OAwgPAxAIAwYBEQEBAQEBARIBEgEBDwQFAXABBQUG\nCAF/AUHwmgQLB/QDHAZtYWxsb2MABARmcmVlAAYFc3JhbmQACgxNYXQzMl9jcmVhdGUAEA1NYXQz\nMl9kZXN0cm95ABcKTWF0MzJfZGF0YQAYDk1hdDMyX2RhdGFTaXplABkPTWF0MzJfdHJhbnNwb3Nl\nAB0JTWF0MzJfYWRkAB4OTWF0MzJfc3VidHJhY3QAHwtNYXQzMl9zY2FsZQAgDk1hdDMyX2NvbXBt\ndWx0ACEOTWF0MzJfbXVsdGlwbHkAIg5NYXQzMl9pbnZlcnNlMQAjDk1hdDMyX2ludmVyc2UyACQO\nTWF0MzJfaW52ZXJzZTMAJQ1NYXQzMl9xcl9mdWxsACwQTWF0MzJfcXJfcmVkdWNlZAAvDE1hdDMy\nX3FyX29scwAwEE1hdDMyX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AAQbQaCwwIAAAAUA0AAAEAAAAAQcAaCyQA\nAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=\n"}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var s=t[i]={exports:{}};return e[i](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{"use strict";n.d(i,{default:()=>Vi});var e=n(1001),t=n(9037),o=n(2199),s=n(9192);const r=[],A=[],a="asap"+Math.random().toString(36).substr(1);function d(e,...t){r.unshift(e),A.unshift(t),window.postMessage(a,"*")}window.addEventListener("message",(e=>{if(e.source!==window||e.data!==a)return;if(e.stopPropagation(),0==r.length)return;const t=r.pop(),n=A.pop();t.apply(void 0,n)}),!0);var c=n(8581);const l=navigator.userAgent.includes("Firefox")?(e,...t)=>setTimeout(e,10,...t):(e,...t)=>requestAnimationFrame((()=>e.apply(void 0,t)));class g{constructor(e=2){t.A.assert(e>0),this._initialized=!1,this._pixelBuffer=new Array(e).fill(null).map((()=>new Uint8Array(0))),this._pbo=new Array(e).fill(null),this._consumerIndex=0,this._producerIndex=e-1,this._promise=Array.from({length:e},(()=>s.i.resolve())),this._busy=new Array(e).fill(!1),this._ready=new Array(e).fill(!0)}init(e){this._allocatePBOs(e),e.subscribe(this._allocatePBOs,this,e),this._initialized=!0}release(e){return e.unsubscribe(this._allocatePBOs,this),this._deallocatePBOs(e),this._initialized=!1,null}readPixelsSync(e,n=0,i=0,o=e.width,s=e.height){t.A.assert(this._initialized);const r=e.gl,A=e.glFbo;o=Math.max(0,Math.min(o,e.width)),s=Math.max(0,Math.min(s,e.height)),n=Math.max(0,Math.min(n,e.width-o)),i=Math.max(0,Math.min(i,e.height-s));const a=o*s*4;return this._reallocate(a),r.isContextLost()||(r.bindFramebuffer(r.FRAMEBUFFER,A),r.readPixels(n,i,o,s,r.RGBA,r.UNSIGNED_BYTE,this._pixelBuffer[0]),r.bindFramebuffer(r.FRAMEBUFFER,null)),this._pixelBuffer[0].subarray(0,a)}readPixelsAsync(e,n=0,i=0,o=e.width,r=e.height,A=!1){t.A.assert(this._initialized);const a=e.gl,d=e.glFbo;o=Math.max(0,Math.min(o,e.width)),r=Math.max(0,Math.min(r,e.height)),n=Math.max(0,Math.min(n,e.width-o)),i=Math.max(0,Math.min(i,e.height-r));const c=o*r*4;if(this._reallocate(c),a.isContextLost())return s.i.resolve(this._pixelBuffer[0].subarray(0,c));if(!A){const e=this._pixelBuffer[0].subarray(0,c);return g._readPixelsViaPBO(a,this._pbo[0],e,d,n,i,o,r).then((()=>e))}const l=this._pixelBuffer.length,h=this._producerIndex;if(!this._busy[h]){const e=this._pbo[h],t=this._pixelBuffer[h].subarray(0,c);this._producerIndex=(h+1)%l,this._ready[h]=!1,this._busy[h]=!0,this._promise[h]=g._readPixelsViaPBO(a,e,t,d,n,i,o,r).then((()=>{this._busy[h]=!1,this._ready[h]=!0}))}const p=this._consumerIndex;return this._consumerIndex=(p+1)%l,this._ready[p]?(this._ready[p]=!1,s.i.resolve(this._pixelBuffer[p])):this._promise[p].then((()=>(this._ready[p]=!1,this._pixelBuffer[p])))}_reallocate(e){if(!(e<=this._pixelBuffer[0].byteLength))for(let t=0;t=0;e--)t.deleteBuffer(this._pbo[e]),this._pbo[e]=null}static _readPixelsViaPBO(e,n,i,r,A,a,h,p){const u=h*p*4;t.A.assert(i.byteLength>=u,"Invalid buffer size"),e.bindBuffer(e.PIXEL_PACK_BUFFER,n),e.bufferData(e.PIXEL_PACK_BUFFER,u,e.DYNAMIC_READ),e.bindFramebuffer(e.FRAMEBUFFER,r),e.readPixels(A,a,h,p,e.RGBA,e.UNSIGNED_BYTE,0),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindBuffer(e.PIXEL_PACK_BUFFER,null);const I=e.fenceSync(e.SYNC_GPU_COMMANDS_COMPLETE,0);return e.flush(),new s.i(((t,n)=>{"asap"!=o.w.gpuPollingMode?l(g._clientWaitAsync,e,I,0,t,n):d(g._clientWaitAsync,e,I,0,t,n)})).then((()=>{e.bindBuffer(e.PIXEL_PACK_BUFFER,n),e.getBufferSubData(e.PIXEL_PACK_BUFFER,0,i),e.bindBuffer(e.PIXEL_PACK_BUFFER,null)})).catch((e=>{throw new c.Er("Can't getBufferSubDataAsync(): error in clientWaitAsync()",e)})).finally((()=>{e.deleteSync(I)}))}static _clientWaitAsync(e,t,n,i,s,r=10,A=1e3){!function r(){const a=e.clientWaitSync(t,n,0);A--<=0?s(new c.MU("GPU polling timeout",c.wB.from(e))):a===e.CONDITION_SATISFIED||a===e.ALREADY_SIGNALED?i():"asap"!=o.w.gpuPollingMode?requestAnimationFrame(r):d(r)}()}}var h=n(3816);class p{constructor(e,t,n,i=e.RGBA,o=e.RGBA8,s=e.UNSIGNED_BYTE,r=e.NEAREST,A=e.MIRRORED_REPEAT){this._gl=e,this._width=Math.max(1,0|t),this._height=Math.max(1,0|n),this._hasMipmaps=!1,this._format=i,this._internalFormat=o,this._dataType=s,this._filter=r,this._wrap=A,this._glTexture=p._createTexture(this._gl,this._width,this._height,this._format,this._internalFormat,this._dataType,this._filter,this._wrap)}release(){const e=this._gl;if(null==this._glTexture)throw new c.Er("The SpeedyTexture has already been released");return this.discardMipmaps(),e.deleteTexture(this._glTexture),this._glTexture=null,this._width=this._height=0,null}upload(e,n=this._width,i=this._height){const o=this._gl;return e instanceof HTMLVideoElement&&e.readyState<2||(t.A.assert(n>0&&i>0),this.discardMipmaps(),this._width=n,this._height=i,this._internalFormat=o.RGBA8,this._format=o.RGBA,this._dataType=o.UNSIGNED_BYTE,p._upload(o,this._glTexture,this._width,this._height,e,0,this._format,this._internalFormat,this._dataType)),this}clear(){const e=this._gl;return e.isContextLost()||(e.bindTexture(e.TEXTURE_2D,this._glTexture),e.texImage2D(e.TEXTURE_2D,0,this._internalFormat,this._width,this._height,0,this._format,this._dataType,null),e.bindTexture(e.TEXTURE_2D,null),this.discardMipmaps()),this}resize(e,t){const n=this._gl;if(this._width===e&&this._height===t)return this;if(t|=0,(e|=0)>h.MAX_TEXTURE_LENGTH||t>h.MAX_TEXTURE_LENGTH)throw new c.EM(`Maximum texture size exceeded. Using ${e} x ${t}, expected up to ${h.MAX_TEXTURE_LENGTH} x ${h.MAX_TEXTURE_LENGTH}.`);if(e<1||t<1)throw new c.qw(`Invalid texture size: ${e} x ${t}`);return n.isContextLost()||(this._width=e,this._height=t,n.bindTexture(n.TEXTURE_2D,this._glTexture),n.texImage2D(n.TEXTURE_2D,0,this._internalFormat,this._width,this._height,0,this._format,this._dataType,null),n.bindTexture(n.TEXTURE_2D,null),this.discardMipmaps()),this}generateMipmaps(e=[]){const n=this._gl;if(this._hasMipmaps)return this;if(n.bindTexture(n.TEXTURE_2D,this._glTexture),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.NEAREST_MIPMAP_LINEAR),n.generateMipmap(n.TEXTURE_2D),n.bindTexture(n.TEXTURE_2D,null),e.length>0){const n=this.width,i=this.height,o=1+Math.floor(Math.log2(Math.max(n,i)));t.A.assert(e.length<=o);for(let o=1;o>>o),r=Math.max(1,i>>>o);t.A.assert(e[o].width===s&&e[o].height===r),e[o].copyTo(this,o)}}return this._hasMipmaps=!0,this}discardMipmaps(){const e=this._gl;this._hasMipmaps&&(e.bindTexture(e.TEXTURE_2D,this._glTexture),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,this._filter),e.bindTexture(e.TEXTURE_2D,null),this._hasMipmaps=!1)}hasMipmaps(){return this._hasMipmaps}isReleased(){return null==this._glTexture}get glTexture(){return this._glTexture}get width(){return this._width}get height(){return this._height}get gl(){return this._gl}static _createTexture(e,n,i,o,s,r,A,a){t.A.assert(n>0&&i>0);const d=e.createTexture();return e.bindTexture(e.TEXTURE_2D,d),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,A),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,A),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,a),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,a),e.texImage2D(e.TEXTURE_2D,0,s,n,i,0,o,r,null),e.bindTexture(e.TEXTURE_2D,null),d}static _upload(e,t,n,i,o,s,r,A,a){return e.bindTexture(e.TEXTURE_2D,t),e.texImage2D(e.TEXTURE_2D,s,A,n,i,0,r,a,o),e.bindTexture(e.TEXTURE_2D,null),t}}class u extends p{constructor(e,t,n,i=void 0,o=void 0,s=void 0,r=void 0,A=void 0){super(e,t,n,i,o,s,r,A),this._glFbo=u._createFramebuffer(e,this._glTexture)}release(){const e=this._gl;if(null==this._glFbo)throw new c.Er("The SpeedyDrawableTexture has already been released");return e.deleteFramebuffer(this._glFbo),this._glFbo=null,super.release()}get glFbo(){return this._glFbo}copyTo(e,n=0){const i=this._gl;if(i.isContextLost())return;const o=1<<(n|=0),s=Math.max(1,Math.floor(e.width/o)),r=Math.max(1,Math.floor(e.height/o));t.A.assert(this._width===s&&this._height===r),u._copyToTexture(i,this._glFbo,e.glTexture,0,0,this._width,this._height,n)}clear(){return this.clearToColor(0,0,0,0)}clearToColor(e,t,n,i){const o=this._gl;return o.isContextLost()||(e=Math.max(0,Math.min(+e,1)),t=Math.max(0,Math.min(+t,1)),n=Math.max(0,Math.min(+n,1)),i=Math.max(0,Math.min(+i,1)),this.discardMipmaps(),o.bindFramebuffer(o.FRAMEBUFFER,this._glFbo),o.viewport(0,0,this._width,this._height),o.clearColor(e,t,n,i),o.clear(o.COLOR_BUFFER_BIT),o.bindFramebuffer(o.FRAMEBUFFER,null)),this}inspect(e,t){if(void 0===t){(t=new g).init(e);const n=t.readPixelsSync(this);return t.release(e),new Uint8Array(n)}{const e=t.readPixelsSync(this);return new Uint8Array(e)}}inspect32(e,n){return t.A.assert(h.LITTLE_ENDIAN),new Uint32Array(this.inspect(e,n).buffer)}static _createFramebuffer(e,t){const n=e.createFramebuffer();e.bindFramebuffer(e.FRAMEBUFFER,n),e.framebufferTexture2D(e.FRAMEBUFFER,e.COLOR_ATTACHMENT0,e.TEXTURE_2D,t,0);const i=e.checkFramebufferStatus(e.FRAMEBUFFER);if(i!=e.FRAMEBUFFER_COMPLETE){const t=["FRAMEBUFFER_UNSUPPORTED","FRAMEBUFFER_INCOMPLETE_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_DIMENSIONS","FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT","FRAMEBUFFER_INCOMPLETE_MULTISAMPLE"].filter((t=>e[t]===i))[0]||"unknown error";throw new c.wB(`Can't create framebuffer: ${t} (${i})`)}return e.bindFramebuffer(e.FRAMEBUFFER,null),n}static _copyToTexture(e,t,n,i,o,s,r,A=0){return e.bindTexture(e.TEXTURE_2D,n),e.bindFramebuffer(e.FRAMEBUFFER,t),e.copyTexSubImage2D(e.TEXTURE_2D,A,0,0,i,o,s,r),e.bindFramebuffer(e.FRAMEBUFFER,null),e.bindTexture(e.TEXTURE_2D,null),n}}var I=n(9420);const f=Object.freeze({sampler2D:"uniform1i",isampler2D:"uniform1i",usampler2D:"uniform1i",float:"uniform1f",int:"uniform1i",uint:"uniform1ui",bool:"uniform1i",vec2:"uniform2f",vec3:"uniform3f",vec4:"uniform4f",ivec2:"uniform2i",ivec3:"uniform3i",ivec4:"uniform4i",uvec2:"uniform2ui",uvec3:"uniform3ui",uvec4:"uniform4ui",bvec2:"uniform2i",bvec3:"uniform3i",bvec4:"uniform4i",mat2:"uniformMatrix2fv",mat3:"uniformMatrix3fv",mat4:"uniformMatrix4fv"});class m extends Function{constructor(e,t,n={}){return super("...args","return this._self._call(...args)"),this._self=this.bind(this),this._self._init(e,t,n),this._self}_init(e,t,n){if(e.isContextLost())throw new c.Er("Can't initialize SpeedyProgram: lost context");n=Object.assign({renderToTexture:!0,pingpong:!1},n),this._gl=e,this._program=m._compile(e,t.vertexSource,t.fragmentSource),this._geometry=new C(e,{position:t.locationOfAttributes.position,texCoord:t.locationOfAttributes.texCoord}),this._argnames=t.arguments,this._argIsArray=new Array(this._argnames.length).fill(!1),this._ubo=null,this._renderToTexture=Boolean(n.renderToTexture),this._width=1,this._height=1,this._size=[1,1],this._texture=new Array(n.pingpong?2:1).fill(null),this._textureIndex=0,this._uniform=new Map,this._shaderdecl=t,e.useProgram(this._program);for(const n of t.uniforms){const i=t.uniformType(n),o=e.getUniformLocation(this._program,n);this._uniform.set(n,new E(i,o))}for(let e=0;e=0;t--)if(e[t]===i)throw new c.EM("Can't run shader: don't use its output texture as an input to itself. Consider using pingpong rendering!");if(t.isContextLost())return i;t.useProgram(this._program),t.bindVertexArray(this._geometry.vao);const o=this._renderToTexture?i.glFbo:null,s=this._uniform.get("texSize");this._size[0]=this._width,this._size[1]=this._height,s.setValue(t,this._size);for(let i=0,o=0;i0&&n>0),this._width=0|e,this._height=0|n;for(let e=0;e1&&(this._textureIndex=1-this._textureIndex)}static _compile(e,t,n){const i=e.createProgram(),o=e.createShader(e.VERTEX_SHADER),s=e.createShader(e.FRAGMENT_SHADER);if(e.shaderSource(o,t),e.compileShader(o),e.attachShader(i,o),e.shaderSource(s,n),e.compileShader(s),e.attachShader(i,s),e.linkProgram(i),e.validateProgram(i),e.getProgramParameter(i,e.LINK_STATUS))return i;const r=[e.getShaderInfoLog(s),e.getShaderInfoLog(o),e.getProgramInfoLog(i)];e.deleteProgram(i),e.deleteShader(s),e.deleteShader(o);const A=e=>{return new Array((t=e,Math.max(0,2-Math.floor(Math.log10(t))))).fill(" ").join("")+e+". ";var t},a=(r[0]?n:t).split("\n").map(((e,t)=>A(1+t)+e)).join("\n");throw new c.wB("\n\n---------- ERROR ----------\n\n"+r.filter((e=>e)).join("\n")+"\n\n---------- SOURCE CODE ----------\n\n"+a+"\n")}}function C(e,t){return this.vao=e.createVertexArray(),this.vbo=Object.freeze({position:e.createBuffer(),texCoord:e.createBuffer()}),this._gl=e,e.bindVertexArray(this.vao),e.bindBuffer(e.ARRAY_BUFFER,this.vbo.position),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW),e.enableVertexAttribArray(t.position),e.vertexAttribPointer(t.position,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,this.vbo.texCoord),e.bufferData(e.ARRAY_BUFFER,new Float32Array([0,0,1,0,0,1,0,1,1,0,1,1]),e.STATIC_DRAW),e.enableVertexAttribArray(t.texCoord),e.vertexAttribPointer(t.texCoord,2,e.FLOAT,!1,0,0),e.bindBuffer(e.ARRAY_BUFFER,null),e.bindVertexArray(null),Object.freeze(this)}function E(e,t){if(this.type=String(e),!Object.prototype.hasOwnProperty.call(f,this.type))throw new c.EM(`Unsupported uniform type: ${this.type}`);this.location=t,this.setter=f[this.type];const n=0|Number(this.setter.match(/^uniform(Matrix)?(\d)/)[2]);this.dim=this.type.startsWith("mat")?2:this.type.indexOf("vec")>=0?1:0,this.length=2==this.dim?n*n:n,this._value=null}function x(e,t){this._gl=e,this._program=t,this._nextIndex=0,this._ubo=Object.create(null)}function y(e,t){const n=y.cache;let i=n.get(e);return void 0===i&&n.set(e,i=[]),void 0===i[t]&&(i[t]=`${e}[${t}]`),i[t]}C.prototype.release=function(){const e=this._gl;return e.deleteVertexArray(this.vao),e.deleteBuffer(this.vbo.position),e.deleteBuffer(this.vbo.texCoord),null},E.prototype.setValue=function(e,t,n=-1){const i=e[this.setter];if("object"==typeof t&&this.type.endsWith("sampler2D")){if(n>=e.MAX_COMBINED_TEXTURE_IMAGE_UNITS)throw new c.EM(`Can't activate texture unit ${n}: max is ${e.MAX_COMBINED_TEXTURE_IMAGE_UNITS}`);if(Array.isArray(t))throw new c.EM("Can't pass arrays of textures to shaders");if(null==t)throw new c.qw(`Can't run shader: cannot use ${t} as an input texture`);if(n<0)throw new c.qw("Missing texNo");const i=t;e.activeTexture(e.TEXTURE0+n),e.bindTexture(e.TEXTURE_2D,i.glTexture),e.uniform1i(this.location,n),n++}else if(t===this._value&&"object"!=typeof t);else if("number"==typeof t||"boolean"==typeof t)i.call(e,this.location,t);else{if(!Array.isArray(t))throw new c.qw(`Can't run shader: unrecognized argument "${t}"`);if(t.length!==this.length)throw new c.qw(`Can't run shader: incorrect number of values for ${this.type}: "${t}"`);2==this.dim?i.call(e,this.location,!1,t):i.call(e,this.location,...t)}return this._value=t,n},x.prototype.set=function(e,t){const n=this._gl;void 0===this._ubo[e]&&(this._ubo[e]={buffer:n.createBuffer(),blockBindingIndex:this._nextIndex++,blockIndex:-1,data:null});const i=this._ubo[e];if(i.blockIndex<0){const t=n.getUniformBlockIndex(this._program,e);n.uniformBlockBinding(this._program,t,i.blockBindingIndex),i.blockIndex=t}i.data=t},x.prototype.update=function(){const e=this._gl;for(const t in this._ubo){const n=this._ubo[t];e.bindBuffer(e.UNIFORM_BUFFER,n.buffer),e.bufferData(e.UNIFORM_BUFFER,n.data,e.DYNAMIC_DRAW),e.bindBufferBase(e.UNIFORM_BUFFER,n.blockBindingIndex,n.buffer),e.bindBuffer(e.UNIFORM_BUFFER,null)}},x.prototype.release=function(){const e=this._gl;for(const t in this._ubo){const n=this._ubo[t];e.deleteBuffer(n.buffer),n.data=null}return null},y.cache=new Map;const _=Object.freeze({usesPingpongRendering:()=>({pingpong:!0}),rendersToCanvas:()=>({renderToTexture:!1})});class S{constructor(e){this._gpu=e,this._programs=[]}declare(e,t,n={}){return Object.defineProperty(this,e,{get:(()=>{const i=Symbol(e);return()=>this[i]||(this[i]=this._createProgram(t.build(),n))})()}),this}get program(){return _}release(){for(let e=0;e(e[t]=(0,I.bf)("filters/convolution2d.glsl").withDefines({KERNEL_SIZE_SQUARED:t*t}).withArguments("image","kernel"),e)),{}),N=[3,5,7,9,11,13,15].reduce(((e,t)=>(e[t]=(0,I.bf)("filters/convolution1d.glsl").withDefines({KERNEL_SIZE:t,AXIS:0}).withArguments("image","kernel"),e)),{}),X=[3,5,7,9,11,13,15].reduce(((e,t)=>(e[t]=(0,I.bf)("filters/convolution1d.glsl").withDefines({KERNEL_SIZE:t,AXIS:1}).withArguments("image","kernel"),e)),{}),T=[3,5,7].reduce(((e,t)=>(e[t]=(0,I.bf)("filters/fast-median.glsl").withDefines({KERNEL_SIZE:t}).withArguments("image"),e)),{}),F=(0,I.bf)("filters/normalize-image.glsl").withDefines({GREYSCALE:1}).withArguments("minmax2d","minValue","maxValue"),O=(0,I.bf)("filters/normalize-image.glsl").withDefines({GREYSCALE:0}).withArguments("minmax2dRGB","minValue","maxValue"),U=(0,I.bf)("filters/nightvision.glsl").withDefines({GREYSCALE:0}).withArguments("image","illuminationMap","gain","offset","decay"),G=(0,I.bf)("filters/nightvision.glsl").withDefines({GREYSCALE:1}).withArguments("image","illuminationMap","gain","offset","decay"),q=e=>t.A.gaussianKernel((e=>Math.max(1,e/6))(e),e),H=e=>new Array(e).fill(1/e);class J extends S{constructor(e){super(e),this.declare("rgb2grey",R).declare("median3",T[3]).declare("median5",T[5]).declare("median7",T[7]).declare("convolution3",z[3]).declare("convolution5",z[5]).declare("convolution7",z[7]).declare("convolution3x",N[3]).declare("convolution3y",X[3]).declare("convolution5x",N[5]).declare("convolution5y",X[5]).declare("convolution7x",N[7]).declare("convolution7y",X[7]).declare("convolution9x",N[9]).declare("convolution9y",X[9]).declare("convolution11x",N[11]).declare("convolution11y",X[11]).declare("convolution13x",N[13]).declare("convolution13y",X[13]).declare("convolution15x",N[15]).declare("convolution15y",X[15]).declare("normalizeGreyscale",F).declare("normalizeColored",O).declare("nightvision",U).declare("nightvisionGreyscale",G).declare("illuminationMapLoX",(0,k.convX)(t.A.gaussianKernel(80,31))).declare("illuminationMapLoY",(0,k.convY)(t.A.gaussianKernel(80,31))).declare("illuminationMapX",(0,k.convX)(t.A.gaussianKernel(80,63))).declare("illuminationMapY",(0,k.convY)(t.A.gaussianKernel(80,63))).declare("illuminationMapHiX",(0,k.convX)(t.A.gaussianKernel(80,255))).declare("illuminationMapHiY",(0,k.convY)(t.A.gaussianKernel(80,255))).declare("gaussian3x",(0,k.convX)([.25,.5,.25])).declare("gaussian3y",(0,k.convY)([.25,.5,.25])).declare("gaussian5x",(0,k.convX)([.05,.25,.4,.25,.05])).declare("gaussian5y",(0,k.convY)([.05,.25,.4,.25,.05])).declare("gaussian7x",(0,k.convX)(q(7))).declare("gaussian7y",(0,k.convY)(q(7))).declare("gaussian9x",(0,k.convX)(q(9))).declare("gaussian9y",(0,k.convY)(q(9))).declare("gaussian11x",(0,k.convX)(q(11))).declare("gaussian11y",(0,k.convY)(q(11))).declare("box3x",(0,k.convX)(H(3))).declare("box3y",(0,k.convY)(H(3))).declare("box5x",(0,k.convX)(H(5))).declare("box5y",(0,k.convY)(H(5))).declare("box7x",(0,k.convX)(H(7))).declare("box7y",(0,k.convY)(H(7))).declare("box9x",(0,k.convX)(H(9))).declare("box9y",(0,k.convY)(H(9))).declare("box11x",(0,k.convX)(H(11))).declare("box11y",(0,k.convY)(H(11)))}}var Y=n(6634);class W extends Y.Q{static create(e,n,i){t.A.assert(i%4==0,`Invalid descriptorSize: ${i}`);const o=n.length,s=i/4,r=Math.log2(s*Math.max(o,1))/2,A=1<l)throw new c.EM(`The capacity of the descriptorDB (${l} for ${8*i}-bit descriptors) has been exceeded`);const g=new Uint8Array(a*d*4);for(let e=0;e(t.A.range(ee).forEach((t=>e.subarray(t*V,(t+1)*V).sort())),e),ne=(e,n)=>(t.A.range(ee).forEach((t=>n.subarray((t+1)*V-e,(t+1)*V).fill(195939070))),n),ie=j.reduce(((e,n)=>{return e[n]={32:te(ne(V-(i=n),new Uint32Array([...t.A.shuffle(t.A.range(256)),...t.A.shuffle(t.A.range(256)),...t.A.shuffle(t.A.range(256))].slice(0,ee*V)))),64:te(ne(V-i,new Uint32Array([...t.A.shuffle(t.A.range(512)),...t.A.shuffle(t.A.range(512))].slice(0,ee*V))))},e;var i}),{});class oe{constructor(e,n,i,o=8,s=15,r=.95){const A=i.length,a=A>0?i[0].byteLength:0,d=(c=o,l=s,g=r,j.includes(l)&&Z.includes(c)?[{name:"x-small",bucketCapacity:1,tableCount:c,hashSize:l,capacity:re(l,1,g)},{name:"small",bucketCapacity:2,tableCount:c,hashSize:l,capacity:re(l,2,g)},{name:"small-plus",bucketCapacity:3,tableCount:c,hashSize:l,capacity:re(l,3,g)},{name:"medium",bucketCapacity:4,tableCount:c,hashSize:l,capacity:re(l,4,g)},{name:"medium-plus",bucketCapacity:5,tableCount:c,hashSize:l,capacity:re(l,5,g)},{name:"large",bucketCapacity:6,tableCount:c,hashSize:l,capacity:re(l,6,g)},{name:"x-large",bucketCapacity:8,tableCount:c,hashSize:l,capacity:re(l,8,g)}]:null);var c,l,g;t.A.assert(A>0,"Can't build LSH tables without descriptors!"),t.A.assert($.includes(a),`Can't build LSH tables: unacceptable descriptor size of ${a} bytes`),t.A.assert(i.findIndex((e=>e.byteLength!==a))<0,`Can't build LSH tables: incorrectly sized descriptors. Expected ${a} bytes for each`),t.A.assert(AA<=e.capacity))||d[d.length-1],this._descriptorSize=a,this._descriptorCount=A,this._sequences=this._pickSequences(this._descriptorSize),this._tables=this._createStaticTables(e,this._sequences,i,a),this._descriptorDB=W.create(n,i,a)}get descriptorSize(){return this._descriptorSize}get descriptorCount(){return this._descriptorCount}get sequences(){return this._sequences}get hashSize(){return this._profile.hashSize}get bucketCapacity(){return this._profile.bucketCapacity}get bucketsPerTable(){return 1<1?1<A){const e=100*I/A;t.A.warning(`There are too many descriptors (${I}) for a ${r} LSH table. That's ${e.toFixed(2)}% of its theoretical capacity. Consider increasing the hashSize (currently set to ${l}) or reducing the number of descriptors to avoid degradation.`)}const m=new ArrayBuffer(h*u*4),C=new Uint8Array(m).fill(255),E=new DataView(m),x=t.A.shuffle(t.A.range(I)),y=new Array(a).fill(0);for(let e=0;ee+t),0),S=y.map((e=>100*e/I));return t.A.log(`When building ${a} ${r} LSH tables with ${I} ${8*o}-bit descriptors each and hashSize = ${l} bits, I got the following discard profile: `+S.map((e=>e.toFixed(2)+"%")).join(", ")+". "+`Average: ${(100*_/(a*I)).toFixed(2)}%. `+`Minimum: ${Math.min(...S).toFixed(2)}%. `+`Table capacity: ${A}.`),e.resize(h,u),e.upload(C),e}_hashCodes(e,n){const i=this.tableCount,o=this.hashSize,s=this.bucketsPerTable,r=new Array(i);t.A.assert(o<=V&&n.length>=V*i);for(let A=0;A>>3]&s)}t.A.assert(a>=0&&as?r=a+1:A=a;return a}const Ae=(0,I.bf)("keypoints/fast.glsl","keypoints/fast.vs.glsl").withDefines({FAST_TYPE:916}).withArguments("corners","pyramid","lod","threshold"),ae=[1,3,5,7].reduce(((e,t)=>(e[t]=(0,I.bf)("keypoints/harris.glsl").withDefines({WINDOW_SIZE:t}).withArguments("corners","pyramid","derivatives","lod","lodStep","gaussian"),e)),{}),de=(0,I.bf)("keypoints/score-findmax.glsl").withArguments("corners","iterationNumber"),ce=(0,I.bf)("keypoints/harris-cutoff.glsl").withArguments("corners","maxScore","quality"),le=(0,I.bf)("keypoints/subpixel-refinement.glsl").withDefines({METHOD:0}).withArguments("pyramid","encodedKeypoints","descriptorSize","extraSize","encoderLength","maxIterations","epsilon"),ge=(0,I.bf)("keypoints/subpixel-refinement.glsl").withDefines({METHOD:1}).withArguments("pyramid","encodedKeypoints","descriptorSize","extraSize","encoderLength","maxIterations","epsilon"),he=(0,I.bf)("keypoints/subpixel-refinement.glsl").withDefines({METHOD:2}).withArguments("pyramid","encodedKeypoints","descriptorSize","extraSize","encoderLength","maxIterations","epsilon"),pe=(0,I.bf)("keypoints/subpixel-refinement.glsl").withDefines({METHOD:3}).withArguments("pyramid","encodedKeypoints","descriptorSize","extraSize","encoderLength","maxIterations","epsilon"),ue=(0,I.bf)("keypoints/refine-scale.glsl").withDefines({METHOD:0}).withArguments("pyramid","lodStep","encodedKeypoints","descriptorSize","extraSize","encoderLength"),Ie=(0,I.bf)("keypoints/refine-scale.glsl").withDefines({METHOD:1}).withArguments("pyramid","lodStep","encodedKeypoints","descriptorSize","extraSize","encoderLength","threshold"),fe=(0,I.bf)("keypoints/allocate-descriptors.glsl").withArguments("inputEncodedKeypoints","inputDescriptorSize","inputExtraSize","inputEncoderLength","outputDescriptorSize","outputExtraSize","outputEncoderLength"),me=(0,I.bf)("keypoints/allocate-extra.glsl").withArguments("inputEncodedKeypoints","inputDescriptorSize","inputExtraSize","inputEncoderLength","outputDescriptorSize","outputExtraSize","outputEncoderLength"),Ce=(0,I.bf)("keypoints/transfer-to-extra.glsl").withArguments("encodedData","strideOfEncodedData","encodedKeypoints","descriptorSize","extraSize","encoderLength"),Ee=(0,I.bf)("keypoints/orb-descriptor.glsl").withArguments("image","encodedCorners","extraSize","encoderLength"),xe=(0,I.bf)("keypoints/orb-orientation.glsl").withArguments("image","encodedKeypoints","descriptorSize","extraSize","encoderLength"),ye=(0,I.bf)("keypoints/nonmax-suppression.glsl").withDefines({MULTISCALE:0}).withArguments("image","lodStep"),_e=(0,I.bf)("keypoints/nonmax-suppression.glsl").withDefines({MULTISCALE:1}).withArguments("image","lodStep"),Se=(0,I.bf)("keypoints/nonmax-space.glsl").withArguments("corners"),Pe=(0,I.bf)("keypoints/nonmax-scale.glsl").withDefines({USE_LAPLACIAN:1}).withArguments("corners","pyramid","pyrLaplacian","lodStep"),Be=(0,I.bf)("keypoints/nonmax-scale.glsl").withDefines({USE_LAPLACIAN:0}).withArguments("corners","pyramid","lodStep"),ve=(0,I.bf)("keypoints/laplacian.glsl").withArguments("corners","pyramid","lodStep","lodOffset"),Qe=[3,5,7,9,11,13,15,17,19,21].reduce(((e,t)=>(e[t]=(0,I.bf)("keypoints/lk.glsl").withDefines({WINDOW_SIZE:t}).withArguments("encodedFlow","prevKeypoints","nextPyramid","prevPyramid","level","depth","numberOfIterations","discardThreshold","epsilon","descriptorSize","extraSize","encoderLength"),e)),{}),we=(0,I.bf)("keypoints/transfer-flow.glsl").withArguments("encodedFlow","encodedKeypoints","descriptorSize","extraSize","encoderLength"),be=(0,I.bf)("keypoints/knn-init.glsl").withDefines({ENCODE_FILTERS:0}),De=(0,I.bf)("keypoints/knn-init.glsl").withDefines({ENCODE_FILTERS:1}),Me=(0,I.bf)("keypoints/knn-transfer.glsl").withArguments("encodedMatches","encodedKthMatches","numberOfMatchesPerKeypoint","kthMatch"),Ke=(0,I.bf)("keypoints/bf-knn.glsl").withDefines({DESCRIPTOR_SIZE:32,NUMBER_OF_KEYPOINTS_PER_PASS:16}).withArguments("encodedMatches","encodedFilters","matcherLength","dbEncodedKeypoints","dbDescriptorSize","dbExtraSize","dbEncoderLength","encodedKeypoints","descriptorSize","extraSize","encoderLength","passId"),Le=(0,I.bf)("keypoints/bf-knn.glsl").withDefines({DESCRIPTOR_SIZE:64,NUMBER_OF_KEYPOINTS_PER_PASS:8}).withArguments("encodedMatches","encodedFilters","matcherLength","dbEncodedKeypoints","dbDescriptorSize","dbExtraSize","dbEncoderLength","encodedKeypoints","descriptorSize","extraSize","encoderLength","passId"),ke=(0,I.bf)("keypoints/knn-init.glsl").withDefines({ENCODE_FILTERS:0}),Re=(0,I.bf)("keypoints/knn-init.glsl").withDefines({ENCODE_FILTERS:1}),ze=$.reduce(((e,t)=>(e[t]=j.reduce(((e,n)=>(e[n]=[0,1,2].reduce(((e,i)=>(e[i]=(0,I.bf)("keypoints/lsh-knn.glsl").withDefines({DESCRIPTOR_SIZE:t,HASH_SIZE:n,LEVEL:i,SEQUENCE_MAXLEN:V,SEQUENCE_COUNT:ee}).withArguments("candidates","filters","matcherLength","tables","descriptorDB","tableIndex","bucketCapacity","bucketsPerTable","tablesStride","descriptorDBStride","encodedKeypoints","descriptorSize","extraSize","encoderLength"),e)),{}),e)),{}),e)),{}),Ne=(0,I.bf)("keypoints/knn-transfer.glsl").withArguments("encodedMatches","encodedKthMatches","numberOfMatchesPerKeypoint","kthMatch"),Xe=(0,I.bf)("keypoints/sort-keypoints.glsl").withDefines({STAGE:1}).withArguments("encodedKeypoints","descriptorSize","extraSize","encoderLength"),Te=(0,I.bf)("keypoints/sort-keypoints.glsl").withDefines({STAGE:2}).withArguments("permutation","blockSize","dblLog2BlockSize"),Fe=(0,I.bf)("keypoints/sort-keypoints.glsl").withDefines({STAGE:3}).withArguments("permutation","maxKeypoints","encodedKeypoints","descriptorSize","extraSize"),Oe=(0,I.bf)("keypoints/mix-keypoints.glsl").withDefines({STAGE:1}).withArguments("encodedKeypointsA","encodedKeypointsB","encoderLengthA","encoderLengthB","encoderCapacityA","encoderCapacityB","descriptorSize","extraSize","encoderLength"),Ue=(0,I.bf)("keypoints/mix-keypoints.glsl").withDefines({STAGE:2}).withArguments("encodedKeypoints","descriptorSize","extraSize","encoderLength","maxKeypoints"),Ge=(0,I.bf)("keypoints/mix-keypoints.glsl").withDefines({STAGE:3}).withArguments("array","blockSize"),qe=(0,I.bf)("keypoints/mix-keypoints.glsl").withDefines({STAGE:5}).withArguments("array"),He=(0,I.bf)("keypoints/mix-keypoints.glsl").withDefines({STAGE:4}).withArguments("array","encodedKeypoints","descriptorSize","extraSize","encoderLength"),Je=(0,I.bf)("keypoints/lookup-of-locations.glsl").withDefines({FS_OUTPUT_TYPE:2,STAGE:1}).withArguments("corners"),Ye=(0,I.bf)("keypoints/lookup-of-locations.glsl","keypoints/lookup-of-locations.vs.glsl").withDefines({FS_OUTPUT_TYPE:2,FS_USE_CUSTOM_PRECISION:1,STAGE:2}).withArguments("lookupTable","blockSize","width","height"),We=(0,I.bf)("keypoints/lookup-of-locations.glsl").withDefines({STAGE:-1}).withArguments("lookupTable"),Ze=(0,I.bf)("keypoints/encode-keypoints.glsl").withArguments("corners","lookupTable","stride","descriptorSize","extraSize","encoderLength","encoderCapacity"),je=(0,I.bf)("keypoints/encode-keypoint-offsets.glsl").withArguments("corners","imageSize"),$e=(0,I.bf)("keypoints/encode-keypoint-long-offsets.glsl").withDefines({MAX_ITERATIONS:6}).withArguments("offsetsImage","imageSize"),Ve=(0,I.bf)("keypoints/encode-keypoint-positions.glsl").withArguments("offsetsImage","imageSize","passId","numPasses","keypointLimit","encodedKeypoints","descriptorSize","extraSize","encoderLength"),et=(0,I.bf)("keypoints/encode-keypoint-properties.glsl").withArguments("corners","encodedKeypoints","descriptorSize","extraSize","encoderLength"),tt=(0,I.bf)("keypoints/encode-null-keypoints.glsl").withArguments(),nt=(0,I.bf)("keypoints/transfer-orientation.glsl").withArguments("encodedOrientations","encodedKeypoints","descriptorSize","extraSize","encoderLength"),it=(0,I.bf)("keypoints/upload-keypoints.glsl").withDefines({BUFFER_SIZE:1024}).withArguments("encodedKeypoints","startIndex","endIndex","descriptorSize","extraSize","encoderLength"),ot=(0,I.bf)("keypoints/apply-homography.glsl").withArguments("homography","encodedKeypoints","descriptorSize","extraSize","encoderLength"),st=(0,I.bf)("keypoints/clip-border.glsl").withArguments("imageWidth","imageHeight","borderTop","borderRight","borderBottom","borderLeft","encodedKeypoints","descriptorSize","extraSize","encoderLength"),rt=(0,I.bf)("keypoints/distance-filter.glsl").withArguments("encodedKeypointsA","encoderLengthA","encodedKeypointsB","encoderLengthB","descriptorSize","extraSize","encoderLength","threshold"),At=(0,I.bf)("keypoints/hamming-distance-filter.glsl").withDefines({DESCRIPTOR_SIZE:32}).withArguments("encodedKeypointsA","encoderLengthA","encodedKeypointsB","encoderLengthB","descriptorSize","extraSize","encoderLength","threshold"),at=(0,I.bf)("keypoints/hamming-distance-filter.glsl").withDefines({DESCRIPTOR_SIZE:64}).withArguments("encodedKeypointsA","encoderLengthA","encodedKeypointsB","encoderLengthB","descriptorSize","extraSize","encoderLength","threshold"),dt=(0,I.bf)("keypoints/shuffle.glsl").withDefines({PERMUTATION_MAXLEN:2048}).withArguments("encodedKeypoints","descriptorSize","extraSize","encoderLength"),ct=(0,I.bf)("keypoints/clip.glsl").withArguments("encodedKeypoints","descriptorSize","extraSize","encoderLength","maxKeypoints");class lt extends S{constructor(e){super(e),this.declare("fast9_16",Ae,Object.assign({},this.program.usesPingpongRendering())).declare("harris1",ae[1],Object.assign({},this.program.usesPingpongRendering())).declare("harris3",ae[3],Object.assign({},this.program.usesPingpongRendering())).declare("harris5",ae[5],Object.assign({},this.program.usesPingpongRendering())).declare("harris7",ae[7],Object.assign({},this.program.usesPingpongRendering())).declare("harrisScoreFindMax",de,Object.assign({},this.program.usesPingpongRendering())).declare("harrisScoreCutoff",ce).declare("subpixelQuadratic1d",le).declare("subpixelTaylor2d",ge).declare("subpixelBicubic",pe).declare("subpixelBilinear",he).declare("refineScaleLoG",ue).declare("refineScaleFAST916",Ie).declare("allocateDescriptors",fe).declare("allocateExtra",me).declare("transferToExtra",Ce).declare("orbDescriptor",Ee).declare("orbOrientation",xe).declare("nonmax",ye).declare("pyrnonmax",_e).declare("nonmaxSpace",Se).declare("nonmaxScale",Pe).declare("nonmaxScaleSimple",Be).declare("laplacian",ve).declare("lk21",Qe[21],Object.assign({},this.program.usesPingpongRendering())).declare("lk19",Qe[19],Object.assign({},this.program.usesPingpongRendering())).declare("lk17",Qe[17],Object.assign({},this.program.usesPingpongRendering())).declare("lk15",Qe[15],Object.assign({},this.program.usesPingpongRendering())).declare("lk13",Qe[13],Object.assign({},this.program.usesPingpongRendering())).declare("lk11",Qe[11],Object.assign({},this.program.usesPingpongRendering())).declare("lk9",Qe[9],Object.assign({},this.program.usesPingpongRendering())).declare("lk7",Qe[7],Object.assign({},this.program.usesPingpongRendering())).declare("lk5",Qe[5],Object.assign({},this.program.usesPingpongRendering())).declare("lk3",Qe[3],Object.assign({},this.program.usesPingpongRendering())).declare("transferFlow",we).declare("bfMatcherInitCandidates",be).declare("bfMatcherInitFilters",De).declare("bfMatcherTransfer",Me,Object.assign({},this.program.usesPingpongRendering())).declare("bfMatcher32",Ke,Object.assign({},this.program.usesPingpongRendering())).declare("bfMatcher64",Le,Object.assign({},this.program.usesPingpongRendering())).declare("lshKnnInitCandidates",ke).declare("lshKnnInitFilters",Re).declare("lshKnnTransfer",Ne,Object.assign({},this.program.usesPingpongRendering())).declare("sortCreatePermutation",Xe).declare("sortMergePermutation",Te,Object.assign({},this.program.usesPingpongRendering())).declare("sortApplyPermutation",Fe).declare("mixKeypointsPreInit",Oe).declare("mixKeypointsInit",Ue).declare("mixKeypointsSort",Ge,Object.assign({},this.program.usesPingpongRendering())).declare("mixKeypointsView",qe).declare("mixKeypointsApply",He).declare("encodeNullKeypoints",tt).declare("encodeKeypoints",Ze).declare("initLookupTable",Je).declare("sortLookupTable",Ye,Object.assign({},this.program.usesPingpongRendering())).declare("viewLookupTable",We).declare("encodeKeypointSkipOffsets",je).declare("encodeKeypointLongSkipOffsets",$e,Object.assign({},this.program.usesPingpongRendering())).declare("encodeKeypointPositions",Ve,Object.assign({},this.program.usesPingpongRendering())).declare("encodeKeypointProperties",et).declare("transferOrientation",nt).declare("uploadKeypoints",it,Object.assign({},this.program.usesPingpongRendering())).declare("applyHomography",ot).declare("clipBorder",st).declare("distanceFilter",rt).declare("hammingDistanceFilter32",At).declare("hammingDistanceFilter64",at).declare("shuffle",dt).declare("clip",ct);for(const e of Object.keys(ze))for(const t of Object.keys(ze[e]))for(const n of Object.keys(ze[e][t])){const i=`lshKnn${e}h${t}lv${n}`;this.declare(i,ze[e][t][n],Object.assign({},this.program.usesPingpongRendering()))}}}const gt=(0,I.bf)("pyramids/upsample2.glsl").withArguments("image"),ht=(0,I.bf)("pyramids/downsample2.glsl").withArguments("image");class pt extends S{constructor(e){super(e),this.declare("upsample2",gt).declare("downsample2",ht).declare("smoothX",(0,k.convX)([.05,.25,.4,.25,.05])).declare("smoothY",(0,k.convY)([.05,.25,.4,.25,.05])).declare("smoothX2",(0,k.convX)([.1,.5,.8,.5,.1])).declare("smoothY2",(0,k.convY)([.1,.5,.8,.5,.1],.5))}}const ut=(0,I.bf)("transforms/warp-perspective.glsl").withArguments("image","inverseHomography"),It=(0,I.bf)("transforms/resize.glsl").withDefines({INTERPOLATION_METHOD:0}).withArguments("image"),ft=(0,I.bf)("transforms/resize.glsl").withDefines({INTERPOLATION_METHOD:1}).withArguments("image"),mt=(0,I.bf)("transforms/additive-mix.glsl").withArguments("image0","image1","alpha","beta","gamma");class Ct extends S{constructor(e){super(e),this.declare("warpPerspective",ut).declare("resizeNearest",It).declare("resizeBilinear",ft).declare("additiveMix",mt)}}class Et{constructor(e){this._gpu=e,this._filters=null,this._transforms=null,this._pyramids=null,this._keypoints=null,this._utils=null}get filters(){return this._filters||(this._filters=new J(this._gpu))}get transforms(){return this._transforms||(this._transforms=new Ct(this._gpu))}get pyramids(){return this._pyramids||(this._pyramids=new pt(this._gpu))}get keypoints(){return this._keypoints||(this._keypoints=new lt(this._gpu))}get utils(){return this._utils||(this._utils=new L(this._gpu))}release(){for(const e in this)if(Object.prototype.hasOwnProperty.call(this,e)&&null!=this[e]){const t=this[e];t instanceof S&&t.release()}return null}}const xt=Symbol("Bucket");class yt{constructor(e,t,n){this.texture=e,this.index=t,this.next=n,this.free=!0}}class _t{constructor(e,n=1024){t.A.assert(n>0),this._bucket=Array.from({length:n},((e,t)=>new yt(null,t,t-1))),this._head=n-1,this._gpu=e}allocate(){if(this._head<0)throw new c.l(`Exhausted pool (capacity: ${this._bucket.length})`);const e=this._bucket[this._head];return e.free=!1,this._head=e.next,null==e.texture&&(e.texture=_t._createManagedTexture(this._gpu.gl,e)),e.texture}free(e){const n=e[xt];return t.A.assert(void 0!==n&&!n.free,"Unmanaged texture or double free"),n.next=this._head,n.free=!0,this._head=n.index,null}release(){for(let e=0;e{t.A.log(`Waiting for ${n} to be triggered in ${e}...`);const r=setTimeout((()=>{A(),s(new c.MU(`${n} has not been triggered in ${e}: timeout (${i}ms)`))}),i);function A(){clearTimeout(r),e.removeEventListener("error",a,!1),e.removeEventListener(n,d,!1)}function a(){const t=null!==e.error&&"object"==typeof e.error?e.error:{code:-1,message:""},n=`${t.message} (error code ${t.code})`;A(),s(new c.FJ(`Can't load ${e}. ${n}`))}function d(){A(),o(e)}e.addEventListener("error",a,!1),e.addEventListener(n,d,!1)}))}}class vt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.Image}get width(){return this._data?this._data.naturalWidth:0}get height(){return this._data?this._data.naturalHeight:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");const e=this._data.cloneNode(!0);return vt.load(e)}_load(e){return this.isLoaded()&&this.release(),e.complete&&0!==e.naturalWidth?new s.i((t=>{this._data=e,t(this)})):Bt._waitUntil(e,"load").then((()=>(this._data=e,this)))}static load(e){return new vt(Pt)._load(e)}}class Qt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.Video}get width(){return this._data?this._data.videoWidth:0}get height(){return this._data?this._data.videoHeight:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");const e=this._data.cloneNode(!0);return Qt.load(e)}_load(e){return this.isLoaded()&&this.release(),t.A.log("Loading a video..."),e.load(),Qt._waitUntilPlayable(e).then((()=>Qt._handleAutoplay(e).then((()=>(this._data=e,this)))))}static load(e){return new Qt(Pt)._load(e)}static _handleAutoplay(e){return e.autoplay?new s.i(((t,n)=>{const i=e.play();void 0!==i?i.then(t,n):t()})):s.i.resolve()}static _waitUntilPlayable(e){return e.readyState>=3?s.i.resolve(e):new s.i(((t,n)=>{let i=0,o=setInterval((()=>{e.readyState>=3?(clearInterval(o),t(e)):(i+=500)>=3e4&&(clearInterval(o),n(new c.MU("The video took too long to load")))}),500)}))}}class wt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.Canvas}get width(){return this._data?this._data.width:0}get height(){return this._data?this._data.height:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");const e=t.A.createCanvas(this.width,this.height);return e.getContext("2d").drawImage(this._data,0,0),wt.load(e)}_load(e){return this.isLoaded()&&this.release(),new s.i((t=>{this._data=e,t(this)}))}static load(e){return new wt(Pt)._load(e)}}class bt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.OffscreenCanvas}get width(){return this._data?this._data.width:0}get height(){return this._data?this._data.height:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");const e=new OffscreenCanvas(this.width,this.height);return e.getContext("2d").drawImage(this._data,0,0),bt.load(e)}_load(e){return this.isLoaded()&&this.release(),new s.i((t=>{this._data=e,t(this)}))}static load(e){return new bt(Pt)._load(e)}}class Dt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.Bitmap}get width(){return this._data?this._data.width:0}get height(){return this._data?this._data.height:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");return new s.i(((e,t)=>{createImageBitmap(this._data).then((n=>{new Dt(Pt)._load(n).then(e,t)}),t)}))}release(){return null!=this._data&&this._data.close(),super.release()}_load(e){return this.isLoaded()&&this.release(),new s.i((t=>{this._data=e,t(this)}))}static load(e){return new Dt(Pt)._load(e)}}class Mt extends Bt{constructor(e){super(e),this._data=null}get data(){return this._data}get type(){return St.zu.Data}get width(){return this._data?this._data.width:0}get height(){return this._data?this._data.height:0}clone(){if(null==this._data)throw new c.Er("Media not loaded");const e=new ImageData(new Uint8ClampedArray(this._data.data),this._data.width,this._data.height);return Mt.load(e)}_load(e){return this.isLoaded()&&this.release(),new s.i((t=>{this._data=e,t(this)}))}static load(e){return new Mt(Pt)._load(e)}}var Kt=n(3211);class Lt extends Kt.c{constructor(){super(),this._speedyGL=e.c.instance,this._programs=new Et(this),this._texturePool=new _t(this),this._speedyGL.subscribe(this._reset,this)}get programs(){return this._programs}get gl(){return this._speedyGL.gl}get canvas(){return this._speedyGL.canvas}get texturePool(){return this._texturePool}renderToCanvas(e){const n=e.width,i=e.height,o=this.canvas;return(n>o.width||i>o.height)&&(t.A.warning(`Resizing the canvas to ${n} x ${i}`),o.width=n,o.height=i),this.programs.utils.renderToCanvas.outputs(n,i,null),this.programs.utils.renderToCanvas(e),o}upload(e,t){return t.upload(e.data,e.width,e.height)}release(){return t.A.assert(!this.isReleased()),this._programs=this._programs.release(),this._texturePool=this._texturePool.release(),this._speedyGL.unsubscribe(this._reset),null}isReleased(){return null==this._programs}loseAndRestoreWebGLContext(){return this._speedyGL.loseAndRestoreContext().then((()=>{}))}_reset(){this.isReleased()||(this._programs=new Et(this),this._texturePool=new _t(this),this._notify())}}class kt{constructor(e,t){this._width=Math.max(0,+e),this._height=Math.max(0,+t)}get width(){return this._width}set width(e){this._width=Math.max(0,+e)}get height(){return this._height}set height(e){this._height=Math.max(0,+e)}toString(){return`SpeedySize(${this.width}, ${this.height})`}equals(e){return this.width===e.width&&this.height===e.height}area(){return this.width*this.height}}const Rt=Symbol();class zt{constructor(e,t,n={}){if(e!==Rt)throw new c.Er;if(this._source=t,this._format=void 0!==n.format?n.format:St.f5.RGBA,this._options=Object.freeze(Object.assign(Object.assign({},n),{},{format:this._format})),!t.isLoaded())throw new c.Er(`Source not loaded: ${t}`);if(this._format!==St.f5.RGBA&&this._format!==St.f5.GREY)throw new c.qw(`Invalid format: ${this._format}`)}static load(e,n={},i=!0){return Bt.load(e).then((o=>{t.A.assert(0!==o.width&&0!==o.height);const s=new zt(Rt,o,n);return i&&t.A.log(`Loaded SpeedyMedia with a ${e}.`),s}))}get source(){return this._source?this._source.data:null}get type(){if(this.isReleased())return"unknown";switch(this._source.type){case St.zu.Image:return"image";case St.zu.Video:return"video";case St.zu.Canvas:return"canvas";case St.zu.OffscreenCanvas:return"offscreen-canvas";case St.zu.Bitmap:return"bitmap";case St.zu.Data:return"data";default:return"unknown"}}get width(){return this._source?this._source.width:0}get height(){return this._source?this._source.height:0}get size(){return this._source?new kt(this._source.width,this._source.height):new kt(0,0)}get options(){return this._options}release(){return this.isReleased()||(t.A.log("Releasing SpeedyMedia object..."),this._source=this._source.release()),null}isReleased(){return null==this._source}clone(){if(this.isReleased())throw new c.Er("Can't clone a SpeedyMedia that has been released");const e=new zt(Rt,this._source,this._options);return s.i.resolve(e)}toBitmap(){if(this.isReleased())throw new c.Er("Can't convert SpeedyMedia to ImageBitmap: the media has been released");if(this._source.isLoaded())return this._source.type==St.zu.Bitmap?s.i.resolve(this._source.data):new s.i(((e,t)=>createImageBitmap(this._source.data).then(e,t)));throw new c.Er("Can't convert SpeedyMedia to bitmap: the media hasn't been loaded")}}class Nt extends Y.Q{static get renderer(){return e.c.instance.renderer}static get vendor(){return e.c.instance.vendor}}class Xt{constructor(e,t){this._x=+e,this._y=+t}get x(){return this._x}set x(e){this._x=+e}get y(){return this._y}set y(e){this._y=+e}toString(){return`SpeedyVector2(${this.x.toFixed(5)}, ${this.y.toFixed(5)})`}equals(e){return this.x===e.x&&this.y===e.y}dot(e){return this.x*e.x+this.y*e.y}distanceTo(e){const t=this.x-e.x,n=this.y-e.y;return Math.sqrt(t*t+n*n)}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}normalized(){const e=this.length();return e>0?new Xt(this.x/e,this.y/e):new Xt(0,0)}plus(e){return new Xt(this.x+e.x,this.y+e.y)}minus(e){return new Xt(this.x-e.x,this.y-e.y)}times(e){return new Xt(this.x*e,this.y*e)}}class Tt{constructor(e,t){this._x=+e,this._y=+t}get x(){return this._x}set x(e){this._x=+e}get y(){return this._y}set y(e){this._y=+e}toString(){return`SpeedyPoint2(${this.x.toFixed(5)}, ${this.y.toFixed(5)})`}plus(e){return new Tt(this.x+e.x,this.y+e.y)}minus(e){return new Xt(this.x-e.x,this.y-e.y)}equals(e){return this.x===e.x&&this.y===e.y}}n(6306);var Ft=n(6465),Ot=n(4188);const Ut=Object.freeze({Nothing:Symbol("Nothing"),Image:Symbol("Image"),Keypoints:Symbol("Keypoints"),Vector2:Symbol("Vector2"),LSHTables:Symbol("LSHTables"),KeypointMatches:Symbol("KeypointMatches")});class Gt{constructor(e){this._type=e}get type(){return this._type}hasType(e){return this._type===e}isEmpty(){return this.hasType(Ut.Nothing)}toString(){return`message of type ${Object.keys(Ut).find((e=>Ut[e]===this.type))}`}inspect(e){throw new c.aQ}set(...e){throw new c.aQ}static create(e){return function(e){return new Ht[e]}(e)}}class qt extends Gt{constructor(){super(Ut.Nothing)}set(){return this}inspect(e){return{type:this.constructor.name}}}const Ht=Object.freeze({[Ut.Nothing]:qt,[Ut.Image]:class extends Gt{constructor(){super(Ut.Image),this._image=null,this._format=St.f5.RGBA}set(e,t=St.f5.RGBA){return this._image=e,this._format=t,this}inspect(e){const t=Object.keys(St.f5).find((e=>St.f5[e]===this.format));return{type:this.constructor.name,format:String(t),imageSize:this.image?`${this.image.width}x${this.image.height}`:"0x0",image:this.image?"":"",hasMipmaps:this.image&&this.image.hasMipmaps()?"yes":"no"}}get image(){return this._image}get format(){return this._format}},[Ut.Keypoints]:class extends Gt{constructor(){super(Ut.Keypoints),this._encodedKeypoints=null,this._descriptorSize=0,this._extraSize=0,this._encoderLength=1}set(e,n,i,o){return this._encodedKeypoints=e,this._descriptorSize=0|n,this._extraSize=0|i,this._encoderLength=0|o,t.A.assert(this._descriptorSize>=0&&this._extraSize>=0),t.A.assert(this._encoderLength===this._encodedKeypoints.width,"Invalid encoderLength"),t.A.assert(this._encodedKeypoints.width===this._encodedKeypoints.height,"Invalid encodedKeypoints texture"),this}inspect(e){return{type:this.constructor.name,descriptorSize:this.descriptorSize,extraSize:this.extraSize,encoderLength:this.encoderLength,encodedKeypointsSize:this.encodedKeypoints?`${this.encodedKeypoints.width}x${this.encodedKeypoints.height}`:"0x0",encodedKeypoints:this.encodedKeypoints?t.A.formatBinaryData(this.encodedKeypoints.inspect(e).buffer):""}}get encodedKeypoints(){return this._encodedKeypoints}get descriptorSize(){return this._descriptorSize}get extraSize(){return this._extraSize}get encoderLength(){return this._encoderLength}},[Ut.Vector2]:class extends Gt{constructor(){super(Ut.Vector2),this._vectors=null}set(e){return this._vectors=e,this}inspect(e){return{type:this.constructor.name,vectorsSize:this.vectors?`${this.vectors.width}x${this.vectors.height}`:"0x0",vectors:this.vectors?t.A.formatBinaryData(this.vectors.inspect(e).buffer):""}}get vectors(){return this._vectors}},[Ut.LSHTables]:class extends Gt{constructor(){super(Ut.LSHTables),this._lsh=null}set(e){return this._lsh=e,this}inspect(e){return{type:this.constructor.name,lsh:""}}get lsh(){return this._lsh}},[Ut.KeypointMatches]:class extends Gt{constructor(){super(Ut.KeypointMatches),this._encodedMatches=null,this._matchesPerKeypoint=1}set(e,n){return this._encodedMatches=e,this._matchesPerKeypoint=0|n,t.A.assert(this._matchesPerKeypoint>0),this}inspect(e){return{type:this.constructor.name,matchesPerKeypoint:this.matchesPerKeypoint,encodedMatchesSize:this.encodedMatches?`${this.encodedMatches.width}x${this.encodedMatches.height}`:"0x0",encodedMatches:this.encodedMatches?t.A.formatBinaryData(this.encodedMatches.inspect(e).buffer):""}}get encodedMatches(){return this._encodedMatches}get matchesPerKeypoint(){return this._matchesPerKeypoint}}});const Jt=e=>!0;class Yt{constructor(e,n=Jt){this._expectedMessageType=e,this._isValidMessage="function"==typeof n?n:Jt,t.A.assert(this._expectedMessageType!=Ut.Nothing)}isCompatibleWith(e){return this._expectedMessageType==e._expectedMessageType}accepts(e){return e.hasType(this._expectedMessageType)&&this._isValidMessage(e)}toString(){return`Port expects ${Object.keys(Ut).find((e=>Ut[e]===this._expectedMessageType))} satisfying ${this._isValidMessage}`}get expectedMessageType(){return this._expectedMessageType}}const Wt=/^[a-z][a-zA-Z0-9]*$/,Zt=new qt;class jt{constructor(e,n,i){this._name=String(e),this._spec=n,this._node=i,this._message=Zt,t.A.assert(Wt.test(this._name),`Port name "${this._name}" is not acceptable`)}get name(){return this._name}get node(){return this._node}connectTo(e){throw new c.aQ}isInputPort(){throw new c.aQ}isOutputPort(){return!this.isInputPort()}clearMessage(){this._message=Zt}hasMessage(){return!this._message.isEmpty()}read(){if(this._message.isEmpty())throw new c.Er(`Can't read from port ${this.name}: nothing to read`);return this._message}write(e){throw new c.EM(`Can't write ${e} to port ${this.name}: unsupported operation`)}inspect(e){return this._message.inspect(e)}static get DEFAULT_NAME(){throw new c.aQ}}class $t extends jt{constructor(e,t,n){super(e,t,n),this._cachedMessage=null}connectTo(e){if(!e.isInputPort())throw new c.qw(`Can't connect output port ${this.name} to port ${e.name}: expected an input port`);e.connectTo(this)}isInputPort(){return!1}write(e){if(!this._spec.accepts(e))throw new c.qw(`Can't write ${e} to port ${this.name}. ${this._spec}`);this._message=e}swrite(...e){null==this._cachedMessage&&(this._cachedMessage=Gt.create(this._spec.expectedMessageType)),this.write(this._cachedMessage.set(...e))}static get DEFAULT_NAME(){return"out"}}class Vt extends jt{constructor(e,t,n){super(e,t,n),this._incomingLink=null}get incomingLink(){return this._incomingLink}connectTo(e){if(!e.isOutputPort())throw new c.qw(`Can't connect input port ${this.name} of "${this.node.fullName}" to input port ${e.name} of "${e.node.fullName}": expected an output port`);if(!this._spec.isCompatibleWith(e._spec))throw new c.qw(`Can't connect port ${this.name} of "${this.node.fullName}" to port ${e.name} of "${e.node.fullName}": incompatible types`);this._incomingLink=e}disconnect(){this._incomingLink=null}isInputPort(){return!0}pullMessage(e=""){const t=e.length>0?`${this.name} of ${e}`:this.name;if(null==this._incomingLink)throw new c.Er(`No incoming link for input port ${t}`);const n=this._incomingLink.read();if(!this._spec.accepts(n))throw new c.qw(`Can't receive ${n} at port ${t}: ${this._spec}`);return this._message=n}static get DEFAULT_NAME(){return"in"}}class en{constructor(e,t){this._class=e,this._name=String(t),this._type=Ut.Nothing,this._messageConstraint=void 0}expects(e){return t.A.assert(this._type==Ut.Nothing),t.A.assert(e!=Ut.Nothing),this._type=e,this}satisfying(e){return t.A.assert(this._type!=Ut.Nothing,"You must first declare what type of message this port expects"),t.A.assert(void 0===this._messageConstraint),t.A.assert("function"==typeof e),this._messageConstraint=e,this}build(e){const t=new Yt(this._type,this._messageConstraint);return Reflect.construct(this._class,[this._name,t,e])}}function tn(e=Vt.DEFAULT_NAME){return new en(Vt,e)}function nn(e=$t.DEFAULT_NAME){return new en($t,e)}function on(e){return e.reduce(((e,t)=>(e[t.name]=t,e)),Object.create(null))}function sn(e){return e.reduce(((e,t)=>(e[t.name]=t,e)),Object.create(null))}let rn=!1;class An{constructor(e=(()=>Math.random().toString(16).substr(2))(),t=0,n=[]){this._name=String(e),this._tex=new Array(t).fill(null);const i=n.map((e=>e.build(this))),o=i.filter((e=>e.isInputPort())),s=i.filter((e=>e.isOutputPort()));if(this._inputPorts=on(o),this._outputPorts=sn(s),0==this._name.length)throw new c.qw(`Invalid name "${this._name}" for node ${this.fullName}`);if(0==n.length)throw new c.qw(`No ports have been found in node ${this.fullName}`)}get name(){return this._name}get fullName(){return`${this.constructor.name}[${this.name}]`}input(e=Vt.DEFAULT_NAME){if(e in this._inputPorts)return this._inputPorts[e];throw new c.qw(`Can't find input port ${e} in node ${this.fullName}`)}output(e=$t.DEFAULT_NAME){if(e in this._outputPorts)return this._outputPorts[e];throw new c.qw(`Can't find output port ${e} in node ${this.fullName}`)}execute(e){let t;for(t in this._outputPorts)this._outputPorts[t].clearMessage();for(t in this._inputPorts)this._inputPorts[t].pullMessage(this.fullName);const n=this._run(e);return void 0===n?void this._finishExecution(e):n.then((()=>this._finishExecution(e)))}_finishExecution(e){for(const e in this._outputPorts)t.A.assert(this._outputPorts[e].hasMessage(),`Did you forget to write data to the output port ${e} of ${this.fullName}?`);if("diagnostic"===o.w.logging){t.A.log(`%c ${this.fullName} `,"font-size:12pt;font-weight:bold;color:white;background:blue");for(const n in this._inputPorts)t.A.log(`%c-> ${n}:`,"font-size:10pt;font-weight:bold",this._inputPorts[n].inspect(e));for(const n in this._outputPorts)t.A.log(`%c<- ${n}:`,"font-size:10pt;font-weight:bold",this._outputPorts[n].inspect(e))}}_run(e){throw new c.aQ}init(e){e.subscribe(this._allocateWorkTextures,this,e),this._allocateWorkTextures(e)}release(e){this._deallocateWorkTextures(e),e.unsubscribe(this._allocateWorkTextures,this)}clearPorts(){let e;for(e in this._inputPorts)this._inputPorts[e].clearMessage();for(e in this._outputPorts)this._outputPorts[e].clearMessage()}inputNodes(){const e=[];for(const t in this._inputPorts){const n=this._inputPorts[t];null!=n.incomingLink&&e.push(n.incomingLink.node)}return e}isSource(){return!1}isSink(){return!1}_allocateWorkTextures(e){for(let t=0;t=0;t--)this._tex[t]=e.texturePool.free(this._tex[t])}_visualize(e,t){const n=e.renderToCanvas(t);rn||(document.body.appendChild(n),rn=!0)}}class an extends An{constructor(e=void 0,n=void 0,i=void 0){super(e,n,i),t.A.assert(0==Object.keys(this._inputPorts).length)}isSource(){return!0}}class dn extends An{constructor(e=void 0,n=void 0,i=void 0){super(e,n,i),t.A.assert(0==Object.keys(this._outputPorts).length)}export(){throw new c.aQ}isSink(){return!0}}class cn{constructor(e,t){const n=t0)throw new c.Er("The pipeline has already been initialized");if(0==e.length)throw new c.qw("Can't initialize the pipeline. Please specify its nodes");0==un++&&(t.A.assert(!pn,"Duplicate SpeedyGPU instance"),pn=new Lt);for(let t=0;t=0;e--)this._sequence[e].release(pn);return this._sequence.length=0,this._nodes.length=0,0==--un&&(pn=pn.release()),null}run(){if(t.A.assert(this._sequence.length>0,"The pipeline has not been initialized or has been released"),this._busy)return new s.i(((e,t)=>{setTimeout((()=>this.run().then(e,t)),0)}));this._busy=!0;const e=this._sequence.filter((e=>e.isSink())),n=In._createOutputTemplate(e);return"diagnostic"===o.w.logging&&t.A.log("%c RUNNING PIPELINE ","background:red;color:white;font-size:28pt;font-weight:bold"),In._runSequence(this._sequence).then((()=>s.i.all(e.map((e=>e.export().turbocharge()))).then((t=>t.reduce(((t,n,i)=>(t[e[i].name]=n,t)),n))))).finally((()=>{for(let e=this._sequence.length-1;e>=0;e--)this._sequence[e].clearPorts();this._busy=!1,"diagnostic"===o.w.logging&&(t.A.log("%c PIPELINE OUTPUT \n","background:green;color:white;font-size:16pt;font-weight:bold"),Object.keys(n).forEach((e=>{t.A.log("%c"+e+":","font-size:10pt;font-weight:bold",n[e])})))})).turbocharge()}get _gpu(){return pn}static _runSequence(e,t=0,n=e.length){for(;tIn._runSequence(e,t+1,n)))}return s.i.resolve()}static _tsort(e){const t=In._outlinks(e),n=e.map((e=>[e,!1])),i=new Set,o=new Array(e.length);let s=o.length;for(;n.length>0;){const[e,r]=n.pop();if(r)o[--s]=e;else if(!i.has(e)){const s=t.get(e);if(i.add(e),n.push([e,!0]),n.push(...s.map((e=>[e,!1]))),s.some((e=>i.has(e)&&!o.includes(e))))throw new c.Er("Pipeline networks cannot have cycles!")}}return o}static _outlinks(e){const t=new Map;for(let n=0;n=0;n--)t[e[n].name]=null;return t}static _validateSequence(e){if(0==e.length)throw new c.Er("Pipeline doesn't have nodes");if(!e[0].isSource())throw new c.Er("Pipeline doesn't have a source");if(!e.find((e=>e.isSink())))throw new c.Er("Pipeline doesn't have a sink")}}class fn extends an{constructor(e=void 0){super(e,2,[nn().expects(Ut.Image)]),this._media=null,this._textureIndex=0}get media(){return this._media}set media(e){if(null!==e&&!(e instanceof zt))throw new c.qw(`Not a SpeedyMedia: ${e}`);this._media=e}_run(e){if(null==this._media)throw new c.Er(`Did you forget to set the media of ${this.fullName}?`);this._textureIndex=(this._textureIndex+1)%this._tex.length;const t=this._tex[this._textureIndex];e.upload(this._media._source,t),this.output().swrite(t,this._media._format)}}class mn extends dn{constructor(e="image"){super(e,0,[tn().expects(Ut.Image)]),this._mediaType="bitmap",this._bitmap=null,this._data=null,this._format=St.f5.RGBA,this._textureReader=new g(1)}get mediaType(){return this._mediaType}set mediaType(e){if("bitmap"!=e&&"data"!=e)throw new c.qw(`Invalid mediaType for ${this.fullName}: "${e}"`);this._mediaType=e}init(e){super.init(e),this._textureReader.init(e)}release(e){this._textureReader.release(e),super.release(e)}export(){const e="data"!=this._mediaType?this._bitmap:this._data;return t.A.assert(null!=e),zt.load(e,{format:this._format},!1)}_run(e){const{image:t,format:n}=this.input().read();return"data"!=this._mediaType?new s.i((i=>{const o=e.renderToCanvas(t);createImageBitmap(o,0,o.height-t.height,t.width,t.height).then((e=>{this._bitmap=e,this._format=n,this._data=null,i()}))})):this._textureReader.readPixelsAsync(t,0,0,t.width,t.height,!1).then((e=>{const i=new Uint8ClampedArray(e.buffer);this._data=new ImageData(i,t.width,t.height),this._format=n,this._bitmap=null}))}}const Cn=["in0","in1"];class En extends An{constructor(e=void 0){super(e,0,[...Cn.map((e=>tn(e).expects(Ut.Image))),nn().expects(Ut.Image)]),this._port=0}get port(){return this._port}set port(e){if(e<0||e>=Cn.length)throw new c.qw(`Invalid port: ${e}`);this._port=0|e}_run(e){const t=this.input(Cn[this._port]).read();this.output().write(t)}}class xn extends An{constructor(e=void 0){super(e,2,[tn().expects(Ut.Image),nn().expects(Ut.Image)]),this._pageIndex=0,this._initialized=!1,this._previousFormat=St.f5.RGBA,this._frozen=!1}get frozen(){return this._frozen}set frozen(e){this._frozen=Boolean(e)}release(e){this._initialized=!1,super.release(e)}_run(e){const{image:t,format:n}=this.input().read(),i=this._previousFormat,o=this._tex,s=o[1-this._pageIndex],r=o[this._pageIndex];if(t.hasMipmaps())throw new c.EM(`${this.fullName} can't bufferize a pyramid`);if(this._frozen&&this._initialized||(this._previousFormat=n,s.resize(t.width,t.height),t.copyTo(s),this._pageIndex=1-this._pageIndex),!this._initialized)return this._initialized=!0,void this.output().swrite(s,n);this.output().swrite(r,i)}}const yn=h.PYRAMID_MAX_LEVELS,_n=2*yn;class Sn extends An{constructor(e=void 0){super(e,_n+1,[tn().expects(Ut.Image),nn().expects(Ut.Image)])}_run(e){const{image:t,format:n}=this.input().read(),i=this._tex[0],o=e.programs.pyramids;let s=t.width,r=t.height;const A=1+Math.floor(Math.log2(Math.max(s,r))),a=new Array(_n+1);for(let e=_n;e>=1;e--)a[e-1]=this._tex[e];a[0].resize(s,r),t.copyTo(a[0]);const d=Math.min(A,yn);for(let t=1;t>>1),i=Math.max(1,r>>>1),A=t-1+yn;o.smoothX.outputs(s,r,a[A])(a[t-1]),o.smoothY.outputs(s,r,a[t-1])(a[A]),o.downsample2.outputs(n,i,a[t])(a[t-1]),e.gl.flush(),s=n,r=i}i.resize(t.width,t.height),i.clear(),t.copyTo(i),i.generateMipmaps(a.slice(0,d)),this.output().swrite(i,n)}}class Pn extends An{constructor(e=void 0){super(e,1,[tn("in0").expects(Ut.Image),tn("in1").expects(Ut.Image),nn().expects(Ut.Image)]),this._alpha=.5,this._beta=.5,this._gamma=0}get alpha(){return this._alpha}set alpha(e){this._alpha=+e}get beta(){return this._beta}set beta(e){this._beta=+e}get gamma(){return this._gamma}set gamma(e){this._gamma=+e}_run(e){const t=this.input("in0").read(),n=this.input("in1").read(),i=t.image,o=n.image,s=t.format,r=n.format,A=Math.max(i.width,o.width),a=Math.max(i.height,o.height),d=this._alpha,l=this._beta,g=this._gamma,h=this._tex[0];if(s!=r)throw new c.EM("Can't mix images of different formats");e.programs.transforms.additiveMix.outputs(A,a,h),e.programs.transforms.additiveMix(i,o,d,l,g),this.output().swrite(h,s)}}class Bn extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Image)]),this._format=St.f5.RGBA,this._initialized=!1}get image(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._tex[0]}get format(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._format}init(e){super.init(e),this._tex[0].resize(1,1).clear(),this._format=St.f5.RGBA,this._initialized=!0}release(e){this._initialized=!1,super.release(e)}_run(e){const{image:t,format:n}=this.input().read(),i=this._tex[0];if(t.hasMipmaps())throw new c.EM(`${this.fullName} can't store a pyramid`);this._format=n,i.resize(t.width,t.height),t.copyTo(i)}}class vn extends an{constructor(e=void 0){super(e,0,[nn().expects(Ut.Image)]),this._source=null}get source(){return this._source}set source(e){if(null!==e&&!(e instanceof Bn))throw new c.qw(`Incompatible source for ${this.fullName}`);this._source=e}_run(e){if(null==this._source)throw new c.Er(`${this.fullName} has no source`);this.output().swrite(this._source.image,this._source.format)}}class Qn extends Y.Q{static Source(e=void 0){return new vn(e)}static Sink(e=void 0){return new Bn(e)}}class wn extends Y.Q{static Source(e=void 0){return new fn(e)}static Sink(e=void 0){return new mn(e)}static Multiplexer(e=void 0){return new En(e)}static Buffer(e=void 0){return new xn(e)}static Pyramid(e=void 0){return new Sn(e)}static Mixer(e=void 0){return new Pn(e)}static get Portal(){return Qn}}class bn extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Image),nn().expects(Ut.Image)])}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._tex[0],r=e.programs.filters;r.rgb2grey.outputs(i,o,s),r.rgb2grey(t),this.output().swrite(s,St.f5.GREY)}}const Dn=Object.freeze({3:[.27901008925473514,.44197982149052983,.27901008925473514],5:[.06135959781344021,.2447701955296099,.3877404133138998,.2447701955296099,.06135959781344021],7:[.03873542500847274,.11308485700794121,.2150068609928349,.26634571398150225,.2150068609928349,.11308485700794121,.03873542500847274],9:[.028532262603370988,.067234535494912,.12400932997922749,.17904386461741617,.20236001461014655,.17904386461741617,.12400932997922749,.067234535494912,.028532262603370988],11:[.022656882730580346,.04610857898527292,.08012661469398517,.11890414969751599,.15067709325491124,.16305336127546846,.15067709325491124,.11890414969751599,.08012661469398517,.04610857898527292,.022656882730580346],13:[.018815730430644363,.03447396964662016,.05657737457255748,.08317258170844948,.10952340502389682,.12918787500405662,.13649812722755,.12918787500405662,.10952340502389682,.08317258170844948,.05657737457255748,.03447396964662016,.018815730430644363],15:[.016100340991695383,.027272329212157102,.042598338587449644,.06135478775568558,.08148767614129326,.09979838342934616,.11270444144735056,.11736740487004466,.11270444144735056,.09979838342934616,.08148767614129326,.06135478775568558,.042598338587449644,.027272329212157102,.016100340991695383]}),Mn=new Xt(0,0),Kn=Object.freeze({3:"convolution3x",5:"convolution5x",7:"convolution7x",9:"convolution9x",11:"convolution11x",13:"convolution13x",15:"convolution15x"}),Ln=Object.freeze({3:"convolution3y",5:"convolution5y",7:"convolution7y",9:"convolution9y",11:"convolution11y",13:"convolution13y",15:"convolution15y"});class kn extends An{constructor(e=void 0){super(e,2,[tn().expects(Ut.Image),nn().expects(Ut.Image)]),this._kernelSize=new kt(5,5),this._sigma=Mn,this._kernel={x:Dn[this._kernelSize.width],y:Dn[this._kernelSize.height]}}get kernelSize(){return this._kernelSize}set kernelSize(e){t.A.assert(e instanceof kt);const n=e.width,i=e.height;if(n<3||i<3||n>15||i>15||n%2==0||i%2==0)throw new c.EM(`Unsupported kernel size: ${n}x${i}`);this._kernelSize=e,this._updateKernel()}get sigma(){return this._sigma}set sigma(e){t.A.assert(e instanceof Xt,"Sigma must be a SpeedyVector2"),t.A.assert(e.x>=0&&e.y>=0),this._sigma=e,this._updateKernel()}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._kernel.x,r=this._kernel.y,A=Kn[this._kernelSize.width],a=Ln[this._kernelSize.height],d=this._tex[0],c=this._tex[1];e.programs.filters[A].outputs(i,o,d)(t,s),e.programs.filters[a].outputs(i,o,c)(d,r),this.output().swrite(c,n)}_updateKernel(){this._sigma.x==Mn.x?this._kernel.x=Dn[this._kernelSize.width]:this._kernel.x=t.A.gaussianKernel(this._sigma.x,this._kernelSize.width,!0),this._sigma.y==Mn.y?this._kernel.y=Dn[this._kernelSize.height]:this._kernel.y=t.A.gaussianKernel(this._sigma.y,this._kernelSize.height,!0)}}const Rn=Object.freeze({3:new Array(3).fill(1/3),5:new Array(5).fill(.2),7:new Array(7).fill(1/7),9:new Array(9).fill(1/9),11:new Array(11).fill(1/11),13:new Array(13).fill(1/13),15:new Array(15).fill(1/15)}),zn=Object.freeze({3:"convolution3x",5:"convolution5x",7:"convolution7x",9:"convolution9x",11:"convolution11x",13:"convolution13x",15:"convolution15x"}),Nn=Object.freeze({3:"convolution3y",5:"convolution5y",7:"convolution7y",9:"convolution9y",11:"convolution11y",13:"convolution13y",15:"convolution15y"});class Xn extends An{constructor(e=void 0){super(e,2,[tn().expects(Ut.Image),nn().expects(Ut.Image)]),this._kernelSize=new kt(5,5),this._kernel={x:Rn[this._kernelSize.width],y:Rn[this._kernelSize.height]}}get kernelSize(){return this._kernelSize}set kernelSize(e){t.A.assert(e instanceof kt);const n=e.width,i=e.height;if(n<3||i<3||n>15||i>15||n%2==0||i%2==0)throw new c.EM(`Unsupported kernel size: ${n}x${i}`);this._kernelSize=e,this._kernel.x=Rn[this._kernelSize.width],this._kernel.y=Rn[this._kernelSize.height]}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._kernel.x,r=this._kernel.y,A=zn[this._kernelSize.width],a=Nn[this._kernelSize.height],d=this._tex[0],c=this._tex[1];e.programs.filters[A].outputs(i,o,d)(t,s),e.programs.filters[a].outputs(i,o,c)(d,r),this.output().swrite(c,n)}}const Tn={3:"median3",5:"median5",7:"median7"};class Fn extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),nn().expects(Ut.Image)]),this._kernelSize=new kt(5,5)}get kernelSize(){return this._kernelSize}set kernelSize(e){t.A.assert(e instanceof kt);const n=e.width;if(3!=n&&5!=n&&7!=n)throw new c.EM("Supported kernel sizes: 3x3, 5x5, 7x7");if(e.width!=e.height)throw new c.EM("Use a square kernel");this._kernelSize=e}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._kernelSize.width,r=Tn[s],A=this._tex[0];e.programs.filters[r].outputs(i,o,A)(t),this.output().swrite(A,n)}}const On={3:"convolution3",5:"convolution5",7:"convolution7"};class Un extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Image),nn().expects(Ut.Image)]),this._kernel=Ot.SpeedyMatrix.Create(3,3,[0,0,0,0,1,0,0,0,0])}get kernel(){return this._kernel}set kernel(e){if(e.rows!=e.columns)throw new c.EM("Use a square kernel");if(3!=e.rows&&5!=e.rows&&7!=e.rows)throw new c.EM("Invalid kernel size. Supported sizes: 3x3, 5x5, 7x7");this._kernel=e}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._tex[0],r=this._kernel.rows,A=On[r],a=this._kernel.read();e.programs.filters[A].outputs(i,o,s)(t,a),this.output().swrite(s,n)}}class Gn extends An{constructor(e=void 0){super(e,3,[tn().expects(Ut.Image).satisfying((e=>e.format===St.f5.RGBA||e.format===St.f5.GREY)),nn().expects(Ut.Image)]),this._gain=.5,this._offset=.5,this._decay=0,this._quality="medium"}get gain(){return this._gain}set gain(e){this._gain=+e}get offset(){return this._offset}set offset(e){this._offset=+e}get decay(){return this._decay}set decay(e){this._decay=Math.max(0,Math.min(+e,1))}get quality(){return this._quality}set quality(e){if("high"!==e&&"medium"!==e&&"low"!==e)throw new c.qw(`Invalid quality level for the Nightvision filter: "${e}"`);this._quality=e}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._gain,r=this._offset,A=this._decay,a=this._quality,d=e.programs.filters,c=this._tex[0],l=this._tex[1],g=this._tex[2];"medium"==a?(d.illuminationMapX.outputs(i,o,c),d.illuminationMapY.outputs(i,o,l),d.illuminationMapX(t),d.illuminationMapY(c)):"high"==a?(d.illuminationMapHiX.outputs(i,o,c),d.illuminationMapHiY.outputs(i,o,l),d.illuminationMapHiX(t),d.illuminationMapHiY(c)):"low"==a&&(d.illuminationMapLoX.outputs(i,o,c),d.illuminationMapLoY.outputs(i,o,l),d.illuminationMapLoX(t),d.illuminationMapLoY(c)),n===St.f5.GREY?(d.nightvisionGreyscale.outputs(i,o,g),d.nightvisionGreyscale(t,l,s,r,A)):n===St.f5.RGBA&&(d.nightvision.outputs(i,o,g),d.nightvision(t,l,s,r,A)),this.output().swrite(g,n)}}class qn extends An{constructor(e=void 0){super(e,4,[tn().expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),nn().expects(Ut.Image)]),this._minValue=0,this._maxValue=255}get minValue(){return this._minValue}set minValue(e){this._minValue=Math.max(0,Math.min(+e,255))}get maxValue(){return this._maxValue}set maxValue(e){this._maxValue=Math.max(0,Math.min(+e,255))}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._tex[3];let r=this._minValue,A=this._maxValue;r>A&&(r=A=(r+A)/2);const a=this._scanMinMax(e,t,St.kQ.GREEN);e.programs.filters.normalizeGreyscale.outputs(i,o,s),e.programs.filters.normalizeGreyscale(a,r,A),this.output().swrite(s,n)}_scanMinMax(e,n,i){const o=this._tex,s=e.programs.utils,r=n.width,A=n.height,a=0|Math.ceil(Math.log2(Math.max(r,A)));t.A.assert(void 0!==St.kg[i]),s.copyComponents.outputs(r,A,o[2]),s.scanMinMax2D.outputs(r,A,o[0],o[1]);let d=s.copyComponents(n,n,St.kQ.ALL,St.kg[i]);for(let e=0;e>>1),a=Math.ceil(t.width*t.height/A),d=Math.max(A,a),c=e.programs.keypoints;c.initLookupTable.outputs(A,a,this._tex16[1]),c.sortLookupTable.outputs(A,a,this._tex16[0],this._tex16[1]),c.encodeKeypoints.outputs(r,r,n);let l=c.initLookupTable(t);for(let e=1;e1?1<{this._keypoints=this._decode(e,n,i,r,a)}))}_decode(e,n,i,o,s){const r=h.MIN_KEYPOINT_SIZE+n+i,A=h.LOG2_PYRAMID_MAX_SCALE,a=h.PYRAMID_MAX_LEVELS,d=Math.PI/255,l=[],g=this._includeDiscarded;let p,u,I,f,m,C,E,x,y=si,_=si;if(n%4!=0||i%4!=0)throw new c.qw(`Invalid descriptorSize (${n}) / extraSize (${i})`);const S=o*s*4,P=e.byteLength;P!=S&&t.A.warning(`Expected ${S} bytes when decoding a set of keypoints, found ${P}`),n+i>0&&(e=new Uint8Array(e));for(let o=0;o0&&(_=e.subarray(8+o,8+o+i),_.byteLength0&&(y=e.subarray(8+o+i,8+o+i+n),y.byteLength0&&A%4==0);const a=i.width,d=Vn.encoderCapacity(o,s,a),c=Vn.encoderLength(d,r,A);return e.programs.keypoints.allocateExtra.outputs(c,c,n)(i,o,s,a,r,A,c)}}class Ai extends ri{constructor(e="keypoints"){super(e,0,[tn().expects(Ut.Keypoints)])}_createKeypoint(e,t,n,i,o,s,r){const A=s.byteLength>0?new oi(s):null;return new ln(e,t,n,i,o,A)}}class ai extends ri{constructor(e="keypoints"){super(e,2,[tn().expects(Ut.Keypoints).satisfying((e=>0==e.extraSize)),tn("flow").expects(Ut.Vector2)])}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input().read(),{vectors:s}=this.input("flow").read(),r=n,A=this._allocateExtra(e,this._tex[0],t,n,i,r,4),a=A.width,d=e.programs.keypoints.transferToExtra.outputs(a,a,this._tex[1])(s,s.width,A,r,4,a);return this._download(e,d,r,4,a)}_createKeypoint(e,n,i,o,s,r,A){const a=r.byteLength,d=(A.byteLength,a>0?new oi(r):null),c=t.A.decodeFloat16(A[1]<<8|A[0]),l=t.A.decodeFloat16(A[3]<<8|A[2]),g=new Xt(c,l);return new gn(e,n,i,o,s,d,g)}}class di extends ri{constructor(e="keypoints"){super(e,2,[tn().expects(Ut.Keypoints).satisfying((e=>0==e.extraSize)),tn("matches").expects(Ut.KeypointMatches)])}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input().read(),{encodedMatches:s,matchesPerKeypoint:r}=this.input("matches").read(),A=n,a=4*r,d=this._allocateExtra(e,this._tex[0],t,n,i,A,a),c=d.width,l=e.programs.keypoints.transferToExtra.outputs(c,c,this._tex[1])(s,s.width,d,A,a,c);return this._download(e,l,A,a,c)}_createKeypoint(e,t,n,i,o,s,r){const A=s.byteLength,a=r.byteLength,d=A>0?new oi(s):null,c=a/4,l=new Array(c);for(let e=0;e>>h.MATCH_INDEX_BITS);l[e]=i}return new hn(e,t,n,i,o,d,l)}}const ci=h.MAX_ENCODER_CAPACITY;class li extends An{constructor(e=void 0){super(e,4,[tn().expects(Ut.Keypoints),nn().expects(Ut.Keypoints)]),this._size=ci}get size(){return this._size}set size(e){this._size=Math.max(0,Math.min(0|e,ci))}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input().read(),s=e.programs.keypoints,r=this._size,A=this._tex,a=this._tex[3],d=Vn.encoderCapacity(n,i,o),c=Math.ceil(d/32),l=32*c,g=Math.min(d,r),h=Vn.encoderLength(g,n,i);s.sortCreatePermutation.outputs(32,c,A[0]);let p=s.sortCreatePermutation(t,n,i,o);const u=Math.ceil(Math.log2(l));s.sortMergePermutation.outputs(32,c,A[1],A[2]);for(let e=1;e<=u;e++){const t=1<tn(e).expects(Ut.Keypoints))),nn().expects(Ut.Keypoints)]),this._port=0}get port(){return this._port}set port(e){if(e<0||e>=Ii.length)throw new c.qw(`Invalid port: ${e}`);this._port=0|e}_run(e){const t=this.input(Ii[this._port]).read();this.output().write(t)}}class mi extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Keypoints),nn().expects(Ut.Keypoints)]),this._transform=Ot.SpeedyMatrix.Create(3,3,[1,0,0,0,1,0,0,0,1])}get transform(){return this._transform}set transform(e){if(3!=e.rows||3!=e.columns)throw new c.qw(`Not a 3x3 transformation matrix: ${e}`);this._transform=e}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input().read(),s=this._tex[0],r=this._transform.read();e.programs.keypoints.applyHomography.outputs(t.width,t.height,s)(r,t,n,i,o),this.output().swrite(s,n,i,o)}}const Ci=Object.freeze({quadratic1d:"subpixelQuadratic1d",taylor2d:"subpixelTaylor2d","bicubic-upsample":"subpixelBicubic","bilinear-upsample":"subpixelBilinear"});class Ei extends An{constructor(e=void 0){super(e,2,[tn("image").expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),tn("keypoints").expects(Ut.Keypoints),nn().expects(Ut.Keypoints),nn("displacements").expects(Ut.Vector2)]),this._method="quadratic1d",this._maxIterations=6,this._epsilon=.1}get method(){return this._method}set method(e){if(!Object.prototype.hasOwnProperty.call(Ci,e))throw new c.qw(`Invalid method: "${e}"`);this._method=e}get maxIterations(){return this._maxIterations}set maxIterations(e){this._maxIterations=Math.max(0,+e)}get epsilon(){return this._epsilon}set epsilon(e){this._epsilon=Math.max(0,+e)}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input("keypoints").read(),{image:s,format:r}=this.input("image").read(),A=this._tex,a=Ci[this._method],d=this._maxIterations,c=this._epsilon,l=Vn.encoderCapacity(n,i,o),g=Math.max(1,Math.ceil(Math.sqrt(l))),h=e.programs.keypoints[a].outputs(g,g,A[0])(s,t,n,i,o,d,c),p=e.programs.keypoints.transferFlow.outputs(o,o,A[1])(h,t,n,i,o);this.output().swrite(p,n,i,o),this.output("displacements").swrite(h)}}class xi extends ei{constructor(e=void 0){super(e,5,[tn().expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),nn().expects(Ut.Keypoints)]),this._threshold=20}get threshold(){return this._threshold}set threshold(e){this._threshold=Math.max(0,Math.min(0|e,255))}_run(e){const{image:t,format:n}=this.input().read(),i=t.width,o=t.height,s=this._tex,r=this._capacity,A=this._threshold,a=Math.log2(this.scaleFactor),d=this.levels;if(1!=d&&!t.hasMipmaps())throw new c.Er(`Expected a pyramid in ${this.fullName}`);if(0==r){const t=this._encodeZeroKeypoints(e,s[4]),n=t.width;return void this.output().swrite(t,0,0,n)}e.programs.keypoints.fast9_16.outputs(i,o,s[0],s[1]),e.programs.keypoints.nonmaxSpace.outputs(i,o,s[2]);let l=s[1].clear(),g=Math.max(1,Math.min(d,h.PYRAMID_MAX_LEVELS/a|0));for(let n=a*(g-1);g-- >0;n-=a)l=e.programs.keypoints.fast9_16(l,t,n,A);l=e.programs.keypoints.nonmaxSpace(l),d>1&&(l=e.programs.keypoints.nonmaxScaleSimple.outputs(i,o,s[1])(l,t,a));let p=this._encodeKeypoints(e,l,s[3]);const u=p.width;d>1&&(p=e.programs.keypoints.refineScaleFAST916.outputs(u,u,s[4])(t,a,p,0,0,u,A)),this.output().swrite(p,0,0,u)}}const yi=Object.freeze({1:"harris1",3:"harris3",5:"harris5",7:"harris7"});class _i extends ei{constructor(e=void 0){super(e,6,[tn().expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),nn().expects(Ut.Keypoints)]),this._windowSize=new kt(3,3),this._quality=.1}get quality(){return this._quality}set quality(e){this._quality=Math.max(0,Math.min(+e,1))}get windowSize(){return this._windowSize}set windowSize(e){const t=e.width;if(t!=e.height||1!=t&&3!=t&&5!=t&&7!=t)throw new c.qw(`Invalid window: ${e}. Acceptable sizes: 1x1, 3x3, 5x5, 7x7`);this._windowSize=e}_run(e){const{image:n,format:i}=this.input().read(),o=n.width,s=n.height,r=this._capacity,A=this._quality,a=this._windowSize.width,d=this.levels,l=Math.log2(this.scaleFactor),g=d>1?this.scaleFactor:1,p=e.programs.keypoints[yi[a]],u=this._tex;if(1!=d&&!n.hasMipmaps())throw new c.Er(`Expected a pyramid in ${this.fullName}`);if(0==r){const t=this._encodeZeroKeypoints(e,u[5]),n=t.width;return void this.output().swrite(t,0,0,n)}p.outputs(o,s,u[0],u[1]),e.programs.utils.sobelDerivatives.outputs(o,s,u[2]),e.programs.keypoints.nonmaxSpace.outputs(o,s,u[3]);let I=u[1].clear(),f=Math.max(1,Math.min(d,h.PYRAMID_MAX_LEVELS/l|0));for(let i=l*(f-1);f-- >0;i-=l){const o=t.A.gaussianKernel(g*(1+i),a);I=p(I,n,e.programs.utils.sobelDerivatives(n,i),i,l,o),I=e.programs.keypoints.nonmaxSpace(I)}if(d>1){const t=e.programs.keypoints.laplacian.outputs(o,s,u[0])(I,n,l,0);I=e.programs.keypoints.nonmaxScale.outputs(o,s,u[2])(I,n,t,l)}e.programs.keypoints.harrisScoreFindMax.outputs(o,s,u[0],u[1]),f=Math.ceil(Math.log2(Math.max(o,s)));let m=I;for(let t=0;t1&&(C=e.programs.keypoints.refineScaleLoG.outputs(E,E,u[5])(n,l,C,0,0,E)),this.output().swrite(C,0,0,E)}}class Si extends An{constructor(e=void 0,t=0,n=void 0){super(e,t+1,n)}_allocateDescriptors(e,n,i,o,s,r){t.A.assert(n>=0&&i>=0),t.A.assert(o>=0&&o%4==0&&s===i);const A=r.width,a=Vn.encoderCapacity(n,i,A),d=Vn.encoderLength(a,o,s),c=this._tex[this._tex.length-1];return e.programs.keypoints.allocateDescriptors.outputs(d,d,c)(r,n,i,A,o,s,d)}}class Pi extends Si{constructor(e=void 0){super(e,3,[tn("image").expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),tn("keypoints").expects(Ut.Keypoints),nn().expects(Ut.Keypoints)])}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input("keypoints").read(),s=this.input("image").read().image,r=this._tex,A=this._tex[2],a=Vn.encoderCapacity(n,i,o),d=Math.max(1,Math.ceil(Math.sqrt(a))),c=e.programs.keypoints.orbOrientation.outputs(d,d,r[0])(s,t,n,i,o),l=e.programs.keypoints.transferOrientation.outputs(o,o,r[1])(c,t,n,i,o),g=this._allocateDescriptors(e,n,i,32,i,l),h=g.width,p=e.programs.keypoints.orbDescriptor.outputs(h,h,A)(s,g,i,h);this.output().swrite(p,32,i,h)}}const Bi=new kt(11,11),vi=Math.min(3,h.PYRAMID_MAX_LEVELS),Qi={3:"lk3",5:"lk5",7:"lk7",9:"lk9",11:"lk11",13:"lk13",15:"lk15",17:"lk17",19:"lk19",21:"lk21"};class wi extends An{constructor(e=void 0){super(e,3,[tn("previousImage").expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),tn("nextImage").expects(Ut.Image).satisfying((e=>e.format===St.f5.GREY)),tn("previousKeypoints").expects(Ut.Keypoints),nn().expects(Ut.Keypoints),nn("flow").expects(Ut.Vector2)]),this._windowSize=Bi,this._levels=vi,this._discardThreshold=1e-4,this._numberOfIterations=30,this._epsilon=.01}get windowSize(){return this._windowSize}set windowSize(e){if(e.width!=e.height)throw new c.EM(`LK: window ${this._windowSize.toString()} is not square!`);if(!Object.prototype.hasOwnProperty.call(Qi,e.width)){const e=Object.keys(Qi).sort(((e,t)=>e-t)).map((e=>e+"x"+e)).join(", ");throw new c.EM(`LK: window of size ${this._windowSize.toString()} is not supported! Supported sizes: ${e}`)}this._windowSize=e}get levels(){return this._levels}set levels(e){t.A.assert(e>=1&&e<=h.PYRAMID_MAX_LEVELS),this._levels=0|e}get discardThreshold(){return this._discardThreshold}set discardThreshold(e){t.A.assert(e>=0),this._discardThreshold=+e}get numberOfIterations(){return this._numberOfIterations}set numberOfIterations(e){t.A.assert(e>=1),this._numberOfIterations=0|e}get epsilon(){return this._epsilon}set epsilon(e){t.A.assert(e>=0),this._epsilon=+e}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input("previousKeypoints").read(),s=this.input("previousImage").read().image,r=this.input("nextImage").read().image,A=t,a=this._levels,d=this._windowSize.width,l=this._numberOfIterations,g=this._discardThreshold,h=this._epsilon,p=e.programs.keypoints,u=this._tex;if(!(1==a||s.hasMipmaps()&&r.hasMipmaps()))throw new c.Er("LK: a pyramid is required if levels > 1");if(s.width!==r.width||s.height!==r.height)throw new c.Er("LK: can't use input images of different size");const I=p[Qi[d]],f=Vn.encoderCapacity(n,i,o),m=Math.max(1,Math.ceil(Math.sqrt(f)));I.outputs(m,m,u[0],u[1]);let C=I.clear();for(let e=a-1;e>=0;e--)C=I(C,A,r,s,e,a,l,g,h,n,i,o);p.transferFlow.outputs(o,o,u[2]);const E=p.transferFlow(C,A,n,i,o);this.output().swrite(E,n,i,o),this.output("flow").swrite(C)}}class bi extends an{constructor(e=void 0){super(e,2,[nn().expects(Ut.LSHTables)]),this._keypoints=[],this._keypointsCopy=[],this._numberOfTables=8,this._hashSize=15,this._lsh=null}get keypoints(){return this._keypoints}set keypoints(e){if(!Array.isArray(e)||e.find((e=>!(e instanceof ln))))throw new c.qw("Static LSH tables: an invalid set of keypoints has been provided");this._keypoints!==e&&(this._keypoints=e,this._keypointsCopy=e.slice(0),this._lsh=null)}get numberOfTables(){return this._numberOfTables}set numberOfTables(e){if(!Z.includes(e))throw new c.qw(`Invalid number of tables: ${e}. Acceptable values: ${Z.join(", ")}`);e!==this._numberOfTables&&(this._numberOfTables=0|e,this._lsh=null)}get hashSize(){return this._hashSize}set hashSize(e){if(!j.includes(e))throw new c.qw(`Invalid hash size: ${e}. Acceptable values: ${j.join(", ")}`);e!==this._hashSize&&(this._hashSize=0|e,this._lsh=null)}_run(e){null==this._lsh&&(this._lsh=this._train()),this.output().swrite(this._lsh)}_train(){const e=this._keypointsCopy,t=this._numberOfTables,n=this._hashSize;if(e.find((e=>null==e.descriptor)))throw new c.Er("Static LSH tables: can't train the model with no keypoint descriptors!");const i=e.map((e=>e.descriptor.data)),o=this._tex[0],s=this._tex[1];return new oe(o,s,i,t,n)}}const Di={fastest:0,default:1,demanding:2},Mi=$.reduce(((e,t)=>(e[t]=(e=>{return t=t=>{return n=n=>`lshKnn${e}h${t}lv${n}`,[0,1,2].reduce(((e,t)=>(e[t]=n(t),e)),{});var n},j.reduce(((e,n)=>(e[n]=t(n),e)),{});var t})(t),e)),{});class Ki extends An{constructor(e=void 0){super(e,6,[tn("keypoints").expects(Ut.Keypoints).satisfying((e=>e.descriptorSize>0)),tn("lsh").expects(Ut.LSHTables),nn().expects(Ut.KeypointMatches)]),this._k=1,this._quality="default"}get k(){return this._k}set k(e){this._k=Math.max(1,0|e)}get quality(){return this._quality}set quality(e){if(!Object.prototype.hasOwnProperty.call(Di,e))throw new c.qw(`Invalid quality level: "${e}"`);this._quality=e}_run(e){const{encodedKeypoints:n,descriptorSize:i,extraSize:o,encoderLength:s}=this.input("keypoints").read(),r=this.input("lsh").read().lsh,A=e.programs.keypoints,a=r.tables,d=r.descriptorDB,l=a.width,g=d.width,h=r.tableCount,p=r.hashSize,u=r.bucketCapacity,I=r.bucketsPerTable,f=r.sequences,m=this._tex[0],C=this._tex[1],E=this._tex[2],x=this._tex[3],y=this._tex[4],_=this._tex[5],S=Di[this._quality],P=this._k;if(i!==r.descriptorSize)throw new c.qw(`Can't match different types of descriptors in ${this.fullName}`);t.A.assert(null!=Mi[i]),t.A.assert(null!=Mi[i][p]),t.A.assert(null!=Mi[i][p][S]);const B=Vn.encoderCapacity(i,o,s),v=Math.max(1,Math.ceil(Math.sqrt(B*P)));let Q=_;A.lshKnnTransfer.outputs(v,v,y,_);const w=Math.max(1,Math.ceil(Math.sqrt(B)));A.lshKnnInitCandidates.outputs(w,w,m),A.lshKnnInitFilters.outputs(w,w,x);const b=A[Mi[i][p][S]];b.outputs(w,w,C,E),b.setUBO("LSHSequences",f),Q.clear(),A.lshKnnInitFilters();for(let t=0;te.descriptorSize>0)),tn("database").expects(Ut.Keypoints).satisfying((e=>e.descriptorSize>0)),nn().expects(Ut.KeypointMatches)]),this._matchesPerKeypoint=1}get k(){return this._matchesPerKeypoint}set k(e){this._matchesPerKeypoint=Math.max(1,0|e)}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input("keypoints").read(),s=this.input("database").read(),r=this._tex[0],A=this._tex[1],a=this._tex[2],d=this._tex[3],l=this._tex[4],g=this._tex[5],h=this._matchesPerKeypoint,p=e.programs.keypoints;if(n!==s.descriptorSize)throw new c.qw(`Incompatible descriptors in ${this.fullName}`);if(!Object.prototype.hasOwnProperty.call(Li,n))throw new c.EM(`Unsupported descriptor size (${n}) in ${this.fullName}`);const u=p[Li[n]],I=Vn.encoderCapacity(n,i,o),f=Vn.encoderCapacity(s.descriptorSize,s.extraSize,s.encoderLength),m=u.definedConstant("NUMBER_OF_KEYPOINTS_PER_PASS"),C=Math.ceil(f/m),E=Math.max(1,Math.ceil(Math.sqrt(I))),x=Math.max(1,Math.ceil(Math.sqrt(I*h)));p.bfMatcherTransfer.outputs(x,x,l,g),p.bfMatcherInitCandidates.outputs(E,E,a),p.bfMatcherInitFilters.outputs(E,E,d),u.outputs(E,E,r,A);let y=g.clear(),_=p.bfMatcherInitFilters();for(let r=0;r1&&A.copyTo(_),y=p.bfMatcherTransfer(y,A,h,r)}this.output().swrite(y,h)}}class Ri extends An{constructor(e=void 0){super(e,1,[tn("in").expects(Ut.Keypoints),tn("reference").expects(Ut.Keypoints),nn().expects(Ut.Keypoints)]),this._threshold=h.MAX_TEXTURE_LENGTH+1}get threshold(){return this._threshold}set threshold(e){this._threshold=Math.max(0,+e)}_run(e){const t=this.input("in").read(),n=this.input("reference").read(),i=this._threshold;if(t.descriptorSize!=n.descriptorSize||t.extraSize!=n.extraSize)throw new c.Er("The distance filter requires two compatible shapes of keypoint streams");const o=this._tex[0],s=Math.max(t.encoderLength,n.encoderLength),r=t.descriptorSize,A=t.extraSize;e.programs.keypoints.distanceFilter.outputs(s,s,o)(t.encodedKeypoints,t.encoderLength,n.encodedKeypoints,n.encoderLength,r,A,s,i),this.output().swrite(o,r,A,s)}}const zi={32:"hammingDistanceFilter32",64:"hammingDistanceFilter64"};class Ni extends An{constructor(e=void 0){super(e,1,[tn("in").expects(Ut.Keypoints).satisfying((e=>e.descriptorSize>0)),tn("reference").expects(Ut.Keypoints).satisfying((e=>e.descriptorSize>0)),nn().expects(Ut.Keypoints)]),this._threshold=8*h.MAX_DESCRIPTOR_SIZE}get threshold(){return this._threshold}set threshold(e){this._threshold=Math.max(0,0|e)}_run(e){const t=this.input("in").read(),n=this.input("reference").read(),i=this._threshold;if(t.descriptorSize!=n.descriptorSize||t.extraSize!=n.extraSize)throw new c.Er("The Hamming distance filter requires two compatible shapes of keypoint streams");if(!Object.prototype.hasOwnProperty.call(zi,t.descriptorSize))throw new c.EM(`Hamming distance filter - invalid descriptor size: ${t.descriptorSize}`);const o=this._tex[0],s=Math.max(t.encoderLength,n.encoderLength),r=t.descriptorSize,A=t.extraSize,a=zi[t.descriptorSize];e.programs.keypoints[a].outputs(s,s,o)(t.encodedKeypoints,t.encoderLength,n.encodedKeypoints,n.encoderLength,r,A,s,i),this.output().swrite(o,r,A,s)}}class Xi extends An{constructor(e=void 0){super(e,1,[tn().expects(Ut.Keypoints)]),this._descriptorSize=0,this._extraSize=0,this._encoderLength=0,this._initialized=!1}get encodedKeypoints(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._tex[0]}get descriptorSize(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._descriptorSize}get extraSize(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._extraSize}get encoderLength(){if(!this._initialized)throw new c.Er(`Portal error: ${this.fullName} holds no data`);return this._encoderLength}init(e){super.init(e);const t=Vn.encoderLength(0,0,0);this._tex[0].resize(t,t).clearToColor(1,1,1,1),this._descriptorSize=this._extraSize=0,this._encoderLength=t,this._initialized=!0}release(e){this._initialized=!1,super.release(e)}_run(e){const{encodedKeypoints:t,descriptorSize:n,extraSize:i,encoderLength:o}=this.input().read(),s=this._tex[0];s.resize(t.width,t.height),t.copyTo(s),this._descriptorSize=n,this._extraSize=i,this._encoderLength=o}}class Ti extends an{constructor(e=void 0){super(e,0,[nn().expects(Ut.Keypoints)]),this._source=null}get source(){return this._source}set source(e){if(null!==e&&!(e instanceof Xi))throw new c.qw(`Incompatible source for ${this.fullName}`);this._source=e}_run(e){if(null==this._source)throw new c.Er(`${this.fullName} has no source`);this.output().swrite(this._source.encodedKeypoints,this._source.descriptorSize,this._source.extraSize,this._source.encoderLength)}}class Fi extends Y.Q{static FAST(e=void 0){return new xi(e)}static Harris(e=void 0){return new _i(e)}}class Oi extends Y.Q{static ORB(e=void 0){return new Pi(e)}}class Ui extends Y.Q{static LK(e=void 0){return new wi(e)}}class Gi extends Y.Q{static StaticLSHTables(e=void 0){return new bi(e)}static LSHKNN(e=void 0){return new Ki(e)}static BFKNN(e=void 0){return new ki(e)}}class qi extends Y.Q{static Source(e=void 0){return new Ti(e)}static Sink(e=void 0){return new Xi(e)}}class Hi extends Y.Q{static get Detector(){return Fi}static get Descriptor(){return Oi}static get Tracker(){return Ui}static get Matcher(){return Gi}static get Portal(){return qi}static Source(e=void 0){return new ii(e)}static Sink(e=void 0){return new Ai(e)}static SinkOfTrackedKeypoints(e=void 0){return new ai(e)}static SinkOfMatchedKeypoints(e=void 0){return new di(e)}static Clipper(e=void 0){return new li(e)}static BorderClipper(e=void 0){return new gi(e)}static Buffer(e=void 0){return new hi(e)}static Mixer(e=void 0){return new pi(e)}static Shuffler(e=void 0){return new ui(e)}static Multiplexer(e=void 0){return new fi(e)}static Transformer(e=void 0){return new mi(e)}static SubpixelRefiner(e=void 0){return new Ei(e)}static DistanceFilter(e=void 0){return new Ri(e)}static HammingDistanceFilter(e=void 0){return new Ni(e)}}const Ji=e=>e>1?1<{this._vectors=Yi._decode(e,o,s)}))}static _decode(e,n,i){const o=[];let s=0,r=0,A=0,a=0;const d=n*i*4,c=Math.min(e.length,d);for(let n=0;n=this._updateInterval&&(this._fps=Math.round(this._frames/(.001*t)),this._frames=0,this._lastUpdate=e),this._frames++,requestAnimationFrame(this._boundUpdate)}}const ji=new class extends Function{constructor(){return super("...args","return args.length > 1 ? this._create(...args) : this._from(args[0])"),this.bind(this)}_create(e,t=e,n=[]){return Ot.SpeedyMatrix.Create(e,t,n)}_from(e){return Ot.SpeedyMatrix.From(e)}Zeros(e,t=e){return Ot.SpeedyMatrix.Zeros(e,t)}Ones(e,t=e){return Ot.SpeedyMatrix.Ones(e,t)}Eye(e,t=e){return Ot.SpeedyMatrix.Eye(e,t)}ready(){return Ot.SpeedyMatrix.ready()}qr(e,t,n,{mode:i="reduced"}={}){const o=n,s=n.rows,r=n.columns;if("reduced"==i){if(e.rows!=s||e.columns!=r||t.rows!=r||t.columns!=r)throw new c.qw("Invalid shape for reduced QR")}else{if("full"!=i)throw new c.qw(`Invalid mode for QR: "${i}"`);if(e.rows!=s||e.columns!=s||t.rows!=s||t.columns!=r)throw new c.qw("Invalid shape for full QR")}return Ft.U.ready().then((({wasm:n,memory:s})=>{const r=Ft.U.allocateMat32(n,s,e),A=Ft.U.allocateMat32(n,s,t),a=Ft.U.allocateMat32(n,s,o);return Ft.U.copyToMat32(n,s,a,o),"reduced"==i?n.exports.Mat32_qr_reduced(r,A,a):n.exports.Mat32_qr_full(r,A,a),Ft.U.copyFromMat32(n,s,r,e),Ft.U.copyFromMat32(n,s,A,t),Ft.U.deallocateMat32(n,s,a),Ft.U.deallocateMat32(n,s,A),Ft.U.deallocateMat32(n,s,r),[e,t]}))}ols(e,t,n,{method:i="qr"}={}){const o=t.rows,s=t.columns,r=e;if(o{const A=Ft.U.allocateMat32(o,s,t),a=Ft.U.allocateMat32(o,s,n),d=Ft.U.allocateMat32(o,s,r);if(Ft.U.copyToMat32(o,s,A,t),Ft.U.copyToMat32(o,s,a,n),"qr"!==i)throw new c.qw(`Invalid method: "${i}"`);return o.exports.Mat32_qr_ols(d,A,a,2),Ft.U.copyFromMat32(o,s,d,r),Ft.U.deallocateMat32(o,s,d),Ft.U.deallocateMat32(o,s,a),Ft.U.deallocateMat32(o,s,A),e}))}solve(e,t,n,{method:i="qr"}={}){const o=t.rows,s=t.columns,r=e;if(o!=s)throw new c.qw("Can't solve an over or underdetermined system of equations");if(n.rows!=o||1!=n.columns||r.rows!=o||1!=r.columns)throw new c.qw("Invalid shapes");return Ft.U.ready().then((({wasm:e,memory:o})=>{if("qr"===i)return this.ols(r,t,n,{method:i});throw new c.qw(`Invalid method: "${i}"`)}))}perspective(e,t,n){if(2!=t.rows||4!=t.columns||2!=n.rows||4!=n.columns)throw new c.qw("You need two 2x4 input matrices to compute a perspective transformation");if(3!=e.rows||3!=e.columns)throw new c.qw("The output of perspective() is a 3x3 homography");return Ft.U.ready().then((({wasm:i,memory:o})=>{const s=Ft.U.allocateMat32(i,o,e),r=Ft.U.allocateMat32(i,o,t),A=Ft.U.allocateMat32(i,o,n);return Ft.U.copyToMat32(i,o,r,t),Ft.U.copyToMat32(i,o,A,n),i.exports.Mat32_homography_ndlt4(s,r,A),Ft.U.copyFromMat32(i,o,s,e),Ft.U.deallocateMat32(i,o,A),Ft.U.deallocateMat32(i,o,r),Ft.U.deallocateMat32(i,o,s),e}))}findHomography(e,n,i,{method:o="default",mask:s=null,reprojectionError:r=3,numberOfHypotheses:A=512,bundleSize:a=128}={}){if(2!=n.rows||n.columns<4||2!=i.rows||i.columns!=n.columns)throw new c.qw("You need two 2 x n (n >= 4) input matrices to compute a homography");if(3!=e.rows||3!=e.columns)throw new c.qw("The output of findHomography() is a 3x3 homography");if(null!=s&&(1!=s.rows||s.columns!=n.columns))throw new c.qw("Invalid shape of the inliers mask");return Ft.U.ready().then((({wasm:d,memory:l})=>{const g=Ft.U.allocateMat32(d,l,e),h=Ft.U.allocateMat32(d,l,n),p=Ft.U.allocateMat32(d,l,i),u=null!=s?Ft.U.allocateMat32(d,l,s):0;switch(Ft.U.copyToMat32(d,l,h,n),Ft.U.copyToMat32(d,l,p,i),o){case"pransac":t.A.assert(r>=0&&A>0&&a>0),d.exports.Mat32_pransac_homography(g,u,h,p,A,a,r);break;case"default":case"dlt":d.exports.Mat32_homography_ndlt(g,h,p);break;default:throw new c.qw(`Illegal method for findHomography(): "${o}"`)}return Ft.U.copyFromMat32(d,l,g,e),null!=s&&Ft.U.copyFromMat32(d,l,u,s),null!=s&&Ft.U.deallocateMat32(d,l,u),Ft.U.deallocateMat32(d,l,p),Ft.U.deallocateMat32(d,l,h),Ft.U.deallocateMat32(d,l,g),e}))}applyPerspectiveTransform(e,t,n){if(2!=t.rows||2!=e.rows||t.columns!=e.columns)throw new c.qw("Invalid shapes");if(3!=n.rows||3!=n.columns)throw new c.qw("The perspective transformation must be a 3x3 matrix");return Ft.U.ready().then((({wasm:i,memory:o})=>{const s=Ft.U.allocateMat32(i,o,n),r=Ft.U.allocateMat32(i,o,t),A=Ft.U.allocateMat32(i,o,e);return Ft.U.copyToMat32(i,o,r,t),Ft.U.copyToMat32(i,o,s,n),i.exports.Mat32_transform_perspective(A,r,s),Ft.U.copyFromMat32(i,o,A,e),Ft.U.deallocateMat32(i,o,A),Ft.U.deallocateMat32(i,o,r),Ft.U.deallocateMat32(i,o,s),e}))}affine(e,t,n){if(2!=t.rows||3!=t.columns||2!=n.rows||3!=n.columns)throw new c.qw("You need two 2x3 input matrices to compute an affine transform");if(2!=e.rows||3!=e.columns)throw new c.qw("The output of affine() is a 2x3 matrix");return Ft.U.ready().then((({wasm:i,memory:o})=>{const s=Ft.U.allocateMat32(i,o,e),r=Ft.U.allocateMat32(i,o,t),A=Ft.U.allocateMat32(i,o,n);return Ft.U.copyToMat32(i,o,r,t),Ft.U.copyToMat32(i,o,A,n),i.exports.Mat32_affine_direct3(s,r,A),Ft.U.copyFromMat32(i,o,s,e),Ft.U.deallocateMat32(i,o,A),Ft.U.deallocateMat32(i,o,r),Ft.U.deallocateMat32(i,o,s),e}))}findAffineTransform(e,n,i,{method:o="default",mask:s=null,reprojectionError:r=3,numberOfHypotheses:A=512,bundleSize:a=128}={}){if(2!=n.rows||n.columns<3||2!=i.rows||i.columns!=n.columns)throw new c.qw("You need two 2 x n (n >= 3) input matrices to compute an affine transform");if(2!=e.rows||3!=e.columns)throw new c.qw("The output of findAffineTransform() is a 2x3 matrix");if(null!=s&&(1!=s.rows||s.columns!=n.columns))throw new c.qw("Invalid shape of the inliers mask");return Ft.U.ready().then((({wasm:d,memory:l})=>{const g=Ft.U.allocateMat32(d,l,e),h=Ft.U.allocateMat32(d,l,n),p=Ft.U.allocateMat32(d,l,i),u=null!=s?Ft.U.allocateMat32(d,l,s):0;switch(Ft.U.copyToMat32(d,l,h,n),Ft.U.copyToMat32(d,l,p,i),o){case"pransac":t.A.assert(r>=0&&A>0&&a>0),d.exports.Mat32_pransac_affine(g,u,h,p,A,a,r);break;case"default":d.exports.Mat32_affine_direct(g,h,p);break;default:throw new c.qw(`Illegal method for findAffineTransform(): "${o}"`)}return Ft.U.copyFromMat32(d,l,g,e),null!=s&&Ft.U.copyFromMat32(d,l,u,s),null!=s&&Ft.U.deallocateMat32(d,l,u),Ft.U.deallocateMat32(d,l,p),Ft.U.deallocateMat32(d,l,h),Ft.U.deallocateMat32(d,l,g),e}))}applyAffineTransform(e,t,n){if(2!=t.rows||2!=e.rows||t.columns!=e.columns)throw new c.qw("Invalid shapes");if(2!=n.rows||3!=n.columns)throw new c.qw("The affine transformation must be a 2x3 matrix");return Ft.U.ready().then((({wasm:i,memory:o})=>{const s=Ft.U.allocateMat32(i,o,n),r=Ft.U.allocateMat32(i,o,t),A=Ft.U.allocateMat32(i,o,e);return Ft.U.copyToMat32(i,o,r,t),Ft.U.copyToMat32(i,o,s,n),i.exports.Mat32_transform_affine(A,r,s),Ft.U.copyFromMat32(i,o,A,e),Ft.U.deallocateMat32(i,o,A),Ft.U.deallocateMat32(i,o,r),Ft.U.deallocateMat32(i,o,s),e}))}},$i=new class extends Function{constructor(){return super("...args","return this._create(...args)"),this.bind(this)}_create(e,t){return new Xt(e,t)}Sink(e=void 0){return new Yi(e)}};class Vi{static get version(){return"0.9.1"}static isSupported(){return"undefined"!=typeof WebAssembly&&"undefined"!=typeof WebGL2RenderingContext&&null!=e.c.instance.gl}static get Settings(){return o.w}static get Vector2(){return $i}static Point2(e,t){return new Tt(e,t)}static Size(e,t){return new kt(e,t)}static get Matrix(){return ji}static get Promise(){return s.i}static Pipeline(){return new In}static get Image(){return wn}static get Filter(){return Hn}static get Transform(){return Zn}static get Keypoint(){return Hi}static load(e,t={}){return zt.load(e,t)}static camera(e=640,n=360){const i="object"==typeof e?e:{audio:!1,video:{width:0|e,height:0|n}};return t.A.requestCameraStream(i).then((e=>zt.load(e)))}static get Platform(){return Nt}static get fps(){return Zi.instance.fps}}Object.freeze(Vi),t.A.log(`Speedy Vision version ${Vi.version}. GPU-accelerated Computer Vision for JavaScript by Alexandre Martins. https://github.com/alemart/speedy-vision`),h.LITTLE_ENDIAN||t.A.warning("Running on a big-endian machine")})(),i=i.default})())); \ No newline at end of file