37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
import cv2
|
|
import pyautogui
|
|
import mss
|
|
import justserv
|
|
from PIL import Image
|
|
import time
|
|
import base64
|
|
import platform
|
|
import numpy as np
|
|
|
|
width, height= pyautogui.size()
|
|
mon = {'left': -10, 'top': -10, 'width': width, 'height': height}
|
|
server = input("ziel name eingeben! ")
|
|
stateobj = justserv.client.OnlineState("stream"+server)
|
|
cv2.startWindowThread()
|
|
while True:
|
|
with mss.mss() as sct:
|
|
screenShot = sct.grab(mon)
|
|
screenShot2 = np.array(screenShot)
|
|
if platform.system() != "Darwin":
|
|
screenShot2 = cv2.cvtColor(screenShot2, cv2.COLOR_BGR2RGB)
|
|
screenShot2 = Image.frombytes(
|
|
'RGB',
|
|
(screenShot.width, screenShot.height),
|
|
screenShot.rgb,
|
|
)
|
|
screenShot2.save("test.png")
|
|
screenShot = open("test.png", "rb")
|
|
#im = cv2.imread("test.png")
|
|
#im = cv2.resize(im, pyautogui.size())
|
|
#cv2.imshow('screen', np.array(im))
|
|
#cv2.waitKey(1)
|
|
screenShot = screenShot.read()
|
|
screenShot = base64.b64encode(screenShot)
|
|
state = {}
|
|
state["mainstream"] = screenShot
|
|
stateobj.patch(state) |