2013-05-30 88 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分開)。