Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Frank Tjado Ihmels
medienverarbeitung17.projectmood
Commits
59735d39
Commit
59735d39
authored
Dec 06, 2017
by
tihmels
Browse files
Nachbesserung Sorted_set
parent
5755de74
Changes
1
Hide whitespace changes
Inline
Side-by-side
projectmood/sorted_set_facedetector.py
View file @
59735d39
import
cv2
import
glob
import
time
import
logging
faceDet
=
cv2
.
CascadeClassifier
(
'Haarcascade/haarcascade_frontalface_default.xml'
)
...
...
@@ -15,9 +14,10 @@ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(level
emotions
=
[
"neutral"
,
"anger"
,
"disgust"
,
"happy"
,
"surprise"
]
# Define emotions
totalFiles
:
int
=
0
totalFaces
:
int
=
0
undetected
:
list
=
[]
totalFiles
:
int
=
0
totalFaces
:
int
=
0
undetected
:
list
=
[]
def
detect_faces
(
emotion
):
files
=
glob
.
glob
(
'Basis_data/sorted_set/%s/*'
%
emotion
)
# Get list of all images with emotion
...
...
@@ -26,7 +26,7 @@ def detect_faces(emotion):
global
totalFaces
global
totalFiles
logging
.
debug
(
"
%d
files in folder
%s"
%
(
len
(
files
),
emotion
))
logging
.
debug
(
"
{}
files in folder
{}"
.
format
(
len
(
files
),
emotion
))
fileNumber
=
0
for
f
in
files
:
...
...
@@ -57,7 +57,7 @@ def detect_faces(emotion):
# Cut and save face
for
(
x
,
y
,
w
,
h
)
in
facefeatures
:
# get coordinates and size of rectangle containing face
logging
.
debug
(
"face found in file:
%s"
%
f
)
logging
.
debug
(
"face found in file:
{}"
.
format
(
f
)
)
totalFaces
+=
1
gray
=
gray
[
y
:
y
+
h
,
x
:
x
+
w
]
# Cut the frame to size
...
...
@@ -67,7 +67,7 @@ def detect_faces(emotion):
except
:
pass
# If error, pass file
totalFiles
+=
1
# Increment image number
totalFiles
+=
1
# Increment image number
fileNumber
+=
1
...
...
@@ -75,8 +75,7 @@ for emotion in emotions:
detect_faces
(
emotion
)
# Call functional
logging
.
debug
(
"
\n
"
)
logging
.
debug
(
str
(
totalFaces
)
+
" Gesichter in "
+
str
(
totalFiles
)
+
" Dateien gefunden.
\n
"
)
logging
.
debug
(
"{} Gesichter in {} Dateien gefunden."
.
format
(
totalFaces
,
totalFiles
))
logging
.
debug
(
"Kein Gesicht wurde gefunden in:"
)
for
f
in
undetected
:
logging
.
debug
(
f
)
\ No newline at end of file
logging
.
debug
(
f
)
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