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-09 09:46:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f6985ecf261b057ea552eb3e54a27df7bd56767b
f6985ecf
1 parent
258b802a
Modify register.py
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
18 deletions
register/register.py
register/register.py
View file @
f6985ec
##################################################
#1. webcam에서 얼굴을 인식합니다. #
#2. 얼굴일 확률이 95% 이상인 이미지를 이미지 서버로 전송합니다. #
#3. 전처리 된 데이터를 verification 서버에 전송합니다. #
#1. webcam에서 얼굴을 인식합니다
#2. 인식한 얼굴을 등록합니다
##################################################
import
torch
import
numpy
as
np
...
...
@@ -55,27 +54,33 @@ def detect_face(frame):
image_list
.
append
(
image
)
return
image_list
def
make_face_list
(
frame
):
global
mtcnn
results
,
prob
=
mtcnn
(
frame
,
return_prob
=
True
)
def
detect_face
(
frame
):
results
=
mtcnn
.
detect
(
frame
)
faces
=
mtcnn
(
frame
,
return_prob
=
False
)
image_list
=
[]
face_list
=
[]
if
prob
[
0
]
==
None
:
return
[]
for
result
,
prob
in
zip
(
results
,
prob
):
if
prob
<
0.9
5
:
if
results
[
1
]
[
0
]
==
None
:
return
[]
,
[]
for
box
,
face
,
prob
in
zip
(
results
[
0
],
faces
,
results
[
1
]
):
if
prob
<
0.9
7
:
continue
#np.float32
face_list
.
append
(
result
.
numpy
())
return
face_list
print
(
'face detected. prob:'
,
prob
)
x1
,
y1
,
x2
,
y2
=
box
if
(
x2
-
x1
)
*
(
y2
-
y1
)
<
15000
:
# 얼굴 해상도가 너무 낮으면 무시
continue
# 얼굴 주변 ±3 영역 저장
image
=
frame
[
int
(
y1
-
3
):
int
(
y2
+
3
),
int
(
x1
-
3
):
int
(
x2
+
3
)]
image_list
.
append
(
image
)
# MTCNN 데이터 저장
face_list
.
append
(
face
.
numpy
())
return
image_list
,
face_list
cap
=
cv2
.
VideoCapture
(
0
)
cap
=
cv2
.
VideoCapture
(
0
,
cv2
.
CAP_DSHOW
)
cap
.
set
(
3
,
720
)
cap
.
set
(
4
,
480
)
ret
,
frame
=
cap
.
read
()
frame
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2RGB
)
#img = Image.open('3.jpg')
#frame = np.array(img)
face_list
=
make_face_list
(
frame
)
image_list
=
detect_face
(
frame
)
face_list
,
image_list
=
detect_face
(
frame
)
if
face_list
:
asyncio
.
get_event_loop
()
.
run_until_complete
(
send_face
(
face_list
,
image_list
))
\ No newline at end of file
...
...
Please
register
or
login
to post a comment