From 5e42f324b8dde78798dd4ad52b2162b7222a5cd9 Mon Sep 17 00:00:00 2001 From: Lincoln-LM Date: Wed, 29 Dec 2021 07:17:33 -0700 Subject: [PATCH] window monitor --- config.json | 3 ++- config_cave.json | 3 ++- config_munchlax.json | 3 ++- config_unown.json | 3 ++- config_wild.json | 3 ++- src/position.py | 4 ++-- src/rngtool.py | 12 ++++++------ src/tidsid.py | 2 +- src/wild.py | 4 ++-- src/windowcapture.py | 2 +- 10 files changed, 22 insertions(+), 17 deletions(-) diff --git a/config.json b/config.json index 5e2394d..d02640f 100644 --- a/config.json +++ b/config.json @@ -1,5 +1,6 @@ { - "SysDVR": true, + "MonitorWindow": true, + "WindowPrefix": "SysDVR-Client [PID ", "image": "./munchlax/eye.png", "view": [470, 430, 50, 60], "reidentify": "" diff --git a/config_cave.json b/config_cave.json index 65a217a..9dcee9a 100644 --- a/config_cave.json +++ b/config_cave.json @@ -1,5 +1,6 @@ { - "SysDVR": true, + "MonitorWindow": true, + "WindowPrefix": "SysDVR-Client [PID ", "image": "./trainer/cave/eye.png", "view": [610, 330, 30, 30], "reidentify": "0x37a35d28 0x488e6831 0xb7f56519 0x79a3b387" diff --git a/config_munchlax.json b/config_munchlax.json index 5e2394d..d02640f 100644 --- a/config_munchlax.json +++ b/config_munchlax.json @@ -1,5 +1,6 @@ { - "SysDVR": true, + "MonitorWindow": true, + "WindowPrefix": "SysDVR-Client [PID ", "image": "./munchlax/eye.png", "view": [470, 430, 50, 60], "reidentify": "" diff --git a/config_unown.json b/config_unown.json index 339ae18..c5d6d81 100644 --- a/config_unown.json +++ b/config_unown.json @@ -1,5 +1,6 @@ { - "SysDVR": true, + "MonitorWindow": true, + "WindowPrefix": "SysDVR-Client [PID ", "image": "./trainer/ruins/eye.png", "view": [610, 330, 30, 30], "reidentify": "" diff --git a/config_wild.json b/config_wild.json index 339ae18..c5d6d81 100644 --- a/config_wild.json +++ b/config_wild.json @@ -1,5 +1,6 @@ { - "SysDVR": true, + "MonitorWindow": true, + "WindowPrefix": "SysDVR-Client [PID ", "image": "./trainer/ruins/eye.png", "view": [610, 330, 30, 30], "reidentify": "" diff --git a/src/position.py b/src/position.py index f69d1e5..0e8a6ee 100644 --- a/src/position.py +++ b/src/position.py @@ -4,9 +4,9 @@ import json config = json.load(open("config.json")) -if config["SysDVR"]: +if config["MonitorWindow"]: from windowcapture import WindowCapture - video = WindowCapture("SysDVR-Client [PID ") + video = WindowCapture(config["WindowPrefix"]) else: video = cv2.VideoCapture(0,cv2.CAP_DSHOW) video.set(cv2.CAP_PROP_FRAME_WIDTH,1920) diff --git a/src/rngtool.py b/src/rngtool.py index 8c7d051..554d950 100644 --- a/src/rngtool.py +++ b/src/rngtool.py @@ -16,7 +16,7 @@ def randrange(r,mi,ma): t = (r & 0x7fffff) / 8388607.0 return t * mi + (1.0 - t) * ma -def tracking_blink(img, roi_x, roi_y, roi_w, roi_h, th = 0.9, size = 40, sysdvr = False)->Tuple[List[int],List[int],float]: +def tracking_blink(img, roi_x, roi_y, roi_w, roi_h, th = 0.9, size = 40, MonitorWindow = False, WindowPrefix = "SysDVR-Client [PID ")->Tuple[List[int],List[int],float]: """measuring the type and interval of player's blinks Returns: @@ -25,9 +25,9 @@ def tracking_blink(img, roi_x, roi_y, roi_w, roi_h, th = 0.9, size = 40, sysdvr eye = img - if sysdvr: + if MonitorWindow: from windowcapture import WindowCapture - video = WindowCapture("SysDVR-Client [PID ") + video = WindowCapture(WindowPrefix) else: video = cv2.VideoCapture(0,cv2.CAP_DSHOW) video.set(cv2.CAP_PROP_FRAME_WIDTH,1920) @@ -143,7 +143,7 @@ def tracking_blink_manual(size = 40, reidentify = False)->Tuple[List[int],List[i return (blinks, intervals, offset_time) -def tracking_poke_blink(img, roi_x, roi_y, roi_w, roi_h, size = 60, sysdvr = False)->Tuple[List[int],List[int],float]: +def tracking_poke_blink(img, roi_x, roi_y, roi_w, roi_h, size = 60, MonitorWindow = False, WindowPrefix = "SysDVR-Client [PID ")->Tuple[List[int],List[int],float]: """measuring the type and interval of pokemon's blinks Returns: @@ -152,9 +152,9 @@ def tracking_poke_blink(img, roi_x, roi_y, roi_w, roi_h, size = 60, sysdvr = Fal eye = img - if sysdvr: + if MonitorWindow: from windowcapture import WindowCapture - video = WindowCapture("SysDVR-Client [PID ") + video = WindowCapture(WindowPrefix) else: video = cv2.VideoCapture(0,cv2.CAP_DSHOW) video.set(cv2.CAP_PROP_FRAME_WIDTH,1920) diff --git a/src/tidsid.py b/src/tidsid.py index 0c4215f..e42a6e6 100644 --- a/src/tidsid.py +++ b/src/tidsid.py @@ -32,7 +32,7 @@ def expr(): if munch_eye is None: print("path is wrong") return - gombe_intervals = rngtool.tracking_poke_blink(munch_eye, *config["view"], size=60, sysdvr=config["SysDVR"]) + gombe_intervals = rngtool.tracking_poke_blink(munch_eye, *config["view"], size=60, MonitorWindow=config["MonitorWindow"], WindowPrefix=config["WindowPrefix"]) interval_prng = rngtool.recovByMunchlax(gombe_intervals) state = interval_prng.getState() diff --git a/src/wild.py b/src/wild.py index 89c7c32..8d2e570 100644 --- a/src/wild.py +++ b/src/wild.py @@ -11,7 +11,7 @@ def expr(): if player_eye is None: print("path is wrong") return - blinks, intervals, offset_time = rngtool.tracking_blink(player_eye, *config["view"], sysdvr=config["SysDVR"]) + blinks, intervals, offset_time = rngtool.tracking_blink(player_eye, *config["view"], MonitorWindow=config["MonitorWindow"], WindowPrefix=config["WindowPrefix"]) prng = rngtool.recov(blinks, intervals) waituntil = time.perf_counter() @@ -43,7 +43,7 @@ def reidentify(): print("path is wrong") return - observed_blinks, _, offset_time = rngtool.tracking_blink(player_eye, *config["view"], sysdvr=config["SysDVR"], size=20) + observed_blinks, _, offset_time = rngtool.tracking_blink(player_eye, *config["view"], MonitorWindow=config["MonitorWindow"], WindowPrefix=config["WindowPrefix"], size=20) reidentified_rng = rngtool.reidentifyByBlinks(Xorshift(*state), observed_blinks) waituntil = time.perf_counter() diff --git a/src/windowcapture.py b/src/windowcapture.py index 3b88e7f..128b4bc 100644 --- a/src/windowcapture.py +++ b/src/windowcapture.py @@ -13,7 +13,7 @@ class WindowCapture: self.offset_x = 0 self.offset_y = 0 - # a string contained in the window title, used to find windows who's name is not constant (pid of sysdvr changes) + # a string contained in the window title, used to find windows who's name is not constant (pid of MonitorWindow changes) self.partial_window_title = partial_window_title # find the handle for the window we want to capture hwnds = []