Skip to content

PyKinect

crwilcox edited this page Apr 23, 2015 · 1 revision

PyKinect - write Kinect games using Python!

PyKinect enables writing awesome games and interfaces using Python:

Run

Set breakpoints & Explore Kinect sensor data in the debugger directly:

Run

Prerequisites

PyKinect itself doesn't depend on Pygame - you can write games without it. However, our samples do. We use it because Pygame is awesome & popular.

Installation

PyKinect is a Python package available from PyPI.

You can install it in your CPython 2.7 32-bit environment using:

pip install pykinect

If you use PTVS with the Visual Studio sample project template, it will prompt to install PyKinect for you at project creation.

The Visual Studio sample project template for PyKinect is available as part of the PTVS Samples 2.1.vsix. Download it from the PTVS downloads page.

Don't forget to also install Pygame and the Kinect SDK.

Sample Project

To create a sample project, select File, New, Project, then under Python, Samples, choose PyGame using PyKinect.

New Project

You'll have the option of installing PyKinect in a new virtual environment, your global Python 2.7 environment or skip installation.

Install PyKinect

When the project finishes loading, it will display instructions for installing Pygame. You can skip that if you are using your global Python 2.7 with Pygame already installed.

Install PyGame

The sample code basically sets up the event loop & does basic skeleton tracking.

Install PyGame

For a slightly more involved sample, please see PyGameDemo.py.

This sample renders the skeletons with the video or depth cameras. When you run this sample, it opens a console window & prints the available keyboard commands.

Notes

A couple of things to watch out for:

  • Currently only 32-bit flavor of CPython is supported (ie, don't install it with a 64-bit Python interpreter even if PTVS allows it)
  • If you are not getting skeleton tracking: make sure your body is within the sensor's range & your legs are visible to the camera.
  • Sometimes the Pygame event queue can be overfilled - if this happens an exception is raised and can be handled appropriately.

If you develop a game or a sample that you're willing to share, please let us know! We'd love to see what you've come up with & we can feature it here.

Clone this wiki locally