Hy guys.
I have a homework :
Write a program that gets a filename for its input, then looks for these human faces and prints each one in a separate file 1-1. If e.g. the name of the input file is family.jpg, then the output names should be family-face-01.png, family-face-02.png, ... Make sure that the output portraits contain the full face. (Some hair may be left behind.) Apply a tolerance contrast stretch to the output images one at a time, allowing 1-1% of the pixels to overflow or overflow. You can use e.g. OpenCV's built-in Haar-cascade-based face recognition.
I did face recognition, but i don't how to make the othet parts.
Please help me...
I have a homework :
Write a program that gets a filename for its input, then looks for these human faces and prints each one in a separate file 1-1. If e.g. the name of the input file is family.jpg, then the output names should be family-face-01.png, family-face-02.png, ... Make sure that the output portraits contain the full face. (Some hair may be left behind.) Apply a tolerance contrast stretch to the output images one at a time, allowing 1-1% of the pixels to overflow or overflow. You can use e.g. OpenCV's built-in Haar-cascade-based face recognition.
I did face recognition, but i don't how to make the othet parts.
Please help me...
import cv2 face_cascade = cv2.CascadeClassifier('haarcascade_frontalface_default.xml') img = cv2.imread('csalad1.jpg') gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) faces = face_cascade.detectMultiScale( gray, scaleFactor=1.1, minNeighbors=5, minSize=(50, 50) ) print("[INFO] Talált {0} arcot.".format(len(faces))) i_cont=0 for (x, y, w, h) in faces: cv2.rectangle(img, (x, y), (x+w, y+h), (255, 72, 0), 2) cont_arc = img[y:y + h, x:x + w] print("[INFO] Arcok megtalálva. Mentés helyileg.") cv2.imwrite('csalad_arc%03d.jpg'%i_cont, cont_arc) i_cont+=1 status = cv2.imwrite('arcok_megtalalva.jpg', img) print("[INFO] Kep arcok_megtalalva.jpg kiirva mappába: ", status) cv2.imshow('img', img) cv2.waitKey() [python][/python]
[python][/python]