Advertisement
natym

OpenCV_cat faces

Jun 16th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. def face_mark(image):
  2.     """
  3.     Mark faces with boxes-----cambiar
  4.     """
  5.  
  6.     # work on a copy
  7.     image = image.copy()
  8.    
  9.     # identify boxes
  10.     boxes = face_detect(image)
  11.  
  12.     # get drawing context for the current image
  13.     ctx = ImageDraw.Draw(image)
  14.  
  15.     # crop out faces
  16.     faces = [image.crop(rect) for rect in boxes]
  17.  
  18.    
  19.     # put the cat on the boxes
  20.     cat = Image.open("animal_1.png")
  21.     resize_cat = cat.resize((150, 150), resample=Image.BICUBIC)
  22.     resize_cat.show()
  23.  
  24.     for box in boxes:
  25.         image.paste (resize_cat, box = None)
  26.  
  27.     return image, resize_cat
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement