Skip to content

Commit 6cc7118

Browse files
committed
Make dummy SegmentFromPoint more robust
1 parent e0a519b commit 6cc7118

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

feeding_web_app_ros2_test/feeding_web_app_ros2_test/SegmentFromPoint.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,9 @@ def segment_image(self, seed_point, result, segmentation_success):
262262
mask_msg.depth_image = self.bridge.cv2_to_imgmsg(
263263
depth_img[y_min:y_max, x_min:x_max], "passthrough"
264264
)
265+
depth_points_in_mask = depth_img[y_min:y_max, x_min:x_max][mask_img > 0]
265266
mask_msg.average_depth = (
266-
np.median(depth_img[y_min:y_max, x_min:x_max][mask_img > 0]) / 1000.0
267+
np.median(depth_points_in_mask[depth_points_in_mask > 0]) / 1000.0
267268
) # Convert to meters
268269
mask_msg.item_id = "dummy_food_id_%d" % (i)
269270
mask_msg.confidence = np.random.random()

0 commit comments

Comments
 (0)