Robust piglet counting in crowded environments via small trajectory fusion and multi-line counting module
摘要
Current automated piglet counting systems struggle in modern farming environments. This is due to piglets’ rapid movement, highly similar appearance, and tendency to crowd, pile up, and climb over each other. This study proposes a vision-based counting framework specifically optimized for high-density piglet settings. Our core innovations include three key elements. First, we enhance the recall rate of YOLOv8 detection by using a reweighted loss function. This improves detection completeness, laying a critical foundation for subsequent tracking. Second, we design a small trajectory fusion (STF) algorithm. STF merges short, fragmented trajectories into longer ones if they are spatially and temporally adjacent. Third, we replace the traditional single-line counting method with a multi-line counting module (MLCM). This increases the robustness of the count. By emphasizing operational continuity, our system reduces reliance on appearance-based re-identification. This is particularly important given the piglets’ highly similar looks. Testing on over 29 h of annotated video data demonstrates strong performance. Our system achieves a counting error rate (CER) of 0.5%. This represents a 3.3