Javascript 使用tensorflow.js和bodypix和posenet跟踪头部运动
我尝试使用Tensorflow.js、Posenet和BodyPix来跟踪我的头部运动,即x、y和z轴上的累积距离和加速度 这是正在使用的JSJavascript 使用tensorflow.js和bodypix和posenet跟踪头部运动,javascript,tensorflow,tensorflow.js,bodypix,Javascript,Tensorflow,Tensorflow.js,Bodypix,我尝试使用Tensorflow.js、Posenet和BodyPix来跟踪我的头部运动,即x、y和z轴上的累积距离和加速度 这是正在使用的JS // Use the bodyPix draw API's function draw(personSegmentation) { if (showMaskToggle.checked) { let targetSegmentation = personSegmentation; // Draw a mas
// Use the bodyPix draw API's
function draw(personSegmentation) {
if (showMaskToggle.checked) {
let targetSegmentation = personSegmentation;
// Draw a mask of the body segments - useful for debugging
// Just show the face and hand parts
targetSegmentation.data = personSegmentation.data.map(val => {
if (val !== 0 && val !== 1 && val !== 10 && val !== 11)
return -1;
else
return val;
});
const coloredPartImage = bodyPix.toColoredPartMask(targetSegmentation);
const opacity = 0.7;
const maskBlurAmount = 0;
bodyPix.drawMask(
drawCanvas, sourceVideo, coloredPartImage, opacity, maskBlurAmount,
flipHorizontal);
}
// drawMask clears the canvas, drawKeypoints doesn't
if (showMaskToggle.checked === false) {
// bodyPix.drawMask redraws the canvas. Clear with not
drawCtx.clearRect(0, 0, drawCanvas.width, drawCanvas.height);
}
// Show dots from pose detection
if (showPointsToggle.checked) {
personSegmentation.allPoses.forEach(pose => {
if (flipHorizontal) {
pose = bodyPix.flipPoseHorizontal(pose, personSegmentation.width);
}
drawKeypoints(pose.keypoints, 0.9, drawCtx);
});
}
}
// Draw dots
function drawKeypoints(keypoints, minConfidence, ctx, color = 'aqua') {
for (let i = 0; i < keypoints.length; i++) {
const keypoint = keypoints[i];
if (keypoint.score < minConfidence) {
continue;
}
const {y, x} = keypoint.position;
ctx.beginPath();
ctx.arc(x, y, 4, 0, 2 * Math.PI);
ctx.fillStyle = color;
ctx.fill();
}
}
我应该从哪里开始,从哪里开始对这些位置进行累积测量,开始观察总距离、加速度和移动的运动距离,仅仅是头部本身
提前感谢,
[
{
pose: {
keypoints: [{position:{x,y}, score, part}, ...],
leftAngle:{x, y, confidence},
leftEar:{x, y, confidence},
leftElbow:{x, y, confidence},
...
}
},
{
pose: {
keypoints: [{position:{x,y}, score, part}, ...],
leftAngle:{x, y, confidence},
leftEar:{x, y, confidence},
leftElbow:{x, y, confidence},
...
}
}
]