calculate initial offset from template to correct matcher coord
This commit is contained in:
@@ -38,6 +38,9 @@ tracker.init(image, bb_crop)
|
|||||||
path = []
|
path = []
|
||||||
line_from = None
|
line_from = None
|
||||||
|
|
||||||
|
is_startup = True
|
||||||
|
offset_x = 0
|
||||||
|
offset_y = 1
|
||||||
while True:
|
while True:
|
||||||
# Read a new frame
|
# Read a new frame
|
||||||
ok, image = video.read()
|
ok, image = video.read()
|
||||||
@@ -64,7 +67,19 @@ while True:
|
|||||||
print(f"crop_scaled : {crop_scaled.shape}")
|
print(f"crop_scaled : {crop_scaled.shape}")
|
||||||
print(f"template : {template.shape}")
|
print(f"template : {template.shape}")
|
||||||
print(f"template_scaled : {template_scaled.shape}")
|
print(f"template_scaled : {template_scaled.shape}")
|
||||||
matcher_bbox_local = (max_loc[0]/IMG_SCALE_UP, max_loc[1]/IMG_SCALE_UP, template.shape[1], template.shape[0])
|
|
||||||
|
matcher_start_x = max_loc[0]/IMG_SCALE_UP
|
||||||
|
matcher_start_y = max_loc[0]/IMG_SCALE_UP
|
||||||
|
if is_startup:
|
||||||
|
is_startup = False
|
||||||
|
offset_x = matcher_start_x - bb_template[0]
|
||||||
|
offset_y = matcher_start_y - bb_template[1]
|
||||||
|
print(f"offset : {(offset_x, offset_y)}")
|
||||||
|
|
||||||
|
matcher_start_x -= offset_x
|
||||||
|
matcher_start_y -= offset_y
|
||||||
|
print(f"matcher_start : {(matcher_start_x, matcher_start_y)}")
|
||||||
|
matcher_bbox_local = (round(matcher_start_x), round(matcher_start_y), template.shape[1], template.shape[0])
|
||||||
matcher_top_left_local, matcher_bottom_right_local = to_rect(bbox_round(matcher_bbox_local))
|
matcher_top_left_local, matcher_bottom_right_local = to_rect(bbox_round(matcher_bbox_local))
|
||||||
|
|
||||||
matcher_bbox = bbox_round(bbox_add_position(matcher_bbox_local, bb_crop))
|
matcher_bbox = bbox_round(bbox_add_position(matcher_bbox_local, bb_crop))
|
||||||
|
|||||||
Reference in New Issue
Block a user