A Sudoku recognizer and solver code in Python
python 2.7 opencv 2.4.12 numpy 1.11.0
This file is used to train dataset. It contains a list of path of images named as 'images' which are used for training. If some other images are to be used for training, then list of path must be updated. At the end, it saves all the data to files.
This file is used to solve sudoku image. It requires input as name of image. Both sudoku_solve.py and image must be in same folder otherwise you need to adjust the path. Dataset made during training is used for testing. Digit recognition is done using KNN model.
All the images for training are taken fron www.theguardian.com
All the images for testing are also taken from www.theguardian.com.
As the training set and testing set was from the images of www.theguardian.com, so the accuracy of sudoku recognition is 100%.
- Run the file sudoku_train.py
- For each image in list of path, 81 images are generated one by one and we need to provide input for them by pressing digit represented by them.
- For blank squares, we need to press 0.
- We do not need to provide input for all blank squares. Only a few will work fine.
- To skip input for any particular square, press Enter.
- Trainig will be complete after input for all images are done.
- Run the file sudoku_solve.py
- Provide name of image as input for which we want to solve.
- Sudoku is solved and displayed.