| Compared with the existing manual or ear tag monitoring,the extraction and analysis of pig farm images by computer vision technology have the advantages of non-contact,high efficiency,and full-time period.The existing pig drinking behavior and identification methods can achieve good results under ideal conditions,but there is still room for improvement in the identification effect under complex conditions.Therefore,this paper studies the aspects of improving the brightness and detail features of pig images,enhancing the clarity of the edges of pig body segmentation,selecting the spatial and temporal features of drinking behavior with high correlation,and selecting and merging the identification features of drinking pigs.Based on the above research purposes,the main research contents and results of this paper are as follows:(1)In order to improve the brightness of the pig image and enhance the local details of the pig body.Firstly,the histogram component of the image is processed by the peak global shift processing algorithm,so that the peak area is in the center position to improve the image brightness.Secondly,the multi-stage local equalization algorithm is used to equalize the image from part to the whole to enhance the local details of the pig body.The comparative experiment of different equalization algorithms shows that this algorithm can redistribute the component values and retain richer local details.(2)Aiming at the problem that the edge of the segmented pig is not clear,this paper firstly uses the Pig-YOLOv4 algorithm to detect the single-pig target and provides a single-pig target for the subsequent segmentation.The algorithm introduces the K-Means++ algorithm to adjust the Anchor boxes to improve the accuracy of target detection.Secondly,the RGB-bilateral filtering algorithm is used to filter the single pig target image to improve the edge quality of the pig.Finally,the edge-enhanced image is segmented by the segmentation algorithm of the two-dimensional Otsu ant colony optimization threshold to provide a clear pig body area for identification.In the segmentation comparison experiment,the segmentation edge of this segmentation method is clearer than the segmentation edge of the original image,indicating that the enhanced edge can effectively improve the segmentation effect.(3)In order to improve the recognition rate of the drinking behavior of pigs,this paper proposes a method for recognizing of drinking behavior of pigs based on spatial-temporal features.This method firstly introduces the template matching method of the drinking port area to eliminate the pictures of non-drinking pigs.Then use the relative position characteristics of the pig’s mouth area and the drinking port to judge the drinking behavior in the spatial direction.Finally,the motion optical flow feature of the pig’s head area is used to judge the drinking behavior in the temporal direction.The confusion experiment of drinking behavior recognition shows that this method will not cause misidentification of non-drinking pigs,and can effectively distinguish disturbing behaviors such as playing with drinking fountains.In the comparison experiment of the recognition rate of drinking behavior with other methods,the recognition rate of this method is 95.8%,which is at least 1.8% higher than other methods.It shows that the method in this paper taking into account the characteristics of spatial-temporal feature can effectively improve the recognition rate of pig drinking behavior.(4)Aiming at the problem that various drinking angles affect the identification accuracy of drinking pig,this paper proposes a drinking pig identification method that combines rotationinvariant features.The method expands the dataset by rotating,and extracts the two-dimensional feature map of the rotation-invariant key points,and inputs it and the segmented feature map of drinking pig into the fusion feature classification network to identify the identity of drinking pig.At the same time,in order to improve the recognition speed of the fusion classification network,this paper selects the improved Res Net50 network as the backbone network to extract features.The comparative experiment under different backbone networks indicates that the improved Res Net50 model has improved both in training and recognizing speed.In the comparative experiment of single feature and fusion feature,the accuracy of the fusion feature is 96.8%,which is at least 4.2% higher than other methods,indicating that the fusion of rotation-invariant features can effectively improve the accuracy of drinking pig identification. |