Solving the sudoku puzzle using Image Processing, Artificial Intelligence and the Backtracking Algorithm!
Clone the repository git clone https://github.com/manpreet1130/RealTime-Sudoku-Solver
Realtime solver: cd RealTimeSolver
and run python main.py
Image solver: cd ImageSolver
and run python main.py
The image is converted to grayscale and further Adaptive Thresholding and Dilation are applied to the image to reduce noise and enhance contours. After this happens, the coordinates of the maximum area (the sudoku grid) in the image are found.
Using the coordinates found, we warp the image and form individual grids on the image.These individual grids will help in extracting out the smaller tiles which contain a single digit or a blank.
The individual grids are passed into a convolutional neural network (Christopher) which is pretrained on a custom dataset. These grids are identified and returned in the form of a list.
The predictions are fed into a script which solves the sudoku using the Backtracking algorithm and the solution is shown on an empty sudoku grid.
This script combines all the scripts given below.
This script consists of a Convolutional Neural Network trained on a custom dataset.
This script is used to take as input the original image, apply preprocessing, get the corner points of the board, warp the image and seperate out the individual smaller grids(tiles) containing the individual digits/blanks.
This script is used to take the individual tiles, does a bit of preprocessing and predict the digits in each tile. As the grid is a 9x9, the number of tiles are 81.
This script consists of the backtracking algorithm used to solve the sudoku puzzle. After the predictions are made, they are fed into this script. The final board is than printed onto a blank sudoku grid image.
- Applying augmented reality!