给定 3d 点数组,量化方向的变化
我正在开发一款用 Java 编写的软件,该软件使用一些processing.core 库类和 simpleopenni 来通过 XBOX Kinect 跟踪用户的手部。
我想弄清楚的是如何确定用户的手部运动何时突然改变方向。
我目前可以使用的是 PVector 数组(本质上是 x、y 和 z 坐标的向量:3d 空间中的点),用于记录过去 30 帧或的用户手部位置所以。
我想,在给定最近记录的几个点的情况下,必须有一种方法来获取代表几乎实时方向变化量的值。也许拟合一条曲线并采取一些导数?
理想情况下,该解决方案的计算成本不应非常昂贵,因为我正在尝试实现一个实时的有价值的解决方案。
您能提供的任何方向将不胜感激!
I am working on a piece of software written in Java that uses some processing.core library classes and simpleopenni to track a user's hand with the XBOX Kinect.
What I am trying to figure out is how to determine when a user's hand movement changes direction abruptly.
What I have at my disposal currently is an array of PVectors (essentially a vector of x,y,and z coordinates: A point in 3d space) that record the user's hand position for the past 30 frames or so.
I imagine that there must be a way to obtain a value that represents the amount of directional change in nearly real-time given the most recent few points recorded. Maybe fit a curve and take some derivatives?
Ideally the solution should not be very computationally expensive, as I am trying to implement a real-time worthy solution.
Any direction that you can offer will be greatly appreciated!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
设现在的位置(即 0 帧前)为
(x0, y0, z0)
令
n
帧前的位置为(xn, yn, zn)
。令
2n
帧前的位置为(xm, ym, zm)
。那么帧
2n
和n
之间的位置变化就是(xn-xm, yn-ym, zn-zm)
。您可以将其视为这
n
帧期间的平均速度。n
与现在之间的位置变化为(x0-xn, y0-yn, z0-zn)
。这表示接下来 n 帧期间的平均速度。
现在,您可以获得 n 帧之前结束的 n 帧的速度,以及刚刚结束的 n 帧的速度。
最后
n
帧期间速度的变化必须是这两个向量之间的差值。对于每个坐标:Ax = (x0-xn) - (xn-xm) = x0 -2xn + xm
Ay = (y0-yn) - (yn-ym) = y0 -2yn + ym
Az = (z0-xn) - (zn-zm) = z0 -2zn + zm
加速度的大小为
|A| = sqrt( (Ax)^2 + (Ay)^2 + (Az)^2 )
如果您只关心“大”的变化,并且更看重速度而不是准确性,则可以使用
A' = (Ax)^2 + (Ay)^2 + (Az)^2
A' = (Ax)^2 + (Ay)^2 + (Az)^2代码>甚至
A"=abs(Ax)+abs(Ay)+abs(Az)
这个想法是,你希望每个组件都对整体做出贡献,无论它是正数还是负数,所以你“通过平方或取其绝对值来强制”它为正。
希望有帮助!
Let the position now (that is, 0 frames ago) be
(x0, y0, z0)
Let the position
n
frames ago be(xn, yn, zn)
.Let the position
2n
frames ago be(xm, ym, zm)
.Then the change in position between frames
2n
andn
is(xn-xm, yn-ym, zn-zm)
.You can think of this as the average velocity during those
n
frames.And the change in position between
n
and now is(x0-xn, y0-yn, z0-zn)
.This represents the average velocity during the next
n
frames.Now you have the velocity for the
n
frames that endedn
frames ago, and you have the velocity for then
frames that just ended now.The change in velocity during the last
n
frames must be the difference between those two vectors. For each coordinate:Ax = (x0-xn) - (xn-xm) = x0 -2xn + xm
Ay = (y0-yn) - (yn-ym) = y0 -2yn + ym
Az = (z0-xn) - (zn-zm) = z0 -2zn + zm
The magnitude of the acceleration is
|A| = sqrt( (Ax)^2 + (Ay)^2 + (Az)^2 )
If you're concerned only with "large" changes and prefer speed over accuracy, you may be able to get away with
A' = (Ax)^2 + (Ay)^2 + (Az)^2
or even
A" = abs(Ax) + abs(Ay) + abs(Az)
The idea is that you want each component to contribute to the whole regardless of whether it's positive or negative, so you "force" it to be positive either by squaring it or taking its absolute value.
Hope that helps!
最简单的方法不是计算出向量差,即用一个减去另一个,并确定差异有多大足以判断其方向突然改变。
这在计算上是便宜的。
编辑:只是为了扩展一点,相似方向的两个向量具有接近零的向量差。方向相反的两个向量将有很大的向量差。
例如
(我知道这是二维的,但原理是相同的。)
Wouldn't the simplest way be to work out the vector difference i.e. subtract one from the other, and decide how big a difference is significant enough to judge it an abrupt change of direction.
That would be computationally inexpensive.
EDIT: just to expand on that a bit, 2 vectors of similar direction have a near-zero vector difference. Two vectors in opposing directions will have a large vector difference.
e.g.
(I know that's 2D but the principles are the same.)