2020-08-20 02:10:42 +02:00
|
|
|
import { FaceDetection } from '../classes/FaceDetection';
|
|
|
|
import { FaceLandmarks } from '../classes/FaceLandmarks';
|
|
|
|
import { isWithFaceDetection } from './WithFaceDetection';
|
|
|
|
export function isWithFaceLandmarks(obj) {
|
|
|
|
return isWithFaceDetection(obj)
|
|
|
|
&& obj['landmarks'] instanceof FaceLandmarks
|
|
|
|
&& obj['unshiftedLandmarks'] instanceof FaceLandmarks
|
|
|
|
&& obj['alignedRect'] instanceof FaceDetection;
|
2020-08-18 14:04:33 +02:00
|
|
|
}
|
2020-08-20 02:10:42 +02:00
|
|
|
export 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:10:42 +02:00
|
|
|
const alignedRect = new 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);
|
|
|
|
}
|
|
|
|
//# sourceMappingURL=WithFaceLandmarks.js.map
|