def __init__(self, faceCascadePath):
self.faceCascade = cv2.CascadeClassifier(faceCascadePath)
def detect(self, image, scaleFactor = 1.3, minNeighbors = 5, minSize = (30, 30)):
rects = self.faceCascade.detectMultiScale(image,
scaleFactor = scaleFactor, minNeighbors = minNeighbors,
minSize = minSize,flags = cv2.CASCADE_SCALE_IMAGE)
def render(self,frame,rect):
frame = cv2.rectangle(frame, (x, y), (x+w, y+h), (255, 0, 0), 2)
face_detector = FaceDetector('D:/Anaconda3/Lib/site-packages/cv2/data/haarcascade_frontalface_default.xml')
frame = cv2.imread("E:/Testcomptition/subject/competition_2/test/083941.jpg")
rects = face_detector.detect(frame)
print("rect value is: ", rects)
frame = face_detector.render(frame, rect)
cv2.imshow("face rect", frame)
if cv2.waitKey(0) == ord("q"):