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-26 06:20:34 +0000
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
20170ff0e1c91c2583843f68b78ed04034d6a4ad
20170ff0
1 parent
4518c4d8
Update cropping logic
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
11 deletions
flask/app.py
flask/config.cnf
flask/templates/register.html
flask/app.py
View file @
20170ff
...
...
@@ -108,6 +108,7 @@ def verify():
embedding
=
sess
.
run
(
embeddings_placeholder
,
feed_dict
=
feed_dict
)
# compare received embedding to database embedding
verified_id
=
None
dist_min
=
99
sql
=
"SELECT student_id, embedding FROM student_embedding;"
cursor
.
execute
(
sql
)
result
=
cursor
.
fetchall
()
...
...
@@ -116,16 +117,16 @@ def verify():
db_embedding
=
db_embedding
.
reshape
((
1
,
512
))
distance
=
get_distance
(
embedding
,
db_embedding
)
print
(
distance
)
if
(
distance
<
threshold
):
if
(
distance
<
dist_min
):
verified_id
=
row_data
[
'student_id'
]
new_embedding
=
db_embedding
*
0.8
+
embedding
*
0.2
new_embedding
=
new_embedding
.
tobytes
()
sql
=
"UPDATE student_embedding SET embedding=_binary
%
s WHERE student_id =
%
s"
cursor
.
execute
(
sql
,
(
new_embedding
,
verified_id
))
attendance_db
.
commit
(
)
break
if
verified_id
!=
None
:
dist_min
=
distance
# new_embedding = db_embedding * 0.98 + embedding * 0.02
# new_embedding = new_embedding.tobytes()
# sql = "UPDATE student_embedding SET embedding=_binary %s WHERE student_id = %s"
# cursor.execute(sql, (new_embedding, verified_id)
)
# attendance_db.commit()
if
verified_id
!=
None
and
dist_min
<
threshold
:
sql
=
"SELECT student_name FROM student WHERE student_id =
%
s"
cursor
.
execute
(
sql
,
(
verified_id
))
row_data
=
cursor
.
fetchone
()
...
...
flask/config.cnf
View file @
20170ff
[verification_server]
model=models/20200816-080621
threshold=0.
765
threshold=0.
69
image_size=160
...
...
flask/templates/register.html
View file @
20170ff
...
...
@@ -61,7 +61,7 @@ function detect_face()
let
point1
=
new
cv
.
Point
(
face
.
x
,
face
.
y
);
let
point2
=
new
cv
.
Point
(
face
.
x
+
face
.
width
,
face
.
y
+
face
.
height
);
cv
.
rectangle
(
dst
,
point1
,
point2
,
[
255
,
0
,
0
,
255
],
8
);
let
rect
=
new
cv
.
Rect
(
face
.
x
,
face
.
y
,
face
.
width
,
face
.
height
);
let
rect
=
new
cv
.
Rect
(
Math
.
max
(
face
.
x
-
face
.
width
/
4
,
0
),
Math
.
max
(
face
.
y
-
face
.
height
/
2
,
0
),
Math
.
min
(
face
.
width
+
face
.
width
/
2
,
src
.
cols
),
Math
.
min
(
face
.
height
+
face
.
height
/
2
,
src
.
rows
)
);
let
cropped
=
src
.
roi
(
rect
);
cv
.
imshow
(
tempCanvas
,
cropped
);
}
...
...
Please
register
or
login
to post a comment