SHARE
TWEET

Untitled

a guest Jun 16th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from src import detect_faces
  2. from PIL import Image
  3. import cv2
  4.  
  5. prefix = './images/'
  6. imageName = 'flap_profile.jpg'
  7.  
  8. with Image.open(prefix+imageName) as image:
  9.     bounding_boxes, landmarks = detect_faces(image)
  10.     imageCV = cv2.imread(prefix+imageName)
  11.     for (k, bounding_box) in enumerate(bounding_boxes):
  12.     bounding_box = [int(i) for i in bounding_box]
  13.     print bounding_box
  14.         new_image = imageCV[bounding_box[1]:bounding_box[3]+1, bounding_box[0]:bounding_box[2]+1]
  15.     cv2.imshow("b4 resize", new_image)
  16.         new_image = cv2.resize(new_image, (96,96))
  17.     cv2.imshow("after resize", new_image)
  18.         cv2.imwrite(prefix + imageName[:-4] + '-{0:04}'.format(k) + '.jpg', new_image)
  19.     cv2.waitKey(0)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top