AI-assisted Sudoku Solver

ai sudoku

In this AI-assisted Sudoku Solver, algorithm is able to detect and to directly solve AI sudokus in VR.

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
ai sudoku codes
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 AI Sudoku ?

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/folder/

You can see the options by typing python3 sudoku_solver_main.py -h

You will need some libraries before running it

  • Numpy
  • OpenCV
  • Keras
  • Tensorflow

To Install : pip install <library_name>

Easy way

Take your own picture/video of your process target and use the command
python3 sudoku_solver_main.py -i path/to/your/file
You also want to add -s to save the output result In both cases, the result will be display on your monitor during processing

If you want to use your webcam, you can chose the profile n°2 by adding -p 2 to your command. Nevertheless, the algorithm is too long to give a real-time pleasant experience (mainly cause of the Hough Transform)

Advanced way

The user can use his own Keras model to identify digits. For that use the parameter -mp path/to/your/model

About Diwas

🚀 I'm Diwas Pandey, a Computer Engineer with an unyielding passion for Artificial Intelligence, currently pursuing a Master's in Computer Science at Washington State University, USA. As a dedicated blogger at AIHUBPROJECTS.COM, I share insights into the cutting-edge developments in AI, and as a Freelancer, I leverage my technical expertise to craft innovative solutions. Join me in bridging the gap between technology and healthcare as we shape a brighter future together! 🌍🤖🔬

View all posts by Diwas →

Leave a Reply

Your email address will not be published. Required fields are marked *