From ece2900002d313a51813028e195bf081564a0002 Mon Sep 17 00:00:00 2001 From: Jens Ahrensfeld Date: Sat, 29 Jun 2024 13:45:09 +0200 Subject: [PATCH] - make sure int for bboxes - fixed displaying bbox --- ocv_track.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ocv_track.py b/ocv_track.py index 8ba95a8..350f874 100644 --- a/ocv_track.py +++ b/ocv_track.py @@ -15,8 +15,8 @@ def bbox_extend(bbox: cv2.typing.Rect, search_area: float): he2 = int(round(bbox[3]*search_area/2)) res = (int(round(bbox[0]-we2)),) res += (int(round(bbox[1]-he2)),) - res += (bbox[2]+2*we2,) - res += (bbox[3]+2*he2,) + res += (int(bbox[2]+2*we2),) + res += (int(bbox[3]+2*he2),) return res @@ -133,7 +133,9 @@ while True: endY = startY + bbox[3] # draw the bounding box on the image - cv2.rectangle(frame, (startX, startY), (endX, endY), (255, 0, 0), 3) + p1 = (int(bbox[0]), int(bbox[1])) + p2 = (int(bbox[0] + bbox[2]), int(bbox[1] + bbox[3])) + cv2.rectangle(frame, p1, p2, (255, 0, 0), 3) # Calculate Frames per second (FPS) fps = cv2.getTickFrequency() / (cv2.getTickCount() - timer)