/processed now returns a stream instead of a single picture

This commit is contained in:
Patrice 2019-06-10 20:30:37 +02:00
parent 6ed5ff1046
commit 5a42fd5770
1 changed files with 10 additions and 2 deletions

View File

@ -42,6 +42,13 @@ def gen(camera):
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
def gen_processed(num):
"""Video streaming generator function."""
while True:
frame = cv2.imencode('.jpg', lastImages[int(num)])[1].tobytes()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
######### ###########
### Core ###
######### ###########
@ -112,8 +119,9 @@ def cam_stream(num):
@application.route('/cam/<num>/processed')
def cam_stream_processed(num):
frame = cv2.imencode('.jpg', lastImages[int(num)])[1]
return send_file(io.BytesIO(frame), mimetype='image/jpeg')
#frame = cv2.imencode('.jpg', lastImages[int(num)])[1]
#return send_file(io.BytesIO(frame), mimetype='image/jpeg')
return Response(gen_processed(num), mimetype='multipart/x-mixed-replace; boundary=frame')
######### ###########