我正在尝试开发一个可以用手移动光标的应用程序。我已经用手写了完整的代码和它的移动光标,但范围非常有限,当我向上移动我的手时,光标不会相应地移动。我已经抓取了手点,并使用以下代码设置了鼠标位置。
DepthImagePoint handPt;
Joint hand = skl.Joints[JointType.HandRight];
handPt = sensor.CoordinateMapper.MapSkeletonPointToDepthPoint(hand.Position, DepthImageFormat.Resolution640x480Fps30);
Mouse.setPosition(HandPt.X, handPt.Y)
请告诉我如何在肖像视图中正确移动鼠标
发布于 2014-11-10 21:07:16
我已经做到了,way..this正在为我工作
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);
发布于 2014-11-09 03:24:34
我认为你的问题可能是你没有将光标的位置映射到保持光标或屏幕分辨率的contairner上的等效位置。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)
其中width和height是容器/屏幕的宽度和高度。请让我知道这是否对你有效。
https://stackoverflow.com/questions/26814436
复制相似问题