Abstract:
With increasing awareness and strict regulation of environmental protection, swine production management is becoming more and more intensified. The development of large-scale farming has brought new challenges to breeding managers. Manual pig counting and recognition of pigs' abnormal behaviors are becoming difficult in larger-scale farm. Automatic counting and pig behavior recognition can save manpower and greatly improve management efficiency. Image segmentation and splitting of touching pigs is the key to realize automatic counting and behavior recognition in group-housed pigs. In this study, the methods of pig image segmentation based on decision trees and splitting of touching pigs by recognizing watershed ridge lines on the boundary were proposed. The experiments were carried out in a commercial pig breeding farm belongs to one partner of Chengdu Ruixu Electronic Technology Co. Ltd.. A Hikvision camera was set above a pen at the height of 3 m relative to the ground. Six min video of group-housed pigs was recorded on August 16th, 2018. Frame rate was 25 frame/s. Image frames extracted from the video were processed in a computer (configured with Intel Core i7-4790 CPU (central processing unit), 3.6 GHz) with Matlab R2017a. The image processing mainly included foreground pigs segmentation and splitting of touching pigs. The foreground pigs were segmented by using Decision-Tree-based Segmentation Model (DTSM). After foreground pigs segmentation, the images were used for splitting of touching pigs. Firstly, touching pigs' connected regions were extracted by evaluating the complexity of each connected region. Secondly, the candidates of segmentation lines were detected by marker-controlled watershed segmentation. Thirdly, segmentation lines were determined by their segmentation performance and shape descriptors, including linearity and total number of Harris corners. Finally, selected segmentation lines were used to split the touching pigs and automatic counting was conducted. To evaluate the segmentation performance of DTSM, the segmentation results of DTSM were compared with the results of Otsu and Maximum entropy methods. Twenty five image frames with touching pigs were analyzed to evaluate the performance of segmentation lines recognition. To evaluate the performance of automatic counting, 60 image frames extracted from the video in a 6 s time interval were processed. The result of foreground pigs segmentation indicated that DTSM could remove the complex background effectively and achieved better segmentation performance than Otsu and Maximum entropy methods. The segmentation accuracy (SR) of watershed ridge lines recognition was 89.4%. The contours of separated touching pigs were well saved. The segmentation missing rate (SMR) was 30%, Because pig bodies were heavily overlapped by others in three image frames, this made the recognition of segmentation lines become difficult. SMR was 5.3% if the three image frames were removed from the total 25 images frames used for the recognition of segmentation lines. Location and distribution in pens of group-housed pigs can be obtained by calculating the centroid of connected area and Delaunay triangulation method. Counting mean error (CME) was 0.58, root mean square error (RMSE) was 0.89, average counting time (ACT) was 0.39 s and counting accuracy (CA) was 98.33%. The results showed that this method could be used to automatically count the total number of pigs in pens which was valuable information for breeders and managers in large-scale farming. By locating an individual pig in a pen continuously, trajectory can be plotted and its behaviors can be recognized. This study provides a new method to realize automatic counting and behavior recognition in group-housed pigs.