关于KINECT的问题 [英] QUETION FOR KINECT
问题描述
大家好我已经为获得主手和更新光标位置制作了以下代码,但似乎我有一个错误,我无法纠正代码是这个
Hi everyone i had made the following code for Getting the Primary Hand and Updating the Cursor Position but it seems that i have an error that i can not correct the code is this
private static Joint GetPrimaryHand(Skeleton skeleton)
{
Joint primaryHand = new Joint();
if(skeleton!= null)
{
primaryHand = skeleton.Joints [JointType.HandLeft];
Joint righHand = skeleton.Joints [JointType.HandRight];
if(righHand.TrackingState!= JointTrackingState.NotTracked)
{
if(primaryHand.TrackingState) == JointTrackingState.NotTracked)
{
primaryHand = righHand;
}
其他¥ b $ b {
if(primaryHand.Position.Z> righHand.Position.Z)
{
primaryHand = righHand;
}
}
}
}
返回primaryHand;
}
private static Joint GetPrimaryHand(Skeleton skeleton)
{
Joint primaryHand = new Joint();
if(skeleton != null)
{
primaryHand = skeleton.Joints[JointType.HandLeft];
Joint righHand = skeleton.Joints[JointType.HandRight];
if(righHand.TrackingState != JointTrackingState.NotTracked)
{
if(primaryHand.TrackingState == JointTrackingState.NotTracked)
{
primaryHand = righHand;
}
else
{
if(primaryHand.Position.Z > righHand.Position.Z)
{
primaryHand = righHand;
}
}
}
}
return primaryHand;
}
private void TrackHand(Joint hand)
{
if(hand.TrackingState == JointTrackingState.NotTracked)
{
HandCursorElement.Visibility = System.Windows.Visibility.Collapsed;
}
$
其他
{
HandCursorElement.Visibility = System.Windows.Visibility.Visible ; $
浮动x;
浮动y;
DepthImagePoint point = this.KinectDevice.MapSkeletonPointToDepth(hand.Position,
DepthImageFormat.Resolution640x480Fps30);
$
point.X =(int)((point.X * LayoutRoot.ActualWidth /
this.KinectDevice.DepthStream.FrameWidth) - < br $>
(HandCursorElement.ActualWidth / 2.0));
$
point.Y =(int)((point.Y * LayoutRoot.ActualHeight)/
this.KinectDevice.DepthStream.FrameHeight) -
$
(HandCursorElement.ActualHeight / 2.0));
$
Canvas.SetLeft(HandCursorElement,x);
Canvas.SetTop(HandCursorElement,y);
$
if(hand.ID == JointType.HandRight)< -------- WRONG
private void TrackHand(Joint hand)
{
if(hand.TrackingState == JointTrackingState.NotTracked)
{
HandCursorElement.Visibility = System.Windows.Visibility.Collapsed;
}
else
{
HandCursorElement.Visibility = System.Windows.Visibility.Visible;
float x;
float y;
DepthImagePoint point = this.KinectDevice.MapSkeletonPointToDepth(hand.Position,
DepthImageFormat.Resolution640x480Fps30);
point.X = (int) ((point.X * LayoutRoot.ActualWidth /
this.KinectDevice.DepthStream.FrameWidth) -
(HandCursorElement.ActualWidth / 2.0));
point.Y = (int) ((point.Y * LayoutRoot.ActualHeight) /
this.KinectDevice.DepthStream.FrameHeight) -
(HandCursorElement.ActualHeight / 2.0));
Canvas.SetLeft(HandCursorElement, x);
Canvas.SetTop(HandCursorElement, y);
if(hand.ID == JointType.HandRight)<--------WRONG
{
HandCursorScale.Scal eX = 1;
}
其他
{
HandCursorScale.ScaleX = -1;
}
}
{
HandCursorScale.ScaleX = 1;
}
else
{
HandCursorScale.ScaleX = -1;
}
}
}
错误列表中的说明如下:'Microsoft.Kinect.Joint'不包含 的定义可以找到"ID"并且没有接受"Microsoft.Kinect.Joint"类型的第一个参数的扩展方法"ID"(您是否缺少使用指令
或汇编引用?) 有任何想法吗???所有代码都显示正常。
The description in the error list is the following : 'Microsoft.Kinect.Joint' does not contain a definition for 'ID' and no extension method 'ID' accepting a first argument of type 'Microsoft.Kinect.Joint' could be found (are you missing a using directive
or an assembly reference?) any ideas??? all code exept that seems to be fine.
推荐答案
首先确保您使用的是Kinect for windows SDk
First of all make sure that you are using the Kinect for windows SDk
更新行
if(hand.ID == JointType.HandRight)< -------- WRONG
if(hand.ID == JointType.HandRight)<--------WRONG
if( hand.JointType == JointType.HandRight)< -------- RIGHT
if(hand.JointType == JointType.HandRight)<--------RIGHT
这篇关于关于KINECT的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!