Skip to content

Instantly share code, notes, and snippets.

@biggidvs
Last active July 17, 2020 18:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save biggidvs/4a1c78f5f8b999258165311b2bd409ff to your computer and use it in GitHub Desktop.
Save biggidvs/4a1c78f5f8b999258165311b2bd409ff to your computer and use it in GitHub Desktop.
from flask import Flask, render_template
import os
import time
import cv2
cam = cv2.VideoCapture(0)
img_folder = os.path.join('static', 'image_folder')
full_img = os.path.join(img_folder, 'bb1_img.jpg')
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = img_folder
TEMPLATES_AUTO_RELOAD = True
@app.route('/')
@app.route('/index')
def show_index():
while True:
# Capture frame
ret, frame = cam.read()
#img_name = "bb1_img.png"
img_name = full_img
cv2.imwrite(img_name, frame)
full_filename = os.path.join(app.config['UPLOAD_FOLDER'], 'bb1_img.jpg')
return render_template("index.html", user_image = full_filename)
app.run(host='0.0.0.0')
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
</head>
<body>
<img src="{{ user_image }}" alt="User Image">
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment