#π Real-Time Video-Based Cattle Activity Detection & Surveillance System
A real-time cattle behavior detection and surveillance system built using OpenCV, YOLOv11, Google Gemini Flash 2.0, and Streamlit. This intelligent system monitors cattle behavior in real-time and provides AI-powered semantic understanding of their activity.
-
β Real-time Cattle Detection
Detects and classifies cows, buffaloes, goats, sheep, and pigs using YOLOv11. -
π€ AI-Powered Activity Recognition
Uses Gemini Flash 2.0 for high-speed vision-language scene understanding to analyze posture and activity. -
π₯ Flexible Video Input
Supports live webcam feed and pre-recorded video uploads. -
β‘ Configurable Frame Skipping
Boost performance by skipping frames dynamically. -
π Interactive Streamlit Dashboard
Control, view, and analyze results in a clean, real-time interface. -
π Activity Logging & Frame Storage
Automatically logs animal activity and saves analyzed frames.
Layer | Tools Used |
---|---|
Computer Vision | OpenCV, YOLOv11 |
AI/VLM | Google Gemini Flash 2.0 |
Frontend | Streamlit |
Environment | Python dotenv for config and secrets |
-
Frame Capture
Input from webcam or uploaded video is read using OpenCV. -
YOLOv11 Detection
Objects in each frame are detected and classified (cattle types). -
Cropping + VLM Analysis
Detected animals are cropped and sent to Gemini Flash 2.0, which semantically understands:- Posture (e.g. standing, walking, lying down)
- Behavior (e.g. grazing, fighting, running)
-
Display & Logging
- Results displayed in real-time via Streamlit
- Each detection is logged and saved
cattle-detection/ βββ app.py # Main Streamlit app βββ cattledetection.py # YOLOv11 detection logic βββ vlm.py # Gemini Flash 2.0 integration βββ .env # API key and config βββ uploads/ # Saved analyzed frames
- in folder use .env to manage api (here GEMINI_API_KEY is variable of api)
- then use streamlit run app.py in specfic venv of python where streamlit is installed
- you will taken to a browser, input your video by selecting video and start detect
- this will generate detection and log of detection and vlm answer , the api is called after 3 mins making it cost and time efficent