示例#1
0
def webcam():
    if app.config["WEBCAM"]:
        from app.hardware import webcam as webcam_module
        for webcam_item in Webcam.get_active():
            if webcam_item.grow_session.is_day():
                filename = webcam_module.webcam_make_screenshot()
                # Upload screenshot
                hub.new_webcam_screenshot(filename)
                new_event("Made screenshot " + webcam_item.name)
                # Save screenshot in DB.
                image = Image.open(filename)
                db.session.add(WebcamScreenshot.new_webcam_screenshot(image, webcam_item))
                db.session.commit()
示例#2
0
def time_lapse():
    if app.config["WEBCAM"]:
        from app.hardware import webcam as webcam_module
        for webcam_item in Webcam.get_active():
            screenshots = db.session.query(WebcamScreenshot).order_by(WebcamScreenshot.timestamp).all()
            images = []
            for screenshot in screenshots:
                image = Image.frombytes('RGB', screenshot.get_size(), buffer(screenshot.file))
                images.append(image)
            time_lapse_filename = 'time_lapse.gif'
            writeGif(time_lapse_filename, images, duration=0.2)
            hub.new_webcam_gif(time_lapse_filename)
            new_event("Made Time Lapse")