February 29, 2020

Kinect2 on Windows - motion sensing

This posting is to show the simplest method to use Kinect2 on Windows 10 in Python.

Requirements

 

Follow my previous blog posting, https://blog.keithkim.com/2019/03/kinect-2-and-windows-10-face.html to:
  • Connect XBox One Kinect2 to Windows
  • Install SDK

Install PyKinect2

 

Install from the source, then you'd avoid some errors.  If installed by using pip, then see the issue page:
Dependencies:
  • optional, but best to use with Anaconda, Python 3.7
  • Numpy, comtypes, PyGame

Example Code


From the source, there are two examples:
  • PyKinectBodyGame.py - shows detecting body motion
  • PyKinectInfraRed.py - shows IR camera image




Below photo shows stick figure over my body; where my arms/hands are.  I had to carry my keyboard to take the screenshot so it's not showing the stick figure too well, but it actually works pretty good.



I had to crop the image and cover my face for privacy.


Sum Up

 

I already have Kinect2 to play around, but many folks already implemented similar motion detection/capture just using a webcam with OpenCV python.

For motion capture alone, Kinect doesn't give much benefit over using a cheap webcam with OpenCV.  The real benefit is the depth sensor.  This also now can be done with with dual webcam, or dedicated devices that can also be used with Raspberry Pi.  They are smaller too.

XBox Kinect2 is not for close range motion detection/capture device.  For close range, it's better to use other method -- e.g. older Kinect for PC, or other devices.

If you're into stereo vision based depth sensing, don't get Kinect; rather get two webcams or better yet, get StereoPi, Mynteye, or two webcam based device.  See below links.

Stereo Vision Cameras

 

Other Resources


I didn't install/set up below as it appears to be a lot of effort is needed, but comes with more functionalities.