handDetector

A java program written using OpenCV that will execute a specified script whenever the left or right hand is raised or lowered

Compiling and Running

You will need to have OpenCV installed for java. To compile, use javac -cp opencv-2410.jar HandDetector.java. Use a different classpath if you have a different version of OpenCV. To run, use java -cp opencv-2410.jar;. HandDetector.java. It can be packaged into an executable jar file by creating a manifest.mf file with the following contents:

Main-Class: HandDetector
Class-Path: opencv-2410.jar

and running jar -cfm handDetector.jar manifest.mf *.class to create the jar file.

Note: if you are running the program in the console, always close the JFrame instead of pressing Control+C. Otherwise, you will have to forcibly terminate the program since the webcam would not be released.

script.js

This file must define functions called leftChange and rightChange. If its execution throws any exceptions, they will be printed to the console. When the left hand is raised, leftChange(true) is called, and when it is lowered, leftChange(false) is called. When the right hand is raised, rightChange(true) is called, and when it is lowered, rightChange(false) is called. The Javascript implementation used is Java's Nashorn.

Pong Demo

There is also a pong game made in Unity to deomonstrate the possibilities. It acceps input from the keyboard to move the paddle, and the script.js send keyboard events when the left and right hands are raised and lowered, so the paddle in the pong game can be controlled with hand motions. This can be found here.

Share this project:
×

Updates