server.py 文件源码

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

项目:Vision2016 作者: Team3309 项目源码 文件源码
def update_socket(ws):
    print 'websocket connection request'
    state['draw_output'] = True
    while not ws.closed:
        new_data_condition.acquire()
        new_data_condition.wait()
        new_data_condition.release()
        result = {
            'targets': state['targets'],
            'fps': state['fps'],
            'connected': state['ack']
        }
        _, binframe = cv2.imencode('.jpg', state['output_images']['bin'])
        result['binaryImg'] = base64.b64encode(binframe)
        _, binframe = cv2.imencode('.jpg', state['output_images']['result'])
        result['resultImg'] = base64.b64encode(binframe)
        message = json.dumps(result)
        ws.send(message)
        received = json.loads(ws.receive())
        if 'thresholds' in received:
            config['target'] = received['thresholds']
            save_config(config)
        if 'camera' in received:
            config['camera'] = received['camera']
            save_config(config)

    print 'websocket disconnected'
    state['draw_output'] = False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号