Mercurial Hosting > traffic-intelligence
comparison scripts/dltrack.py @ 1240:bb14f919d1cb
cleaned use of centile (np only) and added info in classify-objects
author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
---|---|
date | Mon, 05 Feb 2024 14:14:14 -0500 |
parents | b684135d817f |
children | 4cd8ace3552f |
comparison
equal
deleted
inserted
replaced
1239:31173c4699d2 | 1240:bb14f919d1cb |
---|---|
10 from torchvision.ops import box_iou | 10 from torchvision.ops import box_iou |
11 import cv2 | 11 import cv2 |
12 | 12 |
13 from trafficintelligence import cvutils, moving, storage, utils | 13 from trafficintelligence import cvutils, moving, storage, utils |
14 | 14 |
15 parser = argparse.ArgumentParser(description='The program tracks objects using the ultralytics models and trakcers.')#, epilog = 'Either the configuration filename or the other parameters (at least video and database filenames) need to be provided.') | 15 parser = argparse.ArgumentParser(description='The program tracks objects using the ultralytics models and trakcers.') |
16 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file', required = True) | 16 parser.add_argument('-i', dest = 'videoFilename', help = 'name of the video file', required = True) |
17 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database file', required = True) | 17 parser.add_argument('-d', dest = 'databaseFilename', help = 'name of the Sqlite database file', required = True) |
18 parser.add_argument('-m', dest = 'detectorFilename', help = 'name of the detection model file', required = True) | 18 parser.add_argument('-m', dest = 'detectorFilename', help = 'name of the detection model file', required = True) |
19 parser.add_argument('-t', dest = 'trackerFilename', help = 'name of the tracker file', required = True) | 19 parser.add_argument('-t', dest = 'trackerFilename', help = 'name of the tracker file', required = True) |
20 parser.add_argument('-o', dest = 'homographyFilename', help = 'filename of the homography matrix', default = 'homography.txt') | 20 parser.add_argument('-o', dest = 'homographyFilename', help = 'filename of the homography matrix', default = 'homography.txt') |
51 frameNum = args.firstFrameNum | 51 frameNum = args.firstFrameNum |
52 capture.set(cv2.CAP_PROP_POS_FRAMES, frameNum) | 52 capture.set(cv2.CAP_PROP_POS_FRAMES, frameNum) |
53 lastFrameNum = args.lastFrameNum | 53 lastFrameNum = args.lastFrameNum |
54 | 54 |
55 success, frame = capture.read() | 55 success, frame = capture.read() |
56 if not success: | |
57 print('Input {} could not be read. Exiting'.format(args.videoFilename)) | |
58 import sys; sys.exit() | |
56 results = model.track(frame, tracker=args.trackerFilename, classes=list(moving.cocoTypeNames.keys()), persist=True, verbose=False) | 59 results = model.track(frame, tracker=args.trackerFilename, classes=list(moving.cocoTypeNames.keys()), persist=True, verbose=False) |
57 # create object with user type and list of 3 features (bottom ones and middle) + projection | 60 # create object with user type and list of 3 features (bottom ones and middle) + projection |
58 while capture.isOpened() and success and frameNum <= lastFrameNum: | 61 while capture.isOpened() and success and frameNum <= lastFrameNum: |
59 #for frameNum, result in enumerate(results): | 62 #for frameNum, result in enumerate(results): |
60 result = results[0] | 63 result = results[0] |