Python application to solve Sudoku puzzle and overlays solution on to real image in real-time.
This project is solely inspired from AnhMinhTran's Youtube Video.
In general Sudoku is solved using Backtracking approach
TheGreedy Best First Search approach (An optimised version of Naive Back Tracking method) was used ie; Chooses a cell with least number of possibilities to search next.
Step-1: Install all required libraries in requirements.txt
or directly run pip install -r requirements.txt
Step-2: Run main.py in the terminal using python3 main.py
.
Step-3: Nothing else, just get your Sudoku puzzle in front of your camera and solutions will be relayed over their respective positions.
Step-4: To stop the camera, click 'Q' on keyboard.
What's happening | Image |
---|---|
Step-1: Reading image from real-time input or a video or an image. | |
Step-2: Convert input image to black and white. Apply threshold to remove unwanted noise. | |
Step-3: Get boundry of largest contour ie: outline of sudoku matrix. | |
Step-4: In each cell of sudoku matrix, detect if any number is there or not by finding contours. | |
Step-5: Predict those detected numbers | |
Step-6: Input the predicted numbers into Sudoku Solving algorithm and get the output. |
|
Step-7: Overlay the corresponding calculated results on to live image/video. |
I used a trained model digitrecognition.h5
to predict the detected digits in the image
.
For solving sudoku: https://norvig.com/sudoku.html
Tech With Tim: https://www.youtube.com/watch?v=lK4N8E6uNr4
Sudoku extraction from image: https://medium.com/@neshpatel/solving-sudoku-part-ii-9a7019d196a2 (with python code)
Solving Sudoku Part1: https://medium.com/@neshpatel/solving-sudoku-part-i-7c4bb3097aa7
Solving Sudoku Part2: https://medium.com/@neshpatel/solving-sudoku-part-ii-9a7019d196a2
Code Reference:
- https://github.com/tahaemara/real-time-sudoku-solver
- https://aakashjhawar.medium.com/sudoku-solver-using-opencv-and-dl-part-2-bbe0e6ac87c5
Taha Emara: https://www.youtube.com/watch?v=Q5F8FteU3OY
🤝 LinkedIn: Lets Connect