Abstract:Aiming at the challenges posed by the highly variable postures of dairy goats, which result in difficulty in extracting edge contour features and frequent misdetection or omission of body size keypoints, an enhanced keypoint detection method was proposed based on an improved YOLO v8n-pose architecture. Firstl, a C2f_Ghost module was integrated into the backbone network to enhance the model's feature extraction capability while maintaining its lightweight nature, making it more suitable for real-time applications. Secondly, a dual-domain selection mechanism (DSM) was designed to emphasize edge-related information in both spatial and frequency domains, thereby enhancing the model's sensitivity to boundary features and improving the localization of keypoints near complex contours. Thirdly, a global attention mechanism (GAM) was employed to effectively capture long-range dependencies and global context, which strengthened the interaction and structural consistency among keypoints. Experimental results showed that the improved model achieved a mAP0.5 of 94.5%, outperforming YOLO v8n-pose by 3.3 percentage points while reducing parameters and computation. Compared with mainstream models, HRNet, Lite-HRNet, YOLO v5-pose, YOLO v7-W6-pose, YOLO v8s-pose, YOLO-NAS-pose-N, and YOLO 11n-pose, mAP0.5 was improved by 4.3, 5.0, 5.9, 3.7, 3.2, 3.0, and 3.5 percentage points, respectively. The mean absolute errors for body height, withers height, body length, chest width, abdominal width, and chest girth were 3.43 cm, 3.21 cm, 3.27 cm, 1.33 cm, 1.34 cm, and 5.64 cm, with mean absolute percentage errors of 4.72%, 4.36%, 4.26%, 6.21%, 4.84%, and 5.83%, respectively. After coordinate correction, chest girth error was further reduced to 4.63%. These results demonstrated the effectiveness of the proposed method in improving keypoint detection accuracy which can provide technical support for dairy goat body measurement.