- util: image_crop no round
- construct tracker object in constructor
This commit is contained in:
@@ -106,7 +106,7 @@ class CornerTracker:
|
|||||||
self.matching_tpl_img = None
|
self.matching_tpl_img = None
|
||||||
self.tracking_bb = None
|
self.tracking_bb = None
|
||||||
self.tracking_img = None
|
self.tracking_img = None
|
||||||
self.tracker = None
|
self.tracker = cv2.TrackerKCF.create()
|
||||||
self.corner_ref = None
|
self.corner_ref = None
|
||||||
self.corner_matcher_list = []
|
self.corner_matcher_list = []
|
||||||
|
|
||||||
@@ -166,7 +166,6 @@ class CornerTracker:
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
# Initialize tracker with first frame and bounding box
|
# Initialize tracker with first frame and bounding box
|
||||||
self.tracker = cv2.TrackerKCF().create()
|
|
||||||
self.tracker.init(_image, self.tracking_ref_bb)
|
self.tracker.init(_image, self.tracking_ref_bb)
|
||||||
|
|
||||||
# Refine initial corners and store them as reference
|
# Refine initial corners and store them as reference
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import cv2
|
import cv2
|
||||||
import sys
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import imutils as im
|
import imutils as im
|
||||||
|
|
||||||
@@ -34,19 +33,18 @@ def bbox_center(bbox):
|
|||||||
return x, y
|
return x, y
|
||||||
|
|
||||||
|
|
||||||
def bbox_extend(bbox: cv2.typing.Rect, factor: float = 0):
|
def bbox_extend(bbox: np.array, factor: float = 0):
|
||||||
we2 = bbox[2]*factor/2
|
we2 = bbox[2]*factor/2
|
||||||
he2 = bbox[3]*factor/2
|
he2 = bbox[3]*factor/2
|
||||||
|
|
||||||
return bbox_round((bbox[0]-we2, bbox[1]-he2, bbox[2]+2*we2, bbox[3]+2*he2))
|
return bbox_round((bbox[0]-we2, bbox[1]-he2, bbox[2]+2*we2, bbox[3]+2*he2))
|
||||||
|
|
||||||
|
|
||||||
def image_crop(src, bbox: cv2.typing.Rect):
|
def image_crop(src, bbox: np.array):
|
||||||
bb = bbox_round(bbox)
|
x = int(bbox[0])
|
||||||
x = bb[0]
|
y = int(bbox[1])
|
||||||
y = bb[1]
|
w = int(bbox[2])
|
||||||
w = bb[2]
|
h = int(bbox[3])
|
||||||
h = bb[3]
|
|
||||||
|
|
||||||
dst = src[y:y+h, x:x+w]
|
dst = src[y:y+h, x:x+w]
|
||||||
return dst
|
return dst
|
||||||
|
|||||||
Reference in New Issue
Block a user