-
Notifications
You must be signed in to change notification settings - Fork 0
/
calibrate.py
33 lines (25 loc) · 1.13 KB
/
calibrate.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import time
from mss import mss
from utils import *
from constants import *
character = "all"
print("Testing detectors: {}".format(character))
wave_model = load_artifact("models\\{}_model.pkl".format(character))
wave_scaler = load_artifact("models\\{}_scaler.pkl".format(character))
drop_model = load_artifact("models\\drop_model.pkl")
drop_scaler = load_artifact("models\\drop_scaler.pkl")
with mss() as sct:
while "Screen capturing":
last_time = time.time()
wave = capture_wave(sct, WAVE_BOUNDARY)
height, width = wave.shape
wave_prediction = wave_model.predict(wave_scaler.transform([wave.reshape(height*width,)]))[0]
drop = capture_drop(sct, DROP_BOUNDARY)
height, width = drop.shape
drop_prediction = drop_model.predict(drop_scaler.transform([drop.reshape(height*width,)]))[0]
fps = round(1 / (time.time() - last_time))
print("WAVE 3 DETECTED: {} ; DROP DETECTED: {} ; FPS: {}".format(wave_prediction, drop_prediction, fps))
# Press "q" to quit
if cv2.waitKey(25) & 0xFF == ord("q"):
cv2.destroyAllWindows()
break