Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import cv2
- import sys
- count = 0
- count1 = 0
- count2 = 0
- for imagePath in os.listdir("Good"):
- #imagePath = 'GirlsFaces/8.jpg'
- faceCascade1 = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
- faceCascade = cv2.CascadeClassifier("cascadeGirls3.xml")
- faceCascade2 = cv2.CascadeClassifier("cascade.xml")
- faceCascade3 = cv2.CascadeClassifier("simplegirlcascade.xml")
- imagePath = "Good"+ "/" + imagePath
- # print(imagePath)
- image = cv2.imread(imagePath, 1)
- gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
- faces = faceCascade2.detectMultiScale(
- gray,
- scaleFactor=1.1,
- minNeighbors=5,
- minSize=(30, 30),
- flags = cv2.CASCADE_SCALE_IMAGE
- )
- #faces = faceCascade1.detectMultiScale(
- # gray,
- # scaleFactor=1.1,
- # minNeighbors=5,
- # minSize=(30, 30),
- # flags= cv2.CASCADE_SCALE_IMAGE
- #)
- #if len(faces) != 0:
- # print ('face!')
- for (x, y, w, h) in faces:
- imag = image[y:y+h, x:x+w]
- gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
- faces1 = faceCascade.detectMultiScale(
- gray,
- scaleFactor=1.1,
- minNeighbors=5,
- minSize=(30, 30),
- flags = cv2.CASCADE_SCALE_IMAGE
- )
- #print "Found {0} girls! {1}".format(len(faces1), imagePath)
- #print "Found {0} girls! {1}".format(len(faces2), imagePath)
- # Draw a recta ngle around the faces
- if (len(faces1) != 0):
- count += 1
- #print("+")
- for (x, y, w, h) in faces:
- cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
- # cv2.imshow("girls found1", image)
- # cv2.waitKey(0)
- #count+=1
- #print "Found {0} girls! {1}".format(len(faces1), imagePath)
- #print "Found {0} girls! {1}".format(len(faces2), imagePath)
- # Draw a recta ngle around the faces
- if len(faces) != 0:
- count1+=1
- #print("-")
- for (x, y, w, h) in faces:
- cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
- #cv2.imshow("girls found2", image)
- # cv2.waitKey(0)
- #print "Found {0} girls! {1}".format(len(faces1), imagePath)
- #print "Found {0} girls! {1}".format(len(faces2), imagePath)
- # Draw a recta ngle around the faces
- #if (len(faces1) != 0):
- # count2+=1
- # for (x, y, w, h) in faces:
- # cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
- # cv2.imshow("girls found3", image)
- # cv2.waitKey(0)
- #count+=1
- print (count, count1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement