Body temperature is a critical indicator of pig health. This study proposes a non-contact method for detecting body temperature in group-housed pigs by extracting temperature data from thermal images of ear roots. Thermal images in the drinking trough area were captured using a thermal camera, with real-time data transmitted to a monitoring room via optical fibers. The YOLO v11m-OBB model was utilized to detect the ear root areas with oriented bounding boxes, while a novel algorithm, the two-stage left and right ear root pairing algorithm (YOLO TEPA-OBB), paired the ear roots of individual pigs using center distance clustering and angular relationships in a polar coordinate system. The maximum temperature of the ear roots was extracted to represent the body temperature. Experimental results based on 749 ear roots show that the YOLO TEPA-OBB achieves 98.7% precision, 98.4% recall, and 98.7% mean average precision (