From 780a41364ba526bd93a7518ffa44fcc073785e50 Mon Sep 17 00:00:00 2001 From: Lincoln-LM Date: Mon, 27 Dec 2021 02:43:40 -0700 Subject: [PATCH] manual reidentification --- src/rngtool.py | 40 ++++++++++++++++++++++------------------ src/wild_manual.py | 38 +++++++++++++++++++++++++++++++++----- 2 files changed, 55 insertions(+), 23 deletions(-) diff --git a/src/rngtool.py b/src/rngtool.py index f17dc12..9e0a417 100644 --- a/src/rngtool.py +++ b/src/rngtool.py @@ -102,39 +102,43 @@ def tracking_blink(img, roi_x, roi_y, roi_w, roi_h, th = 0.9, size = 40, sysdvr cv2.destroyAllWindows() return (blinks, intervals, offset_time) -def tracking_blink_manual(size = 40)->Tuple[List[int],List[int],float]: +def tracking_blink_manual(size = 40, reidentify = False)->Tuple[List[int],List[int],float]: """measuring the type and interval of player's blinks Returns: blinks:List[int],intervals:list[int],offset_time:float: [description] """ - state = IDLE blinks = [] intervals = [] prev_time = 0 - offset_time = 0 + while len(blinks)> 64, t0 & 0xFFFFFFFF, t1 >> 64, t1 & 0xFFFFFFFF] + + observed_blinks, _, offset_time = rngtool.tracking_blink_manual(size = 20, reidentify=True) + reidentified_rng = rngtool.reidentifyByBlinks(Xorshift(*state), observed_blinks) + + waituntil = time.perf_counter() + diff = round(waituntil-offset_time)+1 + reidentified_rng.getNextRandSequence(diff) + + state = reidentified_rng.getState() + print(hex(state[0]<<32|state[1]), hex(state[2]<<32|state[3])) + + advances = 0 + + while True: + advances += 1 + r = reidentified_rng.next() + + waituntil += 1.018 + + print(f"advances:{advances}, blinks:{hex(r&0xF)}") + + next_time = waituntil - time.perf_counter() or 0 + time.sleep(next_time) + def expr(): - player_eye = cv2.imread(config["image"], cv2.IMREAD_GRAYSCALE) - if player_eye is None: - print("path is wrong") - return blinks, intervals, offset_time = rngtool.tracking_blink_manual() prng = rngtool.recov(blinks, intervals) @@ -34,4 +59,7 @@ def expr(): if __name__ == "__main__": - expr() \ No newline at end of file + if input("Find State or Reidentify? (S/R): ") == "R": + reidentify() + else: + expr() \ No newline at end of file