A little something about me

Menu

Ruzzle Solving – The nerd way ..

I’ve been working on this project in my spare time for about three weeks and even though is not yet completed I decided it was time to share something. The idea was to realize a robot that could play Ruzzle versus an human player leaving him no possiblity to win. After a few days of brainstorming I decided to start writing a little of code in Python: In a few hours I managed to obtain all the right words performing a depth-first search and comparing them with a dictionary but I felt that was not enough so I asked myself: Why not use OpenCV for image processing combined to Tesseract for letter recognition ?

The image as captured by the camera

The first step was to isolate the smartphone’s screen: as the outermost frame of Ruzzle is blue, I decided to convert the image to HSV in order to perform a better filtering. Using OpenCV is quite simple to achieve that:

Using the inRange function we only take care of the pixel which values are in range between BLUE_MIN and BLUE_MAX making easily to find the screen edges. The following code snippet looks for the square with the biggest ares which is, in our case, the screen perimeter.

Now we can finally crop out the character to feed Tesseract. I found Tesseract to be very inaccurate if the images present some sort of noise or unexpected shapes so I had to find the bounding rectangle of every char and add an outside border in order to let the OCR motor to recognize them with great accuracy.