我正在尝试开发一个用我的手移动Cursor的应用程序。我用我的手写了完整的代码及其移动光标,但范围非常有限,当我向上移动手时,光标不会相应移动。我已经抓住了手点并使用以下代码设置了鼠标位置。
DepthImagePoint handPt;
Joint hand = skl.Joints[JointType.HandRight];
handPt = sensor.CoordinateMapper.MapSkeletonPointToDepthPoint(hand.Position, DepthImageFormat.Resolution640x480Fps30);
Mouse.setPosition(HandPt.X, handPt.Y)
请告诉我如何在纵向视图中正确移动鼠标
答案 0 :(得分:2)
我这样做了..这对我有用
Joint hand = skl.Joints[JointType.HandRight];
CameraSpacePoint position = hand.Position;
DepthSpacePoint handPt = sensor.CoordinateMapper.MapCameraPointToDepthSpace(position);
Point relativePoint = new Point(handPt.X * (1280 / sensor.DepthFrameSource.FrameDescription.Width), handPt.Y * (720 / sensor.DepthFrameSource.FrameDescription.Height));
Mouse.setPosition(relativePoint.X, relativePoint.Y);
答案 1 :(得分:1)
我认为你的问题可能是你没有将光标的位置映射到与光标或屏幕分辨率相关的容器上的等效位置。 Kinect的图像通常分辨率为640x480px,而你的屏幕显然要大得多。我已将该行添加到您的代码中:
DepthImagePoint handPt;
Joint hand = skl.Joints[JointType.HandRight];
handPt = sensor.CoordinateMapper.MapSkeletonPointToDepthPoint(hand.Position, DepthImageFormat.Resolution640x480Fps30);
Point mappedPoint = new Point(handPt.X * (width / sensor.DepthStream.FrameWidth), handPt.Y * (height / sensor.DepthStream.FrameHeight));
Mouse.setPosition(mappedPoint.X, mappedPoint.Y)
其中宽度和高度是容器/屏幕的宽度和高度。 如果这对您有用,请告诉我。