Setting up the app
Before we can get down to the nitty-gritty of our gesture recognition algorithm, we need to make sure that we can access the Kinect sensor and display a stream of depth frames in a simple GUI.
Accessing the Kinect 3D sensor
Accessing Microsoft Kinect from within OpenCV is not much different from accessing a computer's webcam or camera device. The easiest way to integrate a Kinect sensor with OpenCV is by using an OpenKinect
module called freenect
. For installation instructions, take a look at the preceding information box. The following code snippet grants access to the sensor using cv2.VideoCapture
:
import cv2 import freenect device = cv2.cv.CV_CAP_OPENNI capture = cv2.VideoCapture(device)
On some platforms, the first call to cv2.VideoCapture
fails to open a capture channel. In this case, we provide a workaround by opening the channel ourselves:
if not(capture.isOpened(device)): capture.open(device)
If you want to connect to your Asus Xtion, the device
variable...