Automatic individual pig detection and tracking in surveillance videos

Lei Zhang, Helen Gray, Xujiong Ye, Lisa Collins, N.m. Allinson · DOI

Abstract

Individual pig detection and tracking is an important requirement in many video-based pig monitoring applications. However, it still remains a challenging task in complex scenes, due to problems of light fluctuation, similar appearances of pigs, shape deformations and occlusions. To tackle these problems, we propose a robust real time multiple pig detection and tracking method which does not require manual marking or physical identification of the pigs, and works under both daylight and infrared light conditions. Our method couples a CNN-based detector and a correlation filter-based tracker via a novel hierarchical data association algorithm. The detector gains the best accuracy/speed trade-off by using the features derived from multiple layers at different scales in a one-stage prediction network. We define a tag-box for each pig as the tracking target, and the multiple object tracking is conducted in a key-points tracking manner using learned correlation filters. Under challenging conditions, the tracking failures are modelled based on the relations between responses of detector and tracker, and the data association algorithm allows the detection hypotheses to be refined, meanwhile the drifted tracks can be corrected by probing the tracking failures followed by the re-initialization of tracking. As a result, the optimal tracklets can sequentially grow with on-line refined detections, and tracking fragments are correctly integrated into respective tracks while keeping the original identifications. Experiments with a dataset captured from a commercial farm show that our method can robustly detect and track multiple pigs under challenging conditions. The promising performance of the proposed method also demonstrates a feasibility of long-term individual pig tracking in a complex environment and thus promises a commercial potential.

Introduction

Monitoring individual pig health and behavior is critical for animal welfare and farm productivity. Traditional manual observation is labor-intensive and prone to observer bias, while physical tagging (e.g., RFID) can be expensive and stressful for the animals. Computer vision offers a non-invasive alternative, but commercial pig pens present a "harsh" environment for standard algorithms.

Primary hurdles include:

  1. Light Fluctuation: Sudden shifts between daylight and infrared modes create shadows and contrast changes.
  2. Visual Similarity: Pigs of the same breed look nearly identical from a top-down view.
  3. Complex Occlusions: Pigs frequently huddle together (deforming their perceived shape), and insects often crawl over camera lenses, obscuring the view.
Visual challenges in pig monitoring: (a-c, e-f) insects on lens, (d) shadowing.

Methodology

The proposed system utilizes a "tracking-by-detection" framework designed to balance speed and robustness. By combining deep learning for detection with correlation filters for tracking, the system maintains continuity even when visual features are obscured.

The Detector (SSD)

The researchers compared three CNN architectures (Faster R-CNN, R-FCN, and SSD), ultimately selecting the Single Shot Multibox Detector (SSD) with a VGG-16 backbone. SSD offered the best accuracy-to-speed trade-off and handled overlapping objects effectively through its multi-scale default box mechanism, which is essential when pigs are huddling.

The Tracker (DCF)

To overcome the lack of discriminative features on the whole pig body, the system defines a "tag-box" (a local portion of the pig's body). It employs Discriminative Correlation Filters (DCF) to track these local key points, enabling accurate sub-pixel localization and better differentiation between visually similar animals.

Hierarchical Data Association

This component acts as the "glue" of the system, reconciling detector hypotheses with tracker trajectories using a bipartite graph matching approach solved via the Hungarian algorithm.

The proposed tracking-by-detection framework coupling a CNN detector and correlation filter tracker.

The algorithm handles four primary states to ensure robustness:

  • Tracked: Successful one-to-one matching between detection and trajectory.
  • Tracking Drift: Triggers re-initialization when the tracker shifts away from the detection box.
  • Unstable Detection: Refines "noisy" or missing detections using historical tracklets.
  • Pending: Manages cases where multiple trackers compete for the same detection box.

Experimental Results

The study used a dataset of 22,200 frames captured at Spen Farm, University of Leeds, featuring nine finisher pigs. The system demonstrated high performance across both day and night conditions:

  • Precision: 94.72%
  • Recall: 94.74%
  • MOTA (Multiple Object Tracking Accuracy): 89.58%
  • Reliability: Every pig was successfully tracked for the majority of the sequences (Mostly Lost metric = 0).

While the SSD inference took roughly 420ms per frame on a Titan XP GPU, this speed is sufficient for long-term behavior monitoring where high-frequency frame processing is not always required.

Conclusion

This research presents a robust, real-time system for tracking individual pigs without physical tags. By coupling a CNN-based detector with a correlation filter-based tracker through a novel data association logic, the method overcomes significant environmental challenges. Future work will explore integrating motion cues like velocity and testing in higher-density commercial pens to further enhance commercial potential.

Summary updated

BibTeX
@misc{zhang2018automatic,
  author = {Lei Zhang and Helen Gray and Xujiong Ye and Lisa Collins and N.M. Allinson},
  title = {{Automatic individual pig detection and tracking in surveillance videos}},
  year = {2018},
  eprint = {1812.04901},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1812.04901},
}
Figure