Skip to content

Commit

Permalink
added botsort file
Browse files Browse the repository at this point in the history
  • Loading branch information
Jake0826 committed Sep 26, 2023
1 parent a44880f commit 19a7a05
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions src/botsort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import cv2
from ultralytics import YOLO

# Load the YOLOv8 model
model = YOLO('yolov8n.pt')

# Open the video file
video_path = "test2_10seconds.mp4"
cap = cv2.VideoCapture(video_path)

# Loop through the video frames
while cap.isOpened():
# Read a frame from the video
success, frame = cap.read()

if success:
# Run YOLOv8 tracking on the frame, persisting tracks between frames
# change tracker to botsort.yaml or bytetrack.yaml
results = model.track(frame, persist=True, tracker="bytetrack.yaml")

# Visualize the results on the frame
annotated_frame = results[0].plot()

# Display the annotated frame
cv2.imshow("YOLOv8 Tracking", annotated_frame)

# Break the loop if 'q' is pressed
if cv2.waitKey(1) & 0xFF == ord("q"):
break
else:
# Break the loop if the end of the video is reached
break

# Release the video capture object and close the display window
cap.release()
cv2.destroyAllWindows()

0 comments on commit 19a7a05

Please sign in to comment.