基于YOLOV8-ByteTrack鱼苗自动计数装置的设计与试验
doi: 10.19663/j.issn2095-9869.20241117001
王瑞1 , 权佳宁2,4 , 田云臣2,3,4
1. 天津农学院水产学院 天津 300392
2. 天津农学院计算机与信息工程学院 天津 300392
3. 天津市水产生态及养殖重点实验室 天津 300392
4. 农业农村部智慧养殖重点实验室(部省共建) 天津 300392
基金项目: 国家重点研发计划(2020YFD0900600)、国家现代农业产业技术体系(CARS-47)、天津市海水养殖产业技术体系 (ITTMRS2021000)、天津市重点研发计划科技支撑重点项目(23YFZCSN00310)、天津市教委科研计划(2023KJ004)和农业农村部智慧养殖重点实验室(部省共建)开放基金(2023-TJAUKLSBF-2406)共同资助
Design and Experiment of an Automatic Fish Fry Counting Device Based on YOLOV8-ByteTrack
WANG Rui1 , QUAN Jianing2,4 , TIAN Yunchen2,3,4
1. College of Fisheries, Tianjin Agricultural University, Tianjin 300392 , China
2. College of Computer and Information Engineering, Tianjin Agricultural University, Tianjin 300392 , China
3. Tianjin Key Laboratory of Aquatic Ecology and Aquaculture, Tianjin 300392 , China
4. Key Laboratory of Smart Breeding (Co-construction by Ministry and Province), Ministry of Agriculture and Rural Affairs, Tianjin 300392 , China
摘要
本研究设计了一种鱼苗自动计数装置,旨在提升鱼苗养殖过程中计数的精度与效率。装置的整体结构包括鱼苗输送系统、成像系统和数据处理单元。在结构设计中,对装置在不同载荷条件下的应力和变形特性进行了仿真分析。同时,通过优化 YOLOV8 目标检测模型和 Bytetrack 跟踪流程,实现鱼苗个体的高精度检测和高帧率轨迹预测,有效避免重复计数,并降低下落速度对计数精度的影响。试验以 200、250 和 300 尾 3~5、6~8 和 9~12 cm 3 种规格的鱼苗为测试对象,对计数准确率进行验证,结果显示,3~5 cm 鱼苗的平均计数准确率为 98.5%,6~8 cm 鱼苗为 99.1%,9~12 cm 鱼苗为 99.6%,并且改进 YOLOV8-Bytetrack 算法的平均帧率高达 155 FPS,该装置能够实现高精度的鱼苗计数。
Abstract
With the continuous expansion of the aquaculture industry and the advancement of technology, the production model of the industry has gradually shifted toward greater modernization, mechanization, and automation. This transformation has become the primary trend in industry development, signaling the movement from traditional farming methods to intelligent and automated approaches. Fish fry, as a crucial link in the aquaculture supply chain, play an important role in the entire industry. Accurate fish fry counting is essential for managing the industry effectively, conducting scientific feeding practices, controlling stocking density, and ensuring fair pricing and transparent transactions in the sale of fry. In traditional aquaculture practices, fish fry counting mainly relies on manual methods, which are not only time consuming and labor intensive, but also prone to significant errors. Many farms still use the "pushing method" and "bowl method" for fry counting. The pushing method involves estimating the number of fry in a pile manually, whereas the bowl method estimates this number based on a sample. Both methods are subject to human error and often lead to inaccurate counts. Moreover, these manual methods are not only inefficient but can also harm the fry. During counting, the fry are often handled repeatedly, which can negatively impact their growth and survival, causing stress and affecting fry quality. With the advancement of technology and the development of computer systems, automated devices have been gradually introduced into the aquaculture industry. The advent of automatic fish fry counters has effectively addressed the inefficiencies of manual counting while ensuring accurate and transparent counting. These automated devices use sensors, image recognition, and machine learning technologies to automatically detect and track fry, efficiently completing counting with real-time data collection, high accuracy, and reliability. These tools provide aquaculture operators with a more scientific and convenient way of management, allowing for more precise feeding practices and reducing overfeeding or underfeeding, thus improving farm efficiency. However, despite the widespread use of automated counting technology in aquaculture, several challenges remain. In particular, when dealing with large volumes of fry, existing counting technologies face limitations in efficiency, accuracy, and handling fry overlap. As the number of fry increases, counting accuracy tends to decrease, especially when dealing with smaller fry, where detection systems can make errors. Additionally, the complex environment of aquaculture farms, such as light conditions, bubbles, and debris in the water, can interfere with counting accuracy, making the process complicated for automatic counting systems. Therefore, enhancing the accuracy of automated counting, especially in large volumes of fry or in complex environments, is still a technical issue that needs to be addressed. To tackle these issues, researchers have made significant improvements and innovations in automatic counting technology. The accuracy and efficiency of automatic counting systems have been significantly enhanced by incorporating advanced image recognition algorithms, deep learning techniques, and multisensor fusion technologies. These improved algorithms are effective at separating and tracking targets, achieving precise counting. Furthermore, with the development of simulation technology, virtual testing and simulations have played a crucial role in optimizing and designing automatic counting devices. Simulation allows device performance to be predicted under different working conditions, reducing the need for testing with live fry and minimizing potential losses. It also improves design efficiency and ensures that the stability, safety, and durability of the devices are thoroughly validated before practical application, providing reliable technical support for their implementation. Nevertheless, when handling large volumes of fry counting, challenges related to efficiency and dealing with overlapping fry remain. For instance, when designing automatic fry counting devices, design parameters are often difficult to calculate accurately because of the limitations of the fry and the aquaculture environment. Therefore, machine operating parameters must be adjusted to test counting effectiveness. However, this method wastes both human and material resources, and repeated testing can cause stress and harm to the fry. Simulation allows for testing the operational performance of prototype designs, reducing the need for physical testing and saving costs. This study introduces an improved YOLOV8-ByteTrack algorithm to achieve high-precision detection and tracking of fry. This algorithm focuses on real-time performance and efficiency by combining the lightweight YOLOV8 model for object detection with the precise multi-target tracking capabilities of ByteTrack. YOLOV8, being a lightweight model, reduces computational load while maintaining high detection accuracy, offering fast and stable performance in resource-limited environments. Once the fry are detected, ByteTrack uses an efficient data association strategy to track multiple targets and maintain identity consistency, significantly reducing issues such as ID switching and target loss caused by rapid movement, overlap, or environmental changes. Unlike traditional algorithms that rely solely on high-confidence detections, ByteTrack incorporates low-confidence results by utilizing motion consistency and appearance features, thus improving counting accuracy and continuity. To verify the performance and stability of the proposed fish fry automatic counting device in practical applications, a series of accuracy testing experiments was conducted on fish fry of different sizes. The experiments tested 3–5, 6–8, and 9–12 cm-sized grouper fry, with 200, 250, and 300 fry per group, respectively. The test results showed that the counting accuracy of the device was 99.1% and 99.6% for the 6–8 and 9–12 cm fry, respectively, with a slightly lower accuracy of 98.5% for the 3–5 cm fry. The algorithm achieved an average frame rate of 155 FPS, with a single-frame processing time of approximately 6.5 ms. Moreover, the processing speed at different frame rates demonstrated high real-time stability, with a minimum processing speed of 6.3 ms (158 FPS) and a maximum of 6.6 ms (152 FPS). The lower accuracy for the 3–5 cm fry can be attributed to their smaller size, which makes them more susceptible to background complexity and rapid movement, leading to a slight decrease in detection precision. As fry size increases, their features become more distinct, and their movements become more stable, resulting in higher detection accuracy. These results validate the excellent real-time and efficient performance of the algorithm even with limited hardware resources, meeting the practical needs of speed and accuracy in fish fry counting scenarios. The fish fry automatic counting device proposed in this study offers an innovative solution to improve fry counting precision and efficiency, providing valuable insights for theoretical research and practical applications in aquaculture.
随着水产养殖业规模的不断扩大和技术水平的提升,生产过程正在向全程机械化和智能化方向发展,部分环节已实现初步的智能化应用,该趋势已成为行业发展的主要方向(周小燕等,2022; 黄一心等,2023)。鱼苗在整个水产养殖产业链中占据关键位置。准确计算鱼苗数量是实现科学投饵、控制养殖密度和规范鱼苗销售的基础保障(刘世晶等,2023)。然而,目前我国仍以人工计数为主,常用的推算法和碗量法存在操作费时费力、误差较大且易对鱼苗造成损伤等问题(王润等,2024; Li et al,2022)。相比之下,鱼苗自动计数装置在准确性和效率上具有显著优势,其研发受到越来越多的关注。在该类装置的设计中,关键结构的合理性直接影响其性能和可靠性,而利用有限元分析技术对结构进行仿真(曾智伟等,2021; Liu et al,2023),不仅可以科学评估装置的稳定性和耐久性,还为结构优化提供了理论支持。
目前,多数研究集中在计数算法的设计上,包括利用图像处理技术解决高密度、重叠情况下鱼苗计数问题,并通过图像预处理技术(如二值化、膨胀和腐蚀)提取鱼苗的细节,分别采用细化算法和连通区域算法进行鱼苗计数。基于图像密度分级和局部回归的鱼类自动计数方法,通过利用图像处理技术分割个体连接区域,构建多类型图像特征,并根据区域面积构建局部回归模型以实现计数,计数准确率为 99.01%(Zhang et al,2020);基于卷积神经网络(CNN)的鱼苗计数方法(Lainez et al,2019),通过将采集的图像裁剪为 400×400 像素输入目标检测模型,并通过调整阈值来输出检测结果,得到鱼苗计数数量,平均计数准确率为 99.17%(Lainez et al,2019);利用嵌入式系统开发的观赏鱼自动计数仪器在控制照明条件下,获取固定容器中 0.5~2.3 cm 的孔雀鱼(Poecilia reticulata)和黑玛丽鱼(Poecilia sphenops)的图像,并使用图像处理方法进行计数,平均准确率为 96.64%(Hernández-Ontiveros et al,2018)。此外,双兴趣线(double line-of-interest)计数方法,通过鱼类投影面积分析,构建鱼体面积变化特征,进一步训练支持向量机(support vector machine,SVM)模型估计鱼苗数量,平均计数精度≥90%(刘世晶等,2020)。当鱼苗交叉重叠时,基于面积算法的鱼苗计数正确率为 85.7%,而基于细化算法的鱼苗计数正确率仅为 57%(Zhang et al,2022)。上述研究大多针对数量少或静态计数场景。当处理大量鱼苗计数时,在效率和处理鱼苗重叠方面仍面临限制。
本研究通过改进的 YOLOV8-ByteTrack 实现对不同规格鱼苗的高精度检测和目标精确跟踪,有效解决了在大批量鱼苗处理中因效率低下和重叠率高导致计数准确率偏低的问题。为鱼苗自动计数装置的设计和性能优化提供了新的技术支持和思路。
1 结构与方法
1.1 整机结构与工作流程
鱼苗自动计数装置整机结构如图1所示。鱼苗输送系统主要由进水分流槽、进鱼槽、计数滑道、水泵和进水管组成;成像系统主要由亚克力观察面板、光源面板和摄像头组成;数据处理单元主要由工控机、存储硬盘和触摸屏幕组成。其中,计数滑道、工控机和摄像头是鱼苗自动计数装置的主要工作执行部件。水泵用于连接进水分流槽,进水分流槽从进鱼槽上部进水。鱼苗从进鱼槽的上部倒入,避免鱼苗从侧面进入时水流的冲击对鱼苗造成损伤。计数滑道上方设有可调节光源面板,下方设有摄像头。计数滑道为鱼苗自动计数装置的主要结构,其工作参数直接影响到计数装置的工作性能。计数滑道的计数区域为透明亚克力板结构,两侧为 316 不锈钢。
在鱼苗计数过程中,如图2所示,通常将鱼水混合物倒入计数滑道,使其始终处于有水环境中。这种方法不仅能将堆积的鱼苗均匀分散,还能避免鱼苗在计数滑道入口处的拥挤和损伤。在水流的作用下,鱼苗向前滑动进入计数区域。成像系统快速且清晰地捕捉鱼苗图像,并将鱼苗图像传送至工控机进行分析。最终,计数结果反馈到触控屏幕显示,从而完成计数任务。
1鱼苗自动计数装置结构图
Fig.1Structural diagram of the automatic fish fry counting device
1:机架;2:计数滑道;3:光源面板;4:亚克力观察面板;5:进鱼槽;6:进水分流槽;7:触控屏幕;8:水泵; 9:行走脚轮;10:摄像头;11:存储硬盘;12:工控机;13:进水管;14:拍摄暗箱。
1: Frame; 2: Counting slide way; 3: Light source panel; 4: Acrylic observation panel; 5: Fish inlet trough; 6: Water inlet distribution trough; 7: Touchscreen; 8: Water pump; 9: Mobile casters; 10: Camera; 11: Storage hard disk; 12: Industrial computer; 13: Water inlet pipe; 14: Shooting dark box.
2计数过程图
Fig.2Counting process diagram
1.2 机架结构设计
鱼苗自动计数装置机架设计作为设备的基础结构,对整体性能、精度和耐久性有着重要的影响。一个合理的机架不仅需要提供足够的强度和刚度来支持计数装置的各个部件(杜岳峰等,2019; 张绘敏等,2024),还需保证其结构简洁、安装便捷,以适应水产养殖环境中的复杂工况和长时间稳定运行。机架材料应选择耐腐蚀性强并经过防腐处理的材料,并预留足够的安装空间以容纳摄像头、电控系统和其他必要部件。本设计选用 Q235 碳素结构方钢作为主要材料,不仅具备优异的耐腐蚀性,同时在机械强度和加工性能方面表现良好。机架的结构设计采用了轻量化的框架式布局,如图3所示。主体框架由 4 根主梁、6 根立柱和 14 根横梁构成,主梁之间采用焊接连接以增强整体刚度,确保结构的稳定性和抗扭曲性能。横梁的布置则根据装置内部部件的安装需求进行合理布局,确保各部件安装的稳定性和操作便捷性(孙德强等,2021; 才胜等,2021)。机架底部设计了可刹车脚轮。这些脚轮不仅可以保证装置的水平度,还能够在设备工作时起到刹车缓冲作用,减少振动对计数精度的影响。
3机架结构图
Fig.3Structural diagram of the frame
1.3 计数滑道设计
计数滑道作为鱼苗计数装置的关键组成部分,其设计直接影响着鱼苗的流动性、计数精度及设备的整体性能。滑道的宽度和高度经过简易装置(图4)进行预试验后合理计算,以适应不同尺寸的鱼苗,确保其在滑道中自然流动。滑道计数区域选用耐腐蚀、耐磨以及透光性好的亚克力板。此外,亚克力板表面光滑,能够减少鱼苗在滑道中的摩擦,降低损伤风险。同时,斜度设计考虑到水流的配合,通过水流的动力与重力共同作用,进一步提高鱼苗的流动性。最终,计数滑道采用斜坡型结构设计(图5),具有良好的导流性能,能够有效引导鱼苗从入口流向计数区。
4简易装置图
Fig.4Simplified device diagram
5计数滑道结构图
Fig.5Structure diagram of the counting slide way
1.4 图像采集装置设计
鱼苗自动计数装置的图像采集模块是成像系统获取清晰、可识别鱼苗图像的关键,具体图像采集过程如图6。我们采用海康威视型号为 MV-CS004-10UC、最大帧率为 526.5 FPS 的工业面阵相机,以满足小尺寸鱼苗在动态水体环境中成像的需求。镜头选用上,采用焦距为6 mm镜头,以提高在短工作距离下的成像清晰度,并根据景深需求适当调节光圈大小。高帧率相机的选择有助于减少运动模糊,同时保证连续拍摄的稳定性。镜头的安装位置和角度经过精确设计,使其与鱼苗的运动方向保持一定夹角,从而减少光反射对成像的干扰。本装置采用背光照明方式。背光照明能够有效突出鱼苗轮廓,便于图像分割,并提供均匀的补光,减少阴影和亮度不均现象,从而确保鱼苗在拍摄区域内始终呈现最佳成像效果(史晨阳等,2020)。
6图像采集流程
Fig.6Workflow of image acquisition
1.5 改进的 YOLOV8-ByteTrack 的鱼苗计数算法
本研究提出了一种改进的 YOLOV8-ByteTrack 鱼苗计数算法,以实现高精度的鱼苗数量检测与追踪。该算法在设计上充分考虑了实时性和高效性,如图7所示,通过轻量化目标检测模型 YOLOV8 与精确的多目标跟踪算法 ByteTrack 的有机结合,实现了对鱼苗的稳定识别与连续跟踪。YOLOV8 作为轻量化模型,在降低计算量的同时保持了较高的检测精度,能够在有限计算资源环境中提供快速且稳定的检测性能(袁红春等,2023)。在检测出鱼苗后,ByteTrack 则通过高效的数据关联策略,对多目标进行动态追踪与身份维护,显著减少了因鱼苗快速移动、重叠或环境变化而引起的 ID 切换和目标丢失问题。与传统的仅依赖高置信度检测的算法不同,ByteTrack 会充分利用低置信度的检测结果,通过综合运动一致性和外观信息,将这些结果纳入追踪过程,从而进一步提高计数的准确性和连续性。这种方法有效地结合了 YOLOV8 的检测优势与 ByteTrack 的追踪稳定性,为鱼苗数量监测提供了一种既高效又可靠的技术支撑。
YOLOV8 延续了 YOLO 系列的快速、准确、易部署的设计理念,并在准确性和鲁棒性上有所提升,适用于复杂应用场景。其架构分为主干网络(Backbone)、颈部网络(Neck)和头部网络(Head)三部分。Backbone 采用跨阶段部分网络(CSP)结构,在减少计算量的同时提高特征提取能力和信息流效率,支持高效处理高分辨率输入。Neck 模块创新性地融合多尺度特征,帮助模型更准确地检测不同大小的目标。Head 部分通过多尺度检测优化和边界框定位改进,进一步提升了检测精度,并采用 AutoML 自动调优结构和参数,增强了模型的适应性和效率。
ByteTrack 是一种先进的多目标跟踪算法,其核心创新在于高效的数据关联策略,利用创新机制保持目标身份的连续性,即便在复杂场景中也能稳定追踪(林庆霞等,2024)。与传统方法仅依赖高置信度检测不同,ByteTrack 充分考虑低置信度检测框,通过运动一致性,维持鱼苗在连续视频帧中的身份不变。这种方法显著减少了鱼苗追踪中常见的 ID 切换和目标丢失问题,特别是在鱼苗重叠或遮挡的场景仍能保持较高的跟踪精度(赵海翔等,2024)。
7计数方法流程图
Fig.7Flowchart of the counting method
改进的 YOLOV8-ByteTrack 利用高置信度的检测框来更新已有的跟踪目标,并用置信度接近 0.5 的检测框来处理可能丢失的目标。在第一阶段中,首先从当前帧中提取出置信度较高的检测框,用这些检测框与已有的跟踪目标进行匹配。利用公式 1 来度量跟踪框 ftrack 与检测框 fdetect 之间的特征相似度,余弦相似度越高,表示检测框与跟踪框的特征越相似。利用公式(2)来度量检测框和跟踪框的空间重叠度。IoU 值越高表示两个边界框重叠区域越大,匹配程度越高。
Similarity =ftrack fdetect ftrack fdetect
(1)
IoU=AreaBtrack Bdetect AreaBtrack Bdetect
(2)
式中,ftrack fdetect 表示对 f 进行归一化,在得到特征和空间位置相似度后,根据设定的阈值来确定匹配的跟踪–检测对。针对已匹配的检测和跟踪框对,更新跟踪框的位置和特征信息,以确保当前帧的跟踪结果。若某个跟踪框在高置信度检测框匹配中没有找到对应的检测,则将该目标标记为丢失,表明其在当前帧中未被检测到,这一步为后续置信度偏低的检测框匹配提供了可能。在第二阶段中,算法将置信度在 0.4~0.55 之间的检测框作为可能漏检的目标,对前一步中未匹配的跟踪框进行补充匹配。使用公式(1)和公式(2)来尝试匹配低置信度检测框和未匹配的跟踪框,如果某个跟踪框在高置信度和低置信度检测框中都没有匹配,则保留当前 ID 60 帧直至仍未匹配到,然后将其从跟踪列表中移除。对于高置信度检测框中未匹配的检测结果,将其初始化为新的跟踪目标,并在后续帧中继续跟踪。
2 结果与讨论
2.1 机架静力学仿真分析
机架不仅承担设备的自重,还需在工作过程中承受外部环境和运行时产生的多种载荷。因此,对机架进行静力学分析尤为重要,分析其变形位移情况和应力分布,旨在为机架结构的设计提供理论依据。首先,利用三维建模软件建立机架的几何模型并进行材质分配。选择受力区域平面增加约束集,在受力方向上施加载荷进行分析与计算。机架模型的关键参数如下:Q235 的弹性模量 E=210 Gpa,泊松比 ν=0.3,密度 ρ=7.85 kg/mm3。机架自重和设备部件的总载荷为 500 N,分布在机架的各个连接部位。通过仿真分析,得到了机架在静态载荷作用下的应力分布图(图8)。结果显示,机架的最大应力出现在主梁与横梁的连接处,其应力值为 25 MPa,远低于 Q235 材质的屈服强度(235 MPa)。其他部位的应力较为均匀,主梁和立柱的应力分布均低于 50 MPa,说明机架整体的受力情况良好,能够承受工作中的静态载荷。机架在静态载荷作用下的最大变形量出现在远离支撑点的横梁末端,最大变形为 0.14 mm。总体而言,机架的变形分布呈现自支撑点向远端递减的趋势,符合力学原理。大部分部位的变形量在 0.1 mm 以下,对设备的整体运行没有明显影响。基于静力学分析结果,机架的应力值均未超过材料的屈服强度,表明机架在设计载荷下具有足够的安全性。为了进一步评估机架的设计安全性,计算其安全系数,见公式(3):
8机架仿真分析图
Fig.8Simulation analysis diagram of the frame
安全系数 =σ屈服 σ最大
(3)
式中,材料的屈服强度σ最大 =235 MPa,最大应力σ屈服 =25 MPa。计算得出安全系数为 9.4。这一安全系数远远超出机架需要的结构强度,能够满足实际使用中的安全需求。
2.2 计数滑道静力学仿真分析
通过仿真方法,对计数滑道的静力学性能进行分析,以评估其在工作状态下的变形位移情况及应力分布。计数滑道采用斜坡型结构,设计参数如下,材料:选用亚克力板作为计数区域,具有优良的机械性能和耐腐蚀性。尺寸:滑道宽度为 400 mm,高度为 640 mm,长度为 900 mm。其余部分采用 SUS316 材质,具有良好的耐腐蚀性和机械性能。载荷:考虑到鱼苗及水流的作用力,设计平段部分载荷为 100 N,计数区域斜段部分载荷为 50 N。利用三维建模软件建立计数滑道的几何模型,确保滑道的几何参数与实际设计一致。对模型进行材质划分,约束相应接触固定点,模拟实际使用环境以及鱼苗与水流的合力作用。仿真结果显示(图9),滑道的最大应力集中在滑道的边缘处以及亚克力板中心位置,最大应力值为 15 MPa。应力分布呈现由中心向四周逐渐减小的趋势,符合静力学分析的基本原理。该应力值远低于亚克力板材料的屈服强度(约 25 MPa),表明滑道在设定载荷下具有良好的安全性。根据仿真结果,滑道的最大挠度出现在滑道中部,最大挠度为 1.6 mm。该变形量相对较小,说明滑道在载荷作用下的刚度较好,能够满足鱼苗流动的要求。
2.3 算法对比
为了验证本文提出的基于 YOLOV8-ByteTrack 算法的性能,选择 300 尾 6~8 cm 的石斑鱼苗对 CondInst(Tian Z et al,2020)、BlendMask(Chen et al,2020)、YOLOV7/8+FishMOT(Liu et al,2024)和 TSA(Li et al,2023)等主流的目标检测和跟踪算法进行对比,结果见表1。由表1可知,CondInst 和 BlendMask 的帧率均为 20 FPS,检测准确率分别为 39.1%和 38.4%,表明两种模型的检测精度较为接近,但整体性能相对较低,更适用于小规模数据集或实时性要求较低的应用场景。相比之下,YOLOV7+FishMOT 的检测准确率提升至 45.6%,处理速度为 40 ms;而 YOLOV8+FishMOT 的检测准确率进一步提高至 59.3%,处理速度优化为 30 ms,性能表现明显优于前二者。TSA 模型的检测准确率为 53.9%,处理速度显著提升至 8.3 ms,在实时性上具有显著优势,但检测精度相对较低。值得注意的是,YOLOV8-ByteTrack 的性能表现最好,其处理速度达到 6.5 ms,帧率高达 154 FPS,检测准确率更是达到 99.7%,显著优于其他计数算法,展现出极高的实时检测能力和精度水平。
9计数滑道仿真分析图
Fig.9Simulation analysis of the counting slide way
1算法性能对比
Tab.1Algorithm performance comparison
综上所述,YOLOV8-ByteTrack 的性能在速度和精度上均高于其他几种算法,是当前鱼苗目标检测与跟踪的最优选择,而传统方法和其他深度学习模型在特定场景中仍有一定适用性。
2.4 应用试验与结果分析
为了验证所设计的鱼苗自动计数装置在实际应用中的性能和稳定性,本研究开展了不同规格鱼苗的计数准确率测试试验,试验选取 3~5、6~8 和 9~12 cm 3 种规格的石斑鱼苗作为测试对象,每组分别测试 200、250、300 尾鱼苗。试验采用设计的鱼苗自动计数装置简化版(图10)进行验证。在试验过程中,鱼苗以匀速通过成像区域,成像系统实时采集鱼苗运动影像,并将图像数据传输至数据处理单元进行处理。硬件配置为 Intel Core i5-11400F CPU、8 GB 内存、 NVIDIA GeForce RTX 3050 显卡。数据处理单元基于 C++实现的改进 YOLOV8-ByteTrack 算法,并通过 TensorRT 引擎完成硬件优化和加速。改进后的算法能够对鱼苗运动轨迹进行高效跟踪,有效避免了由于鱼苗重叠或遮挡导致的重复计数或漏计问题。试验过程中,通过保持鱼苗匀速投放以及稳定光照条件,确保了数据采集的准确性和可靠性。
在相同测试条件下,对 3 种规格的石斑鱼苗分别进行了计数准确率测试,结果如表2所示。根据试验结果,通过计算得到该装置对 6~8 cm 和 9~12 cm 石斑鱼苗的平均计数准确率为分别为 99.1%和 99.6%, 3~5 cm 鱼苗的计数准确率稍低,为 98.5%。算法在平均帧率为 155 FPS 时,单帧处理速度约为 6.5 ms。此外,不同帧率条件下的处理速度均表现出较高的实时性与稳定性,最低处理速度为 6.6 ms(152 FPS),最高处理速度为 6.3 ms(158 FPS)。对于 3~5 cm 鱼苗计数准确率稍低的情况,分析认为,鱼苗规格较小时,由于目标特征较小,可能受背景复杂性和鱼苗快速移动的影响,导致检测精度略有下降;而鱼苗规格增大后,其特征更明显,且运动轨迹更稳定,因此检测精度更高。最后,根据标准差分析结果可知,标准差从 3~5 cm 到 9~12 cm 有逐步增加的趋势,分别为 0.33%、 0.49%、0.56%。增加的幅度较小,表明无论鱼苗规格如何,算法对准确率的波动控制均较好。总体来看,标准差较小(均在 1%以内),说明算法在不同规格下具有高度的稳定性和一致性。算法处理速度的标准差为 0.09 ms,这是一个极小的值,表明算法处理速度的波动范围非常有限。处理速度标准差如此之小,说明算法性能在不同规格下表现非常稳定。算法的稳定性非常重要,保证了系统的可靠性和高效性。这些结果验证了算法在硬件资源有限的情况下仍具备良好的实时性和高效性,满足了鱼苗计数场景中对速度和精度的实际需求。
10简化计数装置
Fig.10Simplified counting device
2计数准确率
Tab.2. Counting accuracy
3 结论
(1)通过对机架及计数滑道等关键部件的结构设计与静力学仿真分析,验证了装置在不同载荷条件下的应力分布与变形特性。仿真结果表明,机架和滑道在结构强度、刚度及材料选用方面均满足实际使用需求,具备较高的安全性和可靠性。
(2)试验表明,装置对 3~5、6~8 和 9~12 cm 3 种规格石斑鱼苗的平均计数准确率分别为 98.5%、 99.1%和 99.6%,整体平均准确率为 99.1%。该结果验证了装置在目标检测和轨迹跟踪过程中对鱼苗的准确识别和计数能力,有效解决了鱼苗计数过程中因遮挡、重叠导致的误差问题,同时显著提升了计数效率与可靠性。综上所述,本研究的鱼苗自动计数装置在理论研究与实际应用方面为提升鱼苗计数精度与效率提供了创新解决方案。
1鱼苗自动计数装置结构图
Fig.1Structural diagram of the automatic fish fry counting device
2计数过程图
Fig.2Counting process diagram
3机架结构图
Fig.3Structural diagram of the frame
4简易装置图
Fig.4Simplified device diagram
5计数滑道结构图
Fig.5Structure diagram of the counting slide way
6图像采集流程
Fig.6Workflow of image acquisition
7计数方法流程图
Fig.7Flowchart of the counting method
8机架仿真分析图
Fig.8Simulation analysis diagram of the frame
9计数滑道仿真分析图
Fig.9Simulation analysis of the counting slide way
10简化计数装置
Fig.10Simplified counting device
1算法性能对比
Tab.1Algorithm performance comparison
2计数准确率
CAI S, LUO Y H, LI Q L. State of the art of lightweight technology in agricultural machinery and its development trend. Journal of Mechanical Engineering, 2021, 57(17): 35-52[才胜, 罗颖辉, 李青林. 农业机械轻量化技术研究现状与发展趋势. 机械工程学报, 2021, 57(17): 35-52]
CHEN H, SUN K Y, TIAN Z, et al. BlendMask: Top-down meets bottom-up for instance segmentation. 2020 IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR). June 13-19, 2020. Seattle, WA, USA. IEEE, 2020: 8570-8578
DU Y F, FU S H, MAO E R, et al. Development situation and prospects of intelligent design for agricultural machinery. Transactions of the Chinese Society for Agricultural Machinery, 2019, 50(9): 1-17[杜岳峰, 傅生辉, 毛恩荣, 等. 农业机械智能化设计技术发展现状与展望. 农业机械学报, 2019, 50(9): 1-17]
HERNÁNDEZ-ONTIVEROS J M, INZUNZA-GONZÁLEZ E, GARCÍA-GUERRERO E E, et al. Development and implementation of a fish counter by using an embedded system. Computers and Electronics in Agriculture, 2018, 145: 53-62
HUANG Y X, BAO X T, XU H. Research progress of fishery equipment science and technology in China. Fishery Modernization, 2023, 50(4): 1-11[黄一心, 鲍旭腾, 徐皓. 中国渔业装备科技研究进展. 渔业现代化, 2023, 50(4): 1-11]
LAINEZ S M D, GONZALES D B. Automated fingerlings counting using convolutional neural network. 2019 IEEE 4th International Conference on Computer and Communication Systems (ICCCS). February 23-25, 2019. Singapore. IEEE, 2019: 67-72
LI D L, WANG G X, DU L, et al. Recent advances in intelligent recognition methods for fish stress behavior. Aquacultural Engineering, 2022, 96: 102222
LI Q F, TIAN Y C, CONG X Q, et al. Research on counting method of half-smooth tongue sole fry based on machine vision. 2023 8th International Conference on Intelligent Computing and Signal Processing (ICSP). April 21-23, 2023. Xi’an, China. IEEE, 2023: 61-65
LIN Q X, GU X J, CHEN X W, et al. Method for the automatic calculation of newborn lambs activity using ByteTrack algorithm enhanced by state vector. Transactions of the Chinese Society of Agricultural Engineering, 2024, 40(13): 146-155[林庆霞, 顾兴健, 陈新文, 等. 基于状态向量增强ByteTrack的新生羔羊活动量自动计算方法. 农业工程学报, 2024, 40(13): 146-155]
LIU L, WANG X L, ZHANG X C, et al. The impact of ‘T’-shaped furrow opener of no-tillage seeder on straw and soil based on discrete element method. Computers and Electronics in Agriculture, 2023, 213: 108278
LIU S J, LI G D, LIU H, et al. Current development status of aquaculture equipment in China. Journal of Fisheries of China, 2023, 47(11): 190-203[刘世晶, 李国栋, 刘晃, 等. 中国水产养殖装备发展现状. 水产学报, 2023, 47(11): 190-203]
LIU S J, TU X Y, TIAN C F, et al. Research on the counting system of fish suction pump based on machine vision. Fishery Modernization, 2020, 47(5): 45-51[刘世晶, 涂雪滢, 田昌凤, 等. 基于机器视觉的吸鱼泵过鱼量计数系统试验研究. 渔业现代化, 2020, 47(5): 45-51]
LIU S, ZHENG X Y, HAN L L, et al. FishMOT: A simple and effective method for fish tracking based on IoU matching. Applied Engineering in Agriculture, 2024, 40(5): 599-609
SHI C Y, LIN Y D. LED ring array design for uniform illumination imaging in machine vision. Acta Optica Sinica, 2020, 40(20): 2011003[史晨阳, 林燕丹. 机器视觉中均匀照明成像的 LED 环形阵列设计. 光学学报, 2020, 40(20): 2011003]
SUN D Q, LI B, SHI W, et al. Design of cushioning packaging structure for frame lamps. Packaging Engineering, 2021, 42(21): 160-168[孙德强, 李彬, 石威, 等. 框架式灯具缓冲包装结构设计. 包装工程, 2021, 42(21): 160-168]
TIAN Z, SHEN C H, CHEN H. Conditional convolutions for instance segmentation. Computer Vision-ECCV 2020. Cham: Springer International Publishing, 2020: 282-298
WANG R, LIU Y, YANG Y M, et al. Physiological changes and related gene expression of Cynoglossus semilaevis in response to acute high temperature stress. Progress in Fishery Sciences, 2024, 45(4): 24-33[王润, 刘洋, 杨英明, 等. 半滑舌鳎响应急性高温胁迫的生理变化和相关基因表达. 渔业科学进展, 2024, 45(4): 24-33]
YUAN H C, TAO L. Detection and identification of fish in electronic monitoring data of commercial fishing vessels based on improved Yolov8. Journal of Dalian Ocean University, 2023, 38(3): 533-542[袁红春, 陶磊. 基于改进的 Yolov8 商业渔船电子监控数据中鱼类的检测与识别. 大连海洋大学学报, 2023, 38(3): 533-542]
ZENG Z W, MA X, CAO X L, et al. Critical review of applications of discrete element method in agricultural engineering. Transactions of the Chinese Society for Agricultural Machinery, 2021, 52(4): 1-20[曾智伟, 马旭, 曹秀龙, 等. 离散元法在农业工程研究中的应用现状和展望. 农业机械学报, 2021, 52(4): 1-20]
ZHANG H M, ZHAO Y, HUANG S C, et al. Mechanical characteristics and simulation optimization of multi-frame box structure. Packaging Engineering, 2024, 45(11): 275-281[张绘敏, 赵扬, 黄双成, 等. 多框式箱体结构力学特性仿真分析. 包装工程, 2024, 45(11): 275-281]
ZHANG J F, PANG H T, CAI W M, et al. Using image processing technology to create a novel fry counting algorithm. Aquaculture and Fisheries, 2022, 7(4): 441-449
ZHANG L, LI W S, LIU C H, et al. Automatic fish counting method using image density grading and local regression. Computers and Electronics in Agriculture, 2020, 179: 105844
ZHAO H X, CUI H W, HUANG Z M, et al. Application of a Bytetrack-based, multi-target tracking algorithm for zebrafish toxicity-response behavior recognition. Progress in Fishery Sciences, 2024, 45(2): 136-149[赵海翔, 崔鸿武, 黄桢铭, 等. 基于 Bytetrack 的多目标跟踪算法在斑马鱼毒性行为识别中的应用. 渔业科学进展, 2024, 45(2): 136-149]
ZHOU X Y, NI Q, XU H, et al. Development report of China aquaculture whole-process mechanization in 2021. Journal of Chinese Agricultural Mechanization, 2022, 43(12): 1-4[周小燕, 倪琦, 徐皓, 等. 2021年中国水产养殖全程机械化发展报告. 中国农机化学报, 2022, 43(12): 1-4]