2

我想将 kinect 手形光标用作“普通”鼠标光标。具体来说,我希望能够与 Awesomium 浏览器对象进行交互。

问题是当 kinect 手形光标(例如)在链接上时,或者我单击或任何其他典型的鼠标事件时,不会引发 Awesomium Browser 事件。

我修改了 Control Basics-WPF 示例程序,您可以在 Kinect SDK 的示例目录中找到它

我正在使用 c# Visual Studio 2012、Kinect SDK 1.7、Awesomium 1.7.1。

4

1 回答 1

4

这个问题被问到已经一个月了,所以也许你已经找到了自己的解决方案。

无论如何,我也发现自己处于这种情况下,这是我的解决方案:

在 MainWindow.xaml 中,您需要 KinectRegion 中的 Awesomium 控件(来自 SDK)。

您必须以某种方式告诉 SDK 您希望控件也可以处理手部事件。您可以通过在 Window_Loaded 处理程序的 MainWindow.xaml.cs 中添加以下内容来执行此操作:

KinectRegion.AddHandPointerMoveHandler(webControl1, OnHandleHandMove);
KinectRegion.AddHandPointerLeaveHandler(webControl1, OnHandleHandLeave);

在 MainWindow.xaml.cs 的其他地方,您可以定义手动处理程序事件。顺便说一句,我是这样做的:

    private void OnHandleHandLeave(object source, HandPointerEventArgs args)
    {
        // This just moves the cursor to the top left corner of the screen.
        // You can handle it differently, but this is just one way.
        System.Drawing.Point mousePt = new System.Drawing.Point(0, 0);
        System.Windows.Forms.Cursor.Position = mousePt;
    }

    private void OnHandleHandMove(object source, HandPointerEventArgs args)
    {
        // The meat of the hand handle method.
        HandPointer ptr = args.HandPointer;
        Point newPoint = kinectRegion.PointToScreen(ptr.GetPosition(kinectRegion));
        clickIfHandIsStable(newPoint); // basically handle a click, not showing code here
        changeMouseCursorPosition(newPoint); // this is where you make the hand and mouse positions the same!
    }

    private void changeMouseCursorPosition(Point newPoint)
    {
        cursorPoint = newPoint;
        System.Drawing.Point mousePt = new System.Drawing.Point((int)cursorPoint.X, (int)cursorPoint.Y);
        System.Windows.Forms.Cursor.Position = mousePt;
    }

对我来说,棘手的部分是: 1. 深入了解 SDK 并确定要添加哪些处理程序。文档对此并没有太大帮助。2. 将鼠标光标映射到 kinect 手上。如您所见,它涉及处理 System.Drawing.Point(与另一个库的 Point 分开)和 System.Windows.Forms.Cursor(与另一个库的 Cursor 分开)。

于 2013-07-01T03:13:12.690 回答