# A Review of Posture Detection Methods for Pigs Using Deep Learning
## 3 Application of Deep Learning Methods to Pig Posture Detection
### Two-Stage Detection Models  
R-CNN is a pioneer two-stage deep learning object detector, which is well-known for dramatically outperforming other contemporaneous state-of-the-art traditional machine learning detectors on the 200-class ILSVRC2013 detection dataset [74]. Based on R-CNN, Fast R-CNN and Faster R-CNN were successively proposed to solve the problems of computational redundancy and complex model composition, which could significantly improve the speed and accuracy. As the ultimate version of the R-CNN series, Faster R-CNN framework becomes the most popular among two-stage detection models to be used in pig posture detection [72]. To solve the problem of dependence on the facility environment of traditional machine vision systems, [PERSON] et al. [51] integrated the neural architecture search (NASNet) into the Faster R-CNN framework for pig localization and posture classification. As a result, by using only RGB images, they achieved a mean average precision (mAP) of 80.2% on pig position and posture detection with sufficient similar training images, but the mAP was only 44.8-58.8% under more difficult and demanding training conditions. To search for the optimal method for continuous posture monitoring of pigs throughout the day, [PERSON] et al. [75] tested 150 different deep learning model configurations in their experiments. Finally, a two-stage model consisting of Faster R-CNN and NASNet was identified as optimal despite certain flaws in speed. However, the method has comparatively poor performance at night due to the degraded near-infrared image quality. Although Faster R-CNN greatly outperforms the traditional methods in terms of accuracy and speed, the detection speed is still inadequate to meet the demand of real-time tasks [46]. Hence, region-based fully convolutional networks (R-FCN) [76] and feature pyramid network (FPN) [77] were developed based on the two-stage concept to further improve the detection speed. R-FCN introduces the novel concept of position-sensitive RoI pooling and implements parameter sharing during calculation, which can significantly reduce the calculation time [76]. As a case in point, [PERSON] et al. [20] conducted a series of experiments to test three deep-learning-based detector frameworks (Faster R-CNN, Single Shot MultiBox Detector (SSD) [78], and R-FCN) using various feature extractors of RGB images separately. Finally, they demonstrated that R-FCN incorporating ResNet101 could achieve the highest mAP of 93% and an acceptable framerate, five frames per second, to detect standing and two different lying postures. Because 2D images lack three-dimensional information and are susceptible to light disturbance, researchers began to explore the use of depth images. In a study to recognize and quantitively measure the posture of lactating sows during night and daytime, [PERSON] et al. [29] applied Faster R-CNN detectors to depth images to detect pigs and recognize their postures, including sitting and three different lying patterns, in loose pens. They found that the sows laid down more slowly to avoid crushing piglets. In this experiment, the use of depth images mitigated the disturbance of light during nighttime that may occur on RGB images. After the improvement to Faster R-CNN, [PERSON] et al. [79] detected five postures of lactating sows using the proposed refined two-stream RGB-D faster R-CNN model that used two CNNs to extract features from RGB images and depth images, respectively. The method they proposed takes advantage of feature concatenation fusion, contributingto outstanding detection performance on the five postures, particularly for standing and lateral recumbency, which both have average recognition precision exceeding 99%. The performance of two-stage methods for pig posture detection is summarized in Table 2. It can be seen that the methods using 2D images can barely detect the sitting posture and have difficulty distinguishing between sternal recumbency and ventral recumbency.