diff --git a/.gitignore b/.gitignore index 78839b8..9bfefbb 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file +*.bag +.temp*/* +*.avi \ No newline at end of file diff --git a/detect.py b/detect.py new file mode 100644 index 0000000..fb24671 --- /dev/null +++ b/detect.py @@ -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() \ No newline at end of file diff --git a/yolo11n.pt b/yolo11n.pt new file mode 100644 index 0000000..45b273b Binary files /dev/null and b/yolo11n.pt differ