Skip to content

Commit

Permalink
prelim easy detection
Browse files Browse the repository at this point in the history
  • Loading branch information
mehulgoel873 committed Oct 22, 2024
1 parent b3f973a commit 6997ede
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 1 deletion.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@ rb_ws/src/buggy/bags/2023-02-19-11-27-49.bag
rb_ws/src/buggy/bags/2023-02-19-11-38-48.bag
rb_ws/src/buggy/bags/*
rb_ws/src/buggy/launch/.main.launch.swp
*.bag
*.bag
.temp*/*
*.avi
41 changes: 41 additions & 0 deletions detect.py
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 added yolo11n.pt
Binary file not shown.

0 comments on commit 6997ede

Please sign in to comment.