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`) diff --git a/python/coral_usb/detector_base.py b/python/coral_usb/detector_base.py index 42269a1..dd6b821 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,11 @@ 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) + 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 diff --git a/python/coral_usb/human_pose_estimator.py b/python/coral_usb/human_pose_estimator.py index 619c526..ceed4d3 100644 --- a/python/coral_usb/human_pose_estimator.py +++ b/python/coral_usb/human_pose_estimator.py @@ -191,10 +191,6 @@ def image_cb(self, msg): label_proba=[np.average(score) for score in scores] ) - 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 @@ -203,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): 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(