This project detects and solves a sudoku grid in real time.
Edge is detected using Canny edge detector which gives a noiseless image.
From all the detected contours, the contour whose area is greater than a threshold is selected, that is generally our sudoku grid
The warped grid is splitted into 81 boxes.
All the 81 boxes are pre-processed which follows the followinng sequence:
- Border removal
- Adaptive thresholding
- Moving the number in the middle of the box
All the blank images are converted into black boxes.
The digits are recognisied using a trained CNN model. The model is trained using 10000 images. 25 epochs were done to train the model.
Images of all the numbers were present in almost equal number.
Blank spaces are represented by 0.
The sudoku grid is solved using backtracking.
The solved grid is showed by writing the numbers on blank spaces on the warped image.
- Grid is shown with different colours showing different processes. Red border means it is storing index of blank spaces which will be used later to ensure that sudoku grid is not changed. Yellow border means digits are being recognised and grid is being made. Green border means sudoku is being solved and when it is solved it is shown.
- Index of blank spaces of current sudoku grid is compared with the index of blank spaces stored when grid was red. If at any time there is difference in index of blank spaces then whole process will begin from start. This helps to detect that the sudoku grid has been changed.
- 3 boxes are given at a time to recognise the digits, hence framerate remains constant even in systems which do not have GPU.