From b55e0ae9c810731a61c026d8722b6b746e34d0f0 Mon Sep 17 00:00:00 2001 From: Andrey Bronnikov Date: Fri, 1 Mar 2019 14:08:18 -0800 Subject: [PATCH] Fixing issue #222: FaceLandmarks68 left and right eyes/brows are reversed. --- src/classes/FaceLandmarks68.ts | 8 ++++---- test/tests/faceLandmarkNet/faceLandmark68Net.test.ts | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/classes/FaceLandmarks68.ts b/src/classes/FaceLandmarks68.ts index 1ae65e05..a503cc50 100644 --- a/src/classes/FaceLandmarks68.ts +++ b/src/classes/FaceLandmarks68.ts @@ -7,11 +7,11 @@ export class FaceLandmarks68 extends FaceLandmarks { return this.positions.slice(0, 17) } - public getLeftEyeBrow(): Point[] { + public getRightEyeBrow(): Point[] { return this.positions.slice(17, 22) } - public getRightEyeBrow(): Point[] { + public getLeftEyeBrow(): Point[] { return this.positions.slice(22, 27) } @@ -19,11 +19,11 @@ export class FaceLandmarks68 extends FaceLandmarks { return this.positions.slice(27, 36) } - public getLeftEye(): Point[] { + public getRightEye(): Point[] { return this.positions.slice(36, 42) } - public getRightEye(): Point[] { + public getLeftEye(): Point[] { return this.positions.slice(42, 48) } diff --git a/test/tests/faceLandmarkNet/faceLandmark68Net.test.ts b/test/tests/faceLandmarkNet/faceLandmark68Net.test.ts index 0804243a..f964b59d 100644 --- a/test/tests/faceLandmarkNet/faceLandmark68Net.test.ts +++ b/test/tests/faceLandmarkNet/faceLandmark68Net.test.ts @@ -60,6 +60,14 @@ describe('faceLandmark68Net', () => { const { x, y } = faceLandmarkPositionsRect[i] expectPointClose(pt, { x, y }, 6) }) + expect( + Math.max(...result.getRightEyeBrow().map(_=>_.x)) < + Math.min(...result.getLeftEyeBrow().map(_=>_.x)) + ).toBe(true); + expect( + Math.max(...result.getRightEye().map(_=>_.x)) < + Math.min(...result.getLeftEye().map(_=>_.x)) + ).toBe(true); }) })