OCR web app

Started by VLS, Sep 28, 2023, 10:26 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

VLS

This thread is devoted to our OCR web app.

First casino is Hippodrome for @HardMan 👍

Sample:

Screenshot-20230928-184736-Browser.jpg


-- Victor

VLS

The OCR web app can be reached again for users to check it in real time.

URL: https://rouletteideas.com/ocr/

- OCR rectangles for the 17x28 grid are all set.

- Download button works (numbers to file).

- Image format for Hippodrome is 1200x1920, vertical orientation.

Happy news coming in! 👍


-- Victor

VLS

Okay! What happened to the web OCR? Short answer: I did complete it: all the code for number pre-processing was done. I truly did my part.

What missed? After the numbers were snapped & pre-processed correctly neither Gocr nor Tesseract's web version were suitably returning the recognized numbers back to the web app on the very final step. Tesseract would recognize some numbers incorrectly while Gocr was also a resource hog.

The good news is that -as a result of this- I turned into creating our own/in-house roulette number recognition algorithm, being fast + accurate, while also being light on resources when testing the pre-processed input.



Our in-house OCR is ~80% done.

I'm devoting time to release it without relying on 3rd party OCR libraries at all (!).

Going the in-house way has clear benefits: since we are the developers we are in a position to make it best suit our very defined purpose of recognizing numbers for Roulette (as opposed to having to deal with general purpose usage covering other use cases).

This new OCR algorithm is it! 👍


-- Victor

VLS

Quote from: VLS on Oct 26, 2023, 10:36 PMOur in-house OCR is ~80% done.

It's +90% now. The final algorithm is to recognize the SINGLE DIGITS (0-9) to compare in black & white. When one single digit is detected, then that's the number. When there are two digits detected, the operation is applied individually to join both numbers for the returned result.

Example of color transitions on the vertical axis (center):

28_color-transitions.png

Right now it's mostly doing boilerplate code on each pre-processed image and testing (There's not much math-oriented code left).


-- Victor

VLS

UPDATE: The new OCR is uploaded to showcase where we're at:

https://rouletteideas.com/ocr/

Single and two-number detection is complete. Now the task at hand is testing the actual accuracy of our algorithm for fast single number recognition.

Screenshot from 2023-11-02 01-02-30_two-numbers.png

Screenshot from 2023-11-02 00-45-24_single-number.png

Screenshot from 2023-11-02 00-47-21_two-numbers.png

This is +95% done :)

(Developed in-house for our community's benefit 👍)


-- Victor

VLS

98% UPDATE:

Currently checking for unique transition traits for vertical and horizontal scans per number.

This is a manual process that isn't hard code-wise, but it's proving time-consuming as the algorithm is flipping back & forth when doing double number detection (one pass vs per-number).

Screenshot from 2023-11-04 01-58-49_border-scan.png

Our goal of fast & accurate Roulette number recognition is basically done. We're truly at the very last part of it.


-- Victor

VLS

99% UPDATE:

The numbers are accurately grouped by separating each individual digit and then performing number recognition on each.

Screenshot from 2023-11-11 06-03-19_OCR-steps.png

The algorithm generates a fast read of pixels: once left-to-right, then right-to-left, in order to compare with this table:

"false|true", // 0
"true,false,true|true", // 1
"false,true,false|true,false,true", // 2
"false,true,false,true,false|true", // 3
"true,false,true|true", // 4
"false,true,false|true,false,true", // 5
"false|true,false,true", // 6
"false,true,false|true,false", // 7
"false|true", // 8
"false,true,false|true", // 9

There are collisions on some digits:

- 0|8
- 1|4
- 2|5

That's the 1% remaining :)

The OCR web app is updated:

https://rouletteideas.com/ocr/
_____________

This is how it's currently detecting --actual example:

2|5,2|5
6
3,3
2|5,3
2|5,3
1|4,2|5
2|5
1|4
1|4,2|5
2|5,9
1|4
1|4,7
2|5,0|8
2|5,1|4
7
0|8
2|5,0|8
3,2|5
1|4,2|5
1|4,1|4
0|8
2|5,2|5
1|4
2|5,2|5
9
1|4,9
2|5,9
1|4,1|4
0|8
2|5
9
2|5,1|4
0|8
2|5,2|5
3
2|5,1|4
3
1|4,3
1|4,9
2|5,6
1|4
3,2|5
1|4,0|8
1|4,9
1|4,7
2|5,6
1|4,1|4
2|5,1|4
3,1|4
3
2|5,7
2|5,9
1|4,1|4
1|4,2|5
1|4,9
2|5
7
2|5,0|8
3
2|5,1|4
1|4,0|8
9
1|4
1|4,2|5
0|8
1|4
2|5,6
7
2|5,2|5
1|4,9
1|4,3
1|4,0|8
3,1|4
3,2|5
6
2|5,1|4
2|5,7
2|5,1|4
1|4,1|4
6
3,2|5
2|5,9
3,0|8
2|5,2|5
1|4,0|8
1|4,9
2|5,6
2|5,7
2|5,2|5
2|5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
0|8
0|8
2|5,2|5
2|5
1|4,3
1|4,0|8
0|8
1|4,2|5
3
3,1|4
2|5,2|5
9
3,0|8
9
2|5,3
1|4
1|4,0|8
3,3
0|8
1|4,3
1|4,3
1|4,1|4
1|4,0|8
1|4,6
3,6
6
0|8
1|4,9
2|5,9
2|5,6
2|5,7
2|5,6
1|4,2|5
0|8
3
3,2|5
3,3
3,6
3,1|4
1|4,2|5
1|4,9
6
6
2|5,1|4
6
3,6
3,2|5
2|5
1|4,7
2|5,7
1|4,3
3,1|4
3,2|5
3,2|5

(Sample input image attached)


-- Victor

VLS

Quote from: VLS on Nov 11, 2023, 02:42 PMThere are collisions on some digits:

- 0|8
- 1|4
- 2|5


It's accurately determined now.

Both 0|8 and 1|4 are untied by using the number of black-to-white|white-to-black "toggles" in the middle.

8 has more of such transitions than 0.

4 has more transitions than 1.

In the case of 2|5, the upper quarter is used for comparison, as per the algorithm above. If the boolean sequence is "true,false" = 5.



The OCR web app is updated to reflect this change:

https://rouletteideas.com/ocr/

Current recognized numbers for the sample input image:

25
6
33
23
23
15
2
1
12
29
1
17
28
21
7
0
28
32
12
14
8
25
4
25
9
19
29
11
8
5
9
21
0
22
3
24
3
13
19
26
4
35
10
19
17
26
11
21
31
3
27
29
11
15
19
5
7
20
3
21
18
9
1
12
8
4
26
7
25
19
13
10
34
32
6
24
27
24
11
6
35
29
30
25
18
19
26
27
25
22
14
9
26
5
35
28
22
10
19
9
17
13
20
18
2
26
15
22
11
12
31
29
18
32
26
18
25
14
36
0
1
32
7
21
36
31
19
2
14
21
14
23
33
0
36
1
28
3
17
2
0
9
3
34
13
5
6
7
1
28
1
23
30
17
8
33
25
7
5
30
8
22
20
29
33
8
33
18
34
4
6
21
27
3
34
2
19
36
15
24
29
34
34
30
36
15
14
1
0
15
15
22
18
21
8
18
8
24
12
26
12
7
25
11
29
7
15
2
32
0
35
10
7
30
29
23
25
20
27
28
17
21
0
22
17
29
8
28
14
14
24
14
12
20
36
13
6
16
19
16
28
7
34
33
35
6
11
10
8
2
25
11
10
34
5
29
3
11
9
25
18
18
16
9
11
36
32
17
32
14
30
24
14
5
5
14
20
32
25
3
32
12
27
1
27
30
8
13
11
22
2
0
7
12
0
24
2
32
4
35
19
18
32
10
25
22
1
3
35
12
9
20
9
26
5
23
34
21
10
28
29
25
21
3
31
2
1
24
31
24
30
30
9
25
25
17
34
8
26
19
25
6
17
30
13
29
32
22
14
10
3
22
18
12
31
15
14
19
36
14
15
26
10
14
34
31
27
10
17
25
15
30
31
9
27
6
11
21
32
29
32
35
32
15
7
34
35
30
28
34
23
28
16
11
8
19
15
7
1
34
23
31
13
21
0
8
4
28
20
21
16
0
17
0
29
5
35
8
0
32
13
14
13
13
19
14
10
9
25
24
30
29
32
14
0
0
22
2
13
10
8
15
3
34
25
9
30
9
23
4
10
33
0
13
13
11
10
16
36
6
0
19
29
26
27
26
15
0
3
32
33
36
31
12
19
6
6
24
6
36
35
5
17
27
13
34
32
32

It's pretty usable right now; we could call it done "as is", yet there's still the one row above to be processed.

It's a different rectangle size with first number having a different background color (not black)... but we'll certainly handle it to get this custom OCR to 100% 👍

Let's call this a 99.7% update 😊


-- Victor