Commit 5545121a authored by tihmels's avatar tihmels

Nachbesserung Sorted_set

parent 59735d39
......@@ -31,16 +31,15 @@ def detect_faces(emotion):
fileNumber = 0
for f in files:
frame = cv2.imread(f) # Open image
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) # Convert image to grayscale
# Detect face using 4 different classifiers
face = faceDet.detectMultiScale(gray, scaleFactor=1.05, minNeighbors=6, minSize=(10, 10),
face = faceDet.detectMultiScale(frame, scaleFactor=1.05, minNeighbors=6, minSize=(10, 10),
flags=cv2.CASCADE_SCALE_IMAGE)
face_two = faceDet_two.detectMultiScale(gray, scaleFactor=1.05, minNeighbors=6, minSize=(10, 10),
face_two = faceDet_two.detectMultiScale(frame, scaleFactor=1.05, minNeighbors=6, minSize=(10, 10),
flags=cv2.CASCADE_SCALE_IMAGE)
face_three = faceDet_three.detectMultiScale(gray, scaleFactor=1.05, minNeighbors=6, minSize=(10, 10),
face_three = faceDet_three.detectMultiScale(frame, scaleFactor=1.05, minNeighbors=6, minSize=(10, 10),
flags=cv2.CASCADE_SCALE_IMAGE)
face_four = faceDet_four.detectMultiScale(gray, scaleFactor=1.05, minNeighbors=6, minSize=(10, 10),
face_four = faceDet_four.detectMultiScale(frame, scaleFactor=1.05, minNeighbors=6, minSize=(10, 10),
flags=cv2.CASCADE_SCALE_IMAGE)
# Go over detected faces, stop at first detected face, return empty if no face.
......@@ -54,15 +53,16 @@ def detect_faces(emotion):
facefeatures = face_four
else:
undetected.append(f)
facefeatures = ''
# 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: {}".format(f))
totalFaces += 1
gray = gray[y:y + h, x:x + w] # Cut the frame to size
frame = frame[y:y + h, x:x + w] # Cut the frame to size
try:
out = cv2.resize(gray, (250, 250)) # Resize face so all images have same size
out = cv2.resize(frame, (250, 250)) # Resize face so all images have same size
cv2.imwrite('Basis_data/dataset/%s/%s.jpg' % (emotion, fileNumber), out) # Write image
except:
pass # If error, pass file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment