Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
medienverarbeitung17.projectmood
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
Frank Tjado Ihmels
medienverarbeitung17.projectmood
Commits
59735d39
Commit
59735d39
authored
Dec 06, 2017
by
tihmels
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nachbesserung Sorted_set
parent
5755de74
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
10 deletions
+9
-10
projectmood/sorted_set_facedetector.py
projectmood/sorted_set_facedetector.py
+9
-10
No files found.
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