From a2bb487b3ca52bba6ad3d6c3c3c1762101ddb8a3 Mon Sep 17 00:00:00 2001 From: Gustavo Date: Fri, 24 May 2024 18:56:27 +0200 Subject: [PATCH] Reuse function colors to label --- .../people_recognizer_2d.py | 27 +++++-------------- 1 file changed, 7 insertions(+), 20 deletions(-) diff --git a/people_recognition_2d/src/people_recognition_2d/people_recognizer_2d.py b/people_recognition_2d/src/people_recognition_2d/people_recognizer_2d.py index ab02c05..a6d240a 100644 --- a/people_recognition_2d/src/people_recognition_2d/people_recognizer_2d.py +++ b/people_recognition_2d/src/people_recognition_2d/people_recognizer_2d.py @@ -209,28 +209,15 @@ def _face_properties_to_label(face_properties): face_properties.age) @staticmethod - def _shirt_colors_to_label(shirt_colors): + def _object_colors_to_label(object_colors, object_name): """ - Convert shirt colors array to label string + Convert object colors array to label string - :param: shirt_colors: Array to colors + :param: object_colors: Array to colors :return: string label """ - label = " shirt colors:" - for color in shirt_colors: - label += " {}".format(color) - return label - - @staticmethod - def _hair_colors_to_label(hair_colors): - """ - Convert shirt colors array to label string - - :param: shirt_colors: Array to colors - :return: string label - """ - label = " hair colors:" - for color in hair_colors: + label = f" {object_name} colors:" + for color in object_colors: label += " {}".format(color) return label @@ -347,8 +334,8 @@ def recognize(self, image_msg): face_recognitions): temp_label = PeopleRecognizer2D._face_properties_to_label(face_properties) + \ - PeopleRecognizer2D._shirt_colors_to_label(shirt_colors) + \ - PeopleRecognizer2D._hair_colors_to_label(hair_colors) + PeopleRecognizer2D._object_colors_to_label(shirt_colors, "shirt") + \ + PeopleRecognizer2D._object_colors_to_label(hair_colors, "hair") if face_label: image_annotations.append(face_label + " " + temp_label)