dotrack haved modified!

This commit is contained in:
王庆刚
2024-05-29 20:31:28 +08:00
parent dff029de20
commit d1ea304491
19 changed files with 379 additions and 149 deletions

View File

@ -31,12 +31,19 @@ def readDict(boxes, TracksDict):
def track_equal_track(atrack, btrack, TracksDict):
def track_equal_track(atrack, btrack):
# boxes: [x, y, w, h, track_id, score, cls, frame_index, box_index]
# 0 1 2 3 4 5 6 7 8
aboxes = atrack.boxes
bboxes = btrack.boxes
afeat = atrack.features
bfeat = btrack.features
# afeat = readDict(aboxes, TracksDict)
# bfeat = readDict(bboxes, TracksDict)
''' 1. 判断轨迹在时序上是否有交集 '''
afids = aboxes[:, 7].astype(np.int_)
bfids = bboxes[:, 7].astype(np.int_)
@ -50,8 +57,6 @@ def track_equal_track(atrack, btrack, TracksDict):
return False
''' 2. 轨迹特征相似度判断'''
afeat = readDict(aboxes, TracksDict)
bfeat = readDict(bboxes, TracksDict)
feat = np.concatenate((afeat, bfeat), axis=0)
emb_simil = 1-np.maximum(0.0, cdist(feat, feat, 'cosine'))
@ -82,9 +87,15 @@ def track_equal_track(atrack, btrack, TracksDict):
idx_pair.append((a_idx, b_idx))
ious = []
embs = []
for a, b in idx_pair:
abox, bbox = aboxes[a, :], bboxes[b, :]
af, bf = afeat[a, :], bfeat[b, :]
emb_ab = 1-cdist(af[None, :], bf[None, :], 'cosine')
xa1, ya1 = abox[0] - abox[2]/2, abox[1] - abox[3]/2
xa2, ya2 = abox[0] + abox[2]/2, abox[1] + abox[3]/2
@ -101,12 +112,15 @@ def track_equal_track(atrack, btrack, TracksDict):
union = box1_area + box2_area - inter + 1e-6
ious.append(inter/union)
embs.append(emb_ab[0, 0])
cont = False if len(interfid) else True
# cont2 = emb_[0, 0]>0.75
# cont3 = all(iou>0.5 for iou in ious)
cont = False if len(interfid) else True # fid 无交集
cont1 = all(emb > 0.5 for emb in embs)
cont2 = all(iou > 0.5 for iou in ious)
# cont = cont and cont2 and cont3
cont = cont and cont1 and cont2
return cont