Falko Schindler

A Computer Vision Scientist from Bonn, Germany

Rock-Paper-Scissors with Kinect and Matlab

2012-07-16 by Falko Schindler, tagged as matlab

You might have heard about the cheating robot that beats you at rock, paper, scissors 100 % of the time. I don’t have a high speed robot at my lab. But at least the recognition part should be rather simple to re-implement. All it takes are some basic operations on binary images.

One could easily use a standard webcam and do an image subtraction in order to separate foreground from background. Since I had a Kinect depth camera lying around on my desk anyway, I used its disparity image for this step. The red contour in the screencast visualizes the detected foreground:

Download video

In order to detect the moment of decision, I track the top position of the foreground object, annotated with a magenta line. Detecting and counting local extrema of this vertical position enables noticing the final frame when a decision has to be made.

The decision is made using two thresholds: I extract the foreground object at the 4th and 6th (last) extremum and compute area and perimeter for both objects. The area and perimeter ratio of both frames yields to values that are compared with empirically determined thresholds. Since paper is larger than rock and scissors has a larger perimeter, the distinction is quite simple. The red and blue contours inicate both shapes that are compared.

This is indeed a quick and dirty response to the robot from the Ishikawa Oku Lab, but it’s a proof of concept. (Sorry for the crappy 3d hand, but I spent too much time playing around with this side project already…)