Repository navigation
Releases
YOLOv8_OpenField_Analysis_Script_v2
YOLOv8_CustomModel_Open-Field-Analysis
This project utilizes the YoloV8 object detection model to analyze the distance, speed, and time of objects in video frames. The code snippets provided as Jupyter Script perform various tasks to process and visualize the data extracted from the model's output.
Code Snippets Overview
-
Import Libraries: Essential libraries such as
numpy,pandas, andmatplotlibare imported for data manipulation and visualization. -
Load txt Files: Loads
.txtfiles generated by YOLOv8, which contain detected object information. -
Sort txt Files: Sorts the
.txtfiles based on the frame number extracted from the filenames, ensuring chronological analysis. -
Calculate Centroids: Computes the centroids of bounding boxes for each detected object, providing a single point representing the object's location.
-
Draw ROIs: The user can draw Regions of Interest (ROIs) on the plot for further analysis of object movement within these areas.
-
Average Speed & Time: Calculates the average speed of objects and the time spent in each ROI, offering insights into object behavior.
-
Entries & Exits: Smooths the coordinates and counts the number of entries and exits made per ROI, useful for understanding object interaction with specific areas.
-
Graph Entries/Exits: Visualizes the number of entries and exits for each ROI and highlights the first ROI entered, aiding in the interpretation of object flow.
-
Time Spent in Each ROI: Visualizes the number of seconds spent in each ROI.
Usage
This project is designed to be user-friendly and adaptable to various video analysis needs. Here are the steps to get started:
-
Environment Setup: Ensure you have a Python environment with the necessary libraries (
numpy,pandas,matplotlib) installed. These libraries are fundamental for data manipulation and visualization. -
Data Preparation: Place path to your
.txtfiles in code block 2. Make sure the files are named appropriately to reflect the frame sequence. -
Code Execution: Run the code cells in the provided order. Each cell is designed to perform a specific task, contributing to the overall analysis. You can adjust parameters like
window_sizeas needed for your specific data. -
Result Interpretation: The final outputs include calculated metrics (average speed, time spent, entries, and exits per ROI) and visualizations. These results provide valuable insights into object behavior and interactions within the video frames.
-
Customization: Feel free to modify the code to suit your specific needs. The modular design of the code snippets allows for easy adjustments and enhancements.
By following these steps, users can effectively analyze object movement in video data. This analysis can reveal patterns and behaviors that might not be immediately apparent, providing a deeper understanding of the video content. Whether you're studying traffic patterns, observing wildlife, or monitoring security footage, this project offers a robust toolset for video analysis.
Please feel free to reach out with suggestions and comments. It will help me to improve my coding and to learn more about the needs of the behavioral neuroscience community.
YOLOv8_OpenField_Analysis_Script
YOLOv8_CustomModel_Open-Field-Analysis
This project utilizes the YoloV8 object detection model to analyze the distance, speed, and time of objects in video frames. The code snippets provided as Jupyter Script perform various tasks to process and visualize the data extracted from the model's output.
Code Snippets Overview
-
Import Libraries: Essential libraries such as
numpy,pandas, andmatplotlibare imported for data manipulation and visualization. -
Load txt Files: Loads
.txtfiles generated by YOLOv8, which contain detected object information. -
Sort txt Files: Sorts the
.txtfiles based on the frame number extracted from the filenames, ensuring chronological analysis. -
Calculate Centroids: Computes the centroids of bounding boxes for each detected object, providing a single point representing the object's location.
-
Draw ROIs: The user can draw Regions of Interest (ROIs) on the plot for further analysis of object movement within these areas.
-
Average Speed & Time: Calculates the average speed of objects and the time spent in each ROI, offering insights into object behavior.
-
Entries & Exits: Smooths the coordinates and counts the number of entries and exits made per ROI, useful for understanding object interaction with specific areas.
-
Graph Entries/Exits: Visualizes the number of entries and exits for each ROI and highlights the first ROI entered, aiding in the interpretation of object flow.
-
Time Spent in Each ROI: Visualizes the number of seconds spent in each ROI.
Usage
This project is designed to be user-friendly and adaptable to various video analysis needs. Here are the steps to get started:
-
Environment Setup: Ensure you have a Python environment with the necessary libraries (
numpy,pandas,matplotlib) installed. These libraries are fundamental for data manipulation and visualization. -
Data Preparation: Place path to your
.txtfiles in code block 2. Make sure the files are named appropriately to reflect the frame sequence. -
Code Execution: Run the code cells in the provided order. Each cell is designed to perform a specific task, contributing to the overall analysis. You can adjust parameters like
window_sizeas needed for your specific data. -
Result Interpretation: The final outputs include calculated metrics (average speed, time spent, entries, and exits per ROI) and visualizations. These results provide valuable insights into object behavior and interactions within the video frames.
-
Customization: Feel free to modify the code to suit your specific needs. The modular design of the code snippets allows for easy adjustments and enhancements.
By following these steps, users can effectively analyze object movement in video data. This analysis can reveal patterns and behaviors that might not be immediately apparent, providing a deeper understanding of the video content. Whether you're studying traffic patterns, observing wildlife, or monitoring security footage, this project offers a robust toolset for video analysis.






