Skip to content

Commit

Permalink
Add AdbClient.imageToData()
Browse files Browse the repository at this point in the history
  • Loading branch information
dtmilano committed Apr 25, 2022
1 parent 64ee1e2 commit 3356767
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/com/dtmilano/android/adb/adbclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

from com.dtmilano.android.adb.dumpsys import Dumpsys

__version__ = '20.8.0'
__version__ = '20.9.0'

import sys
import warnings
Expand Down Expand Up @@ -921,6 +921,22 @@ def takeSnapshot(self, reconnect=False):
profileEnd()
return image

def imageToData(self, image, output_type=None):
"""
Helps in cases where the Views cannot be identified.
Returns the text found in the image and its bounding box.
:param image: the image (i.e. from takeScreenshot())
:param output_type: the output type (defualt: pytessearct.Output.DICT)
:return: the data from the image
"""
try:
import pytessearct
except ImportError:
raise Exception("You have to install pytesseract to use imageToData()")
if not output_type:
output_type = pytessearct.Output.DICT
return pytessearct.image_to_data(image, output_type=output_type)

def __transformPointByOrientation(self, xxx_todo_changeme, orientationOrig, orientationDest):
(x, y) = xxx_todo_changeme
if orientationOrig != orientationDest:
Expand Down

0 comments on commit 3356767

Please sign in to comment.