Переглянути джерело

Remove class level variables

master
Adwaith Rao 4 роки тому
джерело
коміт
cefd856c6a
1 змінених файлів з 5 додано та 17 видалено
  1. +5
    -17
      src/app/ar-fan-cam/ar-fan-cam.page.ts

+ 5
- 17
src/app/ar-fan-cam/ar-fan-cam.page.ts Переглянути файл

@@ -19,12 +19,6 @@ export class ArFanCamPage implements OnInit {
areNeuralNetsLoaded = false;
isDetecting = false;

leftEyeX = 0;
leftEyeY = 0;

rightEyeX = 0;
rightEyeY = 0;

width = 360;
height = 270;

@@ -71,20 +65,14 @@ export class ArFanCamPage implements OnInit {
const leftEye = detectionWithLandmarks.landmarks.getLeftEye();
const rightEye = detectionWithLandmarks.landmarks.getRightEye();

this.leftEyeX = leftEye[0].x;
this.leftEyeY = leftEye[0].y;

this.rightEyeX = rightEye[0].x;
this.rightEyeY = rightEye[0].y;

const distanceBetweenEyes = Math.sqrt(Math.pow(this.rightEyeX - this.leftEyeX, 2) + Math.pow(this.rightEyeY - this.leftEyeY, 2));
const angleOfRotation = (Math.atan2(this.rightEyeY - this.leftEyeY, this.rightEyeX - this.leftEyeX) * 180) / Math.PI;
const distanceBetweenEyes = Math.sqrt(Math.pow(rightEye[0].x - leftEye[0].x, 2) + Math.pow(rightEye[0].y - leftEye[0].y, 2));
const angleOfGlassesRotation = (Math.atan2(rightEye[0].y - leftEye[0].y, rightEye[0].x - leftEye[0].x) * 180) / Math.PI;

const scaleMultiplier = distanceBetweenEyes / 130;
const scaleGlassesMultiplier = distanceBetweenEyes / 130;

this.glassProperties = {
transform: `translate(calc(-14.5% + ${this.leftEyeX}px), calc(-45% + ${this.leftEyeY}px)) scale(${scaleMultiplier}) rotate(${angleOfRotation}deg)`,
}
transform: `translate(calc(-14.5% + ${leftEye[0].x}px), calc(-45% + ${leftEye[0].y}px)) scale(${scaleGlassesMultiplier}) rotate(${angleOfGlassesRotation}deg)`,
};
}

requestAnimationFrame(this.detectAndDrawFace);


Завантаження…
Відмінити
Зберегти