如何在纵向视图中使用Kinect移动光标

本文关键字:Kinect 移动 光标 视图 | 更新日期: 2023-09-27 18:29:49

我正在尝试开发一个可以用手移动Cursor的应用程序。我已经用手写了完整的代码及其移动光标,但范围非常有限,当我向上移动手时,光标不会相应地移动。我已经抓住手点,并通过使用以下代码设置鼠标位置。

DepthImagePoint handPt;
Joint hand = skl.Joints[JointType.HandRight]; 
handPt = sensor.CoordinateMapper.MapSkeletonPointToDepthPoint(hand.Position, DepthImageFormat.Resolution640x480Fps30);
Mouse.setPosition(HandPt.X, handPt.Y)

请告诉我如何在纵向视图中正确移动鼠标

如何在纵向视图中使用Kinect移动光标

我已经这样做了。。这对我有用

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);

我认为您的问题可能是您没有将光标的位置映射到保持光标的控制器上的等效位置或屏幕分辨率。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是容器/屏幕的宽度和高度。请告诉我这对你是否有效。