Sudoku Solver

OCR Sudoku Solver in C


This project was done during my third semester at EPITA in a team of 4 members. We had to create a program in C able to take a sudoku grid image, apply image treatments to it if necessary and then solve it using Optical Character Recognition and a simple neural network. We used GTK for the interface and SDL for the image treatments.

Loading of an image using GTK


Here we can see the interface used to load the sudoku grid to solve in the software. Basic image formats like png and jpeg are supported.

Sudoku Solver
Sudoku Solver

Grid loaded before treatments


Here is the main part of the software where the user can select the treatments to apply before solving if necessary. The user can convert the image to grayscale, black and white, rotate it, and apply a gaussian blur.

Sudoku Solver

Grid detection


The software is able to detect the grid in the image and extract the numbers from it with OCR neural network trained on printed and handwritten numbers. The grid is then displayed in the interface and the user can see the boxes detected.

Grid solved


The program uses a backtracking algorithm to explore the possibilities of acceptable solutions for the grid. When faced with an impossible case after trying some numbers, it "backtracks" to try different numbers until finding the solution. This solution is finally displayed in the interface and can be saved to a file by the user ("Save" button).

Sudoku Solver