我目前正在使用带有 Kinect 的可视化 python 来跟踪人右手的运动数据。使用我现在拥有的程序,一个人的身体被屏幕上显示的骨架跟踪。我正在寻找根据一个人在该区域更频繁地移动手的时间来绘制实时更新和增长的球体。基本上,这些球体将代表运动密度。不过,我没有运气让球体更新。任何/所有帮助将不胜感激,谢谢!
下面是我为球体提供的代码。我没有包含骨架代码,因为它工作正常。我一般是 VPython/编码的业余爱好者,所以它可能不是最有效或最有组织的代码
nbins = 2
bincount = 0
xpos = p2.x
ypos = p2.y
zpos = p2.z
xaxis = numpy.linspace(min(xpos), max(xpos), 2)
yaxis = numpy.linspace(min(ypos), max(ypos), 2)
zaxis = numpy.linspace(min(zpos), max(zpos), 2)
###initialize i,j,k???
for i in range(1, nbins):
for j in range(1, nbins):
for k in range(1, nbins):
findpoints = find(p2.x >= xaxis[i] & p2.x <= xaxis[i+1] & p2.y >= yaxis[j] & p2.y <= yaxis[j+1] & p2.z >= zaxis[k] & p2.z <= zaxis[k+1])
count = length(findpoints)
i = i+1
j = j+1
k = k+1
gridcount[i,j,k] = count
count = 0
total = sum(sum(sum(gridcount)))
gridP = gridcount/total
for i in irange(1, nbins):
xcenter = numpy.mean(xaxis[i],xaxis[i+1])
for j in jrange(1, nbins):
ycenter = numpy.mean(yaxis[j],yaxis[j+1])
for k in krange(1, nbins):
zcenter = numpy.mean(zaxis[k], zaxis[k+1])
r = gridP(i,j,k)
binsphere = sphere(radius = r, color = blue)
hold
axes3d.plot_surface(xcenter, ycenter, zcenter)