Write multiple images for face recognition with opencv and python -


i'm new in python programming , want detect faces in pictures downloaded google , have in folder. code recognizes faces in pictures , uses box/square frame them. want save or write image in box different folder same name original pictures have. here code detect faces , frame in box

import cv2 import os  facecascade = cv2.cascadeclassifier('haarcascade_frontalface_default.xml') imgformat = ".jpeg" fullimgpath = "full_image/" faceimgpath = "face_image/" imfilelist = [os.path.join(fullimgpath, f) f in os.listdir(fullimgpath) if f.endswith(imgformat)]  el in imfilelist:     print el    imagen = cv2.imread(el)    gray = cv2.cvtcolor(imagen, cv2.color_bgr2gray)    faces = facecascade.detectmultiscale(         gray,         scalefactor=1.1,         minneighbors=5,         minsize=(30, 30),         flags=cv2.cv.cv_haar_scale_image    )      (x, y, w, h) in faces:         cv2.rectangle(imagen, (x, y), (x + w, y + h), (0, 255, 0), 2)         roi_color = imagen[y:y + h, x:x + w]       cv2.imshow('imagen', imagen)     cv2.waitkey(1000) 

thanks in advance help


Comments