Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
1dba47b7
Commit
1dba47b7
authored
Apr 06, 2014
by
akrynski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update crop_face.py
I propose some changes, to automate file cropping
parent
d1710a85
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
5 deletions
+28
-5
crop_face.py
modules/contrib/doc/facerec/src/crop_face.py
+28
-5
No files found.
modules/contrib/doc/facerec/src/crop_face.py
View file @
1dba47b7
...
...
@@ -81,9 +81,32 @@ def CropFace(image, eye_left=(0,0), eye_right=(0,0), offset_pct=(0.2,0.2), dest_
image
=
image
.
resize
(
dest_sz
,
Image
.
ANTIALIAS
)
return
image
def
readFileNames
():
try
:
inFile
=
open
(
'path_to_created_csv_file.csv'
)
except
:
raise
IOError
(
'There is no file named path_to_created_csv_file.csv in current directory.'
)
return
False
picPath
=
[]
picIndex
=
[]
for
line
in
inFile
.
readlines
():
if
line
!=
''
:
fields
=
line
.
rstrip
()
.
split
(
';'
)
picPath
.
append
(
fields
[
0
])
picIndex
.
append
(
int
(
fields
[
1
]))
return
(
picPath
,
picIndex
)
if
__name__
==
"__main__"
:
image
=
Image
.
open
(
"arnie.jpg"
)
CropFace
(
image
,
eye_left
=
(
252
,
364
),
eye_right
=
(
420
,
366
),
offset_pct
=
(
0.1
,
0.1
),
dest_sz
=
(
200
,
200
))
.
save
(
"arnie_10_10_200_200.jpg"
)
CropFace
(
image
,
eye_left
=
(
252
,
364
),
eye_right
=
(
420
,
366
),
offset_pct
=
(
0.2
,
0.2
),
dest_sz
=
(
200
,
200
))
.
save
(
"arnie_20_20_200_200.jpg"
)
CropFace
(
image
,
eye_left
=
(
252
,
364
),
eye_right
=
(
420
,
366
),
offset_pct
=
(
0.3
,
0.3
),
dest_sz
=
(
200
,
200
))
.
save
(
"arnie_30_30_200_200.jpg"
)
CropFace
(
image
,
eye_left
=
(
252
,
364
),
eye_right
=
(
420
,
366
),
offset_pct
=
(
0.2
,
0.2
))
.
save
(
"arnie_20_20_70_70.jpg"
)
[
images
,
indexes
]
=
readFileNames
()
if
not
os
.
path
.
exists
(
"modified"
):
os
.
makedirs
(
"modified"
)
for
img
in
images
:
image
=
Image
.
open
(
img
)
CropFace
(
image
,
eye_left
=
(
252
,
364
),
eye_right
=
(
420
,
366
),
offset_pct
=
(
0.1
,
0.1
),
dest_sz
=
(
200
,
200
))
.
save
(
"modified/"
+
img
.
rstrip
()
.
split
(
'/'
)[
1
]
+
"_10_10_200_200.jpg"
)
CropFace
(
image
,
eye_left
=
(
252
,
364
),
eye_right
=
(
420
,
366
),
offset_pct
=
(
0.2
,
0.2
),
dest_sz
=
(
200
,
200
))
.
save
(
"modified/"
+
img
.
rstrip
()
.
split
(
'/'
)[
1
]
+
"_20_20_200_200.jpg"
)
CropFace
(
image
,
eye_left
=
(
252
,
364
),
eye_right
=
(
420
,
366
),
offset_pct
=
(
0.3
,
0.3
),
dest_sz
=
(
200
,
200
))
.
save
(
"modified/"
+
img
.
rstrip
()
.
split
(
'/'
)[
1
]
+
"_30_30_200_200.jpg"
)
CropFace
(
image
,
eye_left
=
(
252
,
364
),
eye_right
=
(
420
,
366
),
offset_pct
=
(
0.2
,
0.2
))
.
save
(
"modified/"
+
img
.
rstrip
()
.
split
(
'/'
)[
1
]
+
"_20_20_70_70.jpg"
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment