Skip to content

Commit 682d040

Browse files
authored
Merge pull request #345 from NativeScript/fix-get-text
fix: get text with [email protected]
2 parents 7e46d2f + b0c7050 commit 682d040

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

core/utils/image_utils.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ def get_main_color(image_path):
105105

106106
@staticmethod
107107
def get_text(image_path, use_cv2=True):
108-
char_whitelist = string.digits
108+
char_whitelist = string.whitespace
109+
char_whitelist += string.digits
109110
char_whitelist += string.ascii_lowercase
110111
char_whitelist += string.ascii_uppercase
111112

core_tests/unit/utils/image_tests.py

+7
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ class ImageUtilsTests(unittest.TestCase):
2323
app_image = os.path.join(current_folder, 'resources', 'app.png')
2424
app_image_ng = os.path.join(current_folder, 'resources', 'app_ng.png')
2525
app_image_ios = os.path.join(current_folder, 'resources', 'app_ios.png')
26+
app_image_default_ios = os.path.join(current_folder, 'resources', 'app_ios_default.png')
2627
iphone_image = os.path.join(current_folder, 'resources', 'screenshot.png')
2728
unicode_image = os.path.join(current_folder, 'resources', 'unicode.png')
2829
blue = numpy.array([255, 188, 48])
@@ -43,6 +44,12 @@ def test_03_get_main_color(self):
4344

4445
@unittest.skipIf(os.environ.get('TRAVIS', None) is not None, 'Skip on Travis.')
4546
def test_04_get_text(self):
47+
# OCR on iOS 13
48+
text = ImageUtils.get_text(self.app_image_default_ios)
49+
assert 'taps left' in text
50+
assert 'Tap the button' in text
51+
assert 'TAP' in text
52+
4653
# OCR on Hello-World app
4754
text = ImageUtils.get_text(self.app_image_ios)
4855
assert 'My App' in text
Loading

0 commit comments

Comments
 (0)