diff --git a/jsk_perception/node_scripts/aws_auto_checkin_app.py b/jsk_perception/node_scripts/aws_auto_checkin_app.py index 2f9373f823..d282c7e6a6 100755 --- a/jsk_perception/node_scripts/aws_auto_checkin_app.py +++ b/jsk_perception/node_scripts/aws_auto_checkin_app.py @@ -152,8 +152,10 @@ def findface(self, face_image): CollectionId=self.COLLECTION_ID, Image={'Bytes': encoded_face_image.tobytes()}, FaceMatchThreshold=self.FACE_SIMILARITY_THRESHOLD, MaxFaces=self.MAX_FACES) return res + except self.rekognition.exceptions.InvalidParameterException as e: + rospy.logdebug("No faces detected") except Exception as e: - print(e) + rospy.logerr(e) return None @@ -189,14 +191,16 @@ def callback(self, image, roi): ret = self.findface(img[image_roi_slice]) if ret != None: if ret['FaceMatches'] != []: - face_id = self.dynamodb_table.get_item( - Key={'RekognitionId': + try: + face_id = self.dynamodb_table.get_item( + Key={'RekognitionId': ret['FaceMatches'][0]['Face']['FaceId']})['Item']['Name'] - rospy.logdebug("FaceId: {}\n Similarity: {}".format(face_id, \ - ret['FaceMatches'][0]['Similarity'])) - faces.faces.append(Face(face=Rect(cx - w // 2, cy - h // 2, w, h), - label=face_id, - confidence=ret['FaceMatches'][0]['Similarity'] / 100.0)) + rospy.logdebug("FaceId: {}\n Similarity: {}".format(face_id, \ + ret['FaceMatches'][0]['Similarity'])) + faces.faces.append(Face(face=Rect(cx - w // 2, cy - h // 2, w, h), + label=face_id, + confidence=ret['FaceMatches'][0]['Similarity'] / 100.0)) + except KeyError: return if self.use_window: # copy colored face rectangle to img_gray img_gray[image_roi_slice] = img[image_roi_slice]