Skip to content

jenfung/sudoku-solver

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sudoku-solver

Hi, my name is Rémi LUX. Currently engineer at Niryo, I code this sudoku solver during my free time. My algorithm is able to detect and to directly solve sudokus in VR as shown on the video below

The Application

The Application is based on KivyMD. It currently has 2 screens :

  • One for Live Solving which allows you to chose between full solving and hint mode
  • One which Solve image from gallery
Live Solving Gallery Solving
Live Solving Gallery Solving

How is it working ?

For a single image process, my algorithm is using working as following :

Grids Extraction

Firstly, the algorithm have to find where the grids are !
The pipeline is :

  1. Preprocess image to enhance high frequencies
  2. Find lines thanks to Hough Space
  3. Analyse lines to know which can correspond to a grid

Digits Identification & Grids Solving

Once grids are extracted, for each grid we do :

  • Detect shape which can be digits
  • Use my CNN do identify digits
  • Create a numeric grid in a table & solve it

Grids Reconstruction

  • Create a virtual image to fill the initial image
  • Add the 2 images together to create the final result

Video Case

When user chose to use video as input, the algorithm will act quite differently :

  • For grids extraction, we use position of last grids to deduce if 2 grids in 2 pictures are actually the same
  • For grids solving, we wait to have meet the same extracted numeric grid twice, to be confident on digits extraction
  • It do not resolve a grid if it a grid is detected as same as an already solved grid

How to use ?

Dependencies

You will need some libraries before running it

  • Numpy
  • OpenCV
  • Tensorflow
  • KivyMD >= 1.11.1 (as this version isn't publish on Pypi yet, you should install it form the KivyMD repo)

Run the program

The best way to use my algorithm is to firstly clone the git repo where you want to. Then, open a terminal & go in the repository
cd /path/to/the/repo/

Then, simply use the command

python3 kivy_md.py

Evolution, TODO list, Q&A, ...

Evolution of the Algorithm

Application

Version Visu
2.0 Application

Python Script

Version Source Algorithm Output
1.5 Video
1.3
1.2
1.1
1.0

Where can I find weights for the CNN :( ?

I trained mine personally with on a dataset of 10k numeric digits with data augmentation. It gave me a precision of 99.5+ %

TODO LIST

  • Create App
  • Adapt App for phone !

VERSION LIST

  • v2.0 : Creating the first App' version | 13/09/20

    • Clean old code
    • Use of Kivy
  • v1.7 : Multiple performance improvement | 17/12/19

    • New training method
    • Improve Reconstruction
  • v1.6 : Multiple performance improvement | 19/05/19

    • Optimize method for solving
    • Optimize method for grid detection
    • Improve Robustness It is now able do deal with Real-Time
  • v1.5 : Stabilizing video resolution | 12/05/19

    • Multiple checking if the grid is well detect
    • Jump solving step if seems to be already solved !
  • v1.4 : Video Handling | 08/05/19

  • v1.3 : More flexible / New training, better CNN ! | 05/05/19

  • v1.2 : Multiple grids baby ! | 02/05/19

  • v1.1 : Use probabilistic Hough & detect grid better | 01/05/19

  • v1.0 : First version | 28/04/19

About

Smart solution to solve sudoku in VR

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 100.0%