基于关键点检测和多目标跟踪的猪只体尺估计

    姚裔芃, 徐晨, 陈鸿基, 刘勇, 徐顺来

    姚裔芃, 徐晨, 陈鸿基, 等. 基于关键点检测和多目标跟踪的猪只体尺估计[J]. 华南农业大学学报, 2024, 45(5): 722-729. DOI: 10.7671/j.issn.1001-411X.202404012
    引用本文: 姚裔芃, 徐晨, 陈鸿基, 等. 基于关键点检测和多目标跟踪的猪只体尺估计[J]. 华南农业大学学报, 2024, 45(5): 722-729. DOI: 10.7671/j.issn.1001-411X.202404012
    YAO Yipeng, XU Chen, CHEN Hongji, et al. Estimation of pig body measurements based on keypoint detection and multi-object tracking[J]. Journal of South China Agricultural University, 2024, 45(5): 722-729. DOI: 10.7671/j.issn.1001-411X.202404012
    Citation: YAO Yipeng, XU Chen, CHEN Hongji, et al. Estimation of pig body measurements based on keypoint detection and multi-object tracking[J]. Journal of South China Agricultural University, 2024, 45(5): 722-729. DOI: 10.7671/j.issn.1001-411X.202404012

    基于关键点检测和多目标跟踪的猪只体尺估计

    基金项目: 重庆市技术创新与应用发展专项重点项目(cstc2021jscx-dxwtBX0008);国家生猪技术创新中心先导科技项目(NCTIP-XD/B10)
    详细信息
      作者简介:

      姚裔芃,硕士研究生,主要从事计算机视觉研究,E-mail: 499622418@qq.com

      通讯作者:

      徐顺来,研究员,硕士,主要从事人工智能、机器视觉、物联网与养殖大模型研究,E-mail: 173894636@qq.com

    • 中图分类号: S828;TP391;TP183

    Estimation of pig body measurements based on keypoint detection and multi-object tracking

    • 摘要:
      目的 

      减少猪场人工测量猪只体尺的工作量,提高测量精度和工作效率。

      方法 

      本研究提出基于关键点检测和多目标跟踪的猪只体尺自动估计方法,该方法使用Yolov8-Pose模型识别各猪只关键点和目标检测框,利用ByteTrack算法对猪群实时跟踪,引入感兴趣区域规避图像畸变,提高识别速度,同时设计姿态和异常检测过滤算法减少因运动模糊、姿态不正等因素造成的误差。

      结果 

      5个猪栏中24头猪只体长、肩宽、臀宽的平均绝对误差均小于3 cm,平均绝对百分比误差分别维持在4%、6%和7%以内。数据处理速度提升为19.3帧/s。

      结论 

      本研究提出的基于关键点检测和多目标跟踪的猪只体尺估计方法为猪场生产场景提供了一个轻量化、易部署的自动体尺测量解决方案。

      Abstract:
      Objective 

      To reduce the manual workload of measuring pig body measurements in pig farms and improve measurement accuracy and efficiency.

      Method 

      An automatic pig body measurement estimation method based on keypoint detection and multi-object tracking was proposed. The method utilized Yolov8-Pose model to identify keypoints and bounding boxes of individual pigs. ByteTrack algorithm was employed for real-time tracking of the pig herd. Regions of interest were introduced to mitigate image distortion and improve recognition speed. Additionally, a posture and anomaly detection filter algorithm was designed to reduce errors caused by motion blur, posture abnormality and other factors.

      Result 

      The mean absolute errors of the body length, shoulder width, and hip width of 24 pigs in five pigpens were less than 3 cm, the mean absolute percentage errors were maintained below 4%, 6% and 7% respectively. The data processing speed reached 19.3 frames/s.

      Conclusion 

      The proposed method for pig body measurement estimation based on keypoint detection and multi-object tracking provides a lightweight and easily deployable solution for automatic body measurement in pig farming scenarios.

    • 图  1   4个不同场景猪只6个关键点的标注

      Figure  1.   Annotation of six key points of pigs in four different scenarios

      图  2   经过Mosaic增强后的样本图片

      Figure  2.   The image enhanced with Mosaic

      图  3   算法的整体流程图

      Figure  3.   Overall workflow of the algorithm

      图  4   畸变矫正后的图像

      Figure  4.   The image after distortion correction

      图  5   猪只6个关键点和体尺测量示意图

      Figure  5.   Schematic diagram of six key points and body measurements for pigs

      图  6   ROI筛选区域

      Figure  6.   ROI selection area

      图  7   异常猪只姿态过滤示例

      Figure  7.   Example of abnormal pig postures for filtering

      图  8   目标框(A)和关键点(B)的P-R曲线

      Figure  8.   P-R curves for bounding boxes (A) and key points (B)

      图  9   随机4张图像的推理效果展示

      Figure  9.   Demonstration of inference results in four random images

      表  1   3种多目标追踪算法对猪只追踪的验证结果1)

      Table  1   Validation results of three multiple target tracking algorithms for pig tracking

      场景
      Scene
      猪数量
      Number
      of pigs
      有无遮挡
      Occlusion
      situation
      FairMOT ByteTrack BoT-SORT
      MOTA/% IDF1/% FPS/(帧·s−1) MOTA/% IDF1/% FPS/(帧·s−1) MOTA/% IDF1/% FPS/(帧·s−1)
      1 5 86.1 87.7 43 91.3 92.9 142 96.7 90.7 59
      2 5 84.6 85.4 42 94.7 97.3 142 95.3 97.6 58
      3 5 73.7 72.3 43 67.6 82.0 144 82.8 88.3 59
      4 >20 76.3 74.9 36 79.8 86.9 129 84.5 91.4 52
       1) MOTA:多目标跟踪准确率,IDF1:IDF1分数,FPS:每秒处理帧数
       1) MOTA: Multiple object tracking accuracy, IDF1: Identity F1 score, FPS: Frames per second
      下载: 导出CSV

      表  2   猪只体长、肩宽、臀宽数据偏差对比1)

      Table  2   Variance comparison of pig body length, shoulder width and hip width data

      性状
      Trait
      圈栏号(猪只数量)
      Circle ID
      (number of pigs)
      第1组 Group 1 第2组 Group 2 第3组 Group 3
      R2 MAE/cm MAPE/% R2 MAE/cm MAPE/% R2 MAE/cm MAPE/%
      体长
      Body
      length
      1(7) 0.83 4.71 5.99 0.89 4.00 4.95 0.50 8.14 9.97
      2(6) 0.92 2.75 3.84 0.93 2.50 3.48 0.45 6.50 8.65
      3(5) 0.67 2.00 2.26 0.82 1.40 1.50 −1.65 5.80 6.34
      4(2) 0.20 12.00 13.98 0.81 6.50 7.10 0.92 4.00 4.15
      5(4) 0.00 2.50 3.66 0.89 1.00 1.47 −2.13 5.25 7.65
      总计 Total(24) 0.85 3.96 5.08 0.94 2.88 3.61 0.75 6.13 7.74
      肩宽
      Shoulder
      width
      1(7) 0.81 1.57 6.15 0.83 1.71 7.50 −0.54 4.71 18.82
      2(6) 0.61 1.00 5.39 0.81 0.83 4.57 0.04 1.50 7.89
      3(5) 0.71 1.00 4.54 0.77 1.00 4.83 0.58 1.40 6.93
      4(2) −0.06 4.00 14.59 0.19 3.00 10.24 −1.31 6.00 22.16
      5(4) −1.13 2.25 13.77 0.28 3.50 12.00 −5.05 3.75 21.87
      总计 Total(24) 0.77 1.63 7.60 0.86 1.25 5.65 0.13 3.17 14.40
      臀宽
      Hip
      width
      1(7) 0.71 1.86 8.76 0.74 1.86 8.79 −0.33 4.14 18.50
      2(6) 0.72 0.67 3.76 0.81 0.67 4.30 0.67 0.83 5.40
      3(5) 0.71 1.60 7.45 0.84 1.40 6.65 0.27 2.80 13.99
      4(2) 0.27 3.00 11.99 0.59 2.00 7.45 −1.49 5.50 22.60
      5(4) 0.25 1.25 8.06 0.80 0.75 5.12 −4.36 4.25 27.14
      总计 Total(24) 0.81 1.54 7.80 0.88 1.29 6.50 0.25 3.13 15.63
       1)R2:决定系数,MAE:平均绝对误差,MAPE:平均绝对百分比误差
       1) R2: Determination coefficient, MAE: Mean absolute error, MAPE: Mean absolute percentage error
      下载: 导出CSV
    • [1]

      NEETHIRAJAN S, KEMP B. Digital livestock farming[J]. Sensing and Bio-Sensing Research, 2021, 32: 100408. doi: 10.1016/j.sbsr.2021.100408

      [2] 李丹, 陈一飞, 李行健, 等. 计算机视觉技术在猪行为识别中应用的研究进展[J]. 中国农业科技导报, 2019, 21(7): 59-69.
      [3]

      NASIRAHMADI A, EDWARDS S A, STURM B. Implementation of machine vision for detecting behaviour of cattle and pigs[J]. Livestock Science, 2017, 202: 25-38. doi: 10.1016/j.livsci.2017.05.014

      [4]

      RANČIĆ K, BLAGOJEVIĆ B, BEZDAN A, et al. Animal detection and counting from UAV images using convolutional neural networks[J]. Drones, 2023, 7(3): 179. doi: 10.3390/drones7030179

      [5]

      VAN DER ZANDE L E, GUZHVA O, RODENBURG T B. Individual detection and tracking of group housed pigs in their home pen using computer vision[J]. Frontiers in Animal Science, 2021, 2: 669312. doi: 10.3389/fanim.2021.669312

      [6]

      SHAO W, KAWAKAMI R, YOSHIHASHI R, et al. Cattle detection and counting in UAV images based on convolutional neural networks[J]. International Journal of Remote Sensing, 2020, 41(1): 31-52. doi: 10.1080/01431161.2019.1624858

      [7]

      TAHERI-GARAVAND A, FATAHI S, OMID M, et al. Meat quality evaluation based on computer vision technique: A review[J]. Meat Science, 2019, 156: 183-195. doi: 10.1016/j.meatsci.2019.06.002

      [8] 宋兰霞, 杨毅. 基于计算机视觉的肉质大理石花纹含量的测定[J]. 云南农业大学学报(自然科学版), 2011, 26(2): 246-248.
      [9] 尹令, 蔡更元, 田绪红, 等. 多视角深度相机的猪体三维点云重构及体尺测量[J]. 农业工程学报, 2019, 35(23): 201-208. doi: 10.11975/j.issn.1002-6819.2019.23.025
      [10] 郭浩, 张胜利, 马钦, 等. 基于点云采集设备的奶牛体尺指标测量[J]. 农业工程学报, 2014, 30(5): 116-122. doi: 10.3969/j.issn.1002-6819.2014.05.015
      [11] 郭浩, 马钦, 张胜利, 等. 基于三维重建的动物体尺获取原型系统[J]. 农业机械学报, 2014, 45(5): 227-232. doi: 10.6041/j.issn.1000-1298.2014.05.035
      [12] 王小品. 基于深度学习的多目标生猪的体尺关键点定位方法研究[D]. 武汉: 华中农业大学, 2023.
      [13] 刘同海, 滕光辉, 付为森, 等. 基于机器视觉的猪体体尺测点提取算法与应用[J]. 农业工程学报., 2013, 29(2): 161-168.
      [14]

      ZHU X, LYU S, WANG X, et al. TPH-YOLOv5: Improved YOLOv5 based on transformer prediction head for object detection on drone-captured scenarios[C]//2021 IEEE/CVF International Conference on Computer Vision Workshops (ICCVW). Montreal: IEEE, 2021. doi: 10.1109/iccvw54120.2021.00312.

      [15]

      REDMON J, FARHADI A. Yolov3: An incremental improvement[EB/OL]. arXiv: 1804.02767 (2018-04-08) [2024-04-06]. https://doi.org/10.48550/arXiv.1804.02767.

      [16]

      REDMON J, DIVVALA S, GIRSHICK R, et al. You only look once: Unified, real-time object detection[C]//2016 IEEE Conference on Computer Vision and Pattern Recognition (CVPR). Las Vegas: IEEE, 2016. doi: 10.1109/cvpr.2016.91.

      [17] 殷献博, 邓小玲, 兰玉彬, 等. 基于改进YOLOX-Nano算法的柑橘梢期长势智能识别[J]. 华南农业大学学报, 2023, 44(1): 142-150. doi: 10.7671/j.issn.1001-411X.202112039
      [18] 杨秋妹, 陈淼彬, 黄一桂, 等. 基于改进YOLO v5n的猪只盘点算法[J]. 农业机械学报, 2023, 54(1): 251-262. doi: 10.6041/j.issn.1000-1298.2023.01.025
      [19]

      ZHANG Y F, SUN P Z, JIANG Y, et al. ByteTrack: Multi-object tracking by associating every detection box[EB/OL] arXiv: 2110.06864 (2021-10-13) [2024-04-06]. https://doi.org/10.48550/arXiv.2110.06864.

      [20]

      ZHENG Z Y, LI J W, QIN L F. YOLO-BYTE: An efficient multi-object tracking algorithm for automatic monitoring of dairy cows[J]. Computers and Electronics in Agriculture, 2023, 209: 107857. doi: 10.1016/j.compag.2023.107857

      [21]

      QIAN Z, CHEN X, JIANG H. Fish tracking based on YOLO and ByteTrack[C]. 2023 16th International Congress on Image and Signal Processing, BioMedical Engineering and Informatics (CISP-BMEI). Taizhou: IEEE, 2023.

    • 期刊类型引用(3)

      1. 刘继芳,周向阳,李敏,韩书庆,郭雷风,迟亮,杨璐,吴建寨. 人工智能驱动畜牧新质生产力高质量发展:制约因素、生成逻辑与推进路径. 智慧农业(中英文). 2025(01): 165-177 . 百度学术
      2. 王亚彬,徐爱俊,周素茵,叶俊华. 基于Byte的生猪多目标跟踪算法. 农业工程学报. 2025(07): 145-155 . 百度学术
      3. 李振波,孙浩翔,郭倩男,张涵钰,刘皓南. 机器视觉技术在大体型家畜无接触体尺测量中的研究进展. 农业工程学报. 2025(07): 1-12 . 百度学术

      其他类型引用(1)

    图(9)  /  表(2)
    计量
    • 文章访问数:  508
    • HTML全文浏览量:  96
    • PDF下载量:  77
    • 被引次数: 4
    出版历程
    • 收稿日期:  2024-04-05
    • 网络出版日期:  2024-06-23
    • 发布日期:  2024-06-30
    • 刊出日期:  2024-08-07

    目录

      Corresponding author: XU Shunlai, 173894636@qq.com

      1. On this Site
      2. On Google Scholar
      3. On PubMed

      /

      返回文章
      返回