forked from augmentedstartups/AS-One
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
47 lines (38 loc) · 1.87 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import argparse
import asone
from asone import ASOne
def main(args):
filter_classes = args.filter_classes
if filter_classes:
filter_classes = [filter_classes]
dt_obj = ASOne(
tracker=asone.BYTETRACK,
detector=asone.YOLOX_DARKNET_PYTORCH,
use_cuda=args.use_cuda
)
# Get tracking function
track_fn = dt_obj.track_video(args.video_path,
output_dir=args.output_dir,
save_result=args.save_result,
display=args.display,
draw_trails=args.draw_trails,
filter_classes=filter_classes)
# Loop over track_fn to retrieve outputs of each frame
for bbox_details, frame_details in track_fn:
bbox_xyxy, ids, scores, class_ids = bbox_details
frame, frame_num, fps = frame_details
print(frame_num)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('video_path', help='Path to input video')
parser.add_argument('--cpu', default=True, action='store_false', dest='use_cuda',
help='run on cpu if not provided the program will run on gpu.')
parser.add_argument('--no_save', default=True, action='store_false',
dest='save_result', help='whether or not save results')
parser.add_argument('--no_display', default=True, action='store_false',
dest='display', help='whether or not display results on screen')
parser.add_argument('--output_dir', default='data/results', help='Path to output directory')
parser.add_argument('--draw_trails', default=False, help='if provided object motion trails will be drawn.')
parser.add_argument('--filter_classes', default=None, help='Filter class name')
args = parser.parse_args()
main(args)