mirror of https://github.com/vladmandic/human
edit blazepose keypoints
parent
ff8f5968fb
commit
c8f85ead30
|
@ -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",
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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'],
|
||||||
};
|
};
|
||||||
|
|
|
@ -353,6 +353,7 @@ export async function body(inCanvas: AnyCanvas, result: Array<BodyResult>, drawO
|
||||||
}
|
}
|
||||||
if (localOptions.drawPoints && result[i].keypoints) {
|
if (localOptions.drawPoints && result[i].keypoints) {
|
||||||
for (let pt = 0; pt < result[i].keypoints.length; pt++) {
|
for (let pt = 0; pt < result[i].keypoints.length; pt++) {
|
||||||
|
if (!result[i].keypoints[pt].score || (result[i].keypoints[pt].score === 0)) continue;
|
||||||
ctx.fillStyle = localOptions.useDepth && result[i].keypoints[pt].position[2] ? `rgba(${127.5 + (2 * (result[i].keypoints[pt].position[2] || 0))}, ${127.5 - (2 * (result[i].keypoints[pt].position[2] || 0))}, 255, 0.5)` : localOptions.color;
|
ctx.fillStyle = localOptions.useDepth && result[i].keypoints[pt].position[2] ? `rgba(${127.5 + (2 * (result[i].keypoints[pt].position[2] || 0))}, ${127.5 - (2 * (result[i].keypoints[pt].position[2] || 0))}, 255, 0.5)` : localOptions.color;
|
||||||
point(ctx, result[i].keypoints[pt].position[0], result[i].keypoints[pt].position[1], 0, localOptions);
|
point(ctx, result[i].keypoints[pt].position[0], result[i].keypoints[pt].position[1], 0, localOptions);
|
||||||
}
|
}
|
||||||
|
@ -360,6 +361,7 @@ export async function body(inCanvas: AnyCanvas, result: Array<BodyResult>, drawO
|
||||||
if (localOptions.drawLabels && result[i].keypoints) {
|
if (localOptions.drawLabels && result[i].keypoints) {
|
||||||
ctx.font = localOptions.font;
|
ctx.font = localOptions.font;
|
||||||
for (const pt of result[i].keypoints) {
|
for (const pt of result[i].keypoints) {
|
||||||
|
if (!pt.score || (pt.score === 0)) continue;
|
||||||
ctx.fillStyle = localOptions.useDepth && pt.position[2] ? `rgba(${127.5 + (2 * pt.position[2])}, ${127.5 - (2 * pt.position[2])}, 255, 0.5)` : localOptions.color;
|
ctx.fillStyle = localOptions.useDepth && pt.position[2] ? `rgba(${127.5 + (2 * pt.position[2])}, ${127.5 - (2 * pt.position[2])}, 255, 0.5)` : localOptions.color;
|
||||||
ctx.fillText(`${pt.part} ${Math.trunc(100 * pt.score)}%`, pt.position[0] + 4, pt.position[1] + 4);
|
ctx.fillText(`${pt.part} ${Math.trunc(100 * pt.score)}%`, pt.position[0] + 4, pt.position[1] + 4);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue