controller_boxes.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:ATLeS 作者: liffiton 项目源码 文件源码
def get_image(tgtbox, boxes_rpc, width=648):
    box = _get_box_rpc(tgtbox, boxes_rpc)

    if box.lock_exists():
        # must yield then return in a generator function
        yield template('error', errormsg="It looks like an experiment is currently running on this box.  Image capture only works while the box is idle.")
        return

    try:
        try:
            box.start_img_stream(width)
        except OSError as e:
            # must yield then return in a generator function
            yield template('error', errormsg="Failed to start image stream capture.", exception=e)
            return

        # all set; carry on
        response.set_header('Content-type', 'multipart/x-mixed-replace; boundary=atlesframe')
        while True:
            if box.lock_exists():
                return
            time.sleep(0.5)
            imgdata = box.get_image()
            if imgdata is None:
                return
            if len(imgdata) < 16:
                continue  # ignore dud frames
            yield b"\n".join([b"--atlesframe", b"Content-Type: image/jpeg", b"", imgdata, b""])
    finally:
        box.stop_img_stream()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号