Commit 59735d39 authored by tihmels's avatar tihmels

Nachbesserung Sorted_set

parent 5755de74
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)
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