提交 acbd36a9 编写于 作者: F feilong

修正车辆目标跟踪的路径bug

上级 cfdcccae
...@@ -19,6 +19,8 @@ tracks = np.empty((0, 5)) ...@@ -19,6 +19,8 @@ tracks = np.empty((0, 5))
sort = Sort(5, 0, 0.2) sort = Sort(5, 0, 0.2)
# do track and render on image # do track and render on image
def track_and_render(detections, img): def track_and_render(detections, img):
global total_frames global total_frames
global total_time global total_time
...@@ -40,7 +42,8 @@ def track_and_render(detections, img): ...@@ -40,7 +42,8 @@ def track_and_render(detections, img):
cycle_time = time.time() - start_time cycle_time = time.time() - start_time
total_time += cycle_time total_time += cycle_time
if total_frames % 100 == 0: if total_frames % 100 == 0:
print("Total Tracking took: %.3f seconds for %d frames or %.1f FPS" % (total_time, total_frames, total_frames / total_time)) print("Total Tracking took: %.3f seconds for %d frames or %.1f FPS" %
(total_time, total_frames, total_frames / total_time))
total_time = 0.0 total_time = 0.0
total_frames = 0 total_frames = 0
...@@ -63,18 +66,18 @@ def track_and_render(detections, img): ...@@ -63,18 +66,18 @@ def track_and_render(detections, img):
if __name__ == '__main__': if __name__ == '__main__':
# detection data, generated by object-detector algo model, including frame image # detection data, generated by object-detector algo model, including frame image
path = 'mot_benchmark\\MY_TEST\\www3' path = 'mot_benchmark/MY_TEST/www3'
# read test data from disk in a loop one frame by frame and send it to sort tracker # read test data from disk in a loop one frame by frame and send it to sort tracker
for i in range(400000): for i in range(400000):
# read frame image # read frame image
bg = cv2.imread(path + '\\' + str(i % 800 + 1) + '.jpg') bg = cv2.imread(path + '/' + str(i % 800 + 1) + '.jpg')
# rescale # rescale
bg = cv2.resize(bg, (int(1280 / scale), int(720 / scale))) bg = cv2.resize(bg, (int(1280 / scale), int(720 / scale)))
# read detection data in current frame # read detection data in current frame
dets = [] dets = []
with open(path + '\\' + str(i % 800 + 1) + '.txt') as txt: with open(path + '/' + str(i % 800 + 1) + '.txt') as txt:
lines = txt.readlines() lines = txt.readlines()
for line in lines: for line in lines:
items = line.split(' ') items = line.split(' ')
...@@ -83,7 +86,8 @@ if __name__ == '__main__': ...@@ -83,7 +86,8 @@ if __name__ == '__main__':
right = float(items[3]) right = float(items[3])
bottom = float(items[4]) bottom = float(items[4])
dets.append((left / scale, top / scale, right / scale, bottom / scale, int(items[0]))) dets.append((left / scale, top / scale, right /
scale, bottom / scale, int(items[0])))
# send to the tracker and draw the result on background image # send to the tracker and draw the result on background image
if len(dets) > 0: if len(dets) > 0:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册