import time
from typing import Any, Callable

from mower.utils import config
from mower.utils import typealias as tp

result = None


def start(func: Callable[[tp.Image], Any] = lambda _: None):
    if config.conf.screencap_strategy == "scrcpy":
        time.sleep(config.conf.screenshot_interval / 500)
    else:
        time.sleep(0.1)
    config.recog.update()
    global result
    result = func(config.recog.img)
