An automated, non-invasive system for measuring cattle hip height in real time using computer vision and depth sensing. The system combines a YOLO-based pose estimation model with an RGB-D stereo camera to detect cattle hip keypoints and compute accurate height measurements — no human intervention required.
Built as a capstone project at the University of Sydney (SOFT3888).
Connect an OAK-D camera, calibrate the ground plane, and start scanning. Detected cattle are tracked in real time with hip height measurements displayed live and exportable to CSV.
- Real-time hip height measurement via YOLO pose estimation + depth camera
- PyQt5 GUI with live depth stream visualization and camera controls
- Ground plane calibration using multi-frame temporal averaging
- CSV export for data collection and downstream analysis
- Mock device mode for testing without physical hardware
- Comprehensive test suite with ~79–90% code coverage
| Component | Technology |
|---|---|
| Pose Estimation | YOLOv8 / YOLO11 (Ultralytics) |
| Depth Camera | OAK-D / OAK-D Lite (DepthAI) |
| GUI | PyQt5 |
| CV & Depth Processing | OpenCV, NumPy, SciPy |
| Object Tracking | filterpy, lap, supervision |
| Model Training | PyTorch, Ultralytics |
| Testing | unittest, pytest |
CattleScanner/
├── Integration/
│ └── GUI/
│ ├── main.py # App entry point
│ ├── requirements.txt
│ ├── cowscanner/
│ │ ├── gui.py # Main PyQt5 GUI
│ │ ├── camera.py # DepthAI camera interface
│ │ ├── mock_device.py # Hardware simulator for testing
│ │ ├── calibration.py # Ground plane calibration
│ │ └── utils.py # Detection, tracking, CSV export
│ ├── Tests/ # Unit test suite
│ └── resources/
│ └── cow_hip_height_model.tar.xz # RVC2 on-device model
├── cattle-measurement-system/
│ └── model_training/ # Training pipelines (YOLOv8 / YOLO11)
├── Demos/ # Hardware and NN demos
├── data/
│ └── cow_hip_heights.csv
└── README.md
- Python 3.9+
- OAK-D or OAK-D Lite camera (optional — mock mode works without hardware)
git clone https://github.com/KAANSSAR/CattleScanner.git
cd CattleScanner/Integration/GUI
pip install -r requirements.txt# From the repo root
python3 -m Integration.GUI.main
# Or directly
cd Integration/GUI
python3 main.pycd Integration/GUI
python -m unittest discover -s Tests- Connect Camera — plug in OAK-D device and click "Connect Camera"
- Calibrate Ground — ensure no cattle are visible, click "Start Calibration" (averages 30 frames)
- Start Scan — click "Start Scan" to begin real-time detection and tracking
- Export — click "Complete Export CSV" to save measurements to
data/cow_hip_heights.csv
No hardware? Click "Enable Test Mode" to use the mock device with synthetic cattle.
Three YOLO pose models were trained on the CattleEyeView dataset, all targeting a single hip_height keypoint:
| Version | Architecture | mAP@50 |
|---|---|---|
| V1 | YOLOv8s-pose | — |
| V2 | YOLO11n-pose | — |
| V3 | YOLO11s-pose | — |
| Best | YOLO11n-pose | 91.3% |
To retrain from scratch, see cattle-measurement-system/model_training/Training.md.
| Parameter | Location | Default |
|---|---|---|
| Camera resolution | camera.py |
640×640 |
| FPS | camera.py |
15 |
| Calibration frames | gui.py |
30 |
| Cow frame buffer | gui.py |
20 |
Hip heights are measured in millimetres relative to the calibrated ground plane. The camera is typically ~3000mm above ground.
This project was built collaboratively as part of SOFT3888 at the University of Sydney.
| Name | GitHub / Contact |
|---|---|
| Kanishka Sarkar | (https://github.com/KAANSSAR) |
| Daniel Gilerman | [email protected] |
| Ananya Rajesh | [email protected] |
| Jake Richards | [email protected] |
| Tasneem Binte Rahman | [email protected] |
| Aaron Khuu | [email protected] |
| Abdullah Fashola | [email protected] |
Client: Luciano Gonzalez (University of Sydney)
Tutor: Xinrui Zhang
This project was developed for academic purposes at the University of Sydney. Please reach out before reusing or redistributing.