-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
35 lines (24 loc) · 849 Bytes
/
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
from flask import Flask, render_template, Response, jsonify
import cv2
import numpy as np
from pygame import mixer
from drowsiness_detection import perform_drowsiness_detection
app = Flask(__name__)
flag = True
score1 = 0
@app.route('/')
def index():
return render_template('index.html', score=score1)
@app.route('/get_score')
def get_score():
# Read the score from the temporary file
with open('score_temp.txt', 'r') as file:
score = int(file.read())
# Determine the driver status based on the score
if score == -1:
score = 0
driver_status = "Drowsy" if score > 5 else "Normal"
return jsonify({'score': score, 'driver_status': driver_status})
@app.route('/video_feed')
def video_feed():
return Response(perform_drowsiness_detection(), mimetype='multipart/x-mixed-replace; boundary=frame')