π GoatMorpho is a Django-based web application that uses computer vision and AI to automatically extract morphometric measurements from goat images, reducing human errors typically associated with manual tape measurements.
- Computer Vision Processing: Uses MediaPipe and OpenCV for pose detection
- 17 Morphometric Measurements: Comprehensive body measurements including:
- Heights: Wither, Back, Sternum, Rump
- Circumferences: Heart Girth, Chest, Abdominal, Neck
- Widths: Chest, Hip, Head, Bi-costal Diameter
- Lengths: Body, Head, Neck, Ear, Tail
- Goat Database: Store and manage multiple goats with breed, age, sex information
- Measurement History: Track measurements over time
- Confidence Scoring: AI confidence ratings for each measurement
- Manual Corrections: Hybrid AI-assisted + manual correction workflow
- Reference Object Scaling: Use known objects in images for accurate scaling
- Keypoint Detection: Detailed anatomical landmark detection
- Multiple Measurement Methods: Automatic, Manual, or Hybrid approaches
| Variable | Code | Description (French) | Description (English) |
|---|---|---|---|
| WH | hauteur_au_garrot | Hauteur au garrot | Wither Height |
| BH | hauteur_au_dos | Hauteur au dos | Back Height |
| SH | hauteur_au_sternum | Hauteur au sternum | Sternum Height |
| RH | hauteur_au_sacrum | Hauteur au Sacrum | Rump Height |
| HG | tour_de_poitrine | Tour de poitrine | Heart Girth |
| CC | perimetre_thoracique | Périmètre thoracique | Chest Circumference |
| AG | tour_abdominal | Tour abdominal | Abdominal Girth |
| BD | diametre_biscotal | Diamètre biscotal | Bi-costal Diameter |
| CW | largeur_poitrine | Largeur poitrine | Chest Width |
| RW | largeur_hanche | Largeur de Hanche/bassin | Rump Width |
| EL | longueur_oreille | Longueur oreille | Ear Length |
| HL | longueur_tete | Longueur de la tΓͺte | Head Length |
| HW | largeur_tete | Largeur de la tΓͺte | Head Width |
| BL | body_length | Body length | Body Length |
| NL | longueur_cou | Longueur du cou | Neck Length |
| NG | tour_du_cou | Tour du cou | Neck Girth |
| TL | longueur_queue | Longueur de la queue | Tail Length |
- Python 3.8+
- pip
- Virtual environment (recommended)
-
Clone the repository
git clone <repository-url> cd GoatMorpho
-
Create and activate virtual environment
python -m venv .venv # Windows .venv\Scripts\activate # Linux/Mac source .venv/bin/activate
-
Install dependencies
pip install -r requirements.txt
-
Configure database
python manage.py makemigrations python manage.py migrate
-
Create superuser
python manage.py createsuperuser
-
Run development server
python manage.py runserver
-
Access the application
- Web Interface: http://127.0.0.1:8000/
- Admin Panel: http://127.0.0.1:8000/admin/
- API Endpoints: http://127.0.0.1:8000/api/
- Dashboard: Overview of your goats and measurements
- Upload Image: Upload goat images for analysis
- Admin Panel: Manage goats, measurements, and review results
POST /api/upload/
Content-Type: multipart/form-data
{
"image": <image_file>,
"goat_id": "<optional_goat_uuid>",
"goat_name": "<optional_new_goat_name>",
"reference_length_cm": <optional_float>
}GET /api/goats/
Authorization: Token <your_token>GET /api/goats/<goat_id>/measurements/
Authorization: Token <your_token>PUT /api/measurements/<measurement_id>/update/
Authorization: Token <your_token>
Content-Type: application/json
{
"hauteur_au_garrot": 75.5,
"body_length": 120.2,
"notes": "Manual correction applied"
}- Image Preprocessing: Resize, normalize, and prepare image
- Pose Detection: Use MediaPipe to detect anatomical landmarks
- Keypoint Extraction: Extract 2D coordinates of key body points
- Scale Calculation: Determine pixel-to-centimeter ratio
- Measurement Calculation: Calculate distances and proportions
- Confidence Assessment: Evaluate reliability of measurements
- Use high-resolution images (minimum 1024x768)
- Ensure good lighting conditions
- Side view preferred for most measurements
- Entire goat should be visible in frame
- Include a reference object of known length
- Goat should be standing naturally
- Minimize background clutter
- Capture when goat is calm and still
- Capture image following best practices
- Upload through web interface or API
- Review AI-generated measurements
- Make manual corrections if needed
- Save final measurements
- Backend: Django 5.2.4, Django REST Framework
- Computer Vision: OpenCV, MediaPipe
- Machine Learning: TensorFlow (future enhancements)
- Database: SQLite (development), PostgreSQL (production)
- Frontend: Bootstrap 5, Vanilla JavaScript
- Image Processing: Pillow, scikit-image
- Goat: Basic goat information (name, breed, age, sex, weight)
- MorphometricMeasurement: All 17 measurements with metadata
- KeyPoint: Detected anatomical landmarks with coordinates
- MeasurementSession: Batch processing sessions
GoatMorpho/
βββ goat_morpho/ # Django project settings
βββ measurements/ # Main application
β βββ models.py # Database models
β βββ views.py # API endpoints and web views
β βββ cv_processor.py # Computer vision processing
β βββ serializers.py # API serializers
β βββ templates/ # Web interface templates
βββ media/ # Uploaded images
βββ static/ # Static files
βββ requirements.txt # Python dependencies
- Add field to
MorphometricMeasurementmodel - Update
cv_processor.pycalculation logic - Add to serializers and admin interface
- Create migration:
python manage.py makemigrations
- 3D pose estimation for circumference measurements
- Breed-specific measurement standards
- Batch processing of multiple images
- Mobile app for field use
- Integration with livestock management systems
- Machine learning model training on goat-specific datasets
- Export to standard formats (CSV, Excel, PDF reports)
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
If you use GoatMorpho in your research, please cite:
GoatMorpho: Automated Goat Morphometric Analysis System
[DOSSOU KPONGAN LFCY/Animal Breeding and genetics]
[2025]
For questions, issues, or contributions:
- Create an issue on GitHub
- Contact: [dossoukponganfleming@gmail.com]
Note: This is a research/development tool. Always verify AI measurements with manual checks for critical applications.