Trajectory Tracking for Group Housed Pigs Based on Locations of Head/tail.
Gao Yun,Yu Houan,Lei Minggang,Li Xuan,Guo Xu,Diao Yaping
DOI: https://doi.org/10.11975/j.issn.1002-6819.2017.02.030
2017-01-01
Abstract:Observing animal’s individual and social behaviors is the most effective way to assess animal welfare and healthy. Automated trajectory tracking based on head/tail locations is supposed to be extremely helpful for the realization of pig behavior recognition, especially for group housed pigs in the commercial pig facility. The methods of trajectory tracking for group housed pigs based on head/tail location were described in this paper. The video of group housed nurseries was taken in a commercial pig breeding farm of Hubei Jinlin Original Breeding Swine Co. Ltd. on January 12th, 2016. A high resolution camera (Woshida CL03) was used to record 15 min video. Afterwards, image frames were extracted from the original video in a one-second time interval. Image frames were processed in a computer (configured with IntelCore i7-4790 CPU (central processing unit), 3.6 GHz, 8 G memory) with MATLAB software platform. The image processing for each image frame included 4 steps: background removal, pigs division, head/tail identification and trajectory tracking modification. The background removal was based on the RGB (red, green, blue) color space, from which a vector of RGB mean values of the pig’s body was calculated. If the Euclidean distance between the RGB values of one pixel and the RGB mean values vector was less than a small threshold of 100, the pixel was involved in a pig body area and set as 1. Otherwise, it was outside any pig body area and set as 0. When all pixels of the image frame were scanned and calculated by this method, a binary image was acquired. The white area referred to pig’s body area, while the black area referred to the background. After that, the morphology erosion and expansion were utilized before the watershed segmentation algorithm to improve the dividing effect for the pigs with adhesion. Pigs division was implemented on the binary images with the improved watershed segmentation algorithm. To discriminate each pig in each image frame, a video tracking and marking method was necessary to be implemented in the video. After being manually marked with the identify number in the first frame, each pig had a unique number and was labelled automatically throughout the video. Abstracting image frames from the video with a very short time interval (1 s), the distance of 2 centroids of the identical pig between 2 continuous image frames would be sufficiently small. Therefore, the video tracking was to find the pig with the closest distance in the next image frame and mark it with the same identify number of the current pig until all the pigs were marked. After each pig was marked throughout the video, using the head/tail location as the coordinates of the pig, the trajectory of each pig in herd could be tracked by the trajectory calculation. Extracting the outline of each pig in frames, the head and the tail outlines were divided from the whole outline, after a sixth of whole outline distance was moved along the outline in 2 opposite directions from the 2 intersection points of the outline and short axis of the minimum bounding rectangle. After the head/tail outline curve was gained from each pig outline, 2 recognition algorithms, the analogous Hough clustering recognition algorithm and the roundness recognition algorithm, were employed to identify the head/tail of each pig. Thus the location of the pig’s head/tail could be spotted by locating the centroid of the heat/tail curve. Then the trajectory tracking of the pigs was calculated based on the location of head/tail, and corrected by the motion trends of pigs. Experiment showed that the background was successfully removed from each image frame using the Euclidean distance of RGB values between the pixels and the mean value vector. The improved watershed segmentation algorithm has been verified as an effective tool to divide the pigs with adhesion. The identify number of each pig was tracked from the first frame to the end. The average recognition rate of analogous Hough clustering algorithm was 71.79% for the identification of pig’s heads/tails, while the roundness algorithm was 79.67%, which was less sensitive to the distortion of head outline curve. If not including the pigs outside the camera range, the recognition rates would be up to 75% and 85.7% respectively. The roundness algorithm shows an obvious advantage in comparison. The modified trajectory of each pig shows a high agreement with the manually labelled trajectory. More understanding for pigs’ behaviors can be acquired from the trajectory of head/tail locations. This trajectory tracking method provides a good reference for further research of behavior recognition.