update tidsid

This commit is contained in:
Lincoln-LM 2021-12-27 01:31:20 -07:00
parent 0046df2467
commit 9142643dbf
6 changed files with 33 additions and 7 deletions

View File

@ -1,5 +1,5 @@
{
"SysDVR": true,
"image": "./trainer/cave/eye.png",
"view": [620, 340, 20, 20]
"image": "./munchlax/eye.png",
"view": [470, 430, 50, 60]
}

5
config_cave.json Normal file
View File

@ -0,0 +1,5 @@
{
"SysDVR": true,
"image": "./trainer/cave/eye.png",
"view": [620, 340, 20, 20]
}

5
config_munchlax.json Normal file
View File

@ -0,0 +1,5 @@
{
"SysDVR": true,
"image": "./munchlax/eye.png",
"view": [470, 430, 50, 60]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -163,6 +163,7 @@ def tracking_poke_blink(img, roi_x, roi_y, roi_w, roi_h, size = 60, sysdvr = Fal
intervals = []
prev_roi = None
prev_time = time.perf_counter()
w, h = eye.shape[::-1]
# 瞬きの観測
@ -176,19 +177,30 @@ def tracking_poke_blink(img, roi_x, roi_y, roi_w, roi_h, size = 60, sysdvr = Fal
prev_roi = roi
res = cv2.matchTemplate(roi,eye,cv2.TM_CCOEFF_NORMED)
_, match, _, _ = cv2.minMaxLoc(res)
_, match, _, max_loc = cv2.minMaxLoc(res)
if 0.4<match<0.85:
cv2.rectangle(frame,(roi_x,roi_y), (roi_x+roi_w,roi_y+roi_h), 255, 2)
if state==IDLE:
interval = (time_counter - prev_time)
print(interval)
intervals.append(interval)
print(f"Intervals {len(intervals)}/{size}")
state = SINGLE
prev_time = time_counter
elif state==SINGLE:
pass
else:
max_loc = (max_loc[0] + roi_x,max_loc[1] + roi_y)
bottom_right = (max_loc[0] + w, max_loc[1] + h)
cv2.rectangle(frame,max_loc, bottom_right, 255, 2)
if state!=IDLE and time_counter - prev_time>0.7:
state = IDLE
cv2.imshow("view", frame)
keypress = cv2.waitKey(1)
if keypress == ord('q'):
cv2.destroyAllWindows()
exit()
cv2.destroyAllWindows()
video.release()
return intervals

View File

@ -2,8 +2,11 @@ import rngtool
import calc
import cv2
import time
import json
from xorshift import Xorshift
config = json.load(open("config.json"))
def randrange(r,mi,ma):
t = (r & 0x7fffff) / 8388607.0
return t * mi + (1.0 - t) * ma
@ -25,15 +28,14 @@ def generate_dangerintervals_list(k):
print(lst[::-1])
def expr():
munch_eye = cv2.imread("./munchlax/eye.png", cv2.IMREAD_GRAYSCALE)
munch_eye = cv2.imread(config["image"], cv2.IMREAD_GRAYSCALE)
if munch_eye is None:
print("path is wrong")
return
gombe_intervals = rngtool.tracking_poke_blink(munch_eye, 730, 670, 50, 60)
gombe_intervals = rngtool.tracking_poke_blink(munch_eye, *config["view"], size=60, sysdvr=config["SysDVR"])
interval_prng = rngtool.recovByMunchlax(gombe_intervals)
state = interval_prng.getState()
print(hex(state[0]<<32|state[1]), hex(state[2]<<32|state[3]))
#timecounter reset
advances = 0
@ -41,6 +43,8 @@ def expr():
id_prng.getNextRandSequence(1)
waituntil = time.perf_counter()
ts = time.time()
print(hex(state[0]<<32|state[1]), hex(state[2]<<32|state[3]), ts)
#ID予測開始
while True:
advances += 1