Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/dltrack.py @ 1230:c582b272108f
(minor) work in progress
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Mon, 21 Aug 2023 15:49:32 -0400 |
| parents | 759d76d6d20c |
| children | 6487ef10c0e0 |
comparison
equal
deleted
inserted
replaced
| 1229:759d76d6d20c | 1230:c582b272108f |
|---|---|
| 10 # detect model | 10 # detect model |
| 11 # tracker model | 11 # tracker model |
| 12 parser.add_argument('--display', dest = 'display', help = 'show the results (careful with long videos, risk of running out of memory)', action = 'store_true') | 12 parser.add_argument('--display', dest = 'display', help = 'show the results (careful with long videos, risk of running out of memory)', action = 'store_true') |
| 13 args = parser.parse_args() | 13 args = parser.parse_args() |
| 14 | 14 |
| 15 # required functionality? | |
| 16 # # filename of the video to process (can be images, eg image%04d.png) | |
| 17 # video-filename = laurier.avi | |
| 18 # # filename of the database where results are saved | |
| 19 # database-filename = laurier.sqlite | |
| 20 # # filename of the homography matrix | |
| 21 # homography-filename = laurier-homography.txt | |
| 22 # # filename of the camera intrinsic matrix | |
| 23 # intrinsic-camera-filename = intrinsic-camera.txt | |
| 24 # # -0.11759321 0.0148536 0.00030756 -0.00020578 -0.00091816 | |
| 25 # distortion-coefficients = -0.11759321 | |
| 26 # distortion-coefficients = 0.0148536 | |
| 27 # distortion-coefficients = 0.00030756 | |
| 28 # distortion-coefficients = -0.00020578 | |
| 29 # distortion-coefficients = -0.00091816 | |
| 30 # # undistorted image multiplication | |
| 31 # undistorted-size-multiplication = 1.31 | |
| 32 # # Interpolation method for remapping image when correcting for distortion: 0 for INTER_NEAREST - a nearest-neighbor interpolation; 1 for INTER_LINEAR - a bilinear interpolation (used by default); 2 for INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood; 3 for INTER_LANCZOS4 | |
| 33 # interpolation-method = 1 | |
| 34 # # filename of the mask image (where features are detected) | |
| 35 # mask-filename = none | |
| 36 # # undistort the video for feature tracking | |
| 37 # undistort = false | |
| 38 # # load features from database | |
| 39 # load-features = false | |
| 40 # # display trajectories on the video | |
| 41 # display = false | |
| 42 # # original video frame rate (number of frames/s) | |
| 43 # video-fps = 29.97 | |
| 44 # # number of digits of precision for all measurements derived from video | |
| 45 # # measurement-precision = 3 | |
| 46 # # first frame to process | |
| 47 # frame1 = 0 | |
| 48 # # number of frame to process: 0 means processing all frames | |
| 49 # nframes = 0 | |
| 50 | |
| 51 # TODO add option to refine position with mask for vehicles | |
| 52 | |
| 15 # Load a model | 53 # Load a model |
| 16 model = YOLO('/home/nicolas/Research/Data/classification-models/yolov8x.pt') # seg yolov8x-seg.pt | 54 model = YOLO('/home/nicolas/Research/Data/classification-models/yolov8x.pt') # seg yolov8x-seg.pt |
| 17 # seg could be used on cropped image... if can be loaded and kept in memory | 55 # seg could be used on cropped image... if can be loaded and kept in memory |
| 18 # model = YOLO('/home/nicolas/Research/Data/classification-models/yolo_nas_l.pt ') # AttributeError: 'YoloNAS_L' object has no attribute 'get' | 56 # model = YOLO('/home/nicolas/Research/Data/classification-models/yolo_nas_l.pt ') # AttributeError: 'YoloNAS_L' object has no attribute 'get' |
| 19 | 57 |
| 21 if args.display: | 59 if args.display: |
| 22 results = model.track(source=args.videoFilename, tracker="/home/nicolas/Research/Data/classification-models/bytetrack.yaml", classes=list(cocoTypeNames.keys()), show=True) # , save_txt=True | 60 results = model.track(source=args.videoFilename, tracker="/home/nicolas/Research/Data/classification-models/bytetrack.yaml", classes=list(cocoTypeNames.keys()), show=True) # , save_txt=True |
| 23 else: | 61 else: |
| 24 results = model.track(source=args.videoFilename, tracker="/home/nicolas/Research/Data/classification-models/bytetrack.yaml", classes=list(cocoTypeNames.keys()), stream=True) | 62 results = model.track(source=args.videoFilename, tracker="/home/nicolas/Research/Data/classification-models/bytetrack.yaml", classes=list(cocoTypeNames.keys()), stream=True) |
| 25 for result in results: | 63 for result in results: |
| 64 print(len(result.boxes)) | |
| 26 for box in result.boxes: | 65 for box in result.boxes: |
| 27 print(box.xyxy) | 66 print(box.xyxy) |
