Accurate and non-contact measurement of cattle body dimensions is essential for precision livestock management. This study presents YOLOv8-DMC, a lightweight deep learning model optimized for anatomical keypoint detection in side-view images of cattle. The model integrates three attention modules—DRAMiTransformer, MHSA-C2f, and CASimAM—to improve robustness under occlusion and lighting variability. Following keypoint prediction, a 16-neighborhood depth completion and pass-through filtering process are applied to generate clean, colored point clouds. This enables precise 3D localization of keypoints by matching them to valid depth values. The model achieves of 0.931 and AP@[0.50:0.95] of 0.868 on a dataset of over 7000 images, improving baseline accuracy by 2.14% and 3.09%, respectively, with only 0.35 M additional parameters and 0.9 GFLOPs in complexity. For real-world validation, strictly lateral-view RGB-D images from 137 cattle were collected, with ground-truth manual measurements. Compared with manual measurements, the average relative errors are 2.43% for body height, 2.26% for hip height, 3.65% for body length, and 4.48% for cannon circumference. The system supports deployment on edge devices, providing an efficient and accurate solution for 3D cattle measurement in real-world farming conditions.