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
9ea9b986
Commit
9ea9b986
authored
Dec 19, 2017
by
tihmels
Browse files
.gitignore bearbeitet, und änderungen
parent
497b8e88
Changes
4
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
9ea9b986
...
...
@@ -20,7 +20,10 @@ Icon
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent
basis_data/*
basis_data/dataset/*
basis_data/sorted_set/*
basis_data/source_emotion/*
basis_data/source_images/*
# Directories potentially created on remote AFP share
.AppleDB
...
...
projectmood/face_detect.py
View file @
9ea9b986
...
...
@@ -22,27 +22,28 @@ def normalize_face(face):
return
face
def
locate_faces
(
image
,
scaleFactor
=
1.4
,
minNeighbors
=
3
):
def
locate_faces
(
image
,
scaleFactor
=
1.4
,
minNeighbors
=
3
,
minSize
=
(
20
,
20
)):
minx
,
miny
=
minSize
face
=
faceDet_one
.
detectMultiScale
(
image
,
scaleFactor
,
minNeighbors
,
minSize
=
(
40
,
40
),
face
=
faceDet_one
.
detectMultiScale
(
image
,
scaleFactor
,
minNeighbors
,
minSize
=
(
minx
,
miny
),
flags
=
cv2
.
CASCADE_SCALE_IMAGE
)
if
len
(
face
)
==
1
:
return
face
face
=
faceDet_two
.
detectMultiScale
(
image
,
scaleFactor
,
minNeighbors
,
minSize
=
(
40
,
40
),
face
=
faceDet_two
.
detectMultiScale
(
image
,
scaleFactor
,
minNeighbors
,
minSize
=
(
minx
,
miny
),
flags
=
cv2
.
CASCADE_SCALE_IMAGE
)
if
len
(
face
)
==
1
:
return
face
face
=
faceDet_three
.
detectMultiScale
(
image
,
scaleFactor
,
minNeighbors
,
minSize
=
(
40
,
40
),
face
=
faceDet_three
.
detectMultiScale
(
image
,
scaleFactor
,
minNeighbors
,
minSize
=
(
minx
,
miny
),
flags
=
cv2
.
CASCADE_SCALE_IMAGE
)
if
len
(
face
)
==
1
:
return
face
face
=
faceDet_four
.
detectMultiScale
(
image
,
scaleFactor
,
minNeighbors
,
minSize
=
(
40
,
40
),
face
=
faceDet_four
.
detectMultiScale
(
image
,
scaleFactor
,
minNeighbors
,
minSize
=
(
minx
,
miny
),
flags
=
cv2
.
CASCADE_SCALE_IMAGE
)
if
len
(
face
)
==
1
:
...
...
projectmood/process_model.py
View file @
9ea9b986
...
...
@@ -12,7 +12,7 @@ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(levelname)-8s %(m
args
=
sys
.
argv
# liest Input Parameter
logging
.
debug
(
'Fisherface training initialized'
)
file
=
open
(
"gray
_equalized
.csv"
,
"w"
)
file
=
open
(
"gray.csv"
,
"w"
)
def
_get_faces_from_emotion
(
emotion
):
"""
...
...
@@ -34,7 +34,8 @@ def image_preprocessing(image):
"""
img
=
cv2
.
imread
(
image
)
# open image
gray
=
cv2
.
cvtColor
(
img
,
cv2
.
COLOR_BGR2GRAY
)
# convert to grayscale
return
gray
equal
=
cv2
.
equalizeHist
(
gray
)
return
equal
def
make_sets
():
training_data
=
[]
...
...
@@ -85,11 +86,13 @@ fishface = cv2.face.FisherFaceRecognizer_create()
# Now run it
metascore
=
[]
for
i
in
range
(
0
,
2
0
):
for
i
in
range
(
0
,
1
0
):
correct
=
run_recognizer
()
file
.
write
(
"{}
\n
"
.
format
(
int
(
correct
)))
logging
.
debug
(
"{} : {}%"
.
format
(
i
,
int
(
correct
)))
file
.
write
(
"{}, {}"
.
format
(
i
,
int
(
correct
)))
metascore
.
append
(
correct
)
file
.
close
()
logging
.
debug
(
"{} iterations - {}% average
\n
"
.
format
(
len
(
metascore
),
np
.
mean
(
metascore
)))
...
...
projectmood/sorted_set_facedetector.py
View file @
9ea9b986
...
...
@@ -14,7 +14,6 @@ totalFiles: int = 0
totalFaces
:
int
=
0
undetected
:
list
=
[]
def
detect_faces
(
emotion
):
files
=
glob
.
glob
(
'basis_data/sorted_set/{}/*'
.
format
(
emotion
))
# Holt alle Dateien zu einer Emotion aus dem sorted_set
...
...
@@ -29,7 +28,7 @@ def detect_faces(emotion):
frame
=
cv2
.
imread
(
f
)
# Open image
gray
=
cv2
.
cvtColor
(
frame
,
cv2
.
COLOR_BGR2GRAY
)
# Convert image to grayscale
facefeatures
=
locate_faces
(
gray
,
1.0
5
,
1
0
)
facefeatures
=
locate_faces
(
gray
,
1.
1
,
10
,
(
4
0
,
4
0
)
)
if
facefeatures
is
''
:
undetected
.
append
(
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