在 Flask 中的 cv2 视频流后重定向到页面

时间:2021-05-20 20:12:19

标签: python-3.x flask cv2 opencv-python

我有一个使用 cv2 和 Flask 的视频流代码。我设置了一个特定的时间来停止流媒体。如果达到设定的时间,我想使用“e_list”变量从流媒体页面重定向到“结果”页面。这是我的代码

app = Flask(__name__)

video = cv2.VideoCapture(0)


@app.route('/')
def index():
    return "Default Message"


def gen():
    s_time = time.time() + 30
    e_list = list()
    while time.time() < s_time:
        success, image = video.read()
        out, label = VideoCamera(success, image) # Do the required process
        print("Emotion : ", label)
        e_list.append(label)
        yield b'--frame\r\n'b'Content-Type: image/jpeg\r\n\r\n' + out + b'\r\n\r\n'
        # Take the count of emotions and insert to db
    video.release()
    cv2.destroyAllWindows()


@app.route('/video_feed')
def video_feed():
    return Response(gen(), mimetype='multipart/x-mixed-replace; boundary=frame')


@app.route('/result')
def result():
    return render_template("result.html")

0 个答案:

没有答案
相关问题