김성연

Fix flask web code and Add weekly report

.ipynb_checkpoints/*
.pynb_checkpoints/*
.DS_Store
web/__pycache__/*
web/face_emotion_recognition/__pycache__
web/face_emotion_recognition/__pycache__/*
web/face_emotion_recogntion/data
web/face_emotion_recogntion/img
web/static/*
......
......@@ -69,11 +69,18 @@ def upload_video():
return redirect(url_for('test'))
@app.route('/faceEmotinoRecognition')
def faceEmotinoRecognition():
face_emotion_dict = video4.videoDetector(3, 'record0')
@app.route('/faceEmotionRecognition', methods=('GET', 'POST'))
def faceEmotionRecognition():
if request.method == 'POST':
f = request.files.get('video')
f.save("./static/video/" + secure_filename(f.filename))
seconds = float(request.form['seconds'])
face_emotion_dict = video4.videoDetector(
seconds, secure_filename(f.filename))
print(face_emotion_dict)
return render_template('result.html', face_emotion_dict=face_emotion_dict, face_imgs=find_face_imgs())
file_name = 'video/' + secure_filename(f.filename)
return render_template('result.html', face_emotion_dict=face_emotion_dict, face_imgs=find_face_imgs(), file_name=file_name)
return redirect(url_for('test'))
if __name__ == "__main__":
......
......@@ -44,7 +44,7 @@ def videoDetector(second, video_name):
], 'happy': [], 'neutral': [], 'sad': [], 'surprise': []}
# video 정보 불러오기
video_path = 'static/video/' + video_name + '.mp4'
video_path = 'static/video/' + video_name
cap = cv2.VideoCapture(video_path)
# 동영상 크기(frame정보)를 읽어옴
......
......@@ -8,12 +8,13 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<link rel="stylesheet" href="{{ url_for('static', filename='css/layout.css') }}">
<title>Flask Face Emotion Recognition App</title>
</head>
<body>
<div class="container" style="margin-top: 100px">
<div class="container" style="justify-self: center; margin-top: 100px;">
<h3>Face Emotion Recognition Platform</h3>
<hr>
......@@ -22,7 +23,7 @@
No face images available
</div>
{% else %}
<table class="table">
<table class="table table-bordered" style="width: 100%; height: 40%;">
<thead>
<tr>
<th scope="col ">id</th>
......@@ -37,8 +38,8 @@
<tr>
<th scope="row">{{ face_img.id }}</th>
<td>{{ face_img.name }}</td>
<td><img src={{ url_for('static', filename=face_img.imgUrl) }} width="100" height="120"></td>
<td><a href="/deleteFace/{{ face_img.name }}" class="btn btn-danger">Delete</a></td>
<td><img src={{ url_for('static', filename=face_img.imgUrl) }} width="80" height="90"></td>
<td><a href="/deleteFace/{{ face_img.name }}" class="btn btn-danger btn-sm">Delete</a></td>
</tr>
{% endfor %}
</tbody>
......@@ -47,11 +48,11 @@
<form action="http://localhost:5000/uploadFace" method="POST" enctype="multipart/form-data">
<div class="form-group">
<div class="form-group" style="margin-top: 100px;">
<label for="title" class="text-uppercase">Face Upload</label>
<input type="file" name="file">
<button type="submit" class="btn btn-outline-primary">Add</button>
<a href="/goTest" type="button" class="btn btn-outline-dark"> 비디오 분석하러 가기 </a>
<input type="file" style="margin-left: 10px;" name="file">
<button type="submit" class="btn btn-primary btn-sm">Add Face Image</button>
<a href="/goTest" type="button" class="btn btn-primary btn-sm">Analysis Your Video </a>
</div>
</form>
</div>
......
......@@ -14,33 +14,26 @@
<body>
<div class="container" style="margin-top: 100px">
<h3>Face Emotion Recognition Platform</h3>
<h3>
<a href="/goTest" class="btn" style="width: 30px; color: grey;"> < </a>
Face Emotion Recognition Platform</h3>
<hr>
<form action="http://localhost:5000/uploadFace" method="POST" enctype="multipart/form-data">
<div class="form-group">
<label for="title" class="text-uppercase">Video Upload</label>
<input type="file" name="file">
<button type="submit" class="btn btn-outline-primary">Add</button>
</div>
</form>
<video id="myVideo" autoplay currentTime=200 width="320" height="240" controls>
<!-- <source src={{ url_for('static', filename=file_name ) }} type="video/mp4"> -->
<source src={{ url_for('static', filename=file_name ) }}>
<video autoplay width="320" height="240" controls>
<source src={{ url_for('static', filename="video/zoom_1.mp4") }} type="video/mp4">
</video>
<a href="/faceEmotinoRecognition" class="btn btn-outline-primary">얼굴 감정 인식 분석하기</a>
<table class="table">
<thead>
<tr>
<th scope="col ">name</th>
<th scope="col">happy</th>
<th scope="col">sad</th>
<th scope="col">fear</th>
<th scope="col">angry</th>
<th scope="col">fear</th>
<th scope="col">happy</th>
<th scope="col">neutral</th>
<th scope="col">sad</th>
<th scope="col">surprise</th>
</tr>
</thead>
......@@ -49,71 +42,22 @@
{% for face_img in face_imgs %}
<tr>
<td scope="row">{{ face_img.name }}</td>
{% if face_emotion_dict[face_img.name].happy %}
<td>
{% for time in face_emotion_dict[face_img.name].happy %}
<span>{{time}}</span>
{% endfor %}
</td>
{% else %}
<td> X </td>
{% endif %}
{% if face_emotion_dict[face_img.name].sad %}
{% for emotion in face_emotion_dict[face_img.name] %}
{% if face_emotion_dict[face_img.name][emotion] %}
<td>
{% for time in face_emotion_dict[face_img.name].sad %}
<span>{{time}}</span>
{% for time in face_emotion_dict[face_img.name][emotion] %}
<a href="#" name="time" id="{{time}}">{{time}}</a>
{% endfor %}
</td>
{% else %}
<td> X </td>
<td> x </td>
{% endif %}
{% if face_emotion_dict[face_img.name].fear %}
<td>
{% for time in face_emotion_dict[face_img.name].fear %}
<span>{{time}}</span>
{% endfor %}
</td>
{% else %}
<td> X </td>
{% endif %}
{% if face_emotion_dict[face_img.name].angry %}
<td>
{% for time in face_emotion_dict[face_img.name].angry %}
<span>{{time}}</span>
{% endfor %}
</td>
{% else %}
<td> X </td>
{% endif %}
{% if face_emotion_dict[face_img.name].neutral %}
<td>
{% for time in face_emotion_dict[face_img.name].neutral %}
<span>{{time}}</span>
{% endfor %}
</td>
{% else %}
<td> X </td>
{% endif %}
{% if face_emotion_dict[face_img.name].surprise %}
<td>
{% for time in face_emotion_dict[face_img.name].surprise %}
<span>{{time}}</span>
{% endfor %}
</td>
{% else %}
<td> X </td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
<hr/>
<hr />
</div>
......@@ -126,6 +70,18 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>
$('a[name="time"]').on("click", function(e){
e.preventDefault(); // 추가이벤트를 막아서 #의 최상위이동막음!!!
const inputTimes = $(this).attr('id').split(":");
let setTime = Number(inputTimes[0]) * 3600 + Number(inputTimes[1]) * 60 + Number(inputTimes[2]);
document.getElementById("myVideo").currentTime = setTime;
document.getElementById("myVideo").autoplay = true;
})
</script>
</body>
</html>
\ No newline at end of file
......
......@@ -8,6 +8,7 @@
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title>Flask Face Emotion Recognition App</title>
</head>
......@@ -17,21 +18,17 @@
<h3>Face Emotion Recognition Platform</h3>
<hr>
<form action="http://localhost:5000/uploadVideo" method="POST" enctype="multipart/form-data">
<div class="form-group">
<form action="http://localhost:5000/faceEmotionRecognition" method="POST" enctype="multipart/form-data">
<div class="form-group" style="margin-top: 20px;">
<p style="color: lightgray">mp4 확장자에 해당하는 비디오만을 추가해주세요</p>
<label for="title" class="text-uppercase">Video Upload</label>
<input type="file" name="video">
<button type="submit" class="btn btn-outline-primary">Add</button>
<input type="file" style="margin-left: 10px;" name="video">
<p></p>
<label class="text-uppercase">Input Seconds</label>
<input type="text" id="seconds" name="seconds">
<button type="submit" class="btn btn-primary btn-sm">Analysis Video</button>
</div>
</form>
<video autoplay width="320" height="240" controls>
<source src={{ url_for('static', filename="video/zoom_1.mp4") }} type="video/mp4">
</video>
<a href="/faceEmotinoRecognition" class="btn btn-outline-primary">얼굴 감정 인식 분석하기</a>
<hr/>
</div>
......@@ -44,6 +41,7 @@
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
</body>
</html>
\ No newline at end of file
......