商店定位到一个数组 - 和比较 [英] Store orientation to an array - and compare

查看:157
本文介绍了商店定位到一个数组 - 和比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要实现以下目标:

我希望用户能够记录的iPhone使用的陀螺仪的运动。在这之后,用户应能复制相同的运动。我解压俯仰,滚转和偏航使用:

I want the user to be able to "record" the movement of the iPhone using the gyroscope. And after that, the user should be able to replicate the same movement. I extract the pitch, roll and yaw using:

 [self.motionManager startDeviceMotionUpdatesToQueue:[NSOperationQueue currentQueue]
                                       withHandler: ^(CMDeviceMotion *motion, NSError *error)
     {
         CMAttitude *attitude = motion.attitude;
         NSLog(@"pitch: %f, roll: %f, yaw: %f]", attitude.pitch, attitude.roll, attitude.yaw);
     }];

我在想,我能这些值存储到一个数组,如果用户在录制模式。并且当用户试图复制动作,我可以在复制运动阵列比较所记录的之一。 的事情是,我怎么能在两个数组比较聪明的方式?他们将永远不会有完全相同的值,但可能有些是相同的。

I'm thinking that I could store these values into an array, if the user is in record mode. And when the user tries to replicate that movement, I'm could compare the replicated movement array to the recorded one. The thing is, how can I compare the two arrays in a smart way? They will never have exactly the same values, but they can be somewhat the same.

我是在所有正确的轨道上吗?

Am I at all on the right track here?

更新:我觉得关于使用DTW可能是正确的方法,我在这里也许阿里的答案。但我没那么聪明(明显),因此,如果有人可以帮助我走出的第一步用比较数组我会是一个快乐的人!

UPDATE: I think that maybe Alis answer about using DTW could be the right way for me here. But I'm not that smart (apparently), so if anyone could help me out with the first steps with comparing to arrays I would be a happy man!

谢谢!

推荐答案

尝试动态时间规整。下面是一个说明性示例用1D阵列。在数据库中,我们已经有以下2个数组:

Try dynamic time warping. Here is an illustrative example with 1D arrays. In the database we already have the following 2 arrays:

阵列1: [5,3,1]
阵列2: [1,3,5,8,8]

Array 1: [5, 3, 1]
Array 2: [1, 3, 5, 8, 8]

我们测量 [2,4,6,7] 。其中阵列的最相似的新测量?显然,第二阵列是类似于新近测定和第一不是

We measured [2, 4, 6, 7]. Which array is the most similar to the newly measured? Obviously, the second array is similar to the newly measured and the first is not.

让根据本文款2.1 的计算成本矩阵:

Let's compute the cost matrices according to this paper, subsection 2.1:

D(i,j)=Dist(i,j)+MIN(D(i-1,j),D(i,j-1),D(i-1,j-1))

下面 D(I,J)(I,J)的成本矩阵的元素,见下面。检查纸图3看到这种递推关系的应用。简而言之:列首先计算,启动 D(1,1); D(0,*) D(*,0)将在MIN冷落。如果我们是在比较数组 A B 然后 DIST(I,J) A [1] B [J] 之间的距离。我只是用 ABS(A [1] -B [J]。)。此示例的成本矩阵:

Here D(i,j) is the (i,j) element of the cost matrix, see below. Check Figure 3 of that paper to see this recurrence relation is applied. In short: columns are computed first, starting from D(1,1); D(0,*) and D(*,0) are left out in the MIN. If we are comparing arrays A and B then Dist(i,j) is the distance between A[i] and B[j]. I simply used ABS(A[i]-B[j]). The cost matrices for this example:

有关阵列1,我们有13的成绩,为阵列2,我们有5较低的分数获胜,所以最相似的阵列阵列2。最好的扭曲路径被标记为灰色。

For Array 1 we have 13 as score, for Array 2 we have 5. The lower score wins, so the most similar array is Array 2. The best warping path is marked gray.

这是大田的只是一个草图。有一些你在现实世界的应用程序来解决问题。例如使用偏移,而不是固定的结束点,或拟合界定措施:见<一href="http://www.mendeley.com/research/using-dynamic-time-warping-to-find-patterns-in-time-series/">this纸,页363,5边界条件和364页上面的链接的论文有进一步的细节了。

This is only a sketch of DTW. There are a number of issues you have to address in a real-world application. For example using offset instead of fixed ending points, or defining measures of fit: see this paper, page 363, 5. boundary conditions and page 364. The above linked paper has further details too.

我使用的是偏航,俯仰和滚转注意到简单地说:不要和<一href="http://stackoverflow.com/questions/5580283/interpolating-between-rotation-matrices/5580491#5580491">another理由不的。您可以使用加速计数据呢? 加速度计是直接测量方向(从 DCM稿件),这是什么你需要。而对于TC的问题,也相对于北方的方向有关系吗?我不这样想。

I just noticed you are using yaw, pitch and roll. Simply put: don't and another reason not to. Can you use the accelerometer data instead? "An accelerometer is a direct measurement of orientation" (from the DCM manuscript) and that is what you need. And as for tc's question, does the orientation relative to North matter? I guess not.

这是更容易比较比方向的加速度矢量(欧拉角,旋转矩阵,四元数)为TC指出了这一点。如果使用的加速​​度数据,则必须在每个时间点3维向量,第(x,Y,Z)坐标。我想简单地计算出

It is far easier to compare the acceleration vectors than orientations (Euler angles, rotation matrices, quaternions) as tc pointed that out. If you are using acceleration data, you have 3 dimensional vectors at each time point, the (x,y,z) coordinates. I would simply compute

DIST(I,J)= SQRT((A [1] [X] -B [J] [X])^ 2 +(A [I] [Y] -B [J ] [Y])^ 2 +(A [1] [Z] -B [J] [Z])^ 2)

这是在两个点之间的 Eucledian距离

这篇关于商店定位到一个数组 - 和比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆