Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from src import detect_faces
- from PIL import Image
- import cv2
- prefix = './images/'
- imageName = 'flap_profile.jpg'
- with Image.open(prefix+imageName) as image:
- bounding_boxes, landmarks = detect_faces(image)
- imageCV = cv2.imread(prefix+imageName)
- for (k, bounding_box) in enumerate(bounding_boxes):
- bounding_box = [int(i) for i in bounding_box]
- print bounding_box
- new_image = imageCV[bounding_box[1]:bounding_box[3]+1, bounding_box[0]:bounding_box[2]+1]
- cv2.imshow("b4 resize", new_image)
- new_image = cv2.resize(new_image, (96,96))
- cv2.imshow("after resize", new_image)
- cv2.imwrite(prefix + imageName[:-4] + '-{0:04}'.format(k) + '.jpg', new_image)
- cv2.waitKey(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement