Working sample for controlling the mouse by hand
As a last recipe of this chapter, we will write a working example for using nite::HandTracker
. In this recipe, we will show you how to control the position of the mouse cursor using the NiTE hand tracker feature and how to simulate a click event.
We are going to use the Hand Raise gesture for the tracking of hands and the Click (push) gesture for the mouse click. Also, because of the low resolution of the depth output compared to the resolution of the monitor, which results in low accuracy of the hand tracker, we decided to move the mouse depending on its distance with the starting point. This is similar to how you control your mouse with a joystick.
Note
This sample is Windows only because it uses the Microsoft Windows API.
Getting ready
Create a project in Visual Studio and prepare it for working with OpenNI and NiTE using the Create a project in Visual Studio 2010 recipe in Chapter 2, OpenNI and C++.
How to do it...
Copy
ReadLastCharOfLine()
...