Skip to content

Commit

Permalink
feat: add debugging of cropped face
Browse files Browse the repository at this point in the history
  • Loading branch information
m-barker committed Feb 9, 2024
1 parent 5f3ab4b commit a4dfcec
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
10 changes: 9 additions & 1 deletion common/vision/lasr_vision_deepface/nodes/service
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ if DEBUG:
learn_face_debug_publisher = rospy.Publisher(
"/learn_face/debug", Image, queue_size=1
)
cropped_face_publisher = rospy.Publisher(
"/learn_face/debug/cropped_query_face", Image, queue_size=1
)


def detect(request: RecogniseRequest) -> RecogniseResponse:
Expand All @@ -37,6 +40,7 @@ def detect(request: RecogniseRequest) -> RecogniseResponse:
similar_face_debug_publisher = recognise_debug_publishers[request.dataset][
1
]
cropped_face_publisher = recognise_debug_publisher[request.dataset][2]
else:
topic_name = re.sub(r"[\W_]+", "", request.dataset)
debug_publisher = rospy.Publisher(
Expand All @@ -45,12 +49,16 @@ def detect(request: RecogniseRequest) -> RecogniseResponse:
similar_face_debug_publisher = rospy.Publisher(
f"/recognise/debug/{topic_name}/similar_face", Image, queue_size=1
)
cropped_face_publisher = rospy.Publisher(
"/learn_face/debug/cropped_query_face", Image, queue_size=1
)
recognise_debug_publishers[request.dataset] = (
debug_publisher,
similar_face_debug_publisher,
cropped_face_publisher,
)
return face_recognition.detect(
request, debug_publisher, similar_face_debug_publisher
request, debug_publisher, similar_face_debug_publisher, cropped_face_publisher
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def detect(
request: RecogniseRequest,
debug_publisher: rospy.Publisher | None,
debug_inference_pub: rospy.Publisher | None,
cropped_detect_pub: rospy.Publisher | None,
) -> RecogniseResponse:
# Decode the image
rospy.loginfo("Decoding")
Expand Down Expand Up @@ -152,6 +153,11 @@ def detect(
detection.confidence = 1.0 - row["distance"][0]
response.detections.append(detection)

cropped_image = cv_im[:][y : y + h, x : x + w]

if cropped_detect_pub is not None:
cropped_detect_pub.publish(cv2_img.cv2_img_to_msg(cropped_image))

# Draw bounding boxes and labels for debugging
cv2.rectangle(cv_im, (x, y), (x + w, y + h), (0, 0, 255), 2)
cv2.putText(
Expand Down

0 comments on commit a4dfcec

Please sign in to comment.