Skip to content
Snippets Groups Projects
Commit ea07cf86 authored by Jerry Kuo's avatar Jerry Kuo
Browse files

Minor Changes

parent 3aa3a90e
No related branches found
No related tags found
No related merge requests found
...@@ -19,7 +19,6 @@ font_scale = 0.75 ...@@ -19,7 +19,6 @@ font_scale = 0.75
font_color = (255, 255, 255) font_color = (255, 255, 255)
line_type = 2 line_type = 2
counter = 0
class obj_dist: class obj_dist:
def __init__(self): def __init__(self):
...@@ -41,25 +40,23 @@ class obj_dist: ...@@ -41,25 +40,23 @@ class obj_dist:
ts.registerCallback(self.callback) ts.registerCallback(self.callback)
def callback(self, bbx, image, depth): def callback(self, bbx, image, depth):
print('Called!')
global counter
if bbx.length: if bbx.length:
cv_depth = self.bridge.imgmsg_to_cv2(depth, 'passthrough') cv_depth = self.bridge.imgmsg_to_cv2(depth, 'passthrough')
cv_image = self.bridge.imgmsg_to_cv2(image, 'bgr8') cv_image = self.bridge.imgmsg_to_cv2(image, 'bgr8')
box = bbx.people_list[0] for box in bbx.people_list:
roi_depth = cv_depth[box.xmin:box.xmax, box.ymin:box.ymax] roi_depth = cv_depth[box.xmin:box.xmax, box.ymin:box.ymax]
x = box.xmax - box.xmin
y = box.ymax - box.ymin filtered_depth = roi_depth[roi_depth <= 2900]
_size = len(filtered_depth)
avg_distance = roi_depth[roi_depth <= 2500].sum() / (x*y) / 1000
cv2.putText(cv_image, '{} meters'.format(avg_distance), avg_distance = filtered_depth.sum() / _size / 1000
(box.xmin, box.ymax-100), cv2.putText(cv_image, '{} meters'.format(avg_distance),
font, (box.xmin, box.ymax-100),
font_scale, font,
font_color, font_scale,
line_type) font_color,
self.dist_pub.publish(self.bridge.cv2_to_imgmsg(cv_image)) line_type)
counter += 1 self.dist_pub.publish(self.bridge.cv2_to_imgmsg(cv_image))
def main(args): def main(args):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment