In Flask, I would like to stop video streaming, in order to perform another task (to redirect to main page). But instead, when streaming stops, the screen freezes to the last frame.
Here is my code:
def gen_temporary(cam):
counter_frames=0
while counter_frames<100:
frame = cam.get_frame()
counter_frames+=1
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
yield redirect('/mainPage')
@app.route('/video_capture')
def video_capture():
return Response(gen_temporary(VideoCamera()),
mimetype='multipart/x-mixed-replace; boundary=frame')