From d81a73175978bb0c7cef2943ce80900b1ce95b99 Mon Sep 17 00:00:00 2001 From: Yoshiki Obinata Date: Mon, 17 Apr 2023 11:26:30 +0900 Subject: [PATCH 1/3] publish Skel --- python/coral_usb/human_pose_estimator.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/python/coral_usb/human_pose_estimator.py b/python/coral_usb/human_pose_estimator.py index 619c526..747f247 100644 --- a/python/coral_usb/human_pose_estimator.py +++ b/python/coral_usb/human_pose_estimator.py @@ -27,10 +27,13 @@ from geometry_msgs.msg import Point from geometry_msgs.msg import Pose from jsk_recognition_msgs.msg import ClassificationResult +from jsk_recognition_msgs.msg import HumanSkeleton +from jsk_recognition_msgs.msg import HumanSkeletonArray from jsk_recognition_msgs.msg import PeoplePose from jsk_recognition_msgs.msg import PeoplePoseArray from jsk_recognition_msgs.msg import Rect from jsk_recognition_msgs.msg import RectArray +from jsk_recognition_msgs.msg import Segment from sensor_msgs.msg import CompressedImage @@ -59,6 +62,8 @@ def __init__(self, model_file=None, namespace='~'): self.label_names = ['human'] # publishers + self.pub_skel = self.advertise( + namespace + 'output/skels', HumanSkeletonArray, queue_size=1) self.pub_pose = self.advertise( namespace + 'output/poses', PeoplePoseArray, queue_size=1) self.pub_rects = self.advertise( @@ -163,11 +168,13 @@ def image_cb(self, msg): points, key_names, visibles, bboxes, labels, scores \ = self._estimate(img) + skels_msg = HumanSkeletonArray(header=msg.header) poses_msg = PeoplePoseArray(header=msg.header) rects_msg = RectArray(header=msg.header) for point, key_name, visible, bbox, label, score in zip( points, key_names, visibles, bboxes, labels, scores): pose_msg = PeoplePose() + skel_msg = HumanSkeleton(header=msg.header) for pt, key_nm, vs, sc in zip(point, key_name, visible, score): if vs: key_y, key_x = pt @@ -175,6 +182,14 @@ def image_cb(self, msg): pose_msg.scores.append(sc) pose_msg.poses.append( Pose(position=Point(x=key_x, y=key_y))) + for i in range(len(pose_msg.poses)): # create skel msg + skel_msg.bone_names.append("{}->{}".format(pose_msg.limb_names[i-1], + pose_msg.limb_names[i])) + seg = Segment() + seg.start_point = pose_msg.poses[i-1].position + seg.end_point = pose_msg.poses[i].position + skel_msg.bones.append(seg) + skels_msg.skeletons.append(skel_msg) poses_msg.poses.append(pose_msg) y_min, x_min, y_max, x_max = bbox rect = Rect( @@ -191,6 +206,7 @@ def image_cb(self, msg): label_proba=[np.average(score) for score in scores] ) + self.pub_skel.publish(skels_msg) self.pub_pose.publish(poses_msg) self.pub_rects.publish(rects_msg) self.pub_class.publish(cls_msg) From b25f81026a9ae404e524a0cbd7c1ef2a7b2d823f Mon Sep 17 00:00:00 2001 From: Yoshiki Obinata Date: Mon, 17 Apr 2023 11:44:58 +0900 Subject: [PATCH 2/3] fix lint --- python/coral_usb/human_pose_estimator.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/python/coral_usb/human_pose_estimator.py b/python/coral_usb/human_pose_estimator.py index 747f247..3243643 100644 --- a/python/coral_usb/human_pose_estimator.py +++ b/python/coral_usb/human_pose_estimator.py @@ -182,11 +182,12 @@ def image_cb(self, msg): pose_msg.scores.append(sc) pose_msg.poses.append( Pose(position=Point(x=key_x, y=key_y))) - for i in range(len(pose_msg.poses)): # create skel msg - skel_msg.bone_names.append("{}->{}".format(pose_msg.limb_names[i-1], - pose_msg.limb_names[i])) + for i in range(len(pose_msg.poses)): + bone_name = "{}->{}".format(pose_msg.limb_names[i - 1], + pose_msg.limb_names[i]) + skel_msg.bone_names.append(bone_name) seg = Segment() - seg.start_point = pose_msg.poses[i-1].position + seg.start_point = pose_msg.poses[i - 1].position seg.end_point = pose_msg.poses[i].position skel_msg.bones.append(seg) skels_msg.skeletons.append(skel_msg) From 583c89e53f77050d44e0e8fd22f7eecb642059a7 Mon Sep 17 00:00:00 2001 From: Yoshiki Obinata Date: Tue, 18 Apr 2023 10:13:40 +0900 Subject: [PATCH 3/3] rename skel to skeletons, add human_ids field --- python/coral_usb/human_pose_estimator.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/coral_usb/human_pose_estimator.py b/python/coral_usb/human_pose_estimator.py index 3243643..9683114 100644 --- a/python/coral_usb/human_pose_estimator.py +++ b/python/coral_usb/human_pose_estimator.py @@ -35,6 +35,7 @@ from jsk_recognition_msgs.msg import RectArray from jsk_recognition_msgs.msg import Segment from sensor_msgs.msg import CompressedImage +from std_msgs.msg import Int32 class EdgeTPUHumanPoseEstimator(EdgeTPUNodeBase): @@ -63,7 +64,7 @@ def __init__(self, model_file=None, namespace='~'): # publishers self.pub_skel = self.advertise( - namespace + 'output/skels', HumanSkeletonArray, queue_size=1) + namespace + 'output/skeletons', HumanSkeletonArray, queue_size=1) self.pub_pose = self.advertise( namespace + 'output/poses', PeoplePoseArray, queue_size=1) self.pub_rects = self.advertise( @@ -197,7 +198,6 @@ def image_cb(self, msg): x=x_min, y=y_min, width=x_max - x_min, height=y_max - y_min) rects_msg.rects.append(rect) - cls_msg = ClassificationResult( header=msg.header, classifier=self.classifier_name, @@ -206,7 +206,8 @@ def image_cb(self, msg): label_names=[self.label_names[lbl] for lbl in labels], label_proba=[np.average(score) for score in scores] ) - + for i in range(len(skels_msg.skeletons)): + skels_msg.human_ids.append(Int32(data=i)) self.pub_skel.publish(skels_msg) self.pub_pose.publish(poses_msg) self.pub_rects.publish(rects_msg)