Abstract:In the process of pig body temperature detection based on thermal infrared video, the head posture of pigs in the nursery period changes greatly, and the ear base area was small, resulting in low positioning accuracy of the head and ear base area, which affected the accurate detection of pig ear base temperature. In view of the above problems, an improved YOLO v4 (Mish Dense YOLO v4, MD-YOLO v4) method for detecting the temperature of pig ears was proposed and a detection model for key parts of pigs was built. Firstly, in the CSPDarknet-53 backbone network, dense connection blocks were added to optimize feature transfer and reuse, and the spatial pyramid pooling (SPP) module was integrated into the backbone network to further increase the backbone network receptive field; secondly, an improved path aggregation network (PANet) was introduced in the neck to shorten the high and low fusion paths of the multi-scale feature pyramid graph; finally, the Mish activation function was used in the backbone and neck of the network to further improve the detection accuracy of the method. The test results showed that the mAP of the model for the detection of key parts of live pigs was 95.71%, which was 5.39 percentage points and 6.43 percentage points higher than that of YOLO v5 and YOLO v4, respectively, and the detection speed was 60.21f/s, which can meet the requirements of real-time detection. The average absolute errors of the left and right ear root temperature extraction of pigs in the thermal infrared video were 0.26℃ and 0.21℃, respectively, and the average relative errors were 0.68% and 0.55%, respectively. The results showed that the pig ear root temperature detection method based on the improved YOLO v4 proposed can be applied to the accurate positioning of the key parts of pigs in thermal infrared video, thereby realizing the accurate detection of pig ear root temperature.