Science Score: 67.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Academic email domains
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (9.6%) to scientific vocabulary
Last synced: 10 months ago · JSON representation ·

Repository

Basic Info
  • Host: GitHub
  • Owner: farhanaugustine
  • License: gpl-3.0
  • Language: Python
  • Default Branch: main
  • Size: 37.1 KB
Statistics
  • Stars: 2
  • Watchers: 1
  • Forks: 0
  • Open Issues: 0
  • Releases: 1
Created about 2 years ago · Last pushed about 2 years ago
Metadata Files
Readme License Citation

README.md

DOI Open In Colab

Yolov8_Enteries_Exits_FullWorkflow

YoloV8_Single Animal Behavior Analysis with Open Field Example

Youtube Video Tutorial:

Single Animal Behavior Analysis (Yolov8)

https://youtu.be/DydI37F5nVM

Object Detection and Tracking with YOLO and OpenCV

This script uses the YOLO (You Only Look Once) model from the Ultralytics library and OpenCV to perform object detection and tracking on a video. The detected objects are then analyzed based on their position in relation to predefined Regions of Interest (ROIs).

Dependencies

  • Ultralytics YOLO
  • OpenCV
  • NumPy
  • csv

How it works

  1. Load the YOLO model: The YOLO model is loaded from the specified path. This model will be used to make predictions on the video frames.

  2. Load the video: The video is loaded from the specified path using cv2.VideoCapture(). This function returns a VideoCapture object which is used to read the video frames.

  3. Initialize frame counter: A frame counter is initialized to keep track of the current frame number.

  4. Create a VideoWriter object: Two VideoWriter objects are created using cv2.VideoWriter(). These objects are used to save the mask video and the video with ROIs and counts drawn on top.

  5. Define multiple ROIs: Multiple ROIs are defined as dictionaries. Each ROI has a top left and bottom right coordinate, as well as counters for entries and exits, a flag for whether the previous position was inside the ROI, frame counters for entries and exits, a counter for total frames, a counter for total distance, and a variable for the previous position.

  6. Create a CSV file and write the header: A CSV file is created to store the frame number and the center coordinates of the detected objects.

  7. Read frames: The script enters a loop where it reads frames from the video one by one.

  8. Object detection: The YOLO model is used to make predictions on the current frame. If any objects are detected, their masks are processed and their centers are calculated.

  9. ROI analysis: For each detected object, the script checks if its center is inside any of the ROIs. If the object has entered or exited an ROI, the corresponding counters are updated. The total distance traveled by the object inside the ROI is also calculated.

  10. Draw on frame: The ROIs and the centers of the detected objects are drawn on the frame. The entry and exit counts for each ROI are also drawn on the frame.

  11. Save frame and mask to video: The frame with the drawn ROIs and counts, as well as the mask of the detected objects, are saved to video files using the VideoWriter objects.

  12. Increment frame counter: The frame counter is incremented.

  13. Write CSV data to file: After all frames have been processed, the CSV data is written to the file.

  14. Release resources: The VideoCapture and VideoWriter objects are released and any openCV windows are destroyed.

  15. Print ROI counts: The entry and exit counts, total frames spent, and average velocity for each ROI are printed.

  16. Write ROI counts to CSV file: The entry and exit counts, total frames spent, and average velocity for each ROI are written to the CSV file.

Usage

To run the script, simply execute it with Python:

```bash python yolov8_seg.py

Owner

  • Name: Farhan
  • Login: farhanaugustine
  • Kind: user
  • Location: Maryland
  • Company: University of Maryland Baltimore County

Citation (CITATION.cff)

authors:
  - family-names: Augustine
    given-names: Farhan
    orcid: "https://orcid.org/0000-0002-8348-6039"
cff-version: 1.0.0
date-released: "05-23-2024"
identifiers:
  - description: "This is the collection of archived snapshots of the latest release versions of BehaviorAnalysis_YOLOv8."
    type: doi
    value: https://zenodo.org/doi/10.5281/zenodo.11264288
keywords:
  - BehaviorAnalysis
  - AnimalBehaviorResearch
  - Open-FieldTestAnalysis
  - T-MazeAnalysis
  - ElevatedPlusMaze
  - AnimalTracking
license: 
  - GPL-3.0
message: "If you use this software, please cite it using these metadata."
repository-code: "https://github.com/farhanaugustine/BehaviorAnalysis_YOLOv8/tree/main"
title: "BehaviorAnalysis_YOLOv8"
version: 1.0.0

GitHub Events

Total
  • Watch event: 1
Last Year
  • Watch event: 1