2020-08-20 02:05:34 +02:00
|
|
|
"use strict";
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
exports.extendWithFaceLandmarks = exports.isWithFaceLandmarks = void 0;
|
|
|
|
const FaceDetection_1 = require("../classes/FaceDetection");
|
|
|
|
const FaceLandmarks_1 = require("../classes/FaceLandmarks");
|
|
|
|
const WithFaceDetection_1 = require("./WithFaceDetection");
|
|
|
|
function isWithFaceLandmarks(obj) {
|
|
|
|
return WithFaceDetection_1.isWithFaceDetection(obj)
|
|
|
|
&& obj['landmarks'] instanceof FaceLandmarks_1.FaceLandmarks
|
|
|
|
&& obj['unshiftedLandmarks'] instanceof FaceLandmarks_1.FaceLandmarks
|
|
|
|
&& obj['alignedRect'] instanceof FaceDetection_1.FaceDetection;
|
2020-08-18 14:04:33 +02:00
|
|
|
}
|
2020-08-20 02:05:34 +02:00
|
|
|
exports.isWithFaceLandmarks = isWithFaceLandmarks;
|
|
|
|
function extendWithFaceLandmarks(sourceObj, unshiftedLandmarks) {
|
2020-08-18 14:04:33 +02:00
|
|
|
const { box: shift } = sourceObj.detection;
|
|
|
|
const landmarks = unshiftedLandmarks.shiftBy(shift.x, shift.y);
|
|
|
|
const rect = landmarks.align();
|
|
|
|
const { imageDims } = sourceObj.detection;
|
2020-08-20 02:05:34 +02:00
|
|
|
const alignedRect = new FaceDetection_1.FaceDetection(sourceObj.detection.score, rect.rescale(imageDims.reverse()), imageDims);
|
2020-08-18 14:04:33 +02:00
|
|
|
const extension = {
|
|
|
|
landmarks,
|
|
|
|
unshiftedLandmarks,
|
|
|
|
alignedRect
|
|
|
|
};
|
|
|
|
return Object.assign({}, sourceObj, extension);
|
|
|
|
}
|
2020-08-20 02:05:34 +02:00
|
|
|
exports.extendWithFaceLandmarks = extendWithFaceLandmarks;
|
2020-08-18 14:04:33 +02:00
|
|
|
//# sourceMappingURL=WithFaceLandmarks.js.map
|