not round too early

This commit is contained in:
2024-07-03 22:03:59 +02:00
parent 348624c6a2
commit 19d5aedf22
3 changed files with 13 additions and 13 deletions
+1 -1
View File
@@ -48,7 +48,7 @@ class CornerTracker:
matcher_start_y -= self.ref['offset'][1]
self._print(f"matcher_start : {(matcher_start_x, matcher_start_y)}")
matcher_bbox_local = (round(matcher_start_x), round(matcher_start_y), template.shape[1], template.shape[0])
matcher_bbox_local = (matcher_start_x, matcher_start_y, template.shape[1], template.shape[0])
cv2.imshow(f"{self.name}: Matcher res", matcher_res)
# cv2.imshow("{self.name}: Matcher view", matcher_crop)
+6 -5
View File
@@ -119,7 +119,7 @@ while True:
ct.path_add(line_to)
for p in ct.path:
cv2.line(image_anno, p['from'], p['to'], (0, 0, 255), 2)
cv2.line(image_anno, bbox_round(p['from']), bbox_round(p['to']), (0, 0, 255), 2)
refine_corner(cv2.cvtColor(image, cv2.COLOR_BGR2GRAY), np.array(corners, dtype=np.float32))
@@ -182,7 +182,8 @@ while True:
k = cv2.waitKey(key_wait) & 0xff
if k == 27:
break
if k == ord('g'):
key_wait = 30
if k == ord('s'):
key_wait = -1
if k == ord(' '):
if key_wait == -1:
key_wait = 30
else:
key_wait = -1
+6 -7
View File
@@ -20,17 +20,16 @@ def bbox_add_position(bbox, bbox_add):
def bbox_round(src):
x = int(round(src[0]))
y = int(round(src[1]))
w = int(round(src[2]))
h = int(round(src[3]))
res = ()
for s in src:
res += (int(round(s)),)
return x, y, w, h
return res
def bbox_center(bbox):
x = round(bbox[0] + bbox[2]/2)
y = round(bbox[1] + bbox[3]/2)
x = bbox[0] + bbox[2]/2
y = bbox[1] + bbox[3]/2
return x, y