Mercurial > hg > nsaunier > traffic-intelligence
comparison scripts/dltrack.py @ 1235:855abc69fa99
forgot to use detector and tracker filename
| author | Nicolas Saunier <nicolas.saunier@polymtl.ca> |
|---|---|
| date | Fri, 15 Sep 2023 11:56:16 -0400 |
| parents | dd969637381e |
| children | 100fe098abe9 |
comparison
equal
deleted
inserted
replaced
| 1234:dd969637381e | 1235:855abc69fa99 |
|---|---|
| 59 | 59 |
| 60 | 60 |
| 61 # check if one can go to specific frame https://docs.ultralytics.com/modes/track/#persisting-tracks-loop | 61 # check if one can go to specific frame https://docs.ultralytics.com/modes/track/#persisting-tracks-loop |
| 62 | 62 |
| 63 # Load a model | 63 # Load a model |
| 64 model = YOLO('/home/nicolas/Research/Data/classification-models/yolov8x.pt', ) # seg yolov8x-seg.pt | 64 model = YOLO(args.detectorFilename, ) # seg yolov8x-seg.pt |
| 65 # seg could be used on cropped image... if can be loaded and kept in memory | 65 # seg could be used on cropped image... if can be loaded and kept in memory |
| 66 # model = YOLO('/home/nicolas/Research/Data/classification-models/yolo_nas_l.pt ') # AttributeError: 'YoloNAS_L' object has no attribute 'get' | 66 # model = YOLO('/home/nicolas/Research/Data/classification-models/yolo_nas_l.pt ') # AttributeError: 'YoloNAS_L' object has no attribute 'get' |
| 67 | 67 |
| 68 # Track with the model | 68 # Track with the model |
| 69 #results = model.track(source=args.videoFilename, tracker="/home/nicolas/Research/Data/classification-models/bytetrack.yaml", classes=list(moving.cocoTypeNames.keys()), show=True) # , save_txt=True | 69 #results = model.track(source=args.videoFilename, tracker="/home/nicolas/Research/Data/classification-models/bytetrack.yaml", classes=list(moving.cocoTypeNames.keys()), show=True) # , save_txt=True |
| 80 frameNum = args.firstFrameNum | 80 frameNum = args.firstFrameNum |
| 81 capture.set(cv2.CAP_PROP_POS_FRAMES, frameNum) | 81 capture.set(cv2.CAP_PROP_POS_FRAMES, frameNum) |
| 82 lastFrameNum = args.lastFrameNum | 82 lastFrameNum = args.lastFrameNum |
| 83 | 83 |
| 84 success, frame = capture.read() | 84 success, frame = capture.read() |
| 85 results = model.track(frame, tracker="/home/nicolas/Research/Data/classification-models/bytetrack.yaml", classes=list(moving.cocoTypeNames.keys()), persist=True) | 85 results = model.track(frame, tracker=args.trackerFilename, classes=list(moving.cocoTypeNames.keys()), persist=True) |
| 86 # create object with user type and list of 3 features (bottom ones and middle) + projection | 86 # create object with user type and list of 3 features (bottom ones and middle) + projection |
| 87 while capture.isOpened() and success and frameNum <= lastFrameNum: | 87 while capture.isOpened() and success and frameNum <= lastFrameNum: |
| 88 #for frameNum, result in enumerate(results): | 88 #for frameNum, result in enumerate(results): |
| 89 result = results[0] | 89 result = results[0] |
| 90 print(frameNum, len(result.boxes)) | 90 print(frameNum, len(result.boxes)) |
