You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+74-9Lines changed: 74 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,13 +1,36 @@
1
1
<imgsrc="imgs/Banner.png"width=100%></img>
2
2
3
-
4
3
## Table of Contents
5
4
-[Introduction](#introduction)
5
+
-[How to use](#how-to-use)
6
6
-[How it works](#how-it-works)
7
-
-[Getting Started](#getting-started)
7
+
-[Build](#build)
8
8
9
9
## Introduction
10
10
11
+
This project is an android app that solves sudoku, hence the name, recognized from images using Optical Character Recognition or entered manually.
12
+
13
+
I've built this project the first time in early 2022 ( [v1](https://github.com/hypertensiune/Android-Sudoku-Solver-OCR/tree/v1) branch ) and this is a refresh, an update to the original project.
14
+
15
+
What's new:
16
+
- Better image processing and sudoku board recognition
17
+
- Better text recognition
18
+
- Code refactoring in Kotlin
19
+
- Improved documentation
20
+
21
+
## How to use
22
+
23
+
Download or [build](#build) the app yourself.
24
+
Use it like a camera app, press the shutter button when the sudoku it's detected and it will be solved. You can also edit it or input it manually if you want.
25
+
26
+
It works on both puzzles on paper or on screen, the only requirement is there is enough light and that it's smooth.
27
+
28
+
<palign="center">
29
+
<imgsrc="imgs/scr1.jpeg"width=30%></img>
30
+
   
31
+
<imgsrc="imgs/scr2.jpeg"width=30%></img>
32
+
</p>
33
+
11
34
## How it works
12
35
13
36
### Sudoku board detection
@@ -19,8 +42,6 @@ To identify the sudoku board the input image is processed as follows with [OpenC
19
42
20
43
The numbers are detected using [MLKit Text Recognition](https://developers.google.com/ml-kit/vision/text-recognition/v2).
21
44
22
-
<br>
23
-
24
45
<palign="center">
25
46
<imgsrc="demo/demo1.gif"></img>
26
47
</p>
@@ -29,11 +50,11 @@ The numbers are detected using [MLKit Text Recognition](https://developers.googl
29
50
30
51
### Solving
31
52
For solving the puzzle I'm using a fairly simple, brute-force algorithm that relies on backtracking to generate the valid solution.
32
-
<br>
53
+
33
54
It goes through the whole 2D array and for each number that needs to be found it tries all possibilities and continues with the following numbers.
34
-
<br>
35
-
<br>
36
-
For each cell there are 9 possible numbers which means the time complexity of this algorithm is O(9<sup>N</sup>).
55
+
56
+
57
+
For each cell there are 9 possible numbers which means the time complexity of this algorithm is O(9<sup>n</sup>).
37
58
38
59
```
39
60
private fun solve(index: Int = 0): Boolean {
@@ -64,4 +85,48 @@ private fun solve(index: Int = 0): Boolean {
64
85
<span>Solve algorithm demo</span>
65
86
</p>
66
87
67
-
## Getting Started
88
+
## Build
89
+
90
+
- Download or clone the repository and open it in Android Studio.
91
+
- Download the android version of [OpenCV](https://opencv.org/releases/). I used the latest version, 4.8.0.
92
+
- Import the OpenCV module in Android Studio.
93
+
* Click **File > New > Import Module**, select the **OpenCV-android-sdk/sdk** directory and change the module name to **opencv**.
94
+
* Goto **File > Project Structure > Dependencies** and on the **app** module add **opencv** as a dependency.
95
+
* In **opencv build.gradle** add ```android { namespace 'org.opencv' }```, change ```compileSdkVersion``` and ```targetSdkVersion``` to 33 and finally, add
96
+
```
97
+
kotlinOptions {
98
+
jvmTarget = '1.8'
99
+
}
100
+
buildFeatures {
101
+
buildConfig true
102
+
aidl true
103
+
}
104
+
```
105
+
* Further we need to modify the following classes in the OpenCV module:
106
+
* **CameraBridgeViewBase**: add ```canvas.rotate(90f, canvas.getWidth() / 2, canvas.getHeight() / 2);``` in function ```deliverAndDrawFrame```, right before drawing the bitmap.
0 commit comments