我想使用 kinect 手形光标作为“普通”鼠标光标。具体来说,我希望能够与 Awesomium 浏览器对象进行交互。
问题是,当 kinect 手形光标(例如)位于链接上、或者我单击鼠标或任何其他典型的鼠标事件时,不会引发 Awesomium 浏览器事件。
我修改了Control Basics-WPF示例程序,您可以在Kinect SDK的示例目录中找到该程序
我使用的是 c# Visual Studio 2012、Kinect SDK 1.7、Awesomium 1.7.1。
最佳答案
这个问题已经一个月了,所以也许您已经找到了自己的解决方案。
无论如何,我发现自己也处于这种情况,这是我的解决方案:
在 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 分开)。
关于c# - KinectRegion HandPointer 光标作为 Awesomium 浏览器中的鼠标光标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16838111/