Abstract:Aiming to address the high labor intensity, low efficiency of traditional pig body size measurement, and the lack of edge computing methods for automated measurement, an automatic pig body size measurement approach tailored for the Jetson Orin NX edge platform was proposed. A time-series dataset comprising 10,413 posture images and 9,555 keypoint images was constructed and partitioned by enclosure. To achieve a lightweight yet high-performing model, an improved YOLO 11nds-based architecture was developed for posture and keypoint detection. The network width coefficient was reduced to compress model size, and DySample dynamic upsampling was incorporated to reduce computational redundancy and enhance cross-scale feature interactions, enabling efficient feature extraction and fusion with fewer parameters. A three-stage weight conversion process from pt to ONNX to engine was employed to reconstruct the network structure, optimize inference speed, and deploy the model on Jetson Orin NX. The SGBM algorithm was integrated to obtain 3D coordinates of key measurement points for body size estimation. Experimental results demonstrated that the improved YOLO 11nds model achieved superior accuracy, inference speed, and parameter efficiency. For posture detection, it reached 99.17% of accuracy, an F1 score of 94.26%, an inference speed of 156.25 f/s, and 8.2×10? parameters. For keypoint detection, it achieved 97.50% OKS, 97.06% PCK, 169.49 f/s, and 8.7×10? parameters. Optimizations improved inference speeds by 265.47% and 362.71% for the two tasks. Automatic measurements using videos from January 28 and March 9, 2024, showed mean relative errors of 1.58%, 1.70%, 2.17%, 2.00%, and 2.93%, and 1.90%, 2.18%, 2.90%, 3.10%, and 2.80% for body length, body width, rump width, body height, and rump height compared with that of manual measurements. This method demonstrated high accuracy and real-time performance, efficiently operating on Jetson Orin NX and providing a reliable solution for automated pig body size measurement.