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