Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import os
- import cv2
- import sys
- def genGood():
- count = 0
- f = open("Good.dat", 'w')
- for i in range(1, 588):
- imagePath = "GirlsFaces/" + str(i) +".jpg"
- faceCascade = cv2.CascadeClassifier("haarcascade_frontalface_default.xml")
- print(imagePath)
- image = cv2.imread(imagePath, 1)
- gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
- faces = faceCascade.detectMultiScale(
- gray,
- scaleFactor=1.1,
- minNeighbors=5,
- minSize=(30, 30),
- flags = cv2.CASCADE_SCALE_IMAGE
- )
- print "Found {0} faces! {1}".format(len(faces), imagePath)
- # Draw a rectangle around the faces
- if len(faces) == 1:
- f.write(imagePath + " ")
- f.write(str(len(faces)) + " ")
- for (x, y, w, h) in faces:
- f.write(str(x) +" " + str(y) + " " + str(w) + " " + str(h))
- f.write("\n")
- #cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)
- count += 1
- print (count)
- #cv2.imshow("Faces found", image)
- #cv2.waitKey(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement