import numpy as np
import cv2
filepath = '/ByteTrack-y/tools/datasets/mot/train/MOT17-05-FRCNN/gt/gt.txt'
file_list = []
with open(filepath, 'r') as fp:
for eachline in fp.readlines():
eachline = eachline.rstrip().split(',')
file_list.append(eachline)
# print(file_list)
results = []
N = len(file_list)
for i in range(N-1):
if file_list[i][1] != file_list[i+1][1] or file_list[i][1] != file_list[i-1][1]:
results.append(file_list[i])
results.append(file_list[N-1])
bgimg = np.zeros((480, 640, 3), dtype=np.uint8)
for l in results:
l0, l1, l2, l3 = int(l[2]), int(l[3]), int(l[2]+l[4]), int(l[3]+l[5])
l0 = max(l0, 0)
l1 = max(l1, 0)
l2 = max(l2, 0)
l3 = max(l3, 0)
bgimg[l1:l3+1, l0:l2+1] += 1
# cv2.imshow("dd", bgimg)
# cv2.waitKey(0)
cv2.imwrite('/ByteTrack-y/tools/datasets/mot/train/MOT17-05-FRCNN/gt/sss.jpg', bgimg)
MOT17每个tracklet的热力图
最新推荐文章于 2024-10-03 19:06:10 发布