Published January 28, 2025 | Journal article | Version v1 | https://doi.org/10.3390/s25030785

Machine-Learning-Based Activity Tracking for Individual Pig Monitoring in Experimental Facilities for Improved Animal Welfare in Research

Description

In experimental research, animal welfare should always be of the highest priority. Currently, physical in-person observations are the standard. This is time-consuming, and results are subjective. Video-based machine learning models for monitoring experimental pigs provide a continuous and objective observation method for animal misthriving detection. The aim of this study was to develop and validate a pig tracking technology, using video-based data in a machine learning model to analyze the posture and activity level of experimental pigs living in single-pig pens. A research prototype was created using a microcomputer and a ceiling-mounted camera for live recording based on the obtained images from the experimental facility, and a combined model was created based on the Ultralytics YOLOv8n for object detection trained on the obtained images. As a second step, the Lucas–Kanade sparse optical flow technique for movement detection was applied. The resulting model successfully classified whether individual pigs were lying, standing, or walking. The validation test showed an accuracy of 90.66%, precision of 90.91%, recall of 90.66%, and correlation coefficient of 84.53% compared with observed ground truth. In conclusion, the model demonstrates how machine learning can be used to monitor experimental animals to potentially improve animal welfare.

Additional details

Funding

The A.P. Moeller Foundation for Medical Research
L-2023-00228

Dates

Issued
January 28, 2025

References

  1. Poole, T. (1997). Happy animals make good science. Laboratory Animals, 31(2), 116–124. https://doi.org/10.1258/002367797780600198
  2. Martínez-Miró, S., Tecles, F., Ramón, M., Escribano, D., Hernández, F., Madrid, J., Orengo, J., Martínez-Subiela, S., Manteca, X., & Cerón, J. J. (2016). Causes, consequences and biomarkers of stress in swine: an update. BMC Veterinary Research, 12(1), Article 171. https://doi.org/10.1186/s12917-016-0791-8
  3. Lohmann, S., Eijken, M., Møldrup, U., Møller, B. K., Hunter, J., Moers, C., Ploeg, R. J., Baan, C. C., Jespersen, B., & Keller, A. K. (2019). A Pilot Study of Postoperative Animal Welfare as a Guidance Tool in the Development of a Kidney Autotransplantation Model With Extended Warm Ischemia. Transplantation Direct, 5(11), e495. https://doi.org/10.1097/txd.0000000000000941
  4. Tuyttens, F. A. M., de Graaf, S., Heerkens, J. L. T., Jacobs, L., Nalon, E., Ott, S., Stadig, L., Van Laer, E., & Ampe, B. (2014). Observer bias in animal behaviour research: can we believe what we score, if we score what we believe?. Animal Behaviour, 90, 273–280. https://doi.org/10.1016/j.anbehav.2014.02.007
  5. The Principles of Humane Experimental Technique. (1960). The Principles of Humane Experimental Technique. Medical Journal of Australia, 1(13), 500–500. https://doi.org/10.5694/j.1326-5377.1960.tb73127.x
  6. Zhang, L., Gray, H., Ye, X., Collins, L., & Allinson, N. (2019). Automatic Individual Pig Detection and Tracking in Pig Farms. Sensors, 19(5), 1188. https://doi.org/10.3390/s19051188
  7. Ahn, H., Son, S., Kim, H., Lee, S., Chung, Y., & Park, D. (2021). EnsemblePigDet: Ensemble Deep Learning for Accurate Pig Detection. Applied Sciences, 11(12), 5577. https://doi.org/10.3390/app11125577
  8. Kim, J., Chung, Y., Choi, Y., Sa, J., Kim, H., Chung, Y., Park, D., & Kim, H. (2017). Depth-Based Detection of Standing-Pigs in Moving Noise Environments. Sensors, 17(12), 2757. https://doi.org/10.3390/s17122757
  9. T. Psota, E., Schmidt, T., Mote, B., & C. Pérez, L. (2020). Long-Term Tracking of Group-Housed Livestock Using Keypoint Detection and MAP Estimation for Individual Animal Identification. Sensors, 20(13), 3670. https://doi.org/10.3390/s20133670
  10. Larsen, M. L. V., Wang, M., & Norton, T. (2021). Information Technologies for Welfare Monitoring in Pigs and Their Relation to Welfare Quality®. Sustainability, 13(2), 692. https://doi.org/10.3390/su13020692
  11. Tu, S., Cai, Y., Liang, Y., Lei, H., Huang, Y., Liu, H., & Xiao, D. (2024). Tracking and monitoring of individual pig behavior based on YOLOv5-Byte. Computers and Electronics in Agriculture, 221, 108997. https://doi.org/10.1016/j.compag.2024.108997
  12. Bhujel, A., Arulmozhi, E., Moon, B. E., & Kim, H. T. (2021). Deep Learning-based Automatic Monitoring of Pigs Physico-temporal Activities at Different Greenhouse Gas Concentrations [Preprint]. MDPI AG. https://doi.org/10.20944/preprints202110.0319.v1
  13. Yin, J., Chen, Y., Huang, Y., & Xiao, D. (2025). Analysis and classification of pig health status using hourly activity data: Combining statistical analysis and machine learning. Applied Animal Behaviour Science, 282, 106488. https://doi.org/10.1016/j.applanim.2024.106488
  14. Bonde, A., Codling, J.R., Naruethep, K., Dong, Y., Siripaktanakon, W., Ariyadech, S., Sangpetch, A., Sangpetch, O., Pan, S., and Noh, H.Y. (2021, January 18). PigNet: Failure-Tolerant Pig Activity Monitoring System Using Structural Vibration. Proceedings of the 20th International Conference on Information Processing in Sensor Networks (Co-Located with CPS-IoT Week 2021), Nashville, TN, USA.
  15. Amazon (2024, June 04). USB Camera Automatic Webcam Board 3MP Mini USB 2.0 Webcam Board Manual; USB Camera. Available online: https://www.amazon.de/dp/B0BQGXKQ9M/ref=pe_27091401_487027711_TE_SCE_dp_i1
  16. Amazon (2025, January 26). SMALLRIG Mini Magic Arm with Super Clamp. Available online: https://www.amazon.de/dp/B08BLDMZB4/ref=asc_df_B08BLDMZB4?language=da_DK&mcid=323e457ce54b36538fe90288fd8c9d36&tag=dkgoshpadde-21&linkCode=df0&hvadid=718119745823&hvpos=&hvnetw=g&hvrand=18131265976582119572&hvpone=&hvptwo=&hvqmt=&hvdev=c&hvdvcmdl=&hvlocint=&hvlocphy=9189474&hvtargid=pla-948992719175&psc=1&language=da_DK&gad_source=1
  17. Raspberrypi.dk (2024, November 15). Raspberry Pi 4 Model B Starter Kit. Available online: https://raspberrypi.dk/produkt/raspberry-pi-4-model-b-starter-kit-2/?gad_source=1&gbraid=0AAAAADwblR1uPS2WSqIZJg5Mvbmivbv2a&gclid=CjwKCAjw-JG5BhBZEiwAt7JR60rWYQ0QVpkxibxQZx8aFwih7k9C0aSdSLvnPgMMgvSHj7b8EyrfihoCKhQQAvD_BwE
  18. Ultralytics.com (2024, November 15). Ultralytics, Quickstart. Available online: https://docs.ultralytics.com/quickstart
  19. Roboflow.com (2024, November 15). Roboflow: Computer Vision Tools for Developers and Enterprises. Available online: https://roboflow.com
  20. Google.com (2024, November 15). Google Colab. Available online: https://colab.research.google.com/github/roboflow-ai/notebooks/blob/main/notebooks/train-yolov8-object-detection-on-custom-dataset.ipynb#scrollTo=Wjc1ctZykYuf
  21. Ultralytics.com (2024, December 01). A Guide on How to Use JupyterLab to Train Your YOLO11 Models. Available online: https://docs.ultralytics.com/integrations/jupyterlab
  22. OpenCV.org (2024, November 15). OpenCV—Open Computer Vision Library. Available online: https://opencv.org
  23. Postit.com (2024, December 09). R Studio Desktop. [Cited 2024 9/12]. Available online: https://posit.co/download/rstudio-desktop
  24. Huang, Y., Xiao, D., Liu, J., Liu, Y., Tan, Z., Hui, X., & Huang, S. (2024). Analysis of pig activity level and body temperature variation based on ear tag data. Computers and Electronics in Agriculture, 219, Article 108768. https://doi.org/10.1016/j.compag.2024.108768
  25. Costa, A., Ismayilova, G., Borgonovo, F., Viazzi, S., Berckmans, D., & Guarino, M. (2013). Image-processing technique to measure pig activity in response to climatic variation in a pig barn. Animal Production Science, 54(8), 1075–1083. https://doi.org/10.1071/an13031

1–25 of 33

Citations

  1. Ufitikirezi, J. de D. M., Umurungi, S. N., Bumbálek, R., Zoubek, T., Kuneš, R., Stehlík, R., Lin, H.-I., & Bartoš, P. (2026). Computer vision in livestock and poultry farming: A quantitative and translational review of research trends and real-world impact. Smart Agricultural Technology, 14, Article 102018. https://doi.org/10.1016/j.atech.2026.102018
  2. Hasan, M. K., Mun, H.-S., Mehtab, A., Kang, J.-G., Sharifuzzaman, M., Lagua, E. B., Kim, Y.-H., Park, H.-R., & Yang, C.-J. (2026). Computer Vision-Based Detection of Agonistic Behaviors in Pigs: Advances and Applications for Precision Livestock Farming. Agriculture, 16(6), 700. https://doi.org/10.3390/agriculture16060700
  3. Deutch, F., Hansen, L. S., Saleh, F. O., Weiss, M. G., Figueiredo, C., Moers, C., Keller, A. K., & Wagner, S. R. (2026). Developing and Assessing the Performance of a Machine Learning Model for Analyzing Drinking Behaviors in Minipigs for Experimental Research. Sensors, 26(2), 402. https://doi.org/10.3390/s26020402
  4. Lee, S., Nam, K., Son, S., Kim, J., Kang, S., & Chung, Y. (2026). ORAT: Detector-Side Identity and Observation Relations for Online Multi-Pig Tracking. Sensors, 26(21), 6691. https://doi.org/10.3390/s26216691
  5. Wang, Y., Yin, W., Pan, J., Wang, M., Wang, H., Yang, K., & Xiao, Q. (2025). Characterization of gas–liquid two-phase mixing state in pyrometallurgical process of non-ferrous metal by electrical resistance tomography. Physics of Fluids, 37(10). https://doi.org/10.1063/5.0293466
  6. Kennedy, M. E., Kaczmarek, E. B., Smith, A. E., Volpe, E. C., Anderson, D. J., Wallace, S. M., Shideler, H. E., Smith, H. I., Stroud, T. H., & Mayerl, C. J. (2025). Infant pigs demonstrate motor adaptation across multiple physiologic functions during feeding in response to dynamic changes in milk flow rate. Journal of Applied Physiology, 139(3), 719–730. https://doi.org/10.1152/japplphysiol.00552.2025
  7. Zhao, X., Tanaka, R., Mandour, A. S., Shimada, K., & Hamabe, L. (2025). Remote Vital Sensing in Clinical Veterinary Medicine: A Comprehensive Review of Recent Advances, Accomplishments, Challenges, and Future Perspectives. Animals, 15(7), 1033. https://doi.org/10.3390/ani15071033