use Corner calss

This commit is contained in:
2024-07-04 12:39:08 +02:00
parent ce9797b2b5
commit a2df78b5f8
+3 -4
View File
@@ -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()