From a5e447a926d86cd0bdacd62ea41c131011ce1874 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Thu, 4 Jul 2024 21:59:17 +0200 Subject: [PATCH] use bbox_round() --- ocv_corner_tracker.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/ocv_corner_tracker.py b/ocv_corner_tracker.py index 58c29f0..ba29e62 100644 --- a/ocv_corner_tracker.py +++ b/ocv_corner_tracker.py @@ -2,7 +2,7 @@ import cv2 import numpy as np import imutils as im -from util import image_crop, to_rect, bbox_add_position, bbox_center, bbox_int +from util import image_crop, to_rect, bbox_add_position, bbox_center, bbox_round IMG_SCALE_UP = 1 IMG_ROTATE = 0 @@ -116,18 +116,18 @@ class CornerTracker: print(f"{self.name}: {s}") def _debug(self, _image_anno, tracking_anno, matcher_bbox_local): - matcher_bbox = bbox_int(bbox_add_position(matcher_bbox_local, self.tracking_bb)) + matcher_bbox = bbox_round(bbox_add_position(matcher_bbox_local, self.tracking_bb)) template_top_left, template_bottom_right = to_rect(self.matching_tpl_bb) cv2.rectangle(tracking_anno, template_top_left, template_bottom_right, COLOR_TEMPLATE, 1) - matcher_top_left_local, matcher_bottom_right_local = to_rect(bbox_int(matcher_bbox_local)) + matcher_top_left_local, matcher_bottom_right_local = to_rect(bbox_round(matcher_bbox_local)) cv2.rectangle(tracking_anno, matcher_top_left_local, matcher_bottom_right_local, COLOR_MATCHER, 1) matcher_rect = to_rect(matcher_bbox) cv2.rectangle(_image_anno, matcher_rect[0], matcher_rect[1], COLOR_MATCHER, 1) - tracker_rect = to_rect(bbox_int(self.tracking_bb)) + tracker_rect = to_rect(bbox_round(self.tracking_bb)) cv2.rectangle(_image_anno, tracker_rect[0], tracker_rect[1], self.color, 1) def init_reference_frame(self, _image: np.array): @@ -215,7 +215,7 @@ class CornerTracker: # draw path for _ct in self.corner_matcher_list: for p in _ct.path: - cv2.line(_image_anno, bbox_int(p['from']), bbox_int(p['to']), COLOR_TRACK, 1) + cv2.line(_image_anno, bbox_round(p['from']), bbox_round(p['to']), COLOR_TRACK, 1) distances = [] for _i in range(0, corners_refined.shape[0]): @@ -229,7 +229,7 @@ class CornerTracker: self._print(f" -- Corner coarse [{i}] {corners_raw[_i]}") self._print(f" -- Corner fine [{i}] {corners_refined[_i]}") self._print(f" -- Corner distance [{i}] {corners_refined[_i] - self.corner_ref[_i]}") - cv2.circle(_image_anno, (int(corners_refined[_i, 0]), int(corners_refined[_i, 1])), 4, COLOR_CIRCLE) + cv2.circle(_image_anno, (int(corners_refined[_i, 0] + 0.5), int(corners_refined[_i, 1] + 0.5)), 4, COLOR_CIRCLE) if IMAGE_DEBUG: cv2.imshow(f"{self.name}: Tracker: ", self.tracking_img)