- refactored

- use MOSSE tracker
This commit is contained in:
2024-06-29 14:24:38 +02:00
parent e00b9fad4e
commit 56bd0d3a3b
+5 -3
View File
@@ -78,7 +78,7 @@ trackers = {
'BOOSTING': cv2.legacy.TrackerBoosting, 'BOOSTING': cv2.legacy.TrackerBoosting,
'MEDIANFLOW': cv2.legacy.TrackerMedianFlow 'MEDIANFLOW': cv2.legacy.TrackerMedianFlow
} }
tracker_type = 'KCF' tracker_type = 'MOSSE'
tracker = trackers[tracker_type].create() tracker = trackers[tracker_type].create()
video = cv2.VideoCapture("./data/production_id 4525346 (1080p).mp4") video = cv2.VideoCapture("./data/production_id 4525346 (1080p).mp4")
@@ -120,17 +120,19 @@ while True:
image_template_rotated = image_template image_template_rotated = image_template
if ok: if ok:
current_angle, best_maxLoc = match(image_bbox, image_template, current_angle) current_angle, max_loc = match(image_bbox, image_template, current_angle)
image_template_rotated = im.rotate(image_template, current_angle) image_template_rotated = im.rotate(image_template, current_angle)
# determine the starting and ending (x, y)-coordinates of the # determine the starting and ending (x, y)-coordinates of the
# bounding box # bounding box
(startX, startY) = best_maxLoc (startX, startY) = max_loc
startX += bbox[0] startX += bbox[0]
startY += bbox[1] startY += bbox[1]
endX = startX + bbox[2] endX = startX + bbox[2]
endY = startY + bbox[3] endY = startY + bbox[3]
print(f"startX: {startX}, startY: {startY}")
# draw the bounding box on the image # draw the bounding box on the image
p1 = (int(bbox[0]), int(bbox[1])) p1 = (int(bbox[0]), int(bbox[1]))
p2 = (int(bbox[0] + bbox[2]), int(bbox[1] + bbox[3])) p2 = (int(bbox[0] + bbox[2]), int(bbox[1] + bbox[3]))