From 957872e5a1e73cd93b2025e20c2eec64fa121a78 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Sun, 28 Mar 2021 08:49:56 -0400 Subject: [PATCH] minor rotation calculation fix --- CHANGELOG.md | 4 +++- src/faceall.ts | 12 +++--------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 346fc5d1..ac29b2d8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,8 +9,10 @@ Repository: **** ## Changelog -### **HEAD -> main** 2021/03/28 animethemegadget@gmail.com +### **HEAD -> main** 2021/03/28 mandic00@live.com +- new face rotation calculations +- cleanup - rotationmatrixtoeulerangle, and fixes - experimental: add efficientpose - implement nanodet diff --git a/src/faceall.ts b/src/faceall.ts index 8f16dd48..9e6ee675 100644 --- a/src/faceall.ts +++ b/src/faceall.ts @@ -39,24 +39,18 @@ const calculateFaceAngle = (face, image_size): { angle: { pitch: number, yaw: nu if (r10 < 1) { // YZX calculation if (r10 > -1) { thetaZ = Math.asin(r10); + thetaY = Math.atan2(-r20, r00); thetaX = Math.atan2(-r12, r11); } else { thetaZ = -Math.PI / 2; + thetaY = -Math.atan2(r21, r22); thetaX = 0; } } else { thetaZ = Math.PI / 2; + thetaY = Math.atan2(r21, r22); thetaX = 0; } - if (r02 < 1) { // compensate Y rotation which is not accurate and too small in YZX calculation - if (r02 > -1) { - thetaY = Math.asin(r02); - } else { - thetaY = -Math.PI / 2; - } - } else { - thetaY = Math.PI / 2; - } return { pitch: 2 * -thetaX, yaw: 2 * -thetaY, roll: 2 * -thetaZ }; }; // simple Euler angle calculation based existing 3D mesh