Commit 59735d39 authored by tihmels's avatar tihmels
Browse files

Nachbesserung Sorted_set

parent 5755de74
import cv2 import cv2
import glob import glob
import time
import logging import logging
faceDet = cv2.CascadeClassifier('Haarcascade/haarcascade_frontalface_default.xml') faceDet = cv2.CascadeClassifier('Haarcascade/haarcascade_frontalface_default.xml')
...@@ -15,9 +14,10 @@ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(level ...@@ -15,9 +14,10 @@ logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(name)-12s %(level
emotions = ["neutral", "anger", "disgust", "happy", "surprise"] # Define emotions emotions = ["neutral", "anger", "disgust", "happy", "surprise"] # Define emotions
totalFiles:int = 0 totalFiles: int = 0
totalFaces:int = 0 totalFaces: int = 0
undetected:list = [] undetected: list = []
def detect_faces(emotion): def detect_faces(emotion):
files = glob.glob('Basis_data/sorted_set/%s/*' % emotion) # Get list of all images with 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): ...@@ -26,7 +26,7 @@ def detect_faces(emotion):
global totalFaces global totalFaces
global totalFiles global totalFiles
logging.debug("%d files in folder %s" % (len(files), emotion)) logging.debug("{} files in folder {}".format(len(files), emotion))
fileNumber = 0 fileNumber = 0
for f in files: for f in files:
...@@ -57,7 +57,7 @@ def detect_faces(emotion): ...@@ -57,7 +57,7 @@ def detect_faces(emotion):
# Cut and save face # Cut and save face
for (x, y, w, h) in facefeatures: # get coordinates and size of rectangle containing 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 totalFaces += 1
gray = gray[y:y + h, x:x + w] # Cut the frame to size gray = gray[y:y + h, x:x + w] # Cut the frame to size
...@@ -75,8 +75,7 @@ for emotion in emotions: ...@@ -75,8 +75,7 @@ for emotion in emotions:
detect_faces(emotion) # Call functional detect_faces(emotion) # Call functional
logging.debug("\n") 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:") logging.debug("Kein Gesicht wurde gefunden in:")
for f in undetected: for f in undetected:
logging.debug(f) logging.debug(f)
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