forked from SumZer0-git/EDAPGui
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_OCR.py
More file actions
40 lines (30 loc) · 1.21 KB
/
test_OCR.py
File metadata and controls
40 lines (30 loc) · 1.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import unittest
from OCR import OCR
from Screen import *
class OCRTestCase(unittest.TestCase):
def test_simple_OCR(self):
""" Simple check of OCR to bring back text of a know image. """
ocr = OCR(screen=None)
# Load image
image_path = 'test/ocr/ocr-test1.png'
orig_image = cv2.imread(image_path)
ocr_textlist = ocr.image_simple_ocr(orig_image)
actual = str(ocr_textlist)
expected = "['DESTINATION', 'SIRIUS ATMOSPHERICS']"
self.assertEqual(actual, expected) # add assertion here
def test_similarity_test1(self):
ocr = OCR(screen=None)
s1 = "Orbital Construction Site: Wingrove's Inheritance"
s2 = "Wingrove's Inheritance (Orbital Construction Site)"
actual = ocr.string_similarity(s1, s2)
print(f"Dice: {actual}")
self.assertGreater(actual, 0.9) # add assertion here
def test_similarity_test2(self):
ocr = OCR(screen=None)
s1 = "STAR BLAZE V2V-65W"
s2 = "STAR BLAZE (V2V-65W)"
actual = ocr.string_similarity(s1, s2)
print(f"Dice: {actual}")
self.assertGreater(actual, 0.8) # add assertion here
if __name__ == '__main__':
unittest.main()