This commit is contained in:
yumoqing 2021-02-03 18:58:46 +08:00
parent ac8b3969cb
commit 606a0854d6

View File

@ -1,29 +1,30 @@
import kivy import kivy
from PIL import ImageGrab
import numpy as np import numpy as np
from .micphone import Micphone from .micphone import Micphone
from kivy.uix.camera import Camera from kivy.uix.camera import Camera
from kivy.properties import NumericProperty from kivy.properties import NumericProperty
from kivy.event import EventDispatcher from kivy.event import EventDispatcher
class ScreenWithMic(Micphone, EventDispatcher): if kivy.platform in [ 'win', 'linux', 'macosx' ]:
def __init__(self, **kw): from PIL import ImageGrab
super(ScreenWithMic, self).__init__(**kw) class ScreenWithMic(Micphone, EventDispatcher):
def __init__(self, **kw):
super(ScreenWithMic, self).__init__(**kw)
def get_image_data(self): def get_image_data(self):
image = ImageGrab.grab() image = ImageGrab.grab()
imgdata = image.tostring() imgdata = image.tostring()
return imgdata return imgdata
def get_fps_data(self, *args): def get_fps_data(self, *args):
ad = super(CameraWithMic, self).get_fps_data() ad = super(CameraWithMic, self).get_fps_data()
vd = self.get_image_data() vd = self.get_image_data()
d = { d = {
'v':vd, 'v':vd,
'a':ad 'a':ad
} }
return d return d
class CameraWithMic(Micphone, Camera): class CameraWithMic(Micphone, Camera):
angle = NumericProperty(0) angle = NumericProperty(0)