-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b3f973a
commit 6997ede
Showing
3 changed files
with
44 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import cv2 | ||
|
||
from ultralytics import YOLO | ||
|
||
# Load the YOLO model | ||
model = YOLO("yolo11n.pt") | ||
|
||
# Open the video file | ||
video_path = "9-21-whobaat1.avi" | ||
cap = cv2.VideoCapture(video_path) | ||
|
||
# Loop through the video frames | ||
i = 0 | ||
while cap.isOpened(): | ||
# Read a frame from the video | ||
success, frame = cap.read() | ||
|
||
i+= 1 | ||
if (i % 10 != 0): | ||
continue | ||
|
||
if success: | ||
# Run YOLO inference on the frame | ||
results = model(frame) | ||
|
||
# Visualize the results on the frame | ||
annotated_frame = results[0].plot() | ||
|
||
# Display the annotated frame | ||
cv2.imshow("YOLO Inference", 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() |
Binary file not shown.