REAL-TIME-SUDOKU-SOLVER

This project detects and solves a sudoku grid in real time.

Screenshot (89)

  • EDGE DETECTION

Edge is detected using Canny edge detector which gives a noiseless image.

Screenshot (91)

  • CONTOUR DETECTION

From all the detected contours, the contour whose area is greater than a threshold is selected, that is generally our sudoku grid

Screenshot (90)

  • WARPING THE SUDOKU GRID

Screenshot (92)

  • SPLITTING THE GRID

The warped grid is splitted into 81 boxes.

Screenshot (104)

  • PREPROCESSING THE 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.

Screenshot (105)

  • RECOGNISING THE DIGITS

The digits are recognisied using a trained CNN model. The model is trained using 10000 images. 25 epochs were done to train the model.

Screenshot (96)

Images of all the numbers were present in almost equal number.

Screenshot (98)

Accuracy vs Val_Accuracy Graph

Screenshot (97)

  • MAKING THE SUDOKU GRID

Blank spaces are represented by 0.

Screenshot (99)

  • SOLVING THE SUDOKU GRID

The sudoku grid is solved using backtracking.

Screenshot (100)

  • SHOWING THE DIGITS

The solved grid is showed by writing the numbers on blank spaces on the warped image.

Screenshot (93)

WORKING VIDEO

ezgif com-gif-maker (7)

SALIENT FEATURES

  • 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.