edit blazepose keypoints

pull/356/head
Vladimir Mandic 2021-11-19 16:11:03 -05:00
parent c3a5e1f802
commit 9fd7ea723e
3 changed files with 16 additions and 13 deletions

View File

@ -65,7 +65,7 @@
"@tensorflow/tfjs-layers": "^3.11.0", "@tensorflow/tfjs-layers": "^3.11.0",
"@tensorflow/tfjs-node": "^3.11.0", "@tensorflow/tfjs-node": "^3.11.0",
"@tensorflow/tfjs-node-gpu": "^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", "@types/offscreencanvas": "^2019.6.4",
"@typescript-eslint/eslint-plugin": "^5.4.0", "@typescript-eslint/eslint-plugin": "^5.4.0",
"@typescript-eslint/parser": "^5.4.0", "@typescript-eslint/parser": "^5.4.0",

View File

@ -127,7 +127,8 @@ async function detectParts(input: Tensor, config: Config, outputSize: [number, n
for (let i = 0; i < indexes.length - 1; i++) { for (let i = 0; i < indexes.length - 1; i++) {
const pt0 = keypoints.find((kpt) => kpt.part === indexes[i]); const pt0 = keypoints.find((kpt) => kpt.part === indexes[i]);
const pt1 = keypoints.find((kpt) => kpt.part === indexes[i + 1]); 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; annotations[name] = pt;
} }

View File

@ -18,12 +18,12 @@ export const kpt: Array<string> = [
'rightElbow', // 14 'rightElbow', // 14
'leftWrist', // 15 'leftWrist', // 15
'rightWrist', // 16 'rightWrist', // 16
'leftPalm', // 17 'leftPinky', // 17
'rightPalm', // 18 'rightPinky', // 18
'leftIndex', // 19 'leftIndex', // 19
'rightIndex', // 20 'rightIndex', // 20
'leftPinky', // 21 'leftThumb', // 21
'rightPinky', // 22 'rightThumb', // 22
'leftHip', // 23 'leftHip', // 23
'rightHip', // 24 'rightHip', // 24
'leftKnee', // 25 'leftKnee', // 25
@ -36,10 +36,10 @@ export const kpt: Array<string> = [
'rightFoot', // 32 'rightFoot', // 32
'bodyCenter', // 33 'bodyCenter', // 33
'bodyTop', // 34 'bodyTop', // 34
'leftThumb', // 35 'leftPalm', // 35 // z-coord not ok
'leftHand', // 36 'leftHand', // 36 // similar to wrist but z-coord not ok
'rightThumb', // 37 'rightPalm', // 37 // z-coord not ok
'rightHand', // 38 'rightHand', // 38 // similar to wrist but z-coord not ok
]; ];
export const connected: Record<string, string[]> = { export const connected: Record<string, string[]> = {
@ -48,7 +48,9 @@ export const connected: Record<string, string[]> = {
torso: ['leftShoulder', 'rightShoulder', 'rightHip', 'leftHip', 'leftShoulder'], torso: ['leftShoulder', 'rightShoulder', 'rightHip', 'leftHip', 'leftShoulder'],
leftArm: ['leftShoulder', 'leftElbow', 'leftWrist', 'leftPalm'], leftArm: ['leftShoulder', 'leftElbow', 'leftWrist', 'leftPalm'],
rightArm: ['rightShoulder', 'rightElbow', 'rightWrist', 'rightPalm'], rightArm: ['rightShoulder', 'rightElbow', 'rightWrist', 'rightPalm'],
leftHand: [], leftHand: ['leftHand', 'leftPalm', 'leftPinky', 'leftPalm', 'leftIndex', 'leftPalm', 'leftThumb'],
rightHand: [], rightHand: ['rightHand', 'rightPalm', 'rightPinky', 'rightPalm', 'rightIndex', 'rightPalm', 'rightThumb'],
head: [], leftEye: ['leftEyeInside', 'leftEye', 'leftEyeOutside'],
rightEye: ['rightEyeInside', 'rightEye', 'rightEyeOutside'],
mouth: ['leftMouth', 'rightMouth'],
}; };