Project Random: Marble Detection

Over the past week I worked on the marble detection (distinguish black and white marbles) with a RaspberryPi 3 and a camera:

So far openCV worked great for the colors red and green but not very good for white. After a few attempts in getting greater accuracy I abandoned openCV on the Pi and went for a much simpler solution - compare brightness values. Now the camera takes a picture of the marble in the slot and a python script using the python library skimage analyses the brightness of the overall image. As the background of the marble slot is always black, the overall brightness changes significantly when a white marble is in the slot (compared to a black marble). 

Here the simple code:

Screen Shot 2018-02-27 at 10.27.52 PM.png



This means I can now distinguish black and white marbles using the PiCamera and send the right marble-color to the audience who will put them on the installation piece. 

Early prototyping-setup for testing with Pi and PiCamera: