Original Articles Open access

Automatic sheep counting method and experimental study based on mask R-CNN

Authors

  • YiKun Fan – articles in this journal Computer and Information Engineering College, Inner Mongolia Agricultural University, Hohhot; Inner Mongolia Autonomous Region Key Laboratory of Big Data Research and Application of Agriculture and Animal Husbandry, Hohhot, Inner Mongolia Autonomous Region, China.
  • Ting Li – articles in this journal Computer and Information Engineering College, Inner Mongolia Agricultural University, Hohhot; Inner Mongolia Autonomous Region Key Laboratory of Big Data Research and Application of Agriculture and Animal Husbandry, Hohhot, Inner Mongolia Autonomous Region, China.
  • Hao Lian – articles in this journal Computer and Information Engineering College, Inner Mongolia Agricultural University, Hohhot; Inner Mongolia Autonomous Region Key Laboratory of Big Data Research and Application of Agriculture and Animal Husbandry, Hohhot, Inner Mongolia Autonomous Region, China.
  • HuiLin Jiang – articles in this journal Computer and Information Engineering College, Inner Mongolia Agricultural University, Hohhot; Inner Mongolia Autonomous Region Key Laboratory of Big Data Research and Application of Agriculture and Animal Husbandry, Hohhot, Inner Mongolia Autonomous Region, China.
  • Wenqian Yang – articles in this journal Computer and Information Engineering College, Inner Mongolia Agricultural University, Hohhot; Inner Mongolia Autonomous Region Key Laboratory of Big Data Research and Application of Agriculture and Animal Husbandry, Hohhot, Inner Mongolia Autonomous Region, China.
  • Peng Zhou – articles in this journal Computer and Information Engineering College, Inner Mongolia Agricultural University, Hohhot; Inner Mongolia Autonomous Region Key Laboratory of Big Data Research and Application of Agriculture and Animal Husbandry, Hohhot, Inner Mongolia Autonomous Region, China.
  • Meian Li – articles in this journal Corresponding author Email Computer and Information Engineering College, Inner Mongolia Agricultural University, Hohhot; Inner Mongolia Autonomous Region Key Laboratory of Big Data Research and Application of Agriculture and Animal Husbandry, Hohhot, Inner Mongolia Autonomous Region, China.
Published
12 September 2025
Section
Original Articles

Abstract

With the rapid growth of global meat demand and the expansion of livestock farming, accurate and efficient sheep counting has become crucial in modern livestock management. However, traditional manual counting methods are inefficient and lack accuracy, while automatic counting systems based on RFID and GPS, though more precise, are costly and challenging to scale. To address this issue, this paper proposes an automatic sheep counting method based on Mask R-CNN, aiming to enhance the accuracy and robustness of object detection using instance segmentation technology from deep learning. Mask R-CNN not only provides pixel-level precise segmentation for each sheep but also resolves misdetections and missed detections in occluded and densely populated scenes by optimizing bounding box and mask thresholds. The study was conducted using sheep image data from an actual livestock farm in Inner Mongolia, China, and tested the model under various environmental factors, such as lighting, background complexity, and sheep density. The experimental results indicate that the optimized Mask R-CNN model performs exceptionally well in diverse scenarios, achieving a counting accuracy of 96.1% and a generalization accuracy of 88.8%, significantly outperforming traditional detection models like YOLOv5M (80.3%) and SSD (83.7%). This research not only demonstrates the excellent performance of Mask R-CNN in sheep counting tasks but also provides a low-cost, efficient automated management solution for modern livestock farms.

Supporting Agencies

Inner Mongolia Natural Science Foundation Project "Research on Feature Point Space Invariance Method for Multi target Individual Identity Recognition of Livestock" , Basic Research Business Fee Project of Inner Mongolia Autonomous Region Directly Affiliated Universities "Research and Demonstration of Key Technologies for Multi scale Yellow River Ice Situation Automatic Detection Based on AIoT"

References

  1. Bharati, P., Pramanik, A. 2020. Deep learning techniques - R‑CNN to Mask R‑CNN: A survey. In: Das, A., Nayak, J., Naik, B., Pati, S., Pelusi, D. (eds.), Computational Intelligence in Pattern Recognition. Advances in Intelligent Systems and Computing, vol 999. Singapore, Springer. pp. 657-68. DOI: https://doi.org/10.1007/978-981-13-9042-5_56
  2. Bridge, E.S., Wilhelm, J., Pandit, M.M., Mordecai, R.S., Mountain, R.D. 2019. An Arduino-based RFID platform for animal research. Front. Ecol. Evol. 7:257. DOI: https://doi.org/10.3389/fevo.2019.00257
  3. Chen, L.-C., Zhu, Y., Papandreou, G., Schroff, F., Adam, H., 2018. Encoder-decoder with atrous separable convolution for semantic image segmentation. In: Ferrari, V., Hebert, M., Sminchisescu, C., Weiss, Y. (eds.), Computer Vision – ECCV 2018. Lecture Notes in Computer Science, vol 11211. Cham, Springer. pp. 801-18. DOI: https://doi.org/10.1007/978-3-030-01234-2_49
  4. Dac, H.H., Gonzalez Viejo, C., Lipovetzky, N., Tongson, E., Dunshea, F.R., Fuentes, S. 2022. Livestock identification using deep learning for traceability. Sensors 22:8256. DOI: https://doi.org/10.3390/s22218256
  5. de Lima Weber, F., de Moraes Weber, V.A., de Moraes, P.H., de Oliveira, J.S., Lima, R.C.F. 2023. Counting cattle in UAV images using convolutional neural network. Remote Sens. Appl. 29:100900. DOI: https://doi.org/10.1016/j.rsase.2022.100900
  6. He, K., Gkioxari, G., Dollár, P., Girshick, R., 2017. Mask R-CNN. Proc. IEEE Int. Conf. on Computer Vision, Venice. pp. 2961-9. DOI: https://doi.org/10.1109/ICCV.2017.322
  7. Liu, S., Qi, L., Qin, H., Shi, J., Jia, J., 2018. Path aggregation network for instance segmentation. Proc. IEEE Conf. Computer Vision and Pattern Recognition, Salt Lake City. pp. 8759-68. DOI: https://doi.org/10.1109/CVPR.2018.00913
  8. Long, J., Shelhamer, E., Darrell, T., 2015. Fully convolutional networks for semantic segmentation. Proc. IEEE Conf. Computer Vision and Pattern Recognition, Boston. pp. 3431-40. DOI: https://doi.org/10.1109/CVPR.2015.7298965
  9. Ronneberger, O., Fischer, P., Brox, T., 2015. U-Net: Convolutional Networks for Biomedical Image Segmentation. In: Navab, N., Hornegger, J., Wells, W., Frangi, A. (eds.), Medical Image Computing and Computer-Assisted Intervention – MICCAI 2015. Lecture Notes in Computer Science, vol 9351. Cham, Springer. pp. 234-41. DOI: https://doi.org/10.1007/978-3-319-24574-4_28
  10. Wang, G. 2019. Machine learning for inferring animal behavior from location and movement data. Ecol. Inform. 49:69-76. DOI: https://doi.org/10.1016/j.ecoinf.2018.12.002
  11. Wang, Y., Xu, D. 2019. Cow target detection in farm environments based on YOLOv3 algorithm. J. Guangdong Univ. Petrochem. Technol. 29:31-35.
  12. Xu, B., Wang, W., Falzon, G., Guo, L., Chen, G. 2020. Livestock classification and counting in quadcopter aerial images using Mask R-CNN. Int. J. Remote Sens. 41:2661-2682. DOI: https://doi.org/10.1080/01431161.2020.1734245

Metrics

Citations and online attention from Dimensions, Altmetric and PlumX.