Up to date

This commit is contained in:
cubernetes 2023-08-11 16:38:54 +02:00
parent a86cc5e4f6
commit fd02dd21d4
2 changed files with 26 additions and 4 deletions

24
game.py
View File

@ -3,6 +3,7 @@
import sys import sys
import random import random
from time import sleep
import numpy as np import numpy as np
import cv2 import cv2
import requests import requests
@ -100,14 +101,27 @@ def show_frame(frame: np.ndarray, to_stdout: bool=False) -> None:
cv2.imshow("Image", frame) cv2.imshow("Image", frame)
cv2.waitKey(1) cv2.waitKey(1)
def collect_vfx() -> None:
requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/5/connect')
sleep(1)
requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/7/connect')
def die_vfx() -> None:
requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/6/connect')
sleep(3)
requests.post('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/7/connect')
def green() -> None: def green() -> None:
threading.Thread(target=requests.get, args=('http://10.11.250.225:8080/api/v1/composition/layers/2/clips/5/connect')).start() threading.Thread(target=collect_vfx).start()
def die() -> None:
threading.Thread(target=die_vfx).start()
def main() -> int: def main() -> int:
music = start_game_sfx() music = start_game_sfx()
capture: cv2.VideoCapture = cv2.VideoCapture(0) capture: cv2.VideoCapture = cv2.VideoCapture(0)
hands: mp.solutions.hands.Hands = mp_hands.Hands(max_num_hands=2) hands: mp.solutions.hands.Hands = mp_hands.Hands(max_num_hands=3)
collected_42: bool = True collected_42: bool = True
noise_42img: int = 5 noise_42img: int = 5
img42_x: int = -img42_side_len - 1 - noise_42img img42_x: int = -img42_side_len - 1 - noise_42img
@ -118,7 +132,7 @@ def main() -> int:
finger_y: int = -1 finger_y: int = -1
no_collect_ratio = 0 no_collect_ratio = 0
no_finger_ratio = 0 no_finger_ratio = 0
timer = 1000 timer = 200
i: int = 0 i: int = 0
while True: while True:
@ -156,8 +170,10 @@ def main() -> int:
no_fingers = 0 no_fingers = 0
if ratio > 0.99: if ratio > 0.99:
music.kill() if music:
music.kill()
lost_sfx() lost_sfx()
die()
return score return score
for positions in finger_positions: for positions in finger_positions:

View File

@ -1,10 +1,13 @@
absl-py==1.4.0 absl-py==1.4.0
attrs==23.1.0 attrs==23.1.0
certifi==2023.7.22
cffi==1.15.1 cffi==1.15.1
charset-normalizer==3.2.0
contourpy==1.1.0 contourpy==1.1.0
cycler==0.11.0 cycler==0.11.0
flatbuffers==23.5.26 flatbuffers==23.5.26
fonttools==4.42.0 fonttools==4.42.0
idna==3.4
kiwisolver==1.4.4 kiwisolver==1.4.4
matplotlib==3.7.2 matplotlib==3.7.2
mediapipe==0.10.3 mediapipe==0.10.3
@ -20,5 +23,8 @@ pycparser==2.21
PyGObject==3.44.1 PyGObject==3.44.1
pyparsing==3.0.9 pyparsing==3.0.9
python-dateutil==2.8.2 python-dateutil==2.8.2
requests==2.31.0
six==1.16.0 six==1.16.0
sounddevice==0.4.6 sounddevice==0.4.6
soundfile==0.12.1
urllib3==2.0.4