From 9fd7ea723e4e4f9067b453fbb7cd76ff7c5d85d1 Mon Sep 17 00:00:00 2001 From: Vladimir Mandic Date: Fri, 19 Nov 2021 16:11:03 -0500 Subject: [PATCH] edit blazepose keypoints --- package.json | 2 +- src/body/blazepose.ts | 3 ++- src/body/blazeposecoords.ts | 24 +++++++++++++----------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index b11bea96..6330c370 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "@tensorflow/tfjs-layers": "^3.11.0", "@tensorflow/tfjs-node": "^3.11.0", "@tensorflow/tfjs-node-gpu": "^3.11.0", - "@types/node": "^16.11.7", + "@types/node": "^16.11.9", "@types/offscreencanvas": "^2019.6.4", "@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/parser": "^5.4.0", diff --git a/src/body/blazepose.ts b/src/body/blazepose.ts index 0e0da2c5..e0ac35ac 100644 --- a/src/body/blazepose.ts +++ b/src/body/blazepose.ts @@ -127,7 +127,8 @@ async function detectParts(input: Tensor, config: Config, outputSize: [number, n for (let i = 0; i < indexes.length - 1; i++) { const pt0 = keypoints.find((kpt) => kpt.part === indexes[i]); const pt1 = keypoints.find((kpt) => kpt.part === indexes[i + 1]); - if (pt0 && pt1 && pt0.score > (config.body.minConfidence || 0) && pt1.score > (config.body.minConfidence || 0)) pt.push([pt0.position, pt1.position]); + // if (pt0 && pt1 && pt0.score > (config.body.minConfidence || 0) && pt1.score > (config.body.minConfidence || 0)) pt.push([pt0.position, pt1.position]); + if (pt0 && pt1) pt.push([pt0.position, pt1.position]); } annotations[name] = pt; } diff --git a/src/body/blazeposecoords.ts b/src/body/blazeposecoords.ts index 428ffde9..4699ad0e 100644 --- a/src/body/blazeposecoords.ts +++ b/src/body/blazeposecoords.ts @@ -18,12 +18,12 @@ export const kpt: Array = [ 'rightElbow', // 14 'leftWrist', // 15 'rightWrist', // 16 - 'leftPalm', // 17 - 'rightPalm', // 18 + 'leftPinky', // 17 + 'rightPinky', // 18 'leftIndex', // 19 'rightIndex', // 20 - 'leftPinky', // 21 - 'rightPinky', // 22 + 'leftThumb', // 21 + 'rightThumb', // 22 'leftHip', // 23 'rightHip', // 24 'leftKnee', // 25 @@ -36,10 +36,10 @@ export const kpt: Array = [ 'rightFoot', // 32 'bodyCenter', // 33 'bodyTop', // 34 - 'leftThumb', // 35 - 'leftHand', // 36 - 'rightThumb', // 37 - 'rightHand', // 38 + 'leftPalm', // 35 // z-coord not ok + 'leftHand', // 36 // similar to wrist but z-coord not ok + 'rightPalm', // 37 // z-coord not ok + 'rightHand', // 38 // similar to wrist but z-coord not ok ]; export const connected: Record = { @@ -48,7 +48,9 @@ export const connected: Record = { torso: ['leftShoulder', 'rightShoulder', 'rightHip', 'leftHip', 'leftShoulder'], leftArm: ['leftShoulder', 'leftElbow', 'leftWrist', 'leftPalm'], rightArm: ['rightShoulder', 'rightElbow', 'rightWrist', 'rightPalm'], - leftHand: [], - rightHand: [], - head: [], + leftHand: ['leftHand', 'leftPalm', 'leftPinky', 'leftPalm', 'leftIndex', 'leftPalm', 'leftThumb'], + rightHand: ['rightHand', 'rightPalm', 'rightPinky', 'rightPalm', 'rightIndex', 'rightPalm', 'rightThumb'], + leftEye: ['leftEyeInside', 'leftEye', 'leftEyeOutside'], + rightEye: ['rightEyeInside', 'rightEye', 'rightEyeOutside'], + mouth: ['leftMouth', 'rightMouth'], };