Toggle navigation
Toggle navigation
This project
Loading...
Sign in
2020-1-capstone-design2
/
2012102860
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
정희원
2020-06-19 00:56:59 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
124adf5233288e4f8f6eaf6229557237211eabcb
124adf52
1 parent
4ba524e2
Upload new file
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
saucecode/eyecrop.py
saucecode/eyecrop.py
0 → 100644
View file @
124adf5
import
cv2
import
dlib
import
numpy
as
np
IMG_SIZE
=
(
34
,
26
)
def
crop_eye
(
img
,
eye_points
):
x1
,
y1
=
np
.
amin
(
eye_points
,
axis
=
0
)
x2
,
y2
=
np
.
amax
(
eye_points
,
axis
=
0
)
cx
,
cy
=
(
x1
+
x2
)
/
2
,
(
y1
+
y2
)
/
2
w
=
(
x2
-
x1
)
*
1.2
h
=
w
*
IMG_SIZE
[
1
]
/
IMG_SIZE
[
0
]
margin_x
,
margin_y
=
w
/
2
,
h
/
2
min_x
,
min_y
=
int
(
cx
-
margin_x
),
int
(
cy
-
margin_y
)
max_x
,
max_y
=
int
(
cx
+
margin_x
),
int
(
cy
+
margin_y
)
eye_rect
=
np
.
rint
([
min_x
,
min_y
,
max_x
,
max_y
])
.
astype
(
np
.
int
)
gray
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
eye_img
=
gray
[
eye_rect
[
1
]:
eye_rect
[
3
],
eye_rect
[
0
]:
eye_rect
[
2
]]
return
eye_img
,
eye_rect
Please
register
or
login
to post a comment