face-api/src/classes/FaceLandmarks68.ts

42 lines
924 B
TypeScript
Raw Normal View History

2020-12-19 17:46:41 +01:00
import { getCenterPoint } from '../utils/index';
2020-08-18 13:54:53 +02:00
import { FaceLandmarks } from './FaceLandmarks';
import { Point } from './Point';
export class FaceLandmarks68 extends FaceLandmarks {
public getJawOutline(): Point[] {
2020-12-23 17:26:55 +01:00
return this.positions.slice(0, 17);
2020-08-18 13:54:53 +02:00
}
public getLeftEyeBrow(): Point[] {
2020-12-23 17:26:55 +01:00
return this.positions.slice(17, 22);
2020-08-18 13:54:53 +02:00
}
public getRightEyeBrow(): Point[] {
2020-12-23 17:26:55 +01:00
return this.positions.slice(22, 27);
2020-08-18 13:54:53 +02:00
}
public getNose(): Point[] {
2020-12-23 17:26:55 +01:00
return this.positions.slice(27, 36);
2020-08-18 13:54:53 +02:00
}
public getLeftEye(): Point[] {
2020-12-23 17:26:55 +01:00
return this.positions.slice(36, 42);
2020-08-18 13:54:53 +02:00
}
public getRightEye(): Point[] {
2020-12-23 17:26:55 +01:00
return this.positions.slice(42, 48);
2020-08-18 13:54:53 +02:00
}
public getMouth(): Point[] {
2020-12-23 17:26:55 +01:00
return this.positions.slice(48, 68);
2020-08-18 13:54:53 +02:00
}
2021-09-08 19:51:28 +02:00
protected override getRefPointsForAlignment(): Point[] {
2020-08-18 13:54:53 +02:00
return [
this.getLeftEye(),
this.getRightEye(),
2020-12-23 17:26:55 +01:00
this.getMouth(),
].map(getCenterPoint);
2020-08-18 13:54:53 +02:00
}
2020-12-23 17:26:55 +01:00
}