def generate_frames():
capture = cv2.VideoCapture(-1)
while True:
bollean , frame = capture.read()
ret , buffer = cv2.imencode('.jpg',frame)
frame = buffer.tobytes()
yield (b'--frame
'
b'Content-Type: image/jpeg
' + frame + b'
')
@app.route('/video_feed')
def video_feed():
return Response(generate_frames(), mimetype='multipart/x-mixed-replace; boundary=frame')
<html>
<head>
<title>Video Streaming Demonstration</title>
</head>
<body>
<h1>Video Streaming Demonstration</h1>
<img src="{{ url_for('video_feed') }}">
</body>
</html>