Predicting Dairy Calf Body Weight from Depth Images Using Deep Learning (YOLOv8) and Threshold Segmentation with Cross-Validation and Longitudinal Analysis
Simple Summary
Abstract
1. Introduction
2. Materials and Methods
2.1. Animal Procedures, Data Collection, and Image Acquisition
2.2. Threshold-Based Image Processing for Segmentation
2.3. Deep Learning Segmentation Models
2.4. Segmentation Evaluation Metrics and Statistical Analysis
2.5. Correlation Analysis of Body Metrics and Actual Body Weight
2.6. Body Weight Prediction
2.6.1. Cross-Validation for Single-Time-Point Body Weight Prediction
2.6.2. Longitudinal Analysis for Multiple-Time-Point Body Weight Prediction
3. Results
3.1. Segmentation Performance Evaluation
3.2. Correlation Analysis of Body Metrics and Actual Body Weight
3.3. Age-Based Correlation Analysis of Body Metrics and Actual Body Weight
3.4. Body Weight Prediction
3.4.1. Cross-Validation for Single-Time-Point Body Weight Prediction
3.4.2. Longitudinal Analysis for Multiple-Time-Point Body Weight Prediction
4. Discussion
5. Conclusions
Supplementary Materials
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Appleby, M.C.; Weary, D.M.; Chua, B. Performance and feeding behaviour of calves on ad libitum milk from artificial teats. Appl. Anim. Behav. Sci. 2001, 74, 191–201. [Google Scholar] [CrossRef]
- Bradski, G.; Kaehler, A. OpenCV. Dr. Dobb’s J. Softw. Tools 2000, 3. [Google Scholar]
- Sharpe, K.T.; Heins, B.J. Evaluation of a Forefront Weight Scale from an Automated Calf Milk Feeder for Holstein and Crossbred Dairy and Dairy–Beef Calves. Animals 2023, 13, 1752. [Google Scholar] [CrossRef] [PubMed]
- Song, X.; Schuttea, J.; van der Tol, P.; van Halsema, F.; Koerkampa, P.G. Body measurements of dairy calf using a 3-D camera in an automatic feeding system. In Proceedings of the International Conference of Agricultural Engineering, Pune, India, 21–23 February 2014; pp. 6–10. [Google Scholar]
- Cantor, M.C.; Pertuisel, C.H.; Costa, J.H. Estimating body weight of dairy calves with a partial-weight scale attached to an automated milk feeder. J. Dairy Sci. 2020, 103, 1914–1919. [Google Scholar] [CrossRef] [PubMed]
- Heinrichs, A.; Rogers, G.; Cooper, J. Predicting body weight and wither height in Holstein heifers using body measurements. J. Dairy Sci. 1992, 75, 3576–3581. [Google Scholar] [CrossRef]
- Jeong, S.; Kim, H.; Lee, J.; Jung, Y.; Han, J. Study on the prediction of body weight in Holstein dairy cattle using body measurements. RDA J. Livest. Sci. 1998, 40, 126–129. [Google Scholar]
- Bozkurt, Y.; Aktan, S.; Ozkaya, S. Body weight prediction using digital image analysis for slaughtered beef cattle. J. Appl. Anim. Res. 2007, 32, 195–198. [Google Scholar] [CrossRef]
- Stajnko, D.; Vindiš, P.; Janžekovič, M.; Brus, M. Non invasive estimating of cattle live weight using thermal imaging. In New Trends in Technologies: Control, Management, Computational Intelligence and Network Systems; BoD: Norderstedt, Germany, 2010; Volume 243. [Google Scholar]
- Gjergji, M.; de Moraes Weber, V.; Silva, L.O.C.; da Costa Gomes, R.; De Araújo, T.L.A.C.; Pistori, H.; Alvarez, M. Deep learning techniques for beef cattle body weight prediction. In Proceedings of the 2020 International Joint Conference on Neural Networks (IJCNN), Glasgow, UK, 19–24 July 2020. [Google Scholar]
- Kadlec, R.; Indest, S.; Castro, K.; Waqar, S.; Campos, L.M.; Amorim, S.T.; Bi, Y.; Hanigan, M.D.; Morota, G. Automated acquisition of top-view dairy cow depth image data using an RGB-D sensor camera. Transl. Anim. Sci. 2022, 6, txac163. [Google Scholar] [CrossRef]
- Bi, Y.; Campos, L.M.; Wang, J.; Yu, H.; Hanigan, M.D.; Morota, G. Depth video data-enabled predictions of longitudinal dairy cow body weight using thresholding and Mask R-CNN algorithms. Smart Agric. Technol. 2023, 6, 100352. [Google Scholar] [CrossRef]
- Redmon, J.; Divvala, S.; Girshick, R.; Farhadi, A. You only look once: Unified, real-time object detection. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, Las Vegas, NV, USA, 27–30 June 2016. [Google Scholar]
- Chen, T.; Guestrin, C. Xgboost: A scalable tree boosting system. In Proceedings of the 22nd ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, San Francisco, CA, USA, 13–17 August 2016. [Google Scholar]
- Singer, J.D. Applied Longitudinal Data Analysis: Modeling Change and Event Occurrence; Oxford University Press: Oxford, UK, 2003. [Google Scholar]
- Curtis, G.; McGregor Argo, C.; Jones, D.; Grove-White, D. The impact of early life nutrition and housing on growth and reproduction in dairy cattle. PLoS ONE 2018, 13, e0191687. [Google Scholar] [CrossRef]
- Laird, N.M.; Ware, J.H. Random-effects models for longitudinal data. Biometrics 1982, 38, 963–974. [Google Scholar] [CrossRef] [PubMed]
- Henderson, C.R.; Kempthorne, O.; Searle, S.R.; Von Krosigk, C. The estimation of environmental and genetic trends from records subject to culling. Biometrics 1959, 15, 192–218. [Google Scholar] [CrossRef]
- Corporation, I. Librealsense: Intel® RealSense™ SDK 2.0. 2023. Available online: https://github.com/IntelRealSense/librealsense (accessed on 27 December 2023).
- Dwyer, B.; Nelson, J.; Solawetz, J. Roboflow (Version 1.0) [Software]. 2022. Available online: https://roboflow.com (accessed on 12 March 2025).
- Montgomery, D.C.; Peck, E.A.; Vining, G.G. Introduction to Linear Regression Analysis; John Wiley & Sons: Hoboken, NJ, USA, 2021. [Google Scholar]
- Pinheiro, J.; Bates, D. Mixed-Effects Models in S and S-PLUS; Springer Science & Business Media: Berlin/Heidelberg, Germany, 2006. [Google Scholar]
- Bates, D.; Mächler, M.; Bolker, B.; Walker, S. Fitting Linear Mixed-Effects Models Using lme4. J. Stat. Softw. 2015, 67, 1–48. [Google Scholar] [CrossRef]
- Nishide, R.; Yamashita, A.; Takaki, Y.; Ohta, C.; Oyama, K.; Ohkawa, T. Calf robust weight estimation using 3D contiguous cylindrical model and directional orientation from stereo images. In Proceedings of the 9th International Symposium on Information and Communication Technology, Danang City, Vietnam, 6–7 December 2018; pp. 208–215. [Google Scholar]
- Peng, Y.; Peng, Z.; Zou, H.; Liu, M.; Hu, R.; Xiao, J.; Liao, H.; Yang, Y.; Huo, L.; Wang, Z. A dynamic individual yak heifer live body weight estimation method using the YOLOv8 network and body parameter detection algorithm. J. Dairy Sci. 2024, 107, 6178–6191. [Google Scholar] [CrossRef]
- Hurst, T.S.; Lopez-Villalobos, N.; Boerman, J.P. Predictive equations for early-life indicators of future body weight in Holstein dairy heifers. J. Dairy Sci. 2021, 104, 736–749. [Google Scholar] [CrossRef] [PubMed]
- Dunne, F.; Kelleher, M.; Horan, B.; Evans, R.; Berry, D. Predicting male dairy calf live-weight for use in calf management decision support. JDS Commun. 2021, 2, 257–261. [Google Scholar] [CrossRef]
- Ozkaya, S. Accuracy of body measurements using digital image analysis in female Holstein calves. Anim. Prod. Sci. 2012, 52, 917–920. [Google Scholar] [CrossRef]
- Rotondo, V. Predicting Body Weight with Linear Body Measurements in Beef Calves. Ph.D. Thesis, University of Guelph, Guelph, ON, Canada, 2021. [Google Scholar]
- Cominotte, A.; Fernandes, A.; Dorea, J.; Rosa, G.; Ladeira, M.; Van Cleef, E.; Pereira, G.; Baldassini, W.; Neto, O.M. Automated computer vision system to predict body weight and average daily gain in beef cattle during growing and finishing phases. Livest. Sci. 2020, 232, 103904. [Google Scholar] [CrossRef]
- Martins, B.; Mendes, A.; Silva, L.; Moreira, T.; Costa, J.; Rotta, P.; Chizzotti, M.; Marcondes, M. Estimating body weight, body condition score, and type traits in dairy cows using three dimensional cameras and manual body measurements. Livest. Sci. 2020, 236, 104054. [Google Scholar] [CrossRef]
- Pezzuolo, A.; Guarino, M.; Sartori, L.; González, L.A.; Marinello, F. On-barn pig weight estimation based on body measurements by a Kinect v1 depth camera. Comput. Electron. Agric. 2018, 148, 29–36. [Google Scholar] [CrossRef]
- Liang, J.; Yuan, Z.; Luo, X.; Chen, G.; Wang, C. A Study on the 3D Reconstruction Strategy of a Sheep Body Based on a Kinect v2 Depth Camera Array. Animals 2024, 14, 2457. [Google Scholar] [CrossRef] [PubMed]
- Li, K.; Teng, G. Study on body size measurement method of goat and cattle under different background based on deep learning. Electronics 2022, 11, 993. [Google Scholar] [CrossRef]
Trial | Animals | Data Collection Period | Video Size | Body Weight Data | Video Data | Purpose |
---|---|---|---|---|---|---|
1 | Holstein (n = 20); age range: 21–69 days | January–April 2023 | 196 videos | Manually collected | Manually collected | (1) Correlation between body metrics * and body weight. (2) Body weight prediction using body metrics and actual body weight. |
2 | Holstein (n = 43) and Jersey (n = 5); age range: 14–78 days | January–June 2024 | 3286 videos | None | Automatically collected | (1) Develop segmentation models using deep learning. (2) Compare segmentation performance between threshold-based and deep learning methods. |
Metrics | YOLOv8n | YOLOv8s | YOLOv8m | YOLOv8l | YOLOv8x | Threshold | p-Value 5 | Adjusted p-Value 6 | Eta Squared () 7 |
---|---|---|---|---|---|---|---|---|---|
Segmented Image Numbers (Percentage) 4 | 957 (100%) | 957 (100%) | 957 (100%) | 957 (100%) | 957 (100%) | 573 (60%) | - | - | - |
IoU: % Mean ± SD | 0.966 ± 0.07 b,c | 0.96 ± 0.07 c | 0.976 ± 0.06 a | 0.973 ± 0.06 a,b | 0.975 ± 0.06 a,b | 0.888 ± 0.09 d | 0.123 | ||
Dice Coefficient: % Mean ± SD | 0.981 ± 0.04 b,c | 0.978 ± 0.05 c | 0.987 ± 0.04 a | 0.986 ± 0.04 a,b,c | 0.986 ± 0.04 a,b | 0.938 ± 0.06 d | 0.087 | ||
Pixel Accuracy: % Mean ± SD | 0.993 ± 0.02 b | 0.992 ± 0.02 c | 0.995 ± 0.02 a | 0.995 ± 0.02 a,b | 0.995 ± 0.02 a,b | 0.98 ± 0.02 d | 0.062 |
Metric 2 | YOLOv8m | Threshold | ||||
---|---|---|---|---|---|---|
LR | XGBoost | p -Value 3 | LR | XGBoost | p -Value 4 | |
R2 | 0.85 ± 0.09 b | 0.91 ± 10−3.5 a | 8.80 × 10−12 | 0.73 ± 0.09 b | 0.8 ± 10−3.5 a | 3.00 × 10−14 |
MSE (lb2) | 82.24 ± 36.15 a | 61.74 ± 0.23 b | 6.89 × 10−8 | 168.38 ± 47.7 a | 133.31 ± 0.31 b | 2.00 × 10−12 |
RMSE (lb) | 8.81 ± 2.16 a | 7.86 ± 0.01 b | 4.69 × 10−6 | 12.84 ± 1.87 a | 11.55 ± 0.01 b | 2.75 × 10−10 |
MAE (lb) | 7.21 ± 1.88 a | 6.22 ± 0.01 b | 1.39 × 10−8 | 10.56 ± 1.71 a | 9.47 ± 0.01 b | 7.48 × 10−8 |
MAPE (%) | 5.03 ± 1.07 a | 4.37 ± 0.01 b | 8.80 × 10−8 | 7.4 ± 1.39 a | 6.73 ± 0.01 b | 5.69 × 10−8 |
Metric 2 | Train:Test 3 | LR | XGBoost | LMM | p-Value 4 | Adjusted p-Value 5 | Eta Squared () 6 |
---|---|---|---|---|---|---|---|
R2 | 90:10 | 0.90 ± 0.009 b | 0.89 ± 0.003 c | 0.99 ± 0.002 a | 1.42 × 10−283 | 4.25 × 10−283 | 0.988 |
80:20 | 0.90 ± 0.005 b | 0.88 ± 0.002 c | 0.96 ± 0.001 a | Inf × 10−324 | 1.5 × 10−323 | 0.993 | |
70:30 | 0.91 ± 0.004 b | 0.89 ± 0.002 c | 0.95 ± 0.003 a | 2.3 × 10−287 | 6.9 × 10−287 | 0.988 | |
60:40 | 0.91 ± 0.002 b | 0.88 ± 0.01 c | 0.95 ± 0.006 a | 4.3 × 10−256 | 1.29 × 10−255 | 0.981 | |
50:50 | 0.89 ± 0.005 b | 0.82 ± 0.01 c | 0.92 ± 0.01 a | 1.42 × 10−250 | 4.25 × 10−250 | 0.979 | |
MSE (lb2) | 90:10 | 46.79 ± 1.73 b | 75.07 ± 2.56 a | 19.54 ± 0.72 c | <1 × 10−300 | <1 × 10−300 | 0.994 |
80:20 | 71.65 ± 1.59 b | 77.51 ± 1.11 a | 22.31 ± 0.58 c | <1 × 10−300 | <1 × 10−300 | 0.998 | |
70:30 | 82.22 ± 1.15 a | 71.12 ± 1.02 b | 26.84 ± 0.98 c | <1 × 10−300 | <1 × 10−300 | 0.998 | |
60:40 | 76.45 ± 0.94 a | 76.29 ± 4 a | 34.01 ± 1.34 b | 1.88 × 10−274 | 5.63 × 10−274 | 0.986 | |
50:50 | 89.69 ± 2 b | 112.45 ± 5.17 a | 55.77 ± 3.29 c | 4.65 × 10−243 | 1.39 × 10−242 | 0.977 | |
RMSE (lb) | 90:10 | 6.84 ± 0.12 b | 8.66 ± 0.15 a | 4.42 ± 0.08 c | <1 × 10−300 | <1 × 10−300 | 0.996 |
80:20 | 8.46 ± 0.1 b | 8.8 ± 0.06 a | 4.72 ± 0.06 c | <1 × 10−300 | <1 × 10−300 | 0.999 | |
70:30 | 9.07 ± 0.06 a | 8.43 ± 0.06 b | 5.18 ± 0.09 c | <1 × 10−300 | <1 × 10−300 | 0.998 | |
60:40 | 8.74 ± 0.05 a | 8.73 ± 0.22 a | 5.83 ± 0.11 b | 1.02 × 10−296 | 3.05 × 10−296 | 0.990 | |
50:50 | 9.47 ± 0.11 b | 10.6 ± 0.24 a | 7.46 ± 0.23 c | 2.02 × 10−248 | 6.07 × 10−248 | 0.979 | |
MAE (lb) | 90:10 | 5.01 ± 0.14 b | 7.11 ± 0.15 a | 3.90 ± 0.10 c | 5.48 × 10−307 | 1.64 × 10−306 | 0.991 |
80:20 | 6.85 ± 0.08 b | 7.14 ± 0.07 a | 3.76 ± 0.06 c | <1 × 10−300 | <1 × 10−300 | 0.998 | |
70:30 | 7.50 ± 0.07 a | 6.73 ± 0.07 b | 4.11 ± 0.09 c | <1 × 10−300 | <1 × 10−300 | 0.998 | |
60:40 | 7.11 ± 0.06 a | 7.06 ± 0.24 b | 4.48 ± 0.10 c | 9.82 × 10−272 | 2.94 × 10−271 | 0.985 | |
50:50 | 7.82 ± 0.10 b | 8.51 ± 0.27 a | 5.73 ± 0.16 c | 5.36 × 10−241 | 1.61 × 10−240 | 0.976 | |
MAPE (%) | 90:10 | 3.17 ± 0.10 b | 4.60 ± 0.10 a | 2.39 ± 0.06 c | 7.03 × 10−309 | 2.11 × 10−308 | 0.992 |
80:20 | 4.16 ± 0.04 b | 4.45 ± 0.05 a | 2.23 ± 0.04 c | <1 × 10−300 | <1 × 10−300 | 0.998 | |
70:30 | 4.52 ± 0.04 a | 4.22 ± 0.04 b | 2.45 ± 0.06 c | <1 × 10−300 | <1 × 10−300 | 0.997 | |
60:40 | 4.40 ± 0.05 a | 4.45 ± 0.18 a | 2.78 ± 0.07 b | 2.49 × 10−254 | 7.47 × 10−254 | 0.980 | |
50:50 | 4.80 ± 0.06 b | 5.20 ± 0.22 a | 3.60 ± 0.11 c | 6.87 × 10−205 | 2.06 × 10−204 | 0.958 |
Metric 2 | Train:Test 3 | LR | XGBoost | LMM | p-Value 4 | Adjusted p-Value 5 | Eta Squared () 6 |
---|---|---|---|---|---|---|---|
R2 | 90:10 | 0.72 ± 0.05 b | 0.73 ± 0.01 b | 0.98 ± 0.004 a | 5.06 × 10−194 | 1.52×10−193 | 0.950 |
80:20 | 0.74 ± 0.01 c | 0.75 ± 0.002 c | 0.95 ± 0.002 a | <1 × 10−300 | <1 ×10−300 | 0.997 | |
70:30 | 0.77 ± 0.01 b | 0.75 ± 0.004 c | 0.94 ± 0.003 a | 1.12 × 10−317 | 3.35 × 10−317 | 0.993 | |
60:40 | 0.73 ± 0.01 c | 0.74 ± 0.002 c | 0.94 ± 0.004 a | <1 × 10−300 | <1 × 10−300 | 0.995 | |
50:50 | 0.73 ± 0.01 c | 0.74 ± 0.005 c | 0.9 ± 0.005 a | <1 × 10−300 | <1 × 10−300 | 0.995 | |
MSE (lb2) | 90:10 | 118.73 ± 6.5 b | 175.44 ± 7.21 a | 22.32 ± 1.11 c | 1.89 | 0.993 | |
80:20 | 147.92 ± 3.32 a | 148.94 ± 1.38 a | 27.24 ± 0.87 b | <1 | <1 | 0.999 | |
70:30 | 140.26 ± 3.62 b | 162.1 ± 2.94 a | 35.01 ± 1.12 c | <1 | <1 | 0.998 | |
60:40 | 151.56 ± 3.3 b | 160.53 ± 1.5 a | 36.83 ± 1.29 c | <1 | <1 | 0.999 | |
50:50 | 142.63 ± 1.49 b | 157.29 ± 2.77 a | 65.51 ± 3.63 c | <1 | <1 | 0.996 | |
RMSE (lb) | 90:10 | 10.89 ± 0.28 b | 13.24 ± 0.28 a | 4.72 ± 0.12 c | <1 | <1 | 0.996 |
80:20 | 12.16 ± 0.14 a | 12.20 ± 0.06 a | 5.22 ± 0.08 b | <1 | <1 | 0.999 | |
70:30 | 11.84 ± 0.15 b | 12.73 ± 0.12 a | 5.92 ± 0.09 c | <1 | <1 | 0.999 | |
60:40 | 12.31 ± 0.14 b | 12.67 ± 0.06 a | 6.07 ± 0.11 c | <1 | <1 | 0.999 | |
50:50 | 11.94 ± 0.06 b | 12.54 ± 0.11 a | 8.09 ± 0.23 c | <1 | <1 | 0.995 | |
MAE (lb) | 90:10 | 8.83 ± 0.26 b | 10.56 ± 0.23 a | 3.95 ± 0.11 c | <1 | <1 | 0.995 |
80:20 | 9.29 ± 0.13 b | 9.88 ± 0.06 a | 4.23 ± 0.07 c | <1 | <1 | 0.999 | |
70:30 | 9.65 ± 0.11 b | 10.06 ± 0.1 a | 4.64 ± 0.08 c | <1 | <1 | 0.999 | |
60:40 | 9.73 ± 0.09 b | 10.22 ± 0.07 a | 4.62 ± 0.09 c | <1 | <1 | 0.999 | |
50:50 | 9.55 ± 0.07 b | 10.19 ± 0.1 a | 6.25 ± 0.18 c | <1 | <1 | 0.995 | |
MAPE (%) | 90:10 | 5.71 ± 0.17 b | 7.03 ± 0.17 a | 2.37 ± 0.07 c | <1 | <1 | 0.995 |
80:20 | 5.78 ± 0.08 b | 6.38 ± 0.05 a | 2.49 ± 0.05 c | <1 | <1 | 0.999 | |
70:30 | 5.98 ± 0.06 b | 6.61 ± 0.07 a | 2.76 ± 0.05 c | <1 | <1 | 0.999 | |
60:40 | 6.22 ± 0.06 b | 6.87 ± 0.06 a | 2.80 ± 0.06 c | <1 | <1 | 0.999 | |
50:50 | 6.19 ± 0.04 b | 6.97 ± 0.09 a | 3.89 ± 0.12 c | <1 | 0.996 |
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 (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Liao, M.; Morota, G.; Bi, Y.; Cockrum, R.R. Predicting Dairy Calf Body Weight from Depth Images Using Deep Learning (YOLOv8) and Threshold Segmentation with Cross-Validation and Longitudinal Analysis. Animals 2025, 15, 868. https://doi.org/10.3390/ani15060868
Liao M, Morota G, Bi Y, Cockrum RR. Predicting Dairy Calf Body Weight from Depth Images Using Deep Learning (YOLOv8) and Threshold Segmentation with Cross-Validation and Longitudinal Analysis. Animals. 2025; 15(6):868. https://doi.org/10.3390/ani15060868
Chicago/Turabian StyleLiao, Mingsi, Gota Morota, Ye Bi, and Rebecca R. Cockrum. 2025. "Predicting Dairy Calf Body Weight from Depth Images Using Deep Learning (YOLOv8) and Threshold Segmentation with Cross-Validation and Longitudinal Analysis" Animals 15, no. 6: 868. https://doi.org/10.3390/ani15060868
APA StyleLiao, M., Morota, G., Bi, Y., & Cockrum, R. R. (2025). Predicting Dairy Calf Body Weight from Depth Images Using Deep Learning (YOLOv8) and Threshold Segmentation with Cross-Validation and Longitudinal Analysis. Animals, 15(6), 868. https://doi.org/10.3390/ani15060868