Compare commits
No commits in common. "c2fb041285c912121188ac4806d15855e1868e7f" and "93a01b792bf2480232a0717bd12559d215f28f24" have entirely different histories.
c2fb041285
...
93a01b792b
@ -5,9 +5,6 @@ import time, io, base64
|
||||
import sys
|
||||
from objects.inputs import MouseInput, KeyboardInput, ButtonType
|
||||
from PIL import ImageGrab, ImageDraw # type: ignore
|
||||
from objects import logger as logger_module
|
||||
import logging
|
||||
logger: logging.Logger = logger_module.get_logger(__name__)
|
||||
|
||||
def take_screenshot(cross_position: list[tuple[int, int]] | None = None) -> bytes:
|
||||
"""Take a screenshot of the current screen and return it as bytes."""
|
||||
@ -50,25 +47,6 @@ def perform_ocr(screenshot: bytes) -> list[dict]:
|
||||
'x': data['width'][i] + data['left'][i] // 2, # center x position
|
||||
'y': data['height'][i] + data['top'][i] // 2 # center y position
|
||||
})
|
||||
|
||||
# check if debug is enabled
|
||||
if logging.getLogger().isEnabledFor(logging.DEBUG):
|
||||
# take screenshot + put blue circle with x, y on screenshot for each component
|
||||
screenshot_with_circles = Image.open(io.BytesIO(screenshot))
|
||||
draw = ImageDraw.Draw(screenshot_with_circles)
|
||||
for result in results:
|
||||
x, y = result['x'], result['y']
|
||||
size = 10
|
||||
color = (0, 0, 255) # blue
|
||||
width = 2
|
||||
# horizontal line
|
||||
draw.line((x - size, y, x + size, y), fill=color, width=width)
|
||||
# vertical line
|
||||
draw.line((x, y - size, x, y + size), fill=color, width=width)
|
||||
screenshot_with_circles.save("screenshot_with_circles.png", format='PNG')
|
||||
# save in a file
|
||||
logger.debug("Debug, saving ocr results screenshot with circles")
|
||||
screenshot_with_circles.save("ocr_results.png", format='PNG')
|
||||
return results
|
||||
|
||||
def screenshot_to_base64(screenshot: bytes) -> str:
|
||||
|
@ -91,7 +91,7 @@ class AIProcessor:
|
||||
cps = [
|
||||
aic.Message(
|
||||
role=msg.role,
|
||||
content=msg.content[:80],
|
||||
content=msg.content,
|
||||
image=msg.image[:20] if isinstance(msg.image, str) else None, # type: ignore
|
||||
disable_image=msg.disable_image,
|
||||
name=msg.name,
|
||||
|
Loading…
Reference in New Issue
Block a user