modified for site test
This commit is contained in:
@ -15,17 +15,18 @@ def readDict(boxes, TracksDict):
|
||||
for i in range(boxes.shape[0]):
|
||||
tid, fid, bid = int(boxes[i, 4]), int(boxes[i, 7]), int(boxes[i, 8])
|
||||
|
||||
feat = TracksDict[f"frame_{fid}"]["feats"][bid]
|
||||
img = TracksDict[f"frame_{fid}"]["imgs"][bid]
|
||||
trackdict = TracksDict[f"frame_{fid}"]
|
||||
if "feats" in trackdict:
|
||||
feat = trackdict["feats"][bid]
|
||||
feats.append(feat)
|
||||
|
||||
box = TracksDict[f"frame_{fid}"]["boxes"][bid]
|
||||
if "boxes" in trackdict:
|
||||
box = trackdict["boxes"][bid]
|
||||
assert (box[:4].astype(int) == boxes[i, :4].astype(int)).all(), f"Please check: frame_{fid}"
|
||||
|
||||
assert (box[:4].astype(int) == boxes[i, :4].astype(int)).all(), f"Please check: frame_{fid}"
|
||||
|
||||
feats.append(feat)
|
||||
|
||||
# img = TracksDict[fid][f'{bid}_img']
|
||||
# cv2.imwrite(f'./data/imgs/{tid}_{fid}_{bid}.png', img)
|
||||
if "imgs" in trackdict:
|
||||
img = trackdict["imgs"][bid]
|
||||
cv2.imwrite(f'./data/imgs/{tid}_{fid}_{bid}.png', img)
|
||||
|
||||
return np.asarray(feats, dtype=np.float32)
|
||||
|
||||
@ -59,13 +60,12 @@ def track_equal_track(atrack, btrack):
|
||||
''' 2. 轨迹特征相似度判断'''
|
||||
feat = np.concatenate((afeat, bfeat), axis=0)
|
||||
|
||||
emb_simil = 1-np.maximum(0.0, cdist(feat, feat, 'cosine'))
|
||||
emb_ = 1-cdist(np.mean(afeat, axis=0)[None, :], np.mean(bfeat, axis=0)[None, :], 'cosine')
|
||||
emb_simil = 1 - np.maximum(0.0, cdist(feat, feat, 'cosine'))
|
||||
emb_ = 1 - np.maximum(0.0, cdist(np.mean(afeat, axis=0)[None, :], np.mean(bfeat, axis=0)[None, :], 'cosine'))/2
|
||||
|
||||
if emb_[0, 0]<0.66:
|
||||
return False
|
||||
|
||||
|
||||
''' 3. 轨迹空间iou'''
|
||||
alabel = np.array([0] * afids.size, dtype=np.int_)
|
||||
blabel = np.array([1] * bfids.size, dtype=np.int_)
|
||||
@ -93,7 +93,7 @@ def track_equal_track(atrack, btrack):
|
||||
|
||||
af, bf = afeat[a, :], bfeat[b, :]
|
||||
|
||||
emb_ab = 1-cdist(af[None, :], bf[None, :], 'cosine')
|
||||
emb_ab = 1 - np.maximum(0.0, cdist(af[None, :], bf[None, :], 'cosine'))
|
||||
|
||||
|
||||
xa1, ya1 = abox[0] - abox[2]/2, abox[1] - abox[3]/2
|
||||
@ -113,7 +113,22 @@ def track_equal_track(atrack, btrack):
|
||||
|
||||
ious.append(inter/union)
|
||||
embs.append(emb_ab[0, 0])
|
||||
|
||||
|
||||
''' 4. 和同一手部关联,如何将该代码和 iou 部分相融合,需进一步完善'''
|
||||
# ahands = np.array(atrack.Hands)
|
||||
# bhands = np.array(btrack.Hands)
|
||||
# ahids = ahands[:, 0]
|
||||
# bhids = bhands[:, 0]
|
||||
# interhid = set(ahids).intersection(set(bhids))
|
||||
# for hid in interhid:
|
||||
# aidx = ahands[:, 0] == hid
|
||||
# bidx = bhands[:, 0] == hid
|
||||
|
||||
# ahfids = ahids[aidx, 1]
|
||||
# bhfids = bhids[bidx, 1]
|
||||
|
||||
|
||||
|
||||
|
||||
cont = False if len(interfid) else True # fid 无交集
|
||||
cont1 = all(emb > 0.5 for emb in embs)
|
||||
|
Reference in New Issue
Block a user