Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

State of Kinect-Python-OpenCV in 2019

This question might be slightly off-topic here as it could be interpreted as "looking for software resources" albeit I would like it to be understood as "request for best practice" and couldn't find any other Stack-Exchange Site where this would be more appropriate so:

I happened to get my hands on a MS Kinect depth camera this week. All tutorials and resources I find are either massively outdated (MS) or overly complicated. My question is:

What is the easiest way to get a depth image out of a Kinect and ready to be processed in 2019 - Ideally using OpenCV with Python?

I tried:

Windows 10 + libusbK + freenect + anaconda + openCV

There's a lot of manual compilation involved, manually changing lines of codes in several files etc.

Ubuntu 12.4.(sic!) + kernel drivers + openNI + anaconda + openCV

A little better, but still feels hacky with manually pulling in patches and hotfixes for kernel-driver disable, cross-compilation with cmake/cython etc. (not working reliably with venvs...)

like image 578
Dschoni Avatar asked Dec 09 '25 09:12

Dschoni


1 Answers

I finally found a way after quite some time of testing, using a Raspberry Pi 3 and the latest Raspbian Buster image. Be sure, that a running python version is on your system. I tried everything here using python 2.7.

Install dependencies:

sudo apt-get install git-core cmake freeglut3-dev pkg-config build-essential libxmu-dev libxi-dev libusb-1.0-0-dev

Install OpenCV:

Building manually is super-slow. I found this to be working actually quite well:

sudo apt-get install opencv-python

Manually build libfreenect:

This is needed, as the package version has problems on Pi 3.

git clone git://github.com/OpenKinect/libfreenect.git
cd libfreenect
mkdir build
cd build

Use any means to configure the build to build Python extensions.

cmake ..
make
make install

Refresh ldconfig cache:

sudo ldconfig /usr/local/lib64
sudo ldconfig /usr/local/lib

Install numpy with e.g. pip:

pip install numpy

Build the python extensions from libfreenect:

cd libfreenect/wrappers/python
python setup.py install

Now, you should be able to run the examples in libfreenect\wrappers\python

like image 126
Dschoni Avatar answered Dec 10 '25 21:12

Dschoni