1. Introduction
The limb and leg structure of swine has a major impact on pig production and breeding [
1,
2,
3]. More than 20% of sows are culled because of hoof and leg problems [
4,
5]. Sound leg conformation not only determines hoof health and length of productive life, but also directly affects production performance and reproductive traits, and has therefore become one of the key indicators for evaluating the selection quality of breeding pigs [
6]. However, on most farms leg structure is still assessed by visual inspection and experience-based scoring. This approach is highly subjective, prone to large variation among evaluators [
7], and inefficient and labor-intensive when implemented at scale, making it difficult to meet the demand for efficient and objective phenotypic evaluation in modern large-scale pig production systems [
8].
In recent years, computer vision and digital image processing technologies have been widely introduced into animal husbandry [
9,
10], providing more objective and efficient tools for the quantitative measurement of livestock phenotypes [
11,
12]. For example, Stock et al. (2017) used digital imaging to quantify pig leg structure and obtained high repeatability for key joints such as the carpus and hock (intraclass correlation coefficient, ICC, up to 0.83), thereby laying a technical foundation for replacing subjective scoring and improving the consistency and accuracy of structural trait evaluation [
13]. Peppmeier et al. (2025) automatically extracted structural traits of the fore- and hindlimbs from lateral RGB images. Target limbs were successfully identified in 99.9% of forelimb images and 98.0% of hindlimb images. The estimated heritability of related traits was up to 0.33, with significant genetic correlations with growth and feed-efficiency traits [
14]. The Pig Improvement Company (PIC, Hendersonville, TN, USA) has implemented an image-based leg scoring system for breeding pigs, which can process images in real time and generate culling recommendations during selection [
15,
16]. Liu et al. (2025) developed a 2D image-based scoring system, in which body size features were extracted using a U-Net model, and validated the accuracy of predicting abdominal and chest girths in a sample of 665 pigs (R
2 of 0.85 and 0.84, respectively). By further combining pig dealers’ subjective scores, they found that belly height was significantly positively correlated with conformation scores, whereas vertical belly thickness was significantly negatively correlated, indicating that tall, tight-bellied pigs better match the market-preferred body type [
11].
Salau et al. (2017) proposed a method for automatic measurement of hind-leg angles in freely walking dairy cows using a multi-Kinect 3D scanning system. The calculated angles showed high agreement with human assessments (Spearman’s r = 0.67, Pearson’s r = 0.70), with stride-to-stride repeatability of 47.4% (R
2) and within-subject ICC of 0.64, demonstrating the accuracy and stability of this approach for objective evaluation of structural traits in animals [
17]. In addition, leg structure traits generally exhibit relatively high heritability, so the objectivity and consistency of scoring are crucial for accurate genetic selection [
18]. Building on this, some breeding companies and research institutions have begun to actively explore the integration of digital phenotyping technologies with genomic selection to achieve automated leg structure evaluation and tighter coupling with genetic improvement. For example, Seufert et al. (2022) reported that abnormalities in claw and leg conformation (such as asymmetric claws) significantly increase the risk of lameness and other disorders, thereby reducing animal welfare and production efficiency. This indicates that objective leg scoring is not only valuable for breeding, but also of considerable economic and ethical importance [
19].
The design of leg structure scoring standards is directly related to the scientific validity and practical applicability of an evaluation system. Among the more representative schemes, the replacement gilt evaluation guidelines proposed by Iowa State University place limb and hoof structure at the core and use a color-coded, illustration-based grading system for intuitive on-farm assessment [
20]. The scoring methods adopted by international breeding companies such as Hypor and PIC provide basic criteria for body conformation evaluation and scoring [
8]. In particular, the PIC system defines a nine-point scale for both fore- and hindlimbs, with a score of 5 representing the ideal hind-leg conformation; scores below or above this value indicate excessive curvature or straightness, respectively. Standardized reference images are provided to support field classification. This system has been widely applied worldwide in breeding stock selection, acceptance of imported animals, and lameness risk screening, and has become an important basis for evaluating limb soundness and productive longevity in commercial production.
Companies such as Hypor also incorporate limb and hoof scores into their structural and type evaluation guidelines, integrating them into the breeding goal index system to optimize reproductive performance and herd health. In contrast, traditional Chinese “pig appraisal” places emphasis on comprehensive judgment of constitution based on external traits such as ears, snout, hooves, and teats, forming an integrated “morphology–function–constitution” evaluation logic [
21]. In domestic breeding practice, Yin et al. (2016) proposed an enterprise-oriented scoring system with multiple stages and multi-level grades, providing a practical tool for genetic evaluation [
6]. In addition, the Technical Manual for Breeding Pig Phenotypic Appraisal issued by the Shanghai Animal Disease Prevention and Control Center defines unified standards for key traits such as structural soundness, limb and hoof conformation, mammary system, and external genitalia [
22].
Overall, mainstream industry practice is gradually shifting from experience-based and illustration-based scoring toward data-driven and automated evaluation. Limb and hoof structure scores are now widely used for monitoring production performance, analyzing longevity traits, and managing smart farming systems, which creates a clear practical need and application foundation for the automated scoring system proposed in this study.
However, studies on automatic scoring of swine leg structure are still limited. Most existing methods are based on 2D images, making it difficult to fully capture the three-dimensional geometric characteristics of the animal, and they are easily affected by posture and illumination in complex farm environments, leading to insufficient stability of the measurements [
23,
24]. Recent work has introduced deep learning models to improve recognition accuracy, but these approaches still suffer from strong dependence on annotated samples, poor model interpretability, and limited cross-scene generalization [
25,
26,
27]. In contrast, the present study adopts a non-deep-learning approach based on geometric features and spatial constraints, enabling automatic identification and scoring of leg structure without model training, and offering advantages such as real-time performance and low dependence on labeled data.
Therefore, this study aims to develop an automatic leg structure scoring system for swine based on 3D point cloud scans. The system, summarized in
Figure 1, comprises modules for multi-view depth data acquisition, 3D reconstruction of live pigs, extraction of key leg features and posture discrimination, and objective scoring. Through this automated pipeline, fast, accurate, and consistent evaluation of leg structure is achieved. The system substantially improves the efficiency of leg structure assessment, reduces human error, and provides objective and reliable data in support of breeding selection, health monitoring, and decision-making in genetic improvement of pigs, thereby promoting precision breeding and smart pig farming [
28,
29].
2. Materials and Methods
This section describes the overall technical workflow and experimental design of the study. We first present objective scoring of the experimental subjects and the data acquisition procedure, followed by detailed steps of point cloud preprocessing and coordinate unification, including registration, filtering, and posture normalization. On this basis, we constructed an adaptive leg region segmentation and key point localization method, extracted multi-scale geometric and symmetry features, and performed posture screening of the animals. Finally, following a “classify first, then score” strategy, we established a nine-level linear scoring model along with evaluation metrics and statistical methods.
2.1. Data Acquisition
2.1.1. Hardware Design
Considering the morphological characteristics of pigs and the complexity of commercial farm environments, a dedicated walk-through, acquisition corridor was built on the farm. An arch-shaped data acquisition frame was installed above the corridor. One camera was mounted on the top of the arch and two cameras were mounted on each side, and one additional camera was installed at the front and one at the rear of the corridor, yielding a total of seven cameras (
Figure 2a).
All cameras are time-of-flight (ToF) depth cameras (Femto Bolt, Orbbec Inc., Shenzhen, China). The seven depth cameras were connected to an industrial PC via USB-C interfaces and synchronized using a professional star-topology synchronization hub (Multi-Camera Sync Hub Pro, Orbbec Inc., Shenzhen, China). The industrial PC was configured with an Intel Core i7-8700 CPU, 16 GB RAM, a 256 GB SSD and a 1 TB HDD, running Windows 10 (64-bit). When a pig passed through the corridor, the seven cameras simultaneously captured its external morphology, and multi-view 3D point cloud data were obtained from all perspectives. The cameras were arranged around the animal at different angles and provided a depth resolution of 512 × 512 with a wide field of view of 120° × 120°, ensuring complete multi-angle coverage of the leg structures.
2.1.2. Multi-Camera Synchronous Acquisition
Since pigs were in motion, accurate 3D reconstruction required that multi-view acquisition be completed within a very short time window. Hardware triggering was the basis for synchronized data collection. Each camera received a trigger signal through the professional star topology synchronization hub connected to an eight-channel breakout cable and USB-C data lines (
Figure 2b). All seven images were acquired using the camera’s SDK and stored in a data buffer along with their hardware timestamps. A timestamp comparison procedure was implemented to filter out non-synchronous frames that might occur due to bandwidth conflicts, ensuring that the time error between cameras for each frame was within 3 ms. This design guaranteed temporal and spatial consistency of the multi-camera data; i.e., the leg posture of the pig was captured at essentially the same moment in time.
2.1.3. Acquisition Procedure
The experiment was conducted at a pig farm in Longyao County, Xingtai City, Hebei Province, China, in 2025. The experimental subjects were 36 F1 hybrid commercial pigs, 140–170 days of age, with body weights ranging from 80 to 110 kg. The pigs were randomly selected from the farm population. Each pig was recorded multiple times within the same day to obtain multiple point cloud samples per individual, while data collection for different pigs was conducted across their growth cycle. Frames were randomly sampled rather than collected as consecutive frames in a continuous recording. A fenced corridor was constructed on site to guide animal movement, and the acquisition devices were installed along this corridor. The setup consisted of an arch-shaped frame carrying five cameras and two additional cameras providing frontal and rear views.
Each pig was identified by a unique ear tag. The ear tag IDs were obtained by manual visual inspection and recorded during the experiment. During data collection, pigs were guided into the corridor and briefly maintained in a standing posture. The operator issued the acquisition command via a keyboard, upon which the system simultaneously stored the synchronized point cloud frames from all seven cameras and performed real-time analysis of the acquired data.
2.2. Point Cloud Preprocessing
2.2.1. Multi-View Point Cloud Registration and Fusion
Point clouds were acquired from seven viewpoints. To ensure spatial consistency in a unified coordinate system, these multi-view point clouds had to be registered and fused. Based on the preconfigured and fixed relative poses between cameras, the corresponding transformation matrices were calculated in advance and applied to the point clouds from each view to perform coordinate transformation. All point clouds were then transformed into a global coordinate system and fused into a complete 3D point cloud model, achieving full 3D reconstruction of each pig (
Figure 3a).
2.2.2. Noise Filtering and Background Removal
After multi-view fusion, background removal and noise filtering were performed to extract valid point cloud data of the target pig. First, according to the known spatial range of the acquisition corridor, a 3D bounding box was constructed to delimit the region of interest. In implementation, the ROI parameters were set according to the corridor layout and used consistently across frames. The convex hull of this region was computed to obtain a polyhedral boundary enclosing the animal body. The point cloud was then clipped by this hull to retain only points inside it and remove stray points from non-target objects such as fences and the floor.
For the preliminarily cropped point cloud, a Statistical Outlier Removal (SOR) filter was applied to eliminate outliers and flying points with abnormally low local density. As illustrated in
Figure 3a (“SOR Filtering”), the red crosses represent the points identified as outliers and removed by the SOR filter, while the green points denote those retained as valid points not classified as noise. This was followed by a Radius Outlier Removal (ROR) filter to remove isolated clustered noise and improve the global coherence and continuity of the point cloud. As shown in
Figure 3a (“ROR Filtering”), the red crosses indicate the points removed during radius-based filtering. For each point (black dots), a spherical neighborhood with radius
r is constructed, and the point is retained only if the number of neighbors within this radius exceeds a predefined threshold; otherwise, it is removed as noise. Here,
r represents the spatial search radius that defines the local neighborhood scale. The ROR-refined point cloud was then downsampled using a VoxelGrid filter to reduce the number of points and increase computational efficiency, while simultaneously smoothing local point density (
Figure 3a). In
Figure 3a (“Voxel Downsampling”), the blue cubes represent the predefined voxel size, and all points (blue dots) within each voxel are approximated by a representative point (red dot), thereby achieving point cloud simplifi-cation through spatial aggregation. Voxel downsampling was performed using a cubic voxel with an edge length of 6 mm, resulting in point clouds of approximately 70,000 points on average after preprocessing.
2.2.3. PCA-Based Body Pose Orientation Correction
To address variations in body orientation and posture across acquisitions and to further improve analysis accuracy, principal component analysis (PCA) was employed to standardize the body pose orientation of the point cloud model. The covariance matrix and eigenvectors of the point cloud were computed along three principal directions, from which the longitudinal (head–tail), transverse (left–right), and vertical (dorsal–ventral) axes of the pig’s body were derived. The point cloud was then rotated so that the longitudinal axis aligned with the global x-axis, the transverse axis with the y-axis, and the vertical axis with the z-axis. This pose normalization provided a unified spatial reference frame for subsequent leg structure analysis from fixed viewpoints.
2.3. Adaptive Leg Segmentation Method
2.3.1. Coarse Segmentation
To automatically and accurately extract the leg regions, an adaptive leg segmentation method was proposed based on the pose-normalized point cloud. The method first performed coarse segmentation to localize the approximate positions of the four legs, and then applied fine segmentation to separately extract the left fore, right fore, left hind, and right hind legs (
Figure 4).
First, the anterior part of the point cloud model was cropped along the longitudinal axis of the pig to remove the head region, so as to avoid interference in subsequent left–right partitioning and leg localization. Here, the longitudinal axis denotes the global head–tail direction after pose normalization, obtained as the dominant principal direction of the extracted body point cloud. In practice, after pose normalization, we removed the points belonging to the anterior segment using a fixed proportion of the overall point cloud length measured along the longitudinal axis. The remaining point cloud, which mainly contains the trunk and limbs, was used as the input for leg segmentation (
Figure 4a). Frames with pronounced trunk deformation were treated as non-standard postures and excluded in the subsequent posture screening step (
Section 2.5.2), ensuring that downstream analysis was performed on stable standing poses. The point cloud was then projected onto the xy-plane and was uniformly sampled along the
x-axis. For each sampling interval, the midpoint in the x direction and the median position in the y direction were computed. A quadratic curve representing the midline of the pig’s body was fitted to all sampling points by the least-squares method. The point cloud was divided into left and right parts with respect to this midline, and the anterior and posterior regions were further separated at the central position along the
x-axis. In this way, four coarse spatial regions corresponding to the left fore, left hind, right fore, and right hind legs were obtained (
Figure 4b).
2.3.2. Iterative Cropping with Clustering-Based Verification
After obtaining the four candidate leg regions, a combined strategy of iterative height-based cropping, clustering and geometric verification was used to extract the leg point clouds. In each iteration, the point set was retained
where
denotes an arbitrary candidate leg point set,
is its minimum height, and
is the cropping height.
Euclidean clustering was applied to
, and each cluster was then checked for validity as a roughly cylindrical leg structure candidate. The verification criteria are listed in
Table 1 and include: point count threshold, valid ranges of height and width, height–width ratio, vertical similarity, and cylindricity. Approximating a cluster as a cylinder formed around its principal axis, its cylindricity is defined as:
where
is the standard deviation of the distances from the cylindrical points to the principal axis, representing the consistency of the cross-section, and
is the shortest distance from each point to the principal axis line.
If none of the current clusters met the leg structure criteria, it indicated that the height slice still contained the abdomen or other non-leg regions. In this case, the algorithm further lowered the slicing height and repeated the verification process until four clusters satisfying the structural conditions were obtained as the leg point clouds. This procedure required no manual intervention and showed good adaptability and robustness at the individual level, enabling stable, high-precision leg extraction under varying body sizes and postures (
Figure 4c).
2.4. Feature Extraction of Swine Legs
For each segmented leg point cloud, a multi-scale curvature analysis was performed to locate key anatomical feature points, including the bottom point (hoof/toe tip), middle point (joint inflection point, such as carpus or hock), and top point (the highest attachment point where the leg connects to the trunk).
2.4.1. Extraction of Leg Shape Features
For each leg point cloud, a multi-scale curve analysis was carried out to estimate the leg’s central axis and identify key feature points. Given a leg point cloud
, its height range along the
z-axis was first determined as
(
Figure 5a). This range was then uniformly divided into
horizontal slices. For the
-th slice, the center height was denoted as
. Around each center height
, a symmetric interval
was used to extract the corresponding point set, denoted as
, where
= 8 mm, indicating that each slice represented a local point cloud segment with a thickness of 16 mm. The 3D geometric centroid of each
was computed as
where
denoted the centroid of the
-th slice,
,
,
represented its centroid coordinates,
indicated the number of points in
, and
,
,
denoted the coordinates of each point in the set.
All centroid points were then sorted in ascending order of
to form a coarse centerline point set of the leg shape
where
denote the centroids of the corresponding slices.
As shown in
Figure 5b, to reduce the influence of point cloud noise on the centerline, a 3D Gaussian smoothing filter
is applied to the centroid sequence
, yielding a smoothed point sequence:
Subsequently, cubic spline interpolation was performed on
to reconstruct the centerline curve, and a high-density point set was generated by interpolation along the curve
where
denoted the number of interpolated points. In this work,
was set to 300. In general,
can be chosen to keep a comparable spatial sampling step along the centerline under different sensing resolutions.
The resulting curve
describes a continuous and smooth central axis from top to bottom, which approximately reflects the longitudinal geometric structure of the leg (
Figure 5c).
2.4.2. Multi-Scale Curvature Analysis
For the extracted leg feature curve , a multi-scale curvature analysis was further applied. Joint regions typically exhibit pronounced curvature peaks or sudden changes. By detecting distinct bending points along the leg curve, the spatial locations of the joints could be identified.
For lateral structural analysis of the leg, the fitted curve was first projected onto the sagittal plane (i.e., the xz-plane), and multi-scale curvature analysis was then performed in this plane. Similarly, for structural recognition from frontal or rear views, the curve was projected onto the coronal plane (i.e., the yz-plane).
As shown in
Figure 6, multiple window scales
were defined, each associated with a corresponding weight
. Larger windows capture the overall bending trend of the leg, whereas smaller windows emphasize local shape variations. A vector was constructed
where
(satisfying
) denoted a point in the sequence. Using
as the vertex, the preceding and following points within a symmetric neighborhood,
and
, were selected.
The included angle
between the two vectors is computed as:
Accordingly, the curvature measure at this scale is defined as:
A larger value indicates a more pronounced spatial bend at that point. By fusing results from multiple window scales, the method enhances sensitivity to joint regions while reducing the influence of noise. The final multi-scale fused curvature index is defined as:
2.4.3. Local Refinement of Key Point Localization
After the initial detection of curvature peaks along the leg centerline, a local refinement strategy was applied to further improve the accuracy and stability of joint localization. For each curvature peak point , a neighborhood around its z-coordinate was taken from the original leg point cloud to form a local sub-point cloud.
A local coordinate system was then established within this sub-point cloud, and a local centerline was refitted with higher vertical resolution (i.e., denser horizontal slicing), using the same procedure as for the global curve construction. On this local curve, curvature indices were recalculated with a smaller window length. The point with the maximum curvature on the local curve was identified, and its index was mapped back to the global centerline
as the refined bend point. The final joint position was denoted as
. Finally, three representative key points were selected from the centerline to form a skeletal point set, and vectors were constructed as:
where
denoted the bottom point (hoof region) defined as the lowest point on the curve,
;
denoted the accurately identified joint point; and
denoted the top point (thigh root), defined as the highest point on the curve,
. Based on these three key points, the retreating angle of the hind limb was computed to quantify the degree of curvature.
The retreating angle was defined as the included angle between the two vectors. For the forelimb in sagittal view, characterized the degree of elbow flexion; for the hindlimb in sagittal view, it corresponded to the curvature of the hock. In coronal plane of the forelimb and coronal plane of the hindlimb, reflects the degree of medial–lateral bending of the leg.
Considering that the joint region was likely to suffer from point cloud loss due to occlusion in practical data, this study employed multi-view point cloud fusion to enhance data completeness and thereby improve the stability and robustness of joint localization. With the seven-view acquisition and fusion, occlusion on the inner (medial) side of each leg was largely reduced in our data; for any remaining missing points, leg-wise segmentation, voxel downsampling, and the slice-wise centroid-based centerline extraction with smoothing further mitigate its impact. The final set of extracted key points formed the basis of the skeletal representation of the leg.
2.5. Posture Determination
In the automatic leg scoring system, ensuring that the animal was in a standard standing posture was a fundamental prerequisite for accurately capturing leg structure features. If the pig was in an unnatural or unstable posture, its leg geometry could be distorted by uneven weight-bearing, limb twisting, or occlusions, which can compromise scoring accuracy. Therefore, an automatic posture assessment scheme was proposed to filter out frames acquired under non-standard conditions.
2.5.1. Extraction of Body Skeleton Key Points
To enable automatic assessment of the overall standing posture of pigs, this study proposed four body skeleton key points shown in
Table 2. These are the anterior trunk upper point e, the posterior trunk upper point g, the mid back–abdomen point f, and the head point h. Together with the 12 limb endpoints, these key points formed a skeletal system for posture modeling, which was used to identify posture distortions, asymmetric limb support, and abnormal head positions.
These four points are defined in 3D space using statistical information from their corresponding local point cloud regions, as detailed in
Table 3.
By combining the spatial relationships and statistical features of the limb key points and body skeleton points, a fundamental skeletal structure for posture analysis was constructed (
Figure 7). This structure not only reflected the distribution of key anatomical regions when the pig was standing, but also provides a reliable basis for subsequent posture evaluation.
2.5.2. Posture Evaluation Rules
A standard standing posture was defined as a natural upright state in which the pig met the following conditions: the four limbs were symmetrically distributed and bore weight evenly with stable positions; the spine was approximately horizontal without excessive curvature or lateral deviation; and the head maintained a natural orientation without pronounced lowering, turning, or stretching. In this posture, the leg structure features were most representative and thus most suitable for evaluation. To achieve automatic screening of posture, four judgment criteria were designed, covering four-leg support symmetry, spinal straightness, head orientation, and head height. The specific rules for identifying non-standard postures are summarized in
Table 4, and examples of posture classification results are shown in
Figure 8.
When any of the above rules was triggered, the system labeled the current frame as a “non-standard standing posture” and skipped the corresponding leg structure scoring. This strategy serves as a quality control step that reduces posture-induced variability and improves the stability of geometric measurements for scoring.
2.6. Scoring Elements and Decision Logic in Sagittal and Coronal Planes
In designing the scoring elements and decision logic for sagittal and coronal views, this study drew extensively on authoritative standards and practical experience in breeding pig selection and phenotypic appraisal. Representative references included the
Gilt Evaluation Guide proposed by Iowa State University, the breeding pig selection manuals published by international breeding companies such as Hypor, and the
Technical Manual for Breeding Pig Phenotypic Appraisal issued by the Shanghai Animal Disease Prevention and Control Center. These documents constituted the main industry benchmarks at the time of the study. In addition, expert opinions from breeding specialists and body surface data collected on commercial farms were used to revise and optimize the thresholds, angle ranges, and decision criteria. The specific scoring items are illustrated in
Figure 9.
On this basis, we developed scoring rules for four quantitative traits: Forelimb-sagittal, Hindlimb-sagittal, Forelimb-coronal, and Hindlimb-coronal. The sagittal assessment uses joint angle indicators, whereas the coronal assessment uses indicators related to joint angles and symmetry. We adopt a “classify first, then score” strategy: these indicators first determine a discrete structural type, and then the deviation magnitude within that type is mapped to a 1–9 score (details are given in
Table 5,
Table 6 and
Table 7).
It is worth noting that, at the time of this study, no publicly available quantitative standard was available specifically for pig leg posture angles. In this work, classification intervals for different structural types (
Table 5 and
Table 6) were determined by jointly considering the pictorial guidelines of systems such as Iowa State, PIC, and Hypor, expert experience, manually annotated samples, and statistical analysis of angle distributions. These intervals therefore constituted a set of empirically validated operational quantitative standards.
This approach not only addressed longstanding issues of vague criteria and high inter-observer subjectivity in traditional evaluation, but also provided a rigorous quantitative foundation for implementing an automatic scoring system. The primary purpose of establishing these scoring rules was to build a baseline reference framework for a 3D point cloud-based automatic scoring system and, through empirical analysis, to verify its accuracy, stability, and practical value.
2.6.1. Sagittal Trait Analysis
Lateral view analysis was mainly based on the joint angles of the fore- and hindlimbs in the sagittal plane (the xz-plane). Using the localized key points on the lateral view, key angles of the fore- and hindlimbs in the sagittal (lateral) plane were calculated. These quantitative angles were then used to determine whether the joints were in a normal, excessively flexed, or overextended state, thereby reflecting the stability and coordination of leg structure.
For the forelimb, three points—shoulder joint, carpal (knee) joint, and hoof—were extracted to construct the foreleg angle. For the hindlimb, three points—hip (leg root), hock, and hoof—were used to compute the hock angle. The following decision rules, formulated on the basis of the aforementioned literature and expert opinion, were proposed as ‘Recommended Reference Criteria’ and served as the unified standard in this study.
According to angle ranges and the spatial arrangement of joints, leg structures in sagittal view were classified into the types listed in
Table 5.
2.6.2. Coronal Structural Analysis
Frontal- and rear-view structural analysis focused on symmetry in the coronal plane (the yz-plane), evaluating medial–lateral deviations of the left and right limbs. A core parameter, the Difference Ratio, was defined to quantify the degree of divergence between the upper and lower segments of the limb. The index was computed as:
where Top Difference (upper segment), Middle Difference (middle segment), and Bottom Difference (lower segment) were the horizontal (
y-axis) distance differences between the left and right forelimbs or hind limbs at the shoulder/hip level, knee/hock level, and hoof level, respectively.
The introduction of the Difference Ratio is intended to eliminate the influence of absolute spacing differences among animals of different body sizes and instead focus on whether the limb structure “narrows or opens” from top to bottom. When the Difference Ratio is close to 0, the distances between shoulders/hips and hooves are similar, indicating that the legs are approximately parallel and upright. A larger Difference Ratio suggests a pronounced non-parallel opening or closing trend. For example, a high Difference Ratio with a “wide top and narrow bottom” pattern typically corresponds to inward-deviated legs (toe-in), whereas a “narrow top and wide bottom” pattern indicates outward-deviated legs (toe-out).
By combining the Difference Ratio and the projected leg angle in the yz-plane, the system could automatically classify coronal-plane leg structures into the types listed in
Table 6. In particular, the Difference Ratio is mainly used to distinguish normal vs. inward-leaning vs. outward-splaying patterns, for which the projected angles can be similar, whereas the yz-plane angle is sufficient to identify X-type vs. O-type deviations.
2.6.3. Scoring Methodology
To achieve a systematic and continuous evaluation of swine leg structure, this study constructed a difference-based scoring model based on the structural classification from the previous section. The scoring system used a 1–9 point linear scale, which was consistent with commonly used standards such as PIC breeding for pigs and ICAR conformation scoring for dairy cattle. Additionally, a score of 5 represented the ideal or normal structure, while scores of 1 and 9 indicated severe deviations at both ends. This system facilitated the description of the gradual deviation from the ideal to the extremes and made it easier to conduct genetic analysis. Based on this, the degree of deviation from the ideal structure was quantified using linear interpolation within the corresponding scoring intervals, with scores continuously changing according to the degree of deviation. The specific scoring method is shown in
Table 7. Compared with nonlinear, purely categorical grading methods, the linear scoring approach not only reflected the relative quality of individual leg structure, but also better supported type-specific discrimination and its association with the underlying genetic architecture. The weights of each scoring item were set equally.
Scoring ranges on four indicators were developed using the biomechanically ideal structural state as the reference. For each indicator, a linear scoring function was defined over its predefined scoring range with the central score (midpoint of the nine-point scale) corresponding to the most desirable structural state. As the measured structural index deviated from this ideal, the score moved linearly toward either boundary of the assigned interval.
To provide a unified measure of deviation, a structural deviation loss function was defined as
where
denoted the structural score of the
-th indicator, and
represented the distance between the
-th structural score and the ideal structural state. The final composite score is:
where
denoted the weighting factor assigned to each scoring item. Given that each item score
lies in the nine-point scale (1–9) and the weights are equally set and sum to 1, the composite score
is bounded within [0, 9], where values closer to 9 indicate a more desirable structure and values closer to 0 indicate a larger deviation.
This expression normalizes the linear deviation loss so that the final output score remains within the nine-point scale. A composite score closer to 9 indicates a more desirable structure, whereas a score closer to 0 reflects a greater deviation from the normal structural state. The scoring mechanism shows high consistency and repeatability in capturing the symmetry, stability, and coordination of the biological structure.
3. Results
This study aimed to comprehensively evaluate the performance of a 3D point cloud-based automatic leg scoring system, verifying its performance from three aspects: structural classification accuracy, scoring rationality, and evaluation stability. A total of 315 valid 3D point cloud datasets were obtained and cleaned from a pig farm (
Figure 10 shows the on-site operation), covering 36 pigs. The number of datasets used for analysis was approximately balanced across individuals, with an average of about 9 frames per pig. These point cloud data were preprocessed and screened by the posture evaluator, and all retained frames were standard standing postures for subsequent leg segmentation and skeletal key point extraction. The joint angles of the fore- and hindlimbs in the sagittal plane and symmetry indices in the coronal plane were calculated. Based on these parameters, the structural type was determined, and a nine-point linear scoring model was used to quantify the structural deviation into numerical scores. We further validated the leg segmentation stage on 489 point cloud samples, achieving a 93.2% success rate in separating all four legs (manual inspection). The system processes each pig’s point cloud data in 1.6 to 3.0 s.
3.1. Classification Accuracy
To evaluate structural type classification, manually annotated labels were used as ground truth. Specifically, for each classification task, the structural type of the corresponding leg (or leg pair) was annotated on the fused 3D point cloud following the same type definitions used in this study. A prediction was considered correct if it matched the manual label. Classification accuracy was computed as the percentage of correctly classified samples for each task, and the F1-score was computed from the task-specific confusion matrix. The overall accuracy and F1-score were reported as the mean values across all classification tasks. The results showed that the system achieves high overall classification performance (
Table 8). The overall accuracy reached 93.7%, with an F1-score of 0.934. The proposed system achieved strong and stable classification performance on the dataset (overall Acc = 0.937; F1 = 0.934). Forelimb-related tasks consistently showed higher and more stable recognition, indicating that forelimb posture cues are relatively easier to capture and discriminate from the point clouds. In contrast, hindlimb-related tasks showed a modest performance drop, suggesting that view-dependent ambiguity and the higher geometric complexity of hindlimb structures remain major sources of residual errors. In practice, frame-to-frame variations in posture and body orientation may change the effective geometric representation of hindlimb features in the fused point clouds, thereby increasing ambiguity and contributing to occasional misclassifications. For qualitative assessment,
Figure 11 presents representative negative point cloud samples with poor leg conformation characteristics.
At the individual level, low-score samples (e.g., bent-leg patterns) were not uniformly distributed across pigs; instead, they were predominantly contributed by a relatively small subset of individuals, indicating that these adverse conformation traits tend to persist across multiple frames for the same pig. This pig-level concentration is consistent with the fact that leg conformation characteristics are largely individual-specific and therefore repeatedly expressed in multi-frame point clouds. By contrast, residual misclassifications typically manifest as item-specific recognition failures for an individual pig, while a portion of errors is also dispersed across different pigs, suggesting that the remaining errors are driven by both individual-level difficulty cases and sporadic frame-level ambiguities.
Overall, the system maintains high accuracy and balanced F1-scores across different view-based tasks, demonstrating the effectiveness of the proposed method for automatic recognition of swine leg structure.
3.2. Internal Consistency Verification of the Scoring Model
This section primarily examines the monotonic relationship between the automatic scoring results and the degree of structural deviation from the ideal posture, from the perspective of internal consistency. Since the scoring model is based on a linear (or approximately linear) mapping of the deviation from the ideal posture, theoretically, the larger the deviation (the more abnormal the structure), the lower the score should be. Conversely, samples closer to the ideal structure should receive higher scores. To verify whether the model implementation aligns with this expectation, this study calculates the correlation between the composite score and the deviation index, and compares samples grouped by different levels of deviation.
The single-item deviation is defined as the mean absolute deviation of each item’s score from the ideal value of 5 points. The angle deviation is computed as a weighted sum of the absolute deviations of all measured angles from their corresponding ideal values.
As shown by the correlation analysis in
Figure 12, the composite score was strongly negatively correlated with the single-item deviation, with a Pearson correlation coefficient of r = −0.993 (
p < 0.001). This indicates that the scoring system has a highly consistent internal logic and can reliably convert local structural deviations into a final composite evaluation. At the same time, the correlation between the composite score and the weighted angle deviation is r = −0.835 (
p < 0.001), further confirming the expected pattern that the score decreased significantly as posture deviation increased.
This study further conducted a grouped validation based on the weighted composite angle deviation to examine the logical consistency of the system’s scoring. According to the distribution of the composite deviation, the 315 samples were divided into three groups using the 33% and 67% quantiles (3.339 and 4.551, respectively): a low-deviation group (≤3.339; n = 104), a medium-deviation group (3.339–4.551; n = 107), and a high-deviation group (>4.551; n = 104). The results show a clear decreasing trend in score as deviation increases. The low-deviation group had an average deviation of 2.792 ± 0.414 and achieved the highest scores (7.663 ± 0.395); the medium-deviation group showed an average deviation of 3.988 ± 0.367, with scores decreasing to 7.113 ± 0.396; in the high-deviation group, the deviation further increased to 5.548 ± 0.924, and the scores dropped to 6.425 ± 0.539.
Between-group comparisons indicate that the mean score difference between the low- and high-deviation groups reached 1.238 points, and all pairwise differences were highly significant (p < 0.001). Specifically, the t-statistic for the comparison between the low- and medium-deviation groups was 10.105, with Cohen’s d = 1.391; for the low- versus high-deviation group comparison, the t-statistic was 18.913, with Cohen’s d = 2.623; and for the medium- versus high-deviation group comparison, the t-statistic was 10.560, with Cohen’s d = 1.460. All effect sizes reached the level of a large effect. These findings provide strong evidence for the logical consistency and discriminative power of the scoring system, indicating that the system assigns scores in a manner that appropriately reflects the degree of structural deviation.
3.3. Stability Assessment
To evaluate the consistency of automatic scores for the same animal across multiple frames, a stability analysis was performed on 315 scoring samples from 36 pigs. The intraclass correlation coefficient (ICC) was used as the core metric, treating each pig as a subject and its scores from different frames as repeated measurements, in order to quantify within-individual consistency.
The statistical results in
Figure 13 indicate that the system exhibits a high overall level of stability, with an ICC of 0.777 (95% CI: 0.684–0.860). Variance decomposition shows that between-individual differences account for 79.8% of the total variance, whereas within-individual variance is very small. This suggests that repeated scores for the same pig are highly consistent, and that most of the observed score variation reflects true differences among individuals, thereby ensuring the stability and reliability of the scoring results.
The coefficient of variation (CV) further supports this conclusion: the mean CV was 4.3%, and 72.2% of individuals had CVs below 5%, indicating stable scores for the majority of animals. In addition, the intraclass correlation coefficient (ICC) based on multi-frame repeated measurements across 36 pigs was 0.777 (95% CI: [0.684, 0.860]), reflecting good reliability of the system under multi-frame conditions. Taken together, these results show that the system provides highly consistent and reliable scores for the same pig under multi-frame conditions, effectively distinguishing differences between individuals while maintaining stable repeated measurements within individuals. This indicates that, provided a reasonable number of detection frames is guaranteed, the system’s scores can serve as an important reference index for evaluating leg structure and supporting breeding decisions in pigs.
4. Discussion
The preceding sections have presented the performance of the 3D point cloud-based automatic leg scoring system in terms of structural classification and scoring, including classification accuracy, F1-scores, correlation analyses, and consistency metrics. Overall, the system can reliably recognize swine leg structure and generate quantitative scores, and the results confirm the feasibility of the proposed method. However, numerical results alone are not sufficient to fully demonstrate the practical value and application prospects of the system. It is necessary to discuss the design logic of the method, the implications behind the results, the limitations of the experimental conditions, and potential directions for future improvement.
Accordingly, the discussion is organized into five parts: (1) the advantages of 3D point clouds in structural scoring compared with 2D image-based methods; (2) the rationale and practical significance of the scoring rules; (3) interpretation of the experimental results and their breeding implications; (4) key factors affecting classification accuracy and scoring consistency; and (5) limitations of this study and possible improvements. Through this analysis, we aim to further elucidate the rationality of the proposed system, its potential applications, and the shortcomings and room for enhancement beyond the reported results.
4.1. Advantages of 3D Point Clouds in Structural Scoring Compared with 2D Image Methods
Compared with 2D images, 3D point clouds can comprehensively represent the spatial morphology of individual animals and are not constrained by shooting angle or camera placement (
Figure 14). In practical on-farm acquisition, pigs do not maintain a fixed posture for long periods in the pen, and it is often difficult to obtain ideal sagittal-view and coronal-view RGB images at the desired angles. As a result, the bending angle computed for the same leg can vary under different shooting angles, which reduces scoring accuracy (
Figure 15).
In contrast, after principal component analysis (PCA)-based alignment, 3D point clouds can largely ensure angle consistency during leg structure analysis. This substantially reduces detection errors caused by variation in camera direction and provides a more reliable data foundation for automatic leg structure scoring.
4.2. Rationale and Practical Significance of the Scoring Rules
The scoring rules developed in this study are primarily intended to evaluate the performance of the 3D point cloud-based automatic scoring system. Compared with conventional manual assessment, the key feature of the proposed rules is the use of explicit quantitative indicators, which reduces subjectivity arising from human judgment. The core logic follows a “classify first, then score” strategy, meaning that the system produces two outputs for each trait: a discrete structural type and a continuous nine-point score. Specifically, geometric indicators are first used to assign leg structures to clearly defined categories (e.g., straight, over-bent, overextended, inward-leaning, outward-splaying, X-type, and O-type). The classification step determines the deviation mode and the corresponding scoring interval. Then, within the identified category, the deviation magnitude is mapped onto the appropriate segment of the nine-point scale by linear interpolation. A key advantage of this approach over a learning-based approach is that both the type label and the score remain directly interpretable in terms of physical trait deviation.
This two-stage “classify then score” strategy is consistent with how breeding experts assess leg structure in practice and aligns with the way structural diversity is described in production settings. However, the decision thresholds in this study were designed and optimized for the experimental population and setup, and therefore may not be directly applicable “out of the box” to other breeds, growth stages, or more diverse environments. Notably, the sagittal-plane (
Table 5) and coronal-plane (
Table 6) parameters are computed after pose normalization and are mainly angles or normalized measures, which supports transferability in principle; in practical deployment, applying the method to a new population would typically require only light threshold recalibration on a small reference subset.
4.3. Interpretation of Results and Breeding Implications
The experimental results show that the automatic scoring system achieves high accuracy and F1-scores in the classification tasks, indicating strong reliability in discriminating among different leg types. The scores are strongly and negatively correlated with the composite deviation indices (with high Pearson correlation and highly significant t-statistics), suggesting that the system’s scores are highly consistent with the actual degree of structural deviation. This supports the rationality of the rule design and the explanatory power of the system outputs.
In addition, the intraclass correlation coefficient (ICC) analysis indicates high consistency across different acquisition frames for the same animal, which demonstrates good stability and repeatability under repeated sampling. Taken together, these findings suggest that the system has the potential for long-term deployment in real production environments.
The system is also highly integrated: all components are based on geometric analysis and do not rely on deep learning or external training models. As a result, it features a clear structure, strong interpretability, and fast runtime. Efficiency analysis shows that the total processing time per individual is 1.6–3.0 s, with more than 80% of the computation concentrated in point cloud preprocessing, especially in noise removal. This indicates that the subsequent steps—leg segmentation, feature extraction, and scoring—are relatively lightweight. Overall, the system offers good real-time performance and engineering applicability while maintaining accuracy.
4.4. Key Factors Affecting Classification Accuracy and Scoring Consistency
Despite the generally satisfactory performance, several factors may still affect accuracy and consistency. First, ToF cameras are prone to generating noisy points when encountering reflections from hair or occlusions from pen structures, and measurements at different distances may suffer from error and distortion, which can degrade point cloud quality. Second, even under frames that pass the posture screening stage, small leg movements can still alter the local geometric features of the point cloud, causing individuals near decision boundaries to be misclassified. In practical experiments, pigs may be attracted by the presence and movement of operators, which can induce a mild orientation bias (body yaw) toward the operator; this may lead to an imbalance in left–right view presentation across frames and consequently affect the consistency of left–right limb discrimination.
Moreover, posture quality and animal calmness directly determine the availability of usable frames: under the posture screening criteria used in this study, approximately 70% of frames per pig were filtered out as non-standard, since standard postures substantially improve downstream stability. Larger pigs tended to remain calmer, and gentle operator guidance (e.g., using food to attract and soothe the animal) helped to increase the likelihood of obtaining stable, standard-posture frames. These factors limit, to some extent, the robustness of the system in complex on-farm environments and highlight the need for further optimization of both hardware configuration and preprocessing algorithms.
4.5. Limitations and Future Directions
This study has several limitations. The scoring rules were mainly derived from expert knowledge and existing manuals. Although they were revised and optimized, their applicability to more diverse farming scenarios may still be limited. Moreover, the current dataset provides limited coverage for some rare non-conforming patterns, leading to an imbalanced distribution for certain structural types; therefore, the statistical stability and generalizability for minority categories may be constrained even when the overall accuracy and F1-scores are high. Furthermore, the current workflow relies on posture screening as a quality control step, which improves measurement stability but may limit usability when pigs exhibit non-standard and restless postures.
Future work can be improved in several directions. One direction is to incorporate machine learning and large-sample statistical methods to support adaptive updating of the scoring rules and parameter settings. Another direction is to use multi-source data fusion—such as integrating body measurements and kinematic data—to further enhance the system’s generalization ability and practical value. In addition, end-to-end point cloud segmentation networks have shown strong performance in many applications by learning data-driven representations. However, such approaches often require substantial annotation and training compute. The proposed pipeline follows a geometry-constrained and modular design, offering improved interpretability and lower computational overhead. A systematic comparison with representative end-to-end baselines will be explored in future work to quantify the trade-offs among accuracy, robustness, and cost.