From ad3dd30fa0f23045ade62c7c44f7cbfd3590cd87 Mon Sep 17 00:00:00 2001 From: ButzYung Date: Wed, 23 Dec 2020 00:33:11 +0800 Subject: [PATCH] Variable name changes, setting .rawCoords only if necessary --- src/face/facemesh.js | 10 +++++----- src/face/facepipeline.js | 4 ++-- src/human.js | 6 +++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/face/facemesh.js b/src/face/facemesh.js index 9fbce559..52a5a9f5 100644 --- a/src/face/facemesh.js +++ b/src/face/facemesh.js @@ -17,7 +17,7 @@ class MediaPipeFaceMesh { if (prediction.isDisposedInternal) continue; // guard against disposed tensors on long running operations such as pause in middle of processing const mesh = prediction.coords ? prediction.coords.arraySync() : null; // AT: mesh_raw - const mesh_raw = prediction.rawCoords; + const meshRaw = prediction.rawCoords; const annotations = {}; if (mesh && mesh.length > 0) { for (let key = 0; key < coords.MESH_ANNOTATIONS.length; key++) { @@ -27,7 +27,7 @@ class MediaPipeFaceMesh { } } // AT: raw version of box, the same as the TFJS Facemesh output version (.boundingBox) - const box_raw = (config.face.mesh.requestRawData && prediction.box) ? {topLeft: prediction.box.startPoint, bottomRight: prediction.box.endPoint} : null; + const boxRaw = (config.face.mesh.returnRawData && prediction.box) ? {topLeft: prediction.box.startPoint, bottomRight: prediction.box.endPoint} : null; const box = prediction.box ? [ Math.max(0, prediction.box.startPoint[0]), @@ -40,9 +40,9 @@ class MediaPipeFaceMesh { confidence: prediction.confidence || 0, box, mesh, -// AT: box_raw, mesh_raw - box_raw, - mesh_raw, +// AT: boxRaw, meshRaw + boxRaw, + meshRaw, annotations, image: prediction.image ? tf.clone(prediction.image) : null, }); diff --git a/src/face/facepipeline.js b/src/face/facepipeline.js index c26f3837..6deeb9bc 100644 --- a/src/face/facepipeline.js +++ b/src/face/facepipeline.js @@ -244,13 +244,13 @@ class Pipeline { const transformedCoords = tf.tensor2d(transformedCoordsData); const prediction = { coords: transformedCoords, -// AT: rawCoords - rawCoords: (config.face.mesh.requestRawData) ? rawCoords : null, box: landmarksBox, faceConfidence: confidenceVal, confidence: box.confidence, image: face, }; +// AT: rawCoords + if (config.face.mesh.returnRawData) prediction.rawCoords = rawCoords; // AT: preserve aspect ratio, pulled from Facemesh upstream this.storedBoxes[i] = { ...squarifiedLandmarksBox, landmarks: transformedCoords.arraySync(), confidence: box.confidence, faceConfidence: confidenceVal }; // this.storedBoxes[i] = { ...landmarksBox, landmarks: transformedCoords.arraySync(), confidence: box.confidence, faceConfidence: confidenceVal }; diff --git a/src/human.js b/src/human.js index d5d8b329..e3fc15d1 100644 --- a/src/human.js +++ b/src/human.js @@ -291,9 +291,9 @@ class Human { confidence: face.confidence, box: face.box, mesh: face.mesh, -// AT: box_raw, mesh_raw - box_raw: face.box_raw, - mesh_raw: face.mesh_raw, +// AT: boxRaw, meshRaw + boxRaw: face.boxRaw, + meshRaw: face.meshRaw, annotations: face.annotations, age: ageRes.age, gender: genderRes.gender,