使用“控制基础知识”用于Windows鼠标光标控制的示例(或备选方案) [英] Use "Controls Basics" example (or alternatives) for Windows mouse cursor control

查看:26
本文介绍了使用“控制基础知识”用于Windows鼠标光标控制的示例(或备选方案)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我正在尝试通过Kinect手部跟踪更改Windows鼠标光标位置。因此,我使用了"BodyBasics"。示例并更改了"Reader_FrameArrived"中的一些代码。事件:

I am trying to change the Windows mouse cursor position via Kinect Hand Tracking. Therefore I used the "BodyBasics" example and changed some code in the "Reader_FrameArrived" event:

if (body.IsTracked) { Joint handRight = body.Joints[JointType.HandRight]; // sometimes the depth(Z) of an inferred joint may show as negative // clamp down to 0.1f to prevent coordinatemapper from returning (-Infinity, -Infinity) CameraSpacePoint position = handRight.Position; /* if (position.Z < 0) { position.Z = InferredZPositionClamp; }*/ position.Z = 1; // Coordinate Mapping //DepthSpacePoint colorSpacePoint = this.coordinateMapper.MapCameraPointToDepthSpace(position); ColorSpacePoint colorSpacePoint = this.coordinateMapper.MapCameraPointToColorSpace(position); // Set Mouse int x = Convert.ToInt32(colorSpacePoint.X); /* if (colorSpacePoint.X >= 360.0) { x = Convert.ToInt32(colorSpacePoint.X * (1920 / 512)); } else { x = Convert.ToInt32(1920 - (colorSpacePoint.X * (1920 / 512))); }*/ // = Convert.ToInt32(colorSpacePoint.X * (1920 / 320)); // Console.WriteLine(colorSpacePoint.X); int y = Convert.ToInt32(colorSpacePoint.Y); Console.WriteLine(x); Console.WriteLine(y); setMousePosition(x, y); }

public void setMousePosition(int x,int y)
        {
&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP;&NBSP; SetCursorPos(x,y);
        }

public void setMousePosition(int x, int y)
        {
            SetCursorPos(x, y);
        }


这里的映射是个问题,特别是因为看起来手的z坐标会改变x和y坐标。这就是我将其设置为1的原因。此外,我正在使用ColorSpacePoint。它工作正常,但我真的不想向左或向右移动
到达屏幕的顶角。所以我认为我需要一个倍增因子。



The mapping is the problem here, especially because it seems that the z-coordinate of your hand will change the x and y coordinates. That´s why I set it to 1. Also I am working with an ColorSpacePoint. It´s working ok, but I don´t really want to move to the left or right to get to the top corner of the screen. So I think I need a multiplication factor.


此外,我查看了"控制基础知识"。例。 HandPointer工作得非常好,但我找不到屏幕映射的数学,我认为它只适用于WPF和XAML(?)。

In addition I looked through the "Controls Basics" example. The HandPointer is working very nicely, but I couldn´t find the math for the screen mapping and I think it´s only working for WPF and XAML (?).

任何人都可以启发我请




感谢您的帮助

Alex

Alex

推荐答案

控件中的指针基础是使用KinectCoreWindow的PointerMoved事件。您可以查看指针事件子示例以了解如何获取原始数据。

Hand Pointer in Controls Basics is using KinectCoreWindow's PointerMoved events under the covers. You can look at the pointer events sub sample to see how to get that raw data.

注意,这些指针事件仅提升到当前关注的应用程序。如果您尝试支持您控制的应用程序,这将正常工作。无法集中使用此数据来控制许多应用。

Note, these pointer events only are raised to the current focused app. If you are attempting to support apps you control, this will work fine. It is not possible to use this data centrally to control many apps.

也许您可以描述您尝试做的更多细节,因此我们可以帮助您指导正确的方向。

Perhaps you can describe more details of what you are trying to do, so we can help steer you the right direction.

谢谢,Rob Relyea

Thanks, Rob Relyea


这篇关于使用“控制基础知识”用于Windows鼠标光标控制的示例(或备选方案)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆