| @@ -19,12 +19,6 @@ export class ArFanCamPage implements OnInit { | |||||
| areNeuralNetsLoaded = false; | areNeuralNetsLoaded = false; | ||||
| isDetecting = false; | isDetecting = false; | ||||
| leftEyeX = 0; | |||||
| leftEyeY = 0; | |||||
| rightEyeX = 0; | |||||
| rightEyeY = 0; | |||||
| width = 360; | width = 360; | ||||
| height = 270; | height = 270; | ||||
| @@ -71,20 +65,14 @@ export class ArFanCamPage implements OnInit { | |||||
| const leftEye = detectionWithLandmarks.landmarks.getLeftEye(); | const leftEye = detectionWithLandmarks.landmarks.getLeftEye(); | ||||
| const rightEye = detectionWithLandmarks.landmarks.getRightEye(); | 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 = { | 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); | requestAnimationFrame(this.detectAndDrawFace); | ||||