Imutils Videostream Returns Nonetype While Integrating With Flask
So i want to create a video stream using imutils VideoStream and put it on the web. This is the Code: camera_web.py from flask import Flask, render_template, Response from imutils.
Solution 1:
Alright, so i am the one who just dumb. The code should be like this:
camera_web.py
from flask import Flask, render_template, Response
from imutils.video import WebcamVideoStream
from imutils.video import FPS
import imutils
import time
import cv2
app = Flask(__name__)
@app.route('/')defindex():
""" Video streaming home page """return render_template('index.html')
defgen():
vs = WebcamVideoStream(src=1).start()
time.sleep(2.0)
whileTrue:
frame = vs.read()
frame = imutils.resize(frame, width=500)
rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
cv2.imwrite('t.jpg', frame)
yield (b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + open('t.jpg', 'rb').read() + b'\r\n')
@app.route('/video_feed')defvideo_feed():
return Response(gen(), mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
app.run(host='0.0.0.0', debug=True, port=80)
And there we go! we should now see the videostream. Link to the image
Post a Comment for "Imutils Videostream Returns Nonetype While Integrating With Flask"