Skip to content

Commit d7d1a6b

Browse files
authored
Merge pull request #1259 from Vishisht16/main
Sudoku Solver feature
2 parents 07dc745 + 496497c commit d7d1a6b

File tree

4 files changed

+863
-0
lines changed

4 files changed

+863
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Sudoku Solver
2+
3+
This project is a Sudoku solver that reads a Sudoku puzzle from an image, recognizes the digits using a pre-trained OCR model, and then solves the puzzle. The final solved puzzle is displayed by overlaying the solution onto the original image.
4+
5+
## Features
6+
- Extracts the Sudoku grid from an image using image processing techniques.
7+
- Recognizes the digits in the puzzle using a pre-trained OCR model.
8+
- Solves the puzzle using a backtracking algorithm.
9+
- Overlays the solution onto the original image.
10+
11+
## How it Works
12+
13+
### 1. Image Preprocessing:
14+
The input image is processed to detect the Sudoku grid. Contours are used to locate the largest rectangular region in the image, which is assumed to be the Sudoku puzzle.
15+
16+
### 2. Digit Recognition:
17+
The extracted grid is split into 81 cells, and each cell is resized to match the input size of the pre-trained OCR model. The model predicts the digits in the puzzle, assigning a number to each cell or marking it as empty.
18+
19+
### 3. Puzzle Solving:
20+
The recognized digits are passed into a backtracking algorithm, which solves the Sudoku puzzle. If the puzzle cannot be solved, the model might have misread a digit.
21+
22+
### 4. Output:
23+
The solved digits are overlaid back onto the original image using inverse perspective transformation, showing the solution in the correct position.
24+
25+
## Usage
26+
27+
1. Place your Sudoku puzzle image in the project directory (e.g., `sudoku1.jpg`).
28+
2. Run the script.
7.81 MB
Binary file not shown.

0 commit comments

Comments
 (0)