Skip to content

Commit f819285

Browse files
authored
[BugFix] Move Pointer To $destination In $domain doesn't work (#32)
Signed-off-by: Douglas Chiang <[email protected]>
1 parent c1acaca commit f819285

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

yarf/rf_libraries/libraries/ocr/rapidocr.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def read(self, image: Image.Image | Path) -> str:
6969
Returns:
7070
Text found in image.
7171
"""
72-
image = to_image(image)
72+
image = to_image(image) # type: ignore[assignment]
7373
result, _ = self.reader(np.array(image))
7474

7575
if not result:
@@ -105,7 +105,7 @@ def find(
105105
"""
106106
image_obj = to_image(image)
107107
if region is not None:
108-
image_obj = image_obj.crop(region.as_tuple())
108+
image_obj = image_obj.crop(region.as_tuple()) # type: ignore[union-attr]
109109

110110
text = text.strip()
111111
if not text:

yarf/rf_libraries/libraries/video_input_base.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ async def match_text(
330330
)
331331

332332
text_matches = await self.find_text(
333-
text, image=cropped_image, region=region
333+
text, image=image, region=region
334334
)
335335
if text_matches:
336336
return text_matches, cropped_image
@@ -475,9 +475,7 @@ async def _do_match(
475475
if region:
476476
adjusted_regions = []
477477
for reg in regions:
478-
adjusted_regions.append(
479-
reg.move(region.left, region.top)
480-
)
478+
adjusted_regions.append(reg)
481479
regions = adjusted_regions
482480
except (ValueError, ImageNotFoundError):
483481
# If we're performing match_all, and we fail to match any

yarf/rf_libraries/resources/kvm.resource

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ Documentation Keyword definitions for specialised functionality
66
... using the PlatformVideoInput.Init keyword. The initialization is
77
... platform-specific.
88
9+
Library Collections
910
Library Hid.py AS PlatformHid
1011
Library VideoInput.py AS PlatformVideoInput
1112
Variables video_input_vars.py
@@ -148,12 +149,13 @@ Move Pointer To ${destination} In ${domain}
148149
... Return:
149150
... Absolute position of the pointer after the move, as a tuple (x, y)
150151
... of integers.
151-
IF ${{ isinstance(domain, dict) }}
152-
${sub_region}= Set Variable ${domain}
153-
ELSE IF ${{ isinstance(domain, str) }}
152+
IF ${{ isinstance($domain, dict) }}
153+
${target_region}= Set Variable ${domain}
154+
ELSE IF ${{ isinstance($domain, str) }}
154155
IF ${{ os.path.exists($domain) }}
155156
${sub_regions}= PlatformVideoInput.Match ${domain}
156-
${sub_region}= Set Variable ${sub_regions}[0]
157+
${target_region}= Set Variable ${sub_regions}[0]
158+
Remove From Dictionary ${target_region} path
157159
ELSE
158160
Fail Template ${domain} doesn't exist!
159161
END
@@ -164,12 +166,12 @@ Move Pointer To ${destination} In ${domain}
164166
IF ${{ os.path.exists($destination) }}
165167
${regions}= PlatformVideoInput.Match
166168
... template=${destination}
167-
... region=${sub_region}
169+
... region=${target_region}
168170
${position}= Get Center Of ${regions}[0]
169171
ELSE
170172
${position}= PlatformVideoInput.Get Text Position
171173
... text=${destination}
172-
... region=${sub_region}
174+
... region=${target_region}
173175
END
174176

175177
PlatformHid.Move Pointer To Absolute ${position}[0] ${position}[1]

0 commit comments

Comments
 (0)