Skip to content

Commit

Permalink
Minor: Format local_ocr code with Black
Browse files Browse the repository at this point in the history
  • Loading branch information
Farhan Kathawala committed Aug 31, 2020
1 parent 64f756b commit b259206
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
27 changes: 15 additions & 12 deletions automagica/activities.py
Original file line number Diff line number Diff line change
Expand Up @@ -9491,10 +9491,10 @@ def extract_text_ocr(file_path=None, scale_up=None):

if scale_up:
w, h = img.size
img = img.resize((int(w*scale_up), int(h*scale_up)))
img = img.resize((int(w * scale_up), int(h * scale_up)))

data = image_to_data(img, output_type=Output.DICT)
return " ".join(data['text'])
return " ".join(data["text"])


@activity
Expand Down Expand Up @@ -9579,24 +9579,27 @@ def find_text_on_screen_ocr(text, criteria=None, scale_up=None):
img = Image.open(path)
if scale_up:
w, h = img.size
img = img.resize((int(w*scale_up), int(h*scale_up)))
img = img.resize((int(w * scale_up), int(h * scale_up)))
else:
scale_up = 1

d = image_to_data(img, output_type=Output.DICT)

idxs = [
idx
for idx, elem in enumerate(d['text'])
if elem == text and d['conf'][idx]
i for i, elem in enumerate(d["text"]) if elem == text and d["conf"][i]
]

matches = list(map(lambda i: {
"x": d['left'][i] / scale_up,
"y": d['top'][i] / scale_up,
"w": d['width'][i] / scale_up,
"h": d['height'][i] / scale_up
}, idxs))
matches = list(
map(
lambda i: {
"x": d["left"][i] / scale_up,
"y": d["top"][i] / scale_up,
"w": d["width"][i] / scale_up,
"h": d["height"][i] / scale_up,
},
idxs,
)
)

if not matches:
return None
Expand Down
1 change: 0 additions & 1 deletion automagica/flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,3 @@ def remove_dead_ends(self):
if hasattr(node, "loop_node"):
if node.loop_node not in uids:
node.loop_node = None

0 comments on commit b259206

Please sign in to comment.