An intelligent Sudoku solver that combines Computer Vision, Optical Character Recognition (OCR), Deep Learning (CNN), and Recursive Backtracking (C++) to solve Sudoku puzzles directly from images.
This project demonstrates how classical Data Structures & Algorithms (DSA) can be blended with modern AI techniques to create robust and efficient systems.
- ๐ธ Extract Sudoku puzzle from an image using OpenCV
- ๐ Recognize digits using EasyOCR
- ๐งฎ Solve Sudoku efficiently with Recursive Backtracking (C++ implementation)
- ๐ค Alternative digit recognition using Convolutional Neural Network (CNN)
- ๐ฅ๏ธ CLI output and simple GUI interface
- โก Hybrid pipeline combining traditional algorithms + deep learning
E
โโโ OCR-Implementation
โ โโโ gui.py # GUI interface for Sudoku solver
โ โโโ img_processing.py # Image preprocessing & grid extraction
โ โโโ main.py # Entry point for OCR + solver pipeline
โ โโโ ocr_utils.py # OCR utilities (digit extraction, 2D board creation)
โ โโโ solver.py # Python wrapper to call C++ solver
โ โโโ utils.py # Helper functions
โ
โโโ Helper/sudoku_solver.cpp # C++ recursive backtracking solver
โโโ README.md
-
Image Preprocessing
- Convert to grayscale
- Apply thresholding
- Detect contours & warp perspective to get a clean Sudoku grid
-
Digit Extraction (OCR / CNN)
EasyOCRis used to recognize digits from each cell- CNN model can be used for improved recognition accuracy
-
Board Creation
- Digits are arranged into a 9x9 2D array
- Empty cells are represented as
0
-
Solving
- Board is passed to a C++ backtracking solver for fast computation
- Output is displayed via CLI or GUI
- Input: Raw Sudoku image
- Preprocessing: Grid extraction + thresholding
- OCR/CNN: Digit recognition
- Solver: C++ backtracking
- Output: Solved Sudoku (CLI or GUI view)
-
Clone the repository:
git clone https://github.com/ahmedyar7/GridVision.git cd GridVision -
Install Python dependencies:
pip install -r requirements.txt
-
Compile the C++ solver:
g++ sudoku_solver.cpp -o sudoku_solver
-
Run the OCR pipeline:
python .\OCR-Implementation\main.py
- Python: OpenCV, EasyOCR, NumPy
- C++: Recursive Backtracking for solving
- Deep Learning: CNN model for digit recognition
- GUI: Python (Tkinter / PyQt based, depending on your version)
- Real-time Sudoku solving from camera feed
- Mobile app integration
- More robust CNN training with larger datasets
- Cloud API for solving uploaded puzzles
This project is licensed under the GPL-License License โ feel free to use and modify.
- OpenCV for image preprocessing
- EasyOCR for digit recognition
- GeeksforGeeks for Sudoku references



