Python Wrapper Windows
Currently the cython bindings for windows are not ready out of the box. The distutil build script only supports unix and the vs2010 project generated by cmake is not complete.
Here are changes I hade to do to make the process work on windows 7 using VS 2010 C++ Express edition.
This excludes getting and installing cython and the regular freenect dependencies. This is assuming python 2.6 installed in the standad directory.
- Tick the
CYTHON_EXECUTABLEcmake variable must point to the cython.py script
- ie. c:\Python26\Scripts\cython.py
- cmake did not correctly detect the python to use and referenced the includes from python 2.6 and the lib from python 2.7. Cmake GUI did not expose those to me so I ended up changing them in the vs2010 solution
- in the cython_freenect project properties
- general: change the extension from .dll to .pyd. This allows the files to live side by side.
- C/C++ - General - Additional include directories:
- Make sure the python includes point to the right python version. ie. c:\Python26\include\
- add C:\Python26\Lib\site-packages\numpy\core\include
- Linker - Input = Additional library directories:
- make sure the correct python lib is there. C:\Python26\libs\python26.lib
- make sure the libusb.lib and pthreadVC2.lib are correctly referenced
Also the cython is generating invalid code for windows so in freenect.cyou need to replace
#if HAVE_HYPOT with
#ifdef HAVE_HYPOT since python seems to define the constant diffently in different platforms. This is supposedly fixed in the cython repo but not in the latest 0.14 build.
Finally I copied the dependent .dll files to the same directory as freenect.pyd before being able to run. In general the path to the DLLs should to be in the python
So from a python shell you should be able to do
import freenect depthArray, timestamp = freenect.sync_get_depth()
I tend to get alot of
Error: Can't open device. 1.) is it plugged in? 2.) Read the README
errors when trying to connect but if I keep trying in seems to get through in the end and stay connected.
See also: Python (Main document)