Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-2-capstone-design2
/
2014104149
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
Graduate
2020-11-25 15:27:34 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
55b99c8e3df9479a88d046f51a674b20ce1d3972
55b99c8e
1 parent
cc4d279d
Update flask
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
7 deletions
flask/app.py
flask/templates/index.html
flask/app.py
View file @
55b99c8
...
...
@@ -128,15 +128,15 @@ def verify():
if
verified_id
!=
None
:
sql
=
"SELECT DATE(attendance_time) FROM student_attendance WHERE (lecture_id=
%
s) AND (student_id=
%
s) AND (DATE(attendance_time) = CURDATE());"
cursor
.
execute
(
sql
,
(
'0'
,
verified_id
))
sql
=
"SELECT student_name FROM student WHERE student_id =
%
s"
cursor
.
execute
(
sql
,
(
verified_id
))
row_data
=
cursor
.
fetchone
()
verified_name
=
row_data
[
'student_name'
]
if
cursor
.
rowcount
==
0
:
sql
=
"INSERT INTO student_attendance(lecture_id, student_id, status) VALUES (
%
s,
%
s,
%
s)"
# TODO: attend / late 처리
cursor
.
execute
(
sql
,
(
'0'
,
verified_id
,
'attend'
))
attendance_db
.
commit
()
sql
=
"SELECT student_name FROM student WHERE student_id =
%
s"
cursor
.
execute
(
sql
,
(
verified_id
))
row_data
=
cursor
.
fetchone
()
verified_name
=
row_data
[
'student_name'
]
# log 작성
msg
=
'[{id}] verification success'
.
format
(
id
=
verified_id
)
print
(
msg
)
...
...
@@ -144,7 +144,7 @@ def verify():
else
:
msg
=
'[{id}] verification failed: already verified'
.
format
(
id
=
verified_id
)
print
(
msg
)
send
=
jsonify
({
'status'
:
'already'
,
'student_id'
:
verified_id
})
send
=
jsonify
({
'status'
:
'already'
,
'student_id'
:
verified_id
,
'student_name'
:
verified_name
})
else
:
# 인증 실패
msg
=
'[0000000000] verification failed'
...
...
flask/templates/index.html
View file @
55b99c8
...
...
@@ -105,6 +105,7 @@ function processVideo() {
let
msize
=
new
cv
.
Size
(
120
,
120
);
classifier
.
detectMultiScale
(
gray
,
faces
,
1.1
,
3
,
0
,
msize
);
// draw faces.
console
.
log
(
'draw faces'
);
for
(
let
i
=
0
;
i
<
faces
.
size
();
++
i
)
{
let
face
=
faces
.
get
(
i
);
let
point1
=
new
cv
.
Point
(
face
.
x
,
face
.
y
);
...
...
@@ -115,18 +116,26 @@ function processVideo() {
cropped
=
src
.
roi
(
rect
);
let
tempCanvas
=
document
.
createElement
(
"canvas"
);
cv
.
imshow
(
tempCanvas
,
cropped
);
console
.
log
(
'b64encode'
);
if
(
tracker
.
register
(
face
.
x
,
face
.
y
,
face
.
width
,
face
.
height
,
Date
.
now
())){
let
b64encoded
=
tempCanvas
.
toDataURL
(
"image/jpeg"
,
1.0
);
b64encoded
=
b64encoded
.
replace
(
'data:image/jpeg;base64,'
,
''
)
console
.
log
(
'ajax post'
);
$
.
ajax
({
type
:
"POST"
,
url
:
"/verify"
,
dataType
:
"json"
,
data
:
{
'image'
:
b64encoded
},
success
:
function
(
data
){
if
(
data
.
status
==
"
success
"
){
if
(
data
.
status
==
"
attend
"
){
var
newDiv
=
document
.
createElement
(
"div"
);
var
newContent
=
document
.
createTextNode
(
"출석"
);
var
newContent
=
document
.
createTextNode
(
'['
+
data
.
student_id
+
'/'
+
data
.
student_name
+
']'
+
"출석"
);
newDiv
.
appendChild
(
newContent
);
document
.
body
.
appendChild
(
newDiv
);
}
else
if
(
data
.
status
==
"already"
){
var
newDiv
=
document
.
createElement
(
"div"
);
var
newContent
=
document
.
createTextNode
(
'['
+
data
.
student_id
+
'/'
+
data
.
student_name
+
']'
+
"이미 출석처리 되었습니다."
);
newDiv
.
appendChild
(
newContent
);
document
.
body
.
appendChild
(
newDiv
);
}
...
...
Please
register
or
login
to post a comment