def gen():
r = redis.StrictRedis(host=REDIS_HOST, port=REDIS_PORT, db=REDIS_DB, password=PASS_WORD)
while True:
try:
# print(r.get('pic_path').decode())
img = cv2.imread(r.get('realtime_frame').decode(), 1)
# img = cv2.imread("static/result.png", 1)
ret, jpeg = cv2.imencode('.jpg', img)
frame = jpeg.tobytes()
# frame = {'file': open(r.get('pic_path'), 'rb')}
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
except:
pass
@bp.route('/video_feed')
def video_feed():
return Response(gen(), mimetype='multipart/x-mixed-replace; boundary=frame')
标签:web,img,get,flask,REDIS,frame,cv2,jpeg,播放
From: https://www.cnblogs.com/bitterteaer/p/17129424.html