Commit 77e5cbf5 by vincent

put typescript build into build folder and bundled script into dist

parent ccdd16ec
import { FaceLandmarks } from './faceLandmarkNet/FaceLandmarks';
import { Rect } from './Rect';
/**
* Aligns the face landmarks after face detection from the relative positions of the faces
* bounding box, or it's current shift. This function should be used to align the face images
* after face detection has been performed, before they are passed to the face recognition net.
* This will make the computed face descriptor more accurate.
*
* @param detection (optional) The bounding box of the face or the face detection result. If
* no argument was passed the position of the face landmarks are assumed to be relative to
* it's current shift.
* @returns The bounding box of the aligned face.
*/
export declare function alignFace(faceLandmarks: FaceLandmarks, detection?: Rect): Rect;
import { getCenterPoint } from './commons/getCenterPoint';
import { FaceDetection } from './faceDetectionNet/FaceDetection';
import { Rect } from './Rect';
var relX = 0.5;
var relY = 0.43;
var relScale = 0.45;
/**
* Aligns the face landmarks after face detection from the relative positions of the faces
* bounding box, or it's current shift. This function should be used to align the face images
* after face detection has been performed, before they are passed to the face recognition net.
* This will make the computed face descriptor more accurate.
*
* @param detection (optional) The bounding box of the face or the face detection result. If
* no argument was passed the position of the face landmarks are assumed to be relative to
* it's current shift.
* @returns The bounding box of the aligned face.
*/
export function alignFace(faceLandmarks, detection) {
if (detection) {
var box = detection instanceof FaceDetection
? detection.getBox().floor()
: detection;
return alignFace(faceLandmarks.shift(box.x, box.y));
}
var centers = [
faceLandmarks.getLeftEye(),
faceLandmarks.getRightEye(),
faceLandmarks.getMouth()
].map(getCenterPoint);
var leftEyeCenter = centers[0], rightEyeCenter = centers[1], mouthCenter = centers[2];
var distToMouth = function (pt) { return mouthCenter.sub(pt).magnitude(); };
var eyeToMouthDist = (distToMouth(leftEyeCenter) + distToMouth(rightEyeCenter)) / 2;
var size = Math.floor(eyeToMouthDist / relScale);
var refPoint = getCenterPoint(centers);
// TODO: pad in case rectangle is out of image bounds
var x = Math.floor(Math.max(0, refPoint.x - (relX * size)));
var y = Math.floor(Math.max(0, refPoint.y - (relY * size)));
return new Rect(x, y, size, size);
}
//# sourceMappingURL=alignFace.js.map
\ No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AO,CAAC,CAAA;IACxC,qDAAqD;IACrD,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IAC7D,IAAM,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,CAAA;IAE7D,OAAO,IAAI,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;AACnC,CAAC"}
\ No newline at end of file
import * as tf from '@tensorflow/tfjs-core';
export declare function imageTensorToCanvas(imgTensor: tf.Tensor4D, canvas?: HTMLCanvasElement): Promise<HTMLCanvasElement>;
import * as tslib_1 from "tslib";
import * as tf from '@tensorflow/tfjs-core';
export function imageTensorToCanvas(imgTensor, canvas) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var targetCanvas, _a, _, height, width, numChannels;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
targetCanvas = canvas || document.createElement('canvas');
_a = imgTensor.shape, _ = _a[0], height = _a[1], width = _a[2], numChannels = _a[3];
return [4 /*yield*/, tf.toPixels(imgTensor.as3D(height, width, numChannels).toInt(), targetCanvas)];
case 1:
_b.sent();
return [2 /*return*/, targetCanvas];
}
});
});
}
//# sourceMappingURL=imageTensorToCanvas.js.map
\ No newline at end of file
{"version":3,"file":"imageTensorToCanvas.js","sourceRoot":"","sources":["../src/imageTensorToCanvas.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,MAAM,uBAAuB,CAAC;AAK5C,MAAM,8BACJ,SAAsB,EACtB,MAA0B;;;;;;oBAEpB,YAAY,GAAG,MAAM,IAAK,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;oBAE1D,KAAkC,SAAS,CAAC,KAAK,EAAhD,CAAC,QAAA,EAAE,MAAM,QAAA,EAAE,KAAK,QAAA,EAAE,WAAW,QAAA,CAAmB;oBACvD,qBAAM,EAAE,CAAC,QAAQ,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,WAAW,CAAC,CAAC,KAAK,EAAE,EAAE,YAAY,CAAC,EAAA;;oBAAnF,SAAmF,CAAA;oBAEnF,sBAAO,YAAY,EAAA;;;;CACpB"}
\ No newline at end of file
......@@ -2,8 +2,8 @@
"name": "face-api.js",
"version": "0.3.0",
"description": "JavaScript API for face detection and face recognition in the browser with tensorflow.js",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"main": "./build/index.js",
"typings": "./build/index.d.ts",
"scripts": {
"rollup-min": "rollup -c rollup.config.js --environment minify:true",
"rollup": "rollup -c rollup.config.js",
......
......@@ -12,7 +12,8 @@ export default {
typescript({
tsconfigOverride: {
compilerOptions: {
module: 'ES2015'
module: 'ES2015',
declaration: false
}
}
}),
......
......@@ -21,7 +21,7 @@
"module": "commonjs",
"moduleResolution": "node",
"target": "es5",
"outDir": "dist",
"outDir": "build",
"baseUrl": ".",
"lib": ["es2015", "dom"],
"typeRoots": [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment