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
评论列表
文章目录