From 606a0854d6faad21888ab07480aea64f691c73f0 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 3 Feb 2021 18:58:46 +0800 Subject: [PATCH] bugfix --- kivyblocks/camerawithmic.py | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/kivyblocks/camerawithmic.py b/kivyblocks/camerawithmic.py index 701f459..7d2dc71 100644 --- a/kivyblocks/camerawithmic.py +++ b/kivyblocks/camerawithmic.py @@ -1,30 +1,31 @@ import kivy -from PIL import ImageGrab import numpy as np from .micphone import Micphone from kivy.uix.camera import Camera from kivy.properties import NumericProperty from kivy.event import EventDispatcher -class ScreenWithMic(Micphone, EventDispatcher): - def __init__(self, **kw): - super(ScreenWithMic, self).__init__(**kw) +if kivy.platform in [ 'win', 'linux', 'macosx' ]: + from PIL import ImageGrab + class ScreenWithMic(Micphone, EventDispatcher): + def __init__(self, **kw): + super(ScreenWithMic, self).__init__(**kw) - def get_image_data(self): - image = ImageGrab.grab() - imgdata = image.tostring() - return imgdata - - def get_fps_data(self, *args): - ad = super(CameraWithMic, self).get_fps_data() - vd = self.get_image_data() - d = { - 'v':vd, - 'a':ad - } - return d - + def get_image_data(self): + image = ImageGrab.grab() + imgdata = image.tostring() + return imgdata + + def get_fps_data(self, *args): + ad = super(CameraWithMic, self).get_fps_data() + vd = self.get_image_data() + d = { + 'v':vd, + 'a':ad + } + return d + class CameraWithMic(Micphone, Camera): angle = NumericProperty(0) def __init__(self, **kw):