Microsoft Kinect to JS communication using Python with WebSockets.
First run the Python server.py
script to start the Kinect tracking and websocket server.
$ python server.py
In a HTML file, load in the funicular.js
file and add the following JavaScript.
<script src="funicular.js"></script>
<script>
/* Override Funicular functions as shown below: */
window.Funicular = {
// Connected to websocket server
onSocketOpen: function() {},
// Disconnected from websocket server
onSocketClose: function() {},
onSocketMessage: function() {},
// Detected wave gesture
// x, y, z are coordinates of gesture
onGestureWave: function(x, y, z) {},
// Detected click gesture
// x, y, z are coordinates of gesture
onGestureClick: function(x, y, z) {},
// Hand detected, now tracking
// hand: {id, x, y, z}
onHandsRegister: function(hand) {},
// Hand moved.
// hands: [{id, x, y, z}]
onHandsMove: function(hands) {},
// Hand tracking lost hand, no longer tracking
// hand: {id}
onHandsUnregister: function(hand) {}
};
</script>
Note: Funicular.js has only been tested on OS X Yosemite running Python 2.7.6. It has been tested in Safari 8.0.2 and Google Chrome 39
- Install OpenNI. Some instructions for the installation of this are here.
- Next, you should install PyOpenNI. Be sure to copy the generated
lib/openni.<ext>
to your Python modules directory. Check it has installed sucessfully by running some of PyOpenNI demos to ensure that the Kinect sensor is communicating with Python. - Next, Tornado should be downloaded and installed from the website.
- Clone the Funicular.js repo to your local webserver.
git clone [email protected]:adeniszczyc/Funicular.js.git
- Ensure your Kinect is plugged into USB and connected to a power source.
- From Terminal, run the Python websocket file:
$ python server.py
- In your browser navigate to the client demo webpage. Be sure to do this through your webserver.
- Wave at the Kinect sensor, and you should see the hand tracking displaying the coordinates of your hand.
- Add more gestures on top of wave and click provided by PyOpenNI. This can include swipe, pull and move.
- Better error handling and support.
- Support for hardware control such as for motor and LEDs.
- Andrew Deniszczyc - Funicular.js
- DepthJS for inspiration for this project.
- Robert Deniszczyc for the name.