Destroy select window after enter
This commit is contained in:
@@ -22,11 +22,10 @@ class Corner:
|
||||
self.line_from = None
|
||||
self.first_frame = True
|
||||
|
||||
def _debug(self, matcher_res, matcher_start_x, matcher_start_y, template_scaled, crop_scaled):
|
||||
template = self.ref['image']
|
||||
def _debug(self, image, matcher_res, matcher_start_x, matcher_start_y, template_scaled, crop_scaled):
|
||||
template_img = self.ref['image']
|
||||
offset = self.ref['offset']
|
||||
|
||||
matcher_bbox_local = (matcher_start_x, matcher_start_y, template.shape[1], template.shape[0])
|
||||
(min_val, max_val, min_loc, max_loc) = cv2.minMaxLoc(matcher_res)
|
||||
|
||||
self._print(f"(min_val, max_val, min_loc, max_loc): {(min_val, max_val, min_loc, max_loc)}")
|
||||
@@ -34,10 +33,11 @@ class Corner:
|
||||
self._print(f"matcher_res : {matcher_res.shape}")
|
||||
self._print(f"crop : {image.shape}")
|
||||
self._print(f"crop_scaled : {crop_scaled.shape}")
|
||||
self._print(f"template : {template.shape}")
|
||||
self._print(f"template : {template_img.shape}")
|
||||
self._print(f"template_scaled : {template_scaled.shape}")
|
||||
self._print(f"offset : {offset}")
|
||||
|
||||
matcher_bbox_local = (matcher_start_x, matcher_start_y, template_img.shape[1], template_img.shape[0])
|
||||
matcher_crop = image_crop(image, matcher_bbox_local)
|
||||
cv2.imshow(f"{self.name}: Matcher res", matcher_res)
|
||||
cv2.imshow(f"{self.name}: Matcher view", matcher_crop)
|
||||
@@ -46,6 +46,7 @@ class Corner:
|
||||
print(f"{self.name}: {s}")
|
||||
|
||||
def process(self, image: np.array):
|
||||
image_anno = image.copy()
|
||||
crop_scaled = im.resize(image, IMG_SCALE_UP * image.shape[1], IMG_SCALE_UP * image.shape[0])
|
||||
template = self.ref['image']
|
||||
bb_template = self.ref['bbox']
|
||||
@@ -73,7 +74,7 @@ class Corner:
|
||||
|
||||
matcher_bbox_local = (matcher_start_x, matcher_start_y, template.shape[1], template.shape[0])
|
||||
|
||||
self._debug(matcher_res, matcher_start_x, matcher_start_y, template_scaled, crop_scaled)
|
||||
self._debug(image_anno, matcher_res, matcher_start_x, matcher_start_y, template_scaled, crop_scaled)
|
||||
|
||||
return matcher_bbox_local, matcher_res
|
||||
|
||||
@@ -120,7 +121,7 @@ class CornerTracker:
|
||||
|
||||
def init_reference_frame(self, image: np.array):
|
||||
print(f"Select tracking object")
|
||||
self.tracking_ref_bb = cv2.selectROI("Image", image, False)
|
||||
self.tracking_ref_bb = cv2.selectROI("Select", image, False)
|
||||
self.tracking_ref_img = image_crop(image.copy(), self.tracking_ref_bb)
|
||||
self.tracking_ref_gray_img = cv2.cvtColor(self.tracking_ref_img, cv2.COLOR_BGR2GRAY)
|
||||
|
||||
@@ -144,6 +145,7 @@ class CornerTracker:
|
||||
# Initialize tracker with first frame and bounding box
|
||||
self.tracker = cv2.TrackerKCF().create()
|
||||
self.tracker.init(image, self.tracking_ref_bb)
|
||||
cv2.destroyWindow("Select")
|
||||
|
||||
def process(self, image: np.array):
|
||||
if self.tracker is None:
|
||||
|
||||
Reference in New Issue
Block a user