将保存的运动与使用Kinect的其他运动进行比较 [英] Comparing a saved movement with other movement with Kinect

查看:74
本文介绍了将保存的运动与使用Kinect的其他运动进行比较的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要开发一个应用程序,其中用户(物理治疗师)将在Kinect前面执行动作,然后将数据动作写入数据库中,然后患者将尝试模仿该动作.系统将计算记录和执行的动作之间的相似度.

I need to develop an application where a user (physiotherapist) will perform a movement in front of the Kinect, I'll write the data movement in the database and then the patient will try to imitate this motion. The system will calculate the similarity between the movement recorded and executed.

我的第一个想法是在记录过程中(例如,每5秒)存储点的位置(x,y,z),然后在执行时间(按患者)进行比较.

My first idea is, during recording (each 5 second, by example), to store the position (x, y, z) of the points and then compare them in the execution time(by patient).

我知道这种方法太简单了,因为我认为在不同大小的人中骨骼的识别方式不同,因此比较是不可靠的.

I know that this approach is too simple, because I imagine that in people of different sizes the skeleton is recognized differently, so the comparison is not reliable.

我的问题是将保存的动作与执行的动作(进行中)进行比较的最佳方法.

My question is about the best way to compare a saved motion with a movement executed (on the fly).

推荐答案

我已经完成了此操作,其中将医生框架投影到患者框架上,但是由于骨骼高度不同,整个骨骼无法很好地工作:/.可以在此处找到该代码. 它处于beta 2代码中,尽管它是最新版本,但可以在此处找到.当前效果不佳

I have done this, where a doctors frame is projected onto the patients frame, but with the whole skeleton this doesn't work so well because of different bone heights :/. The code can be found here. It is in beta 2 code, the more current version can be found here, although it is not currently working perfectly

至于比较,做这样的事情

As for comparing, do something like this

for (int i = 0; i < patientList.Count; i++)
{
    int diff = (int)Math.Abs(patientList[i] - doctorList[i]);

    if (diff < 100) //or whatever number you want
    {
         Debug.WriteLine("Good Job");
    }
}

由于Fixus提到的骨骼高度,我放弃了整个图形的想法,所以我当前的程序看起来像这样:

I have abandoned the idea of a whole figure because of the bone heights mentioned by Fixus, so my current program looks some thing like:

编辑

这是使用kinect对两个运动进行露营的概念,并计算出我深入解释的两个运动之间的相似性.

假设我有以下两个点,A点(0、0、0)和B点(1、1、1).现在,我想找到从点A到B的差,所以我将所有X,Y和Z数相减,所以差为1 X 1 Y 1Z.这很简单.现在执行它.我上面编写的代码会像这样实现.

Suppose I have the following 2 points, point A (0, 0, 0) and point B (1, 1, 1). Now I want to find the difference from point A to B, so I would subtract all of the X, Y, and Z numbers, so the difference is 1 X 1 Y 1 Z. That is the simple stuff. Now to implement it. The code I have written above, I would implement like this.

//get patient hand coordinates
double patienthandX = Canvas.GetLeft(patienthand);
double patienthandY = Canvas.GetTop(patienthand);

//get doctor hand coordinates
double doctorhandX = Canvas.GetLeft(doctorhand);
double doctorhandY = Canvas.GetTop(doctorhand);

//compare difference for each x and y
//take Absolute value so that it is positive
double diffhandX = Math.Abs(patienthandX - doctorhandX);
double diffhandY = Math.Abs(patienthandY - doctorhandY);

现在是另一个问题.医生坐标始终是相同的,但是如果患者不站在记录医生坐标的地方怎么办?现在,我们实现更简单的数学运算.举这个简单的例子.假设我希望点A(8,2)移至点B(4,12).您将A的x和y乘以得到B.因此,我将X乘以.5,将Y乘以6.因此对于Kinect,我将一个元素放在患者臀部上,然后将其与医生的臀部进行比较.然后,将全部的医生关节数乘以该数字,以使医生关节位于患者之上(或多或少).例如

Now here comes another issue. The doctor coordinates are always the same, but what if the patient isn't standing where the doctor coordinates were recorded? Now we implement more simple math. Take this simple example. suppose I want point A(8, 2) to move to point B(4, 12). You multiply the x and y's of A to get to B. So I would multiply the X by .5, and the Y by 6. So for Kinect, I would put a element on the patients hip, then compare this to the doctors hip. Then multiply all of the doctor joints by that number to achieve the doctor joints on top of the patients (more or less). For example

double whatToMultiplyX = (double) doctorhipX / patienthipX;
double whatToMultiplyY = (double) doctorhipY / patienthipY;

这一切都非常简单,但是将其组合在一起则是更困难的部分.到目前为止,我们:1)在患者框架上方缩放医生框架,2)计算差异. 3)比较整个代表的差异.和4)重置为下一个代表.这似乎很简单,但事实并非如此.要计算销售代表的整体差异,请执行以下操作:

This is all pretty simple, but bringing it together is the harder part. So far we, 1) Scale the doctor frames on top of the patient frames, 2) Calculate the difference. 3) Compare the difference throughout the entire rep. and 4) Reset for the next rep. This seems simple but it is not. To calculate the entire difference for the rep, do something like this:

//get patient hand coordinates
double patienthandX = Canvas.GetLeft(patienthand);
double patienthandY = Canvas.GetTop(patienthand);

//get doctor hand coordinates
double doctorhandX = Canvas.GetLeft(doctorhand);
double doctorhandY = Canvas.GetTop(doctorhand);

//compare difference for each x and y
//take Absolute value so that it is positive
double diffhandX = Math.Abs(patienthandX - doctorhandX);
double diffhandY = Math.Abs(patienthandY - doctrorhandY);

//+= so that it keeps adding to it.
totaldiffhandX += diffhandX;
totaldiffhandY += diffhandY;

现在我们可以进行比较,并说:

Now we can compare, and say:

if (totaldiffhandX < 1000 && totaldiffhandY < 1000) //keep numbers pretty high since it is an entire rep
{
     //reset difference
     totaldiffhandX = 0;
     totaldiffhandY = 0;

     //tell the patient good job
     Debug.WriteLine("Good Job");
}

这很容易,但是请记住,必须对每个关节的x和y进行此操作.否则它将无法正常工作.希望对您有所帮助.

This is pretty easy, but keep in mind you must do this for every single joint's x and y. Otherwise it will not work. Hope this Helps.

这篇关于将保存的运动与使用Kinect的其他运动进行比较的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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