Skip to content

fix: get text with [email protected] #345

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion core/utils/image_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ def get_main_color(image_path):

@staticmethod
def get_text(image_path, use_cv2=True):
char_whitelist = string.digits
char_whitelist = string.whitespace
char_whitelist += string.digits
char_whitelist += string.ascii_lowercase
char_whitelist += string.ascii_uppercase

Expand Down
7 changes: 7 additions & 0 deletions core_tests/unit/utils/image_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class ImageUtilsTests(unittest.TestCase):
app_image = os.path.join(current_folder, 'resources', 'app.png')
app_image_ng = os.path.join(current_folder, 'resources', 'app_ng.png')
app_image_ios = os.path.join(current_folder, 'resources', 'app_ios.png')
app_image_default_ios = os.path.join(current_folder, 'resources', 'app_ios_default.png')
iphone_image = os.path.join(current_folder, 'resources', 'screenshot.png')
unicode_image = os.path.join(current_folder, 'resources', 'unicode.png')
blue = numpy.array([255, 188, 48])
Expand All @@ -43,6 +44,12 @@ def test_03_get_main_color(self):

@unittest.skipIf(os.environ.get('TRAVIS', None) is not None, 'Skip on Travis.')
def test_04_get_text(self):
# OCR on iOS 13
text = ImageUtils.get_text(self.app_image_default_ios)
assert 'taps left' in text
assert 'Tap the button' in text
assert 'TAP' in text

# OCR on Hello-World app
text = ImageUtils.get_text(self.app_image_ios)
assert 'My App' in text
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.