这是来自我的主窗口:
foreach (Joint joint in skeleton.Joints)
{
if (joint.TrackingState != JointTrackingState.Tracked)
continue;
if ((joint.JointType == JointType.HandRight) || (joint.JointType == JointType.HandLeft))
{
swipeGestureRecognizer.Add(joint.Position, kinectSensor, joint.JointType);
}
}
我的手势是这样写的:
// Swipe to right
if (ScanPositions((p1, p2) => Math.Abs(p2.Y - p1.Y) < SwipeMaximalHeight, // Height
(p1, p2) => p2.X - p1.X > -0.05f, // Progression to right
(p1, p2) => Math.Abs(p2.X - p1.X) > SwipeMinimalLength, // Length
SwipeMininalDuration, SwipeMaximalDuration)) // Duration
{
if (jointul == JointType.HandLeft)
{
SetClothByGesture(1, 0);
RaiseGestureDetected("SwipeToRight");
}
return;
}
// Swipe to left
if (ScanPositions((p1, p2) => Math.Abs(p2.Y - p1.Y) < SwipeMaximalHeight, // Height
(p1, p2) => p2.X - p1.X < 0.05f, // Progression to right
(p1, p2) => Math.Abs(p2.X - p1.X) > SwipeMinimalLength, // Length
SwipeMininalDuration, SwipeMaximalDuration))// Duration
{
if (jointul == JointType.HandRight)
{
SetClothByGesture(-1, 0);
RaiseGestureDetected("SwipeToLeft");
}
return;
}
我的逻辑是,如果你用右手向左滑动,它会做一些事情,如果你用左手向右滑动,它会做其他事情。有谁知道我做错了什么?