diff --git a/ocv_template_matching.py b/ocv_template_matching.py index 746b410..519618f 100644 --- a/ocv_template_matching.py +++ b/ocv_template_matching.py @@ -4,7 +4,7 @@ import imutils as im import numpy as np from util import bbox_extend, bbox_round, image_crop, to_rect, bbox_add_position, bbox_center -from ocv_corner_tracker import CornerTracker +from ocv_corner_tracker import Corner def refine_corner(src_gray, corners_original: np.array): @@ -51,13 +51,11 @@ crop = image_crop(image.copy(), bb_crop) ct_list = [] count = 1 -key_wait = -1 - while True: print(f"Add Corner {count}") bb_template = cv2.selectROI("Image", crop, fromCenter=True, showCrosshair=True) template = cv2.cvtColor(image_crop(crop.copy(), bb_template), cv2.COLOR_BGR2GRAY) - ct_list.append(CornerTracker(template, bb_template)) + ct_list.append(Corner(template, bb_template, name=f"C-{count}")) print(f"Corner {count} added") print(f"Press any key to add another corner or ESC to continue") @@ -72,6 +70,7 @@ print(f"Added {count} corners") tracker = cv2.TrackerKCF().create() tracker.init(image, bb_crop) +key_wait = -1 while True: # Read a new frame ok, image = video.read()