Being a Sudoku lover, I dedicate this Web-App for all Sudoku learners and pros who can easily check for solutions...
- HTML, CSS, Javascript in Frontend
- OpenCV
- Python 3.8
- TensorFlow-Keras
- Django in backend
- MNIST Dataset (Available with Keras datasets)
The main tasks to do in the pipeline are:
- Creating the algorithm for solving Sudoku
- Extracting Sudoku from the image
- Solving Sudoku and displaying results
- Developing the Web-App
The most obvious way to solve a partially-filled sudoku grid is to use backtracking algorithm - just check for a suitable number in each cell that doesn't repeat in its row, column and 3X3 subgrid, until all cells are successfully filled up.
The algorithm is implemented here.
This is implemented using OpenCV, Python and TensorFlow-Keras as follows:
- Create a model for digit-recognition by training neural network over MNIST dataset containing 60,000 images of digits from 0 to 9.
- Preprocess the image to detect sudoku grid.
- Extract the sudoku grid and warp the image to perspective view.
- Extract each cell by slicing the grid sequentially.
- Using the saved model, detect digit for every cell, otherwise mark it empty.
- Save the values of the sudoku grid in a matrix and return it.
- Get the sudoku matrix.
- Solve the sudoku using the algorithm.
- Print the solution over the source image and return output.
The Web-App is designed as such:
- The user needs to upload the image.
- Once uploaded, press Solve.
- The solution to the given Sudoku is provided.