-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient_run_model.py
More file actions
40 lines (25 loc) · 952 Bytes
/
client_run_model.py
File metadata and controls
40 lines (25 loc) · 952 Bytes
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
34
35
36
37
38
import socket
import dxcam
import cv2
from interception_controller import move_mouse
import constants
import numpy as np
import keyboard
FPS = 20
screen_capture = dxcam.create(output_idx=1)
screen_capture.start(target_fps=FPS)
client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
client_socket.connect(("10.0.0.28", 8080))
while not keyboard.is_pressed("ctrl + c"):
frame = screen_capture.get_latest_frame()
frame = cv2.resize(frame, (1920//5, 1080//5))
#frame = frame.reshape
send_data_bytes = frame.tobytes()
# print(len(databytes))
client_socket.sendall(send_data_bytes)
receive_data_bytes = b''
while len(receive_data_bytes) < 8:
receive_data_bytes += client_socket.recv(8 - len(receive_data_bytes))
recieved_mouse_movement = np.frombuffer(receive_data_bytes, dtype=np.int8)
move_mouse(recieved_mouse_movement[0], recieved_mouse_movement[1])
client_socket.close()