UI
def face_rekognition(self,event = None):
client=boto3.client('rekognition')
img = cv2.imread(self.imageFile)
img_PIL = Image.open(self.imageFile)
width, height = img_PIL.size
with open(self.imageFile, 'rb') as image:
faces_response = client.detect_faces(Image=
{'Bytes': image.read()},
Attributes=['ALL'])
face_jsonfile = "faceoutput.json"
with open(face_jsonfile, 'w') as fp:
json.dump(faces_response, fp)
imOut = img.copy()
for faceDetail in faces_response['FaceDetails']:
cv2.rectangle(imOut,
(int(width*faceDetail['BoundingBox']['Left']),
int(height*faceDetail['BoundingBox']['Top'])),
(int(width*(faceDetail['BoundingBox']['Left']+
faceDetail['BoundingBox']['Width'])),
int(height*(faceDetail['BoundingBox']['Top']+
faceDetail['BoundingBox']['Height']))),
self.color_1,int(self.linesizespinbox.get()))
for eachperson in faceDetail['Landmarks']:
cv2.circle(imOut,
(int(width*eachperson['X']),
int(height*eachperson['Y'])),
int(self.linesizespinbox.get()),
self.color_2,
-1)
while True:
cv2.imshow("Output", imOut)
k = cv2.waitKey(0) & 0xFF
if k == 113:
break
cv2.destroyAllWindows()