Skip to content

Instantly share code, notes, and snippets.

@juliussin
Last active December 2, 2020 04:57
Show Gist options
  • Save juliussin/0ff9f6b1a47f9043ed42857f648d3d99 to your computer and use it in GitHub Desktop.
Save juliussin/0ff9f6b1a47f9043ed42857f648d3d99 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
from WebcamVideoStream import WebcamVideoStream
import cv2
import time
from flask import Flask, render_template, Response
app = Flask(__name__)
first_flag = True
vs = None
@app.route('/')
def index():
return render_template('index.php')
# return render_template('index.html')
def gen():
global vs
count = 1
while True:
frame = vs.readDetections()
count = count+1
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n')
time.sleep(0.03)
@app.route('/video_feed')
def video_feed():
global first_flag, vs
if first_flag:
vs = WebcamVideoStream().start()
first_flag = False
return Response(gen(),
mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == '__main__':
app.run(host='192.168.3.106', port=8000, debug=True)
# app.run(host='0.0.0.0', debug=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment