AutoKachalka/debug_snapshot.py
MasterAkulon 7fa101820a Init
2026-06-13 12:19:38 +03:00

57 lines
No EOL
2.1 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"""Однократный снимок экрана с отрисовкой найденной шкалы, целевой зоны и курсора.
Запускать, когда мини-игра видна на экране - результат сохраняется в debug_snapshot.png."""
from time import sleep
import cv2
import vision
from capture import ScreenCapture
def main():
cap = ScreenCapture()
print(f"Захват экрана: {cap.backend}")
frame = cap.grab()
if frame is None:
print("Не удалось получить кадр.")
if cap.backend == "mss":
print("mss обычно не видит эксклюзивный полноэкранный режим.")
print("Установите bettercam (pip install bettercam) или переключите игру в borderless.")
return
out = frame.copy()
bar = vision.locate_bar(frame)
if bar is None:
print("Шкала не найдена. Откройте мини-игру на экране и запустите снова,")
print("либо подправьте пороги BLUE_* в config.py.")
cv2.imwrite("debug_full.png", out)
print("Сохранён полный кадр: debug_full.png")
return
bx, by, bw, bh = bar
print(f"Шкала: x={bx}, y={by}, w={bw}, h={bh}")
cv2.rectangle(out, (bx, by), (bx + bw, by + bh), (255, 0, 0), 2)
zone = vision.find_target_zone(frame, bar)
if zone:
zx0, zx1 = zone
print(f"Узкая (целевая) зона: x от {zx0} до {zx1}")
cv2.rectangle(out, (zx0, by), (zx1, by + bh), (0, 0, 255), 2)
else:
print("Целевая зона не найдена.")
cursor_x = vision.locate_cursor(frame, bar)
if cursor_x is not None:
print(f"Курсор: x = {cursor_x:.1f}")
cv2.line(out, (int(cursor_x), by - 5), (int(cursor_x), by + bh + 5), (255, 0, 255), 2)
else:
print("Курсор не найден.")
cv2.imwrite("debug_snapshot.png", out)
print("Сохранён debug_snapshot.png")
if __name__ == "__main__":
sleep(5)
main()