2013-05-30 92 views
2

我想将kinect手形光标用作'普通'鼠标光标。在具体的我想能够与Awesomium浏览器对象进行交互。KinectRegion HandPointer光标作为鼠标光标在Awesomium浏览器中

问题是当kinect手形光标(例如)通过链接,或者我点击或任何其他典型的鼠标事件时,不会引发Awesomium浏览器事件。

我修改了控制基础,例如WPF程序,您可以在Kinect的SDK

我使用C#的Visual Studio 2012的例子目录中找到,Kinect的SDK 1.7,Awesomium 1.7.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分开)。