header('Access-Control-Allow-Origin: ' . $_SERVER['HTTP_ORIGIN']);
header('Access-Control-Allow-Credentials: true');
header('Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept');
header('Access-Control-Allow-Methods: GET, POST, OPTIONS');
header('Vary: Origin');
withCredentials=true
для AJAX-запросов. import numpy as np
import cv2
from mss import mss
from PIL import Image
import threading
from pygame import mixer
class MyMss():
def __init__(self,mss,mixer):
super(MyMss,self).__init__()
self.bounding_box = {'top': 100, 'left': 0, 'width': 400, 'height': 300}
self.mss = mss
self.mixer = mixer
def _grab(self):
while True:
sct_img = self.mss.grab(self.bounding_box)
cv2.imshow('screen', np.array(sct_img))
if (cv2.waitKey(1) & 0xFF) == ord('q'):
cv2.destroyAllWindows()
break
def start_grab(self):
thread = threading.Thread(target=self._grab)
thread.start()
def _music(self):
self.mixer.init()
self.mixer.music.load('fon.mp3')
self.mixer.music.play()
def play_music(self):
m_th = threading.Thread(target=self._music)
m_th.start()
sct = MyMss(mss(),mixer)
sct.start_grab()
sct.play_music()