face-api/dist/face-api.esm-nobundle.js

10 lines
80 KiB
JavaScript
Raw Normal View History

/*
Face-API
homepage: <https://github.com/vladmandic/face-api>
author: <https://github.com/vladmandic>'
*/
2021-03-31 13:01:22 +02:00
var pr=Object.defineProperty;var ao=Object.prototype.hasOwnProperty,so=Object.getOwnPropertyNames,io=Object.getOwnPropertyDescriptor;var dr=(o,t)=>{for(var e in t)pr(o,e,{get:t[e],enumerable:!0})},wt=(o,t,e)=>{if(t&&typeof t=="object"||typeof t=="function")for(let r of so(t))!ao.call(o,r)&&r!=="default"&&pr(o,r,{get:()=>t[r],enumerable:!(e=io(t,r))||e.enumerable});return o};var n={};wt(n,Qo);wt(n,tn);import*as Qo from"@tensorflow/tfjs/dist/index.js";import*as tn from"@tensorflow/tfjs-backend-wasm";var To={};dr(To,{AnchorPosition:()=>J,DrawBox:()=>ue,DrawBoxOptions:()=>Ae,DrawFaceLandmarks:()=>Oe,DrawFaceLandmarksOptions:()=>$e,DrawTextField:()=>st,DrawTextFieldOptions:()=>Vt,drawContour:()=>q,drawDetections:()=>go,drawFaceExpressions:()=>vo,drawFaceLandmarks:()=>Fo});function q(o,t,e=!1){if(o.beginPath(),t.slice(1).forEach(({x:r,y:a},s)=>{let i=t[s];o.moveTo(i.x,i.y),o.lineTo(r,a)}),e){let r=t[t.length-1],a=t[0];if(!r||!a)return;o.moveTo(r.x,r.y),o.lineTo(a.x,a.y)}o.stroke()}var co={};dr(co,{computeReshapedDimensions:()=>Me,getCenterPoint:()=>dt,isDimensions:()=>ie,isEven:()=>se,isFloat:()=>Ee,isTensor:()=>mt,isTensor1D:()=>mo,isTensor2D:()=>De,isTensor3D:()=>Z,isTensor4D:()=>B,isValidNumber:()=>H,isValidProbablitiy:()=>Pt,range:()=>U,round:()=>pt});var L=class{constructor(t,e){if(!H(t)||!H(e))throw new Error(`Dimensions.constructor - expected width and height to be valid numbers, instead have ${JSON.stringify({width:t,height:e})}`);this._width=t,this._height=e}get width(){return this._width}get height(){return this._height}reverse(){return new L(1/this.width,1/this.height)}};function mt(o,t){return o instanceof n.Tensor&&o.shape.length===t}function mo(o){return mt(o,1)}function De(o){return mt(o,2)}function Z(o){return mt(o,3)}function B(o){return mt(o,4)}function Ee(o){return o%1!=0}function se(o){return o%2==0}function pt(o,t=2){let e=10**t;return Math.floor(o*e)/e}function ie(o){return o&&o.width&&o.height}function Me({width:o,height:t},e){let r=e/Math.max(t,o);return new L(Math.round(o*r),Math.round(t*r))}function dt(o){return o.reduce((t,e)=>t.add(e),new x(0,0)).div(new x(o.length,o.length))}function U(o,t,e){return Array(o).fill(0).map((r,a)=>t+a*e)}function H(o){return!!o&&o!==Infinity&&o!==-Infinity&&!Number.isNaN(o)||o===0}function Pt(o){return H(o)&&o>=0&&o<=1}var x=class{constructor(t,e){this._x=t,this._y=e}get x(){return this._x}get y(){return this._y}add(t){return new x(this.x+t.x,this.y+t.y)}sub(t){return new x(this.x-t.x,this.y-t.y)}mul(t){return new x(this.x*t.x,this.y*t.y)}div(t){return new x(this.x/t.x,this.y/t.y)}abs(){return new x(Math.abs(this.x),Math.abs(this.y))}magnitude(){return Math.sqrt(this.x**2+this.y**2)}floor(){return new x(Math.floor(this.x),Math.floor(this.y))}};var w=class{static isRect(t){return!!t&&[t.x,t.y,t.width,t.height].every(H)}static assertIsValidBox(t,e,r=!1){if(!w.isRect(t))throw new Error(`${e} - invalid box: ${JSON.stringify(t)}, expected object with properties x, y, width, height`);if(!r&&(t.width<0||t.height<0))throw new Error(`${e} - width (${t.width}) and height (${t.height}) must be positive numbers`)}constructor(t,e=!0){let r=t||{},a=[r.left,r.top,r.right,r.bottom].every(H),s=[r.x,r.y,r.width,r.height].every(H);if(!s&&!a)throw new Error(`Box.constructor - expected box to be IBoundingBox | IRect, instead have ${JSON.stringify(r)}`);let[i,c,m,p]=s?[r.x,r.y,r.width,r.height]:[r.left,r.top,r.right-r.left,r.bottom-r.top];w.assertIsValidBox({x:i,y:c,width:m,height:p},"Box.constructor",e),this._x=i,this._y=c,this._width=m,this._height=p}get x(){return this._x}get y(){return this._y}get width(){return this._width}get height(){return this._height}get left(){return this.x}get top(){return this.y}get right(){return this.x+this.width}get bottom(){return this.y+this.height}get area(){return this.width*this.height}get topLeft(){return new x(this.left,this.top)}get topRight(){return new x(this.right,this.top)}get bottomLeft(){return new x(this.left,this.bottom)}get bottomRight(){return new x(this.right,this.bottom)}round(){let[t,e,r,a]=[this.x,this.y,this.width,this.height].map(s=>
//# sourceMappingURL=face-api.esm-nobundle.js.map