Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AWS] logdebug when detect face #2766

Merged
merged 3 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 20 additions & 13 deletions jsk_perception/node_scripts/aws_auto_checkin_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,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

Expand Down Expand Up @@ -211,18 +213,23 @@ def callback(self, image, roi):
ret = self.findface(img[image_roi_slice])
if ret != None:
if ret['FaceMatches'] != []:
item = self.dynamodb_table.get_item(
Key={'RekognitionId':
ret['FaceMatches'][0]['Face']['FaceId']})
if not 'Item' in item:
rospy.loginfo("Item does not have FaceId {}".format(item))
continue
face_id = item['Item']['Name']
rospy.loginfo("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))
try:
item = self.dynamodb_table.get_item(
Key={'RekognitionId':
ret['FaceMatches'][0]['Face']['FaceId']})
if not 'Item' in item:
rospy.loginfo("Item does not have FaceId {}".format(item))
continue
face_id = item['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))
except KeyError as e:
rospy.logwarn(
"{}: Dynamodb does not have FaceID: {}".format(
e, ret['FaceMatches'][0]['Face']['FaceID']))

if self.use_window: # copy colored face rectangle to img_gray
img_gray[image_roi_slice] = img[image_roi_slice]
Expand Down
6 changes: 3 additions & 3 deletions jsk_perception/node_scripts/aws_detect_faces.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ def reconfigure_callback(self, config, level):
return config

def process_attributes(self, text, img, bbox):
rospy.loginfo(" {}".format(text))
rospy.logdebug(" {}".format(text))
if self.use_window:
cv2.putText(img, text,
(bbox.x + bbox.height // 2 + 8, bbox.y - bbox.width // 2 + self.offset), cv2.FONT_HERSHEY_PLAIN,
Expand Down Expand Up @@ -213,7 +213,7 @@ def image_callback(self, image):
landmarks_msgs.poses = []

# See https://docs.aws.amazon.com/rekognition/latest/dg/API_DetectFaces.html for detail
rospy.loginfo("Found {} faces".format(len(faces['FaceDetails'])))
rospy.logdebug("Found {} faces".format(len(faces['FaceDetails'])))
for face in faces['FaceDetails']:

# Bounding box of the face
Expand Down Expand Up @@ -387,7 +387,7 @@ def image_callback(self, image):
self.landmarks_pub.publish(landmarks_msgs)

# debug info
rospy.loginfo("processing time {} on message taken at {} sec ago".format(
rospy.logdebug("processing time {} on message taken at {} sec ago".format(
(rospy.Time.now() - start_time).to_sec(),
(rospy.Time.now() - image.header.stamp).to_sec()))

Expand Down
Loading