Submitted:
27 May 2025
Posted:
28 May 2025
You are already at the latest version
Abstract
Keywords:
1. Introduction
2. Materials and Methods
2.1. Data Collection
2.1.1. Study Location and Duration
2.1.2. Subjects and Data Acquisition
- Cows’ Access to AMS: Cows voluntarily accessed the AMS between one and four times per day, where various physiological and behavioral parameters were recorded.
- BCS Reference Standard: A 3D camera system installed above the AMS served as the reference standard for BCS evaluation.
- Additional Data Recorded: The AMS automatically recorded cow identification (ID), milking session timestamps, and body weights, all compiled into a structured Excel database for further analysis.
2.2. Digital Tools and Camera Setup
2.2.1. Camera Specifications
- 2D Cameras: Three Foscam G4EP PoE 4MP cameras, each equipped with 128 GB SD cards for motion-triggered image capture.
- 3D Camera: Installed above the AMS, capturing depth-related morphological features of cows during milking.
- Data Storage and Processing: Cameras were connected to an Ethernet network, and recording schedules were configured via the Foscam mobile application.
2.2.2. Camera Placement
-
3D Camera Placement:
- ○
- Installed directly above the AMS milking unit, ensuring a top-down view of cows for depth-based morphological analysis.
- ○
- This 3D-based BCS evaluation served as the gold standard for validation.
-
2D Camera Placement:
- ○
- Front View Camera – Positioned at the entrance of the weighing station, capturing head and shoulder regions.
- ○
- Rear View Camera – Mounted behind the weighing scale, providing a backward perspective of the cow’s hindquarters.
- ○
- Top-Down Camera – Installed above the weighing platform, capturing a bird’s-eye view of the cow’s topline and body structure.
2.3. Image Data Processing and Annotation
- 1.
-
Data Collection:
- ○
- Video footage and snapshots were collected daily from 08:00 to 20:00, with images captured whenever movement was detected.
- 2.
-
Frame Extraction:
- ○
- At the end of each milking session, a screenshot was taken of each cow standing on the weighing scale, ensuring a direct link to BCS and ID records.
- 3.
-
Image Sorting:
- ○
- Screenshots were categorized based on cow ID and BCS score.
- 4.
-
BCS Score Adjustment:
- ○
- Scores were rounded to the nearest half or whole grade (e.g., BCS 1.7 → 1.5; BCS 2.8 → 3.0).
- Dataset Annotation and Preparation:
- 1.
-
Manual Annotation:
- ○
- The dataset was uploaded to Roboflow, utilizing their SAM annotation tool. In some cases, the manual polygon tool was used to assign object detection labels to front, rear, and top views.
- 2.
-
Dataset Splitting:
- ○
-
After annotation, the dataset was divided into three sets:
- ■
- 70% Training Data – Used to train the YOLOv8 model.
- ■
- 20% Validation Data – Used for hyperparameter tuning and overfitting prevention.
- ■
- 10% Testing Data – Used for final model evaluation.
2.4. Object Detection Model
2.4.1. Model Architecture and Justification
- Backbone: Extracts hierarchical image features using convolutional layers, C2f blocks, and spatial pyramid pooling.
- Neck: Fuses multi-scale feature maps, optimizing object detection across different perspectives (rear, front, and top).
- Head: Generates final predictions, including bounding box coordinates, class labels, and confidence scores.
2.4.2. Data Preprocessing and Augmentation
- Auto-orientation (Standardized image alignment).
- Resize (All images resized to 640×640 pixels).
- Contrast & Brightness Normalization (To enhance feature visibility).
-
Data Augmentation:
- ○
- Cropping: 0–15% random zoom.
- ○
- Hue & Saturation Adjustments: Random variations (-6 to +6).
- ○
- Brightness: Randomly adjusted (-15% to +15%).
- ○
- Blur & Noise: Minor Gaussian blur & noise applied.
- BCS 2.5 → Class 25
- BCS 3.0 → Class 30
- BCS 3.5 → Class 35
2.4.3. Model Training and Optimization
- Pretrained Weights: Transfer learning was applied using MSCOCO weights.
- Optimizer: Adam optimizer with learning rate = 0.001.
-
Training Setup:
- ○
- Epochs: 50
- ○
- Batch size: 16
- ○
-
Loss Functions:
- ■
- Bounding Box (BBox) loss (Zheng et al., 2019).
- ■
- Classification loss.
- ■
- Distribution Focal Loss (DFL) (Li et al., 2023).
2.4.4. Model Evaluation
- Mean Average Precision (mAP@0.5 & mAP@0.5-0.95).
- Precision-Recall Curves.
- Confusion Matrices (Misclassification analysis).
- Confidence Threshold Optimization (for front, rear, and top views).
2.5. Data Analysis
3. Results
3.1. Model Performance Based on Precision-Recall Curves
3.2. Precision-Confidence Analysis
3.3. Classification Performance Based on Confusion Matrices
4. Discussion
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
Abbreviations
| AI | Artificial Intelligence |
| AMS | Automated Milking System |
| AP | Average Precision |
| LD | Linear dichroism |
| BCS | Body Condition Score |
| Colab | Google Colaboratory |
| RFID | Radio-Frequency Identification |
| SD | Secure Digital (card) |
References
- Albornoz, R.I.; Giri, K.; Hannah, M.C.; Wales, W.J. An Improved Approach to Automated Measurement of Body Condition Score in Dairy Cows Using a Three-Dimensional Camera System. Animals 2021, 12, 72. [Google Scholar] [CrossRef] [PubMed]
- Biscarini, F.; Nicolazzi, E.L.; Stella, A.; Boettcher, P.J.; Gandini, G. Challenges and opportunities in genetic improvement of local livestock breeds. Front. Genet. 2015, 6, 33–33. [Google Scholar] [CrossRef] [PubMed]
- Bewley, J. M. (2008). Automated body condition scoring of dairy cattle: Technical and economic feasibility (Doctoral dissertation, Purdue University).
- Bewley, J. M. , Schutz, M. M., & Torres, A. H. (2008). An evaluation of producer assessment of dairy cow body condition score. Journal of Dairy Science, 91(5), p.1743-1752. [CrossRef]
- Das, S.; Shaji, A.; Nain, D.; Singha, S.; Karunakaran, M.; Baithalu, R.K. Precision technologies for the management of reproduction in dairy cows. Trop. Anim. Heal. Prod. 2023, 55, 1–10. [Google Scholar] [CrossRef] [PubMed]
- Halachmi, I., Klopčič, M., Polak, P., Roberts, D. J., & Bewley, J. M. (). Automatic assessment of dairy cow body condition score using 3D image analysis. Journal of Dairy Science, 2019, 96, 8047–8059. [CrossRef]
- Islam, A.; Lomax, S.; Doughty, A.; Islam, M.R.; Jay, O.; Thomson, P.; Clark, C. Automated Monitoring of Cattle Heat Stress and Its Mitigation. Front. Anim. Sci. 2021, 2. [Google Scholar] [CrossRef]
- Jocher, G. , Chaurasia, A., & Qiu, J. (2023). Ultralytics YOLOv8 (Version 8.0.0) [Software]. https://github.com/ultralytics/ultralytics.
- Krukowski, M. , McKague, K., & Valerio, A. Limitations of manual BCS evaluation in dairy farms: A systematic review. Applied Animal Behaviour Science, 2021; 241, 105378. [Google Scholar] [CrossRef]
- Lemmens, L.; Schodl, K.; Fuerst-Waltl, B.; Schwarzenbacher, H.; Egger-Danner, C.; Linke, K.; Suntinger, M.; Phelan, M.; Mayerhofer, M.; Steininger, F.; et al. The Combined Use of Automated Milking System and Sensor Data to Improve Detection of Mild Lameness in Dairy Cattle. Animals 2023, 13, 1180. [Google Scholar] [CrossRef] [PubMed]
- Li, X. , Lv, C., Wang, W., Li, G., Yang, L., & Yang, J. (2023). Generalized focal loss: Towards efficient representation learning for dense object detection. IEEE Transactions on Pattern Analysis and Machine Intelligence, 45(3), p.3139–3153. [CrossRef]
- Marginean, I. , Papp, Z., and Popescu, C. (2023). Milk Quality and Economic Sustainability in Dairy Farming: A Systematic Review of Performance Indicators. Sustainability, 15(5), p.1204. [CrossRef]
- Mottram, T. , & den Uijl, I. Integrating AI into dairy farming: A future perspective. Animal Science Journal 2022, 13671, 13671. [Google Scholar] [CrossRef]
- Mottram, T. T. F. , & den Uijl, I. (2022). Health and welfare monitoring of dairy cows. In M. I. R. Khan, & M. M. Jamal (Eds.), Digital Agritechnology: Applications and Future Prospects (pp. 113–142). Elsevier. [CrossRef]
- Neethirajan, S. Transforming the Adaptation Physiology of Farm Animals through Sensors. Animals 2020, 10, 1512. [Google Scholar] [CrossRef] [PubMed]
- Roche, J.R.; Friggens, N.C.; Kay, J.K.; Fisher, M.W.; Stafford, K.J.; Berry, D.P. Invited review: Body condition score and its association with dairy cow productivity, health, and welfare. J. Dairy Sci. 2009, 92, 5769–5801. [Google Scholar] [CrossRef] [PubMed]
- Shalloo, L.; Byrne, T.; Leso, L.; Ruelle, E.; Starsmore, K.; Geoghegan, A.; Werner, J.; O’leary, N. A review of precision technologies in pasture-based dairying systems. Ir. J. Agric. Food Res. 2021, 59, 279–291. [Google Scholar] [CrossRef]
- Siachos, N.; Lennox, M.; Anagnostopoulos, A.; Griffiths, B.; Neary, J.; Smith, R.; Oikonomou, G. Development and validation of a fully automated 2-dimensional imaging system generating body condition scores for dairy cows using machine learning. J. Dairy Sci. 2024, 107, 2499–2511. [Google Scholar] [CrossRef] [PubMed]
- Summerfield, G.I.; De Freitas, A.; van Marle-Koster, E.; Myburgh, H.C. Automated Cow Body Condition Scoring Using Multiple 3D Cameras and Convolutional Neural Networks. Sensors 2023, 23, 9051. [Google Scholar] [CrossRef] [PubMed]
- Tullo, E. , Finzi, A., & Guarino, M. (2019). Application of precision livestock farming technologies in dairy farms for monitoring animal welfare state: A review. Journal of Dairy Research, 86(4), p.341–349. [CrossRef]
- Vlaicu, P.A.; Gras, M.A.; Untea, A.E.; Lefter, N.A.; Rotar, M.C. Advancing Livestock Technology: Intelligent Systemization for Enhanced Productivity, Welfare, and Sustainability. Agriengineering 2024, 6, 1479–1496. [Google Scholar] [CrossRef]
- Van Marle-Koster, E. , Myburgh, J.G. (2023). Development of automated imaging systems for assessing body condition in dairy cows: A systematic review. Computers in Agriculture, 56(8), p.1123–1131. [CrossRef]
- Van Nuffel, A.; Zwertvaegher, I.; Van Weyenberg, S.; Pastell, M.; Thorup, V.M.; Bahr, C.; Sonck, B.; Saeys, W. Lameness Detection in Dairy Cows: Part 2. Use of Sensors to Automatically Register Changes in Locomotion or Behavior. Animals 2015, 5, 861–885. [Google Scholar] [CrossRef] [PubMed]
- Wurtz, K.; Camerlink, I.; D’eath, R.B.; Fernández, A.P.; Norton, T.; Steibel, J.; Siegford, J. Recording behaviour of indoor-housed farm animals automatically using machine vision technology: A systematic review. PLOS ONE 2019, 14, e0226669. [Google Scholar] [CrossRef] [PubMed]
- Yaseen, M. What is YOLOv8: An in-depth exploration of the internal features of the next-generation object detector. arXiv, 2024; arXiv:2408.15857. [Google Scholar] [CrossRef]
- Zhang, Y.; Zhang, Q.; Zhang, L.; Li, J.; Li, M.; Liu, Y.; Shi, Y. Progress of Machine Vision Technologies in Intelligent Dairy Farming. Appl. Sci. 2023, 13, 7052. [Google Scholar] [CrossRef]
- Zhao, K.; Zhang, M.; Shen, W.; Liu, X.; Ji, J.; Dai, B.; Zhang, R. Automatic body condition scoring for dairy cows based on efficient net and convex hull features of point clouds. Comput. Electron. Agric. 2022, 205. [Google Scholar] [CrossRef]
- Zheng, Z.; Wang, P.; Liu, W.; Li, J.; Ye, R.; Ren, D. Distance-IoU Loss: Faster and Better Learning for Bounding Box Regression. Proceedings of the AAAI Conference on Artificial Intelligence 2020, 34, 12993–13000. [Google Scholar] [CrossRef]








Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).