From d2c8a348112b8e8e212e4cdcd8cb719ac854d4eb Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Mon, 26 Jun 2023 15:54:28 +0900 Subject: [PATCH 1/5] Change order of publish classification result and visualization --- python/coral_usb/detector_base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/coral_usb/detector_base.py b/python/coral_usb/detector_base.py index 42269a1..86f8528 100644 --- a/python/coral_usb/detector_base.py +++ b/python/coral_usb/detector_base.py @@ -131,9 +131,6 @@ def image_cb(self, msg): label_names=[self.label_names[lbl] for lbl in labels], label_proba=scores) - self.pub_rects.publish(rect_msg) - self.pub_class.publish(cls_msg) - if self.enable_visualization: with self.lock: self.img = img @@ -143,6 +140,9 @@ def image_cb(self, msg): self.labels = labels self.scores = scores + self.pub_rects.publish(rect_msg) + self.pub_class.publish(cls_msg) + def visualize_cb(self, event): if (not self.visualize or self.img is None or self.encoding is None or self.header is None or self.bboxes is None From d850123a015fd7ce3fdd0ccae78e3d21fa49d753 Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Mon, 26 Jun 2023 15:54:52 +0900 Subject: [PATCH 2/5] Add always_publish arg --- python/coral_usb/detector_base.py | 2 ++ python/coral_usb/node_base.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/python/coral_usb/detector_base.py b/python/coral_usb/detector_base.py index 86f8528..dd6b821 100644 --- a/python/coral_usb/detector_base.py +++ b/python/coral_usb/detector_base.py @@ -140,6 +140,8 @@ def image_cb(self, msg): self.labels = labels self.scores = scores + if not self.always_publish and len(cls_msg.labels) <= 0: + return self.pub_rects.publish(rect_msg) self.pub_class.publish(cls_msg) diff --git a/python/coral_usb/node_base.py b/python/coral_usb/node_base.py index afb5e6c..8c64156 100644 --- a/python/coral_usb/node_base.py +++ b/python/coral_usb/node_base.py @@ -124,6 +124,11 @@ def __init__(self, model_file=None, label_file=None, namespace='~'): self.timer = rospy.Timer( rospy.Duration(self.duration), self.visualize_cb) + self.always_publish = rospy.get_param("~always_publish", True) + rospy.loginfo( + "Publish even if object/human_pose is not found : {}".format( + self.always_publish)) + def subscribe(self): if self.transport_hint == 'compressed': self.sub_image = rospy.Subscriber( From 449593f97d291189a2715fd8a6739e3cac8ab96c Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Mon, 26 Jun 2023 17:40:48 +0900 Subject: [PATCH 3/5] add always_publish arg to human_pose_estimator --- python/coral_usb/human_pose_estimator.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/python/coral_usb/human_pose_estimator.py b/python/coral_usb/human_pose_estimator.py index 619c526..b011f85 100644 --- a/python/coral_usb/human_pose_estimator.py +++ b/python/coral_usb/human_pose_estimator.py @@ -191,6 +191,8 @@ def image_cb(self, msg): label_proba=[np.average(score) for score in scores] ) + if not self.always_publish and len(cls_msg.label_names) <= 0: + return self.pub_pose.publish(poses_msg) self.pub_rects.publish(rects_msg) self.pub_class.publish(cls_msg) From d8f61e9957df8ffdfa4601dd487b68016e7e23ad Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Tue, 27 Jun 2023 12:45:16 +0900 Subject: [PATCH 4/5] Change order of publishing and visualization at human_pose_estimator.py --- python/coral_usb/human_pose_estimator.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/python/coral_usb/human_pose_estimator.py b/python/coral_usb/human_pose_estimator.py index b011f85..ceed4d3 100644 --- a/python/coral_usb/human_pose_estimator.py +++ b/python/coral_usb/human_pose_estimator.py @@ -191,12 +191,6 @@ def image_cb(self, msg): label_proba=[np.average(score) for score in scores] ) - if not self.always_publish and len(cls_msg.label_names) <= 0: - return - self.pub_pose.publish(poses_msg) - self.pub_rects.publish(rects_msg) - self.pub_class.publish(cls_msg) - if self.enable_visualization: with self.lock: self.img = img @@ -205,6 +199,12 @@ def image_cb(self, msg): self.points = points self.visibles = visibles + if not self.always_publish and len(cls_msg.label_names) <= 0: + return + self.pub_pose.publish(poses_msg) + self.pub_rects.publish(rects_msg) + self.pub_class.publish(cls_msg) + def visualize_cb(self, event): if (not self.visualize or self.img is None or self.encoding is None or self.points is None or self.visibles is None): From 928a1d5a0107a01fa56bef0d94c6a20894e36296 Mon Sep 17 00:00:00 2001 From: Naoto Tsukamoto Date: Tue, 27 Jun 2023 13:14:42 +0900 Subject: [PATCH 5/5] Add ~always_subscribe parameter to README.md --- README.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/README.md b/README.md index 7daaec7..16621b1 100644 --- a/README.md +++ b/README.md @@ -491,6 +491,10 @@ rosrun image_view image_view image:=/edgetpu_panorama_semantic_segmenter/output/ - Set `compressed` to subscribe compressed image +- `~always_subscribe` (`Bool`, default: `True`) + + - Set false to publish when an object is detected. + #### Dynamic parameters - `~score_thresh`: (`Float`, default: `0.6`) @@ -551,6 +555,10 @@ rosrun image_view image_view image:=/edgetpu_panorama_semantic_segmenter/output/ - Set `compressed` to subscribe compressed image +- `~always_subscribe` (`Bool`, default: `True`) + + - Set false to publish when a face is detected. + #### Dynamic parameters - `~score_thresh`: (`Float`, default: `0.6`) @@ -615,6 +623,10 @@ rosrun image_view image_view image:=/edgetpu_panorama_semantic_segmenter/output/ - Set `compressed` to subscribe compressed image +- `~always_subscribe` (`Bool`, default: `True`) + + - Set false to publish when a human pose is detected. + #### Dynamic parameters - `~score_thresh`: (`Float`, default: `0.2`) @@ -713,6 +725,10 @@ rosrun image_view image_view image:=/edgetpu_panorama_semantic_segmenter/output/ - Set `compressed` to subscribe compressed image +- `~always_subscribe` (`Bool`, default: `True`) + + - Set false to publish when an object is detected. + #### Dynamic parameters - `~score_thresh`: (`Float`, default: `0.6`) @@ -789,6 +805,10 @@ rosrun image_view image_view image:=/edgetpu_panorama_semantic_segmenter/output/ - Set `compressed` to subscribe compressed image +- `~always_subscribe` (`Bool`, default: `True`) + + - Set false to publish when a face is detected. + #### Dynamic parameters - `~score_thresh`: (`Float`, default: `0.6`) @@ -869,6 +889,10 @@ rosrun image_view image_view image:=/edgetpu_panorama_semantic_segmenter/output/ - Set `compressed` to subscribe compressed image +- `~always_subscribe` (`Bool`, default: `True`) + + - Set false to publish when a human pose is detected. + #### Dynamic parameters - `~score_thresh`: (`Float`, default: `0.2`)