refractor tracker and config

This commit is contained in:
bluepulsar
2026-02-01 10:02:49 +08:00
parent 93e0847db6
commit 94cac70e6e
3 changed files with 150 additions and 161 deletions
+6 -6
View File
@@ -36,7 +36,7 @@ def setup_simple_raft():
"""
Setup a simpler version using available models
"""
model = raft_large(pretrained=True, progress=False).to('cuda')
model = raft_small(pretrained=True, progress=False).to('cuda')
model = model.eval()
# Alternative: Use LiteFlowNet (lighter alternative)
print("RAFT loaded successfully")
@@ -61,7 +61,6 @@ def track_raft(prev_frame, frame, model, device):
# Transpose to (H, W, 2) format expected by draw_arrows
flow_np = flow_np.transpose(1, 2, 0) # (2, H, W) -> (H, W, 2)
# torch.onnx.export(
# model, # model to export
# (prev_tensor, curr_tensor), # inputs of the model,
@@ -96,10 +95,11 @@ def main_simple():
dy = 0
frame = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
frame1 = frame[420:660, 840:1080, :]
frame2 = frame[420+dy:660+dy, 840+dx:1080+dx, :]
frame3 = frame[420-dy:660-dy, 840-dx:1080-dx, :]
# frame2 = frame[420+dy:660+dy, 840+dx:1080+dx, :]
# frame3 = frame[420-dy:660-dy, 840-dx:1080-dx, :]
frame = np.concatenate([frame3, frame1, frame2], axis=1)
# frame = np.concatenate([frame3, frame1, frame2], axis=1)
frame = frame1
# cv2.imshow("frame", frame3)
# cv2.waitKey(0)
if prev_gray is None:
@@ -137,7 +137,7 @@ def main_simple():
arrow_scale=1.0
)
arrows = cv2.resize(arrows, (1200, 400))
arrows = cv2.resize(arrows, (400, 400))
cv2.imshow('Optical Flow', arrows)
# prev_gray = gray.copy()