Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design1
/
KHY_Project1
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
Graduate
2020-06-05 17:04:53 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
92bc11962b32be8b8b35dcdf46e90f4bf8206d09
92bc1196
1 parent
44c15106
Modify server.py
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
9 additions
and
19 deletions
server/models/__pycache__/inception_resnet_v1.cpython-37.pyc
server/models/__pycache__/mtcnn.cpython-37.pyc
server/models/utils/__pycache__/detect_face.cpython-37.pyc
server/server.py
server/models/__pycache__/inception_resnet_v1.cpython-37.pyc
View file @
92bc119
No preview for this file type
server/models/__pycache__/mtcnn.cpython-37.pyc
View file @
92bc119
No preview for this file type
server/models/utils/__pycache__/detect_face.cpython-37.pyc
View file @
92bc119
No preview for this file type
server/server.py
View file @
92bc119
...
...
@@ -46,12 +46,6 @@ async def get_cosine_similarity(arr1, arr2):
similarity
=
np
.
inner
(
arr1
,
arr2
)
/
(
np
.
linalg
.
norm
(
arr1
)
*
np
.
linalg
.
norm
(
arr2
))
return
similarity
def
get_argmin
(
someone
,
database
):
distance
=
get_distance
(
someone
,
database
)
for
i
in
range
(
len
(
distance
)):
return
np
.
argmin
(
distance
)
return
-
1
async
def
register
(
websocket
):
global
lock
global
clients
...
...
@@ -140,18 +134,11 @@ async def thread(websocket, path):
distance_min
=
distance
# 출석 데이터 전송
send
=
''
print
(
'[debug] distance:'
,
distance_min
)
if
distance_min
>=
0.5
:
# 해당하는 사람 DB에 없음
msg
=
'[{ip}] verification failed'
.
format
(
ip
=
remote_ip
)
print
(
msg
)
send
=
json
.
dumps
({
'status'
:
'fail'
})
else
:
# 해당하는 사람 DB에 있음
# logging
# TODO: lecture DB에 tuple 삽입해야 아래 코드가 돌아감
# DB에 오늘 이미 출석한 기록이 있는지 확인
send
=
''
if
distance_min
<
0.4
:
# 인증 성공
# 오늘 이미 출석 됐는지 확인
sql
=
"SELECT DATE(timestamp) FROM student_attendance WHERE (lecture_id=
%
s) AND (student_id=
%
s) AND (DATE(timestamp) = CURDATE());"
cursor
.
execute
(
sql
,
(
'0'
,
verified_id
))
...
...
@@ -165,10 +152,14 @@ async def thread(websocket, path):
# log 작성
msg
=
'[{ip}] verification success {id}'
.
format
(
ip
=
remote_ip
,
id
=
verified_id
)
print
(
msg
)
# client에 전달
send
=
json
.
dumps
({
'status'
:
'success'
,
'student_id'
:
verified_id
})
else
:
send
=
json
.
dumps
({
'status'
:
'already'
,
'student_id'
:
verified_id
})
else
:
# 인증 실패
msg
=
'[{ip}] verification failed'
.
format
(
ip
=
remote_ip
)
print
(
msg
)
send
=
json
.
dumps
({
'status'
:
'fail'
})
await
websocket
.
send
(
send
)
elif
data
[
'action'
]
==
"save_image"
:
# 출석이 제대로 이뤄지지 않으면 이미지를 저장하여
...
...
@@ -177,7 +168,6 @@ async def thread(websocket, path):
print
(
msg
)
arr
=
np
.
asarray
(
data
[
'image'
],
dtype
=
np
.
uint8
)
blob
=
arr
.
tobytes
()
# TODO: lecture DB에 tuple 삽입해야 아래 코드가 돌아감
# 테이블 맨 뒤에 datetime attribute가 있음. 서버 시간 가져오게 default로 설정해둠.
cursor
=
attendance_db
.
cursor
(
pymysql
.
cursors
.
DictCursor
)
...
...
Please
register
or
login
to post a comment