为什么我在 tensorflow.js posenet 的响应中将位置 x 和 y 都设置为 0?

Why do I get both positions x and y to be 0 in the response of tensorflow.js posenet?

posenet初始化

const net = await posenet.load();

const pose = await net.estimateSinglePose(videoElement, {
  flipHorizontal: false
});

输出

part: "leftEye"
position: {x: 0, y: 0}
score: 0.9931495785713196

我的问题是,即使分数很高,我总是在每个 body 部分获得位置 0,0。

我想出了解决办法。确保将宽度和高度添加到源元素(图像或视频)。请注意,如果您从 css 添加宽度和高度,它将不起作用,您需要以编程方式添加它。

 video = document.getElementById("video");

 //must add the following
 video.width = 500;
 video.height = 500;