-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
60 lines (48 loc) · 1.77 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Author : linjie
from flask import Flask, render_template, Response, request, session, redirect, url_for, send_from_directory, flash
from werkzeug.utils import secure_filename
from detect import *
import os
import torch
from importlib import import_module
from datetime import datetime
port = int(os.environ.get('PORT', 5000))
# import camera driver
if os.environ.get('CAMERA'):
Camera = import_module('camera_' + os.environ['CAMERA']).Camera
else:
from camera import Camera
# from flack_cors import *
app = Flask(__name__)
# UPLOAD_FOLDER = "C:\Users\Arpit Sharma\Desktop\Friendship goals\content\yolov5\static\uploads"
DETECTION_FOLDER = r'./static/detections'
# app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
#app.config['DETECTION_FOLDER'] = DETECTION_FOLDER
@app.route('/')
def index():
"""Video streaming home page."""
return render_template('index.html')
# the_time = datetime.now().strftime("%A, %d %b %Y %l:%M %p")
# return render_template('index.html')
# return """
# <h1>Hello heroku</h1>
# <p>It is currently {time}.</p>
# <img src="http://loremflickr.com/600/400" />
# <h1>linjie</h1>
# <img src="{{ url_for('video_feed') }}">
# """.format(time=the_time)
def gen(camera):
"""Video streaming generator function."""
while True:
frame = camera.get_frame()
yield (b'--frame\r\n'
b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n')
@app.route('/videovideo_feedapt-get update && apt-get install libgl1')
def video_feed():
"""Video streaming route. Put this in the src attribute of an img tag."""
return Response(gen(Camera()),
mimetype='multipart/x-mixed-replace; boundary=frame')
if __name__ == "__main__":
app.run()