-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
36 lines (26 loc) · 820 Bytes
/
main.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
34
35
36
import mss
import cv2
from PIL import Image, ImageStat
import udpclient
import numpy as np
import time
def screenshot():
# Capture entire screen
with mss.mss() as sct:
monitor = sct.monitors[1]
img = sct.grab(monitor)
img = cv2.resize(np.array(img), (128, 72))
img = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
img = Image.fromarray(img)
return img
def send_color(RGB_array, FPS):
udpclient.send_RGB_string(int(round(RGB_array[0])), int(round(RGB_array[1])), int(round(RGB_array[2])))
time.sleep(1 / FPS*2)
# screenshot().show()
# update_flag = 0
while 1:
if True: # udpclient.incoming('N'):
avg_color = ImageStat.Stat(screenshot()).mean
send_color(avg_color, 144)
# print(avg_color, update_flag)
# update_flag += 1