Non-contact on-line detection method for live pig body size and weight based on 3D machine vision

By optimizing 3D point cloud data processing and posture compensation, the problem of unstable point cloud data in pig body size and weight detection was solved, achieving high-precision, real-time weight monitoring and improving the accuracy and stability of pig weight prediction.

CN122367972APending Publication Date: 2026-07-10INSTITUTE OF ANIMAL SCIENCES OF CHINESE ACADEMY OF AGRICULTURAL SCIENCES
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
INSTITUTE OF ANIMAL SCIENCES OF CHINESE ACADEMY OF AGRICULTURAL SCIENCES
Filing Date
2026-04-14
Publication Date
2026-07-10

AI Technical Summary

Technical Problem

Existing 3D machine vision-based technologies for detecting pig body size and weight suffer from unstable point cloud data quality due to factors such as changes in lighting, reflection from hair surfaces, individual occlusion, group overlap, and pig movement. This leads to decreased accuracy in body size extraction and makes it difficult to achieve continuous and real-time reliable weight prediction.

Method used

By collecting 3D point cloud data, RGB image data, and posture change data of pigs, time synchronization and spatial coordinate registration are performed, the point cloud perception reliability index is calculated, multi-frame fusion, surface completion and outlier removal strategies are implemented, a standard posture point cloud model is constructed, and a dynamic weight prediction model is established by combining posture compensation optimization, and the stability of weight prediction is evaluated.

Benefits of technology

It significantly improves the accuracy and stability of pig body size measurement, realizes online, real-time and reliable weight monitoring, eliminates the influence of posture differences and movement interference on measurement results, and improves the accuracy and adaptability of weight prediction.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122367972A_ABST
    Figure CN122367972A_ABST
Patent Text Reader

Abstract

This invention provides a non-contact online detection method for pig body size and weight based on 3D machine vision, belonging to the field of machine vision technology. This invention collects 3D point cloud data, RGB image data, and posture change data of pigs; constructs a point cloud perception reliability index to evaluate data quality and performs adaptive optimization when requirements are not met; further, it obtains a standard posture point cloud model through key point detection, posture alignment, surface reconstruction, and non-rigid correction, and calculates body size parameters such as body length, body height, and chest circumference; performs posture evaluation and compensation based on the posture standardization deviation index; constructs a dynamic weight prediction model to calculate weight, and verifies and corrects the results online through a weight prediction stability judgment mechanism. This method achieves high-precision, non-contact, real-time detection of pig body size and weight, improving detection accuracy and system stability.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of machine vision technology, specifically to a non-contact online detection method for pig body size and weight based on 3D machine vision. Background Technology

[0002] With the development of large-scale and intelligent farming models, pig production management places higher demands on the accurate acquisition of individual body dimensions and weight. Weight, as a core indicator for measuring growth status, feed conversion efficiency, and health, directly relates to farming decisions and economic benefits. Traditional weighing methods mainly rely on manual herding and contact weighing equipment, which are not only labor-intensive and inefficient but also prone to causing stress in pigs, affecting their normal growth and welfare. Furthermore, in high-density farming environments, frequent weighing operations make continuous and real-time monitoring difficult.

[0003] In recent years, non-contact measurement technology based on 3D machine vision has been increasingly applied to the field of pig body size and weight estimation. By acquiring point cloud data and extracting geometric parameters such as body length, height, and chest circumference, a mapping relationship between body size and weight can be established, enabling indirect weight prediction. However, in actual farming scenarios, due to factors such as changes in lighting, reflection from hair surfaces, individual occlusion, group overlap, and pig movement, the collected point cloud data often suffers from uneven density, structural gaps, and noise interference, leading to decreased accuracy in body size extraction and consequently affecting the reliability of weight prediction results.

[0004] Furthermore, pigs exhibit a wide range of postures in their natural state, including non-standard postures such as head-down, bending, tilting, or walking. These factors further introduce geometric distortions, leading to systematic errors in point cloud-based body size calculations. Meanwhile, existing methods often focus on single-frame data processing or static modeling, lacking full utilization of time-series information, making it difficult to effectively assess and adjust the stability of data and the reliability of the model during dynamic changes. Summary of the Invention

[0005] The purpose of this invention is to provide a non-contact online detection method for pig body size and weight based on 3D machine vision, so as to solve the problems mentioned in the background art.

[0006] To achieve the above objectives, the present invention provides the following technical solution: A non-contact online detection method for pig body size and weight based on 3D machine vision, the specific steps of which include: Step 1: Collect 3D point cloud data, RGB image data, and posture change data of pigs, and perform time synchronization and spatial coordinate registration processing; and obtain point cloud density parameters, occlusion ratio parameters, motion blur parameters, reflection dispersion parameters, and individual overlap rate parameters. Step 2: Calculate the point cloud perception credibility index and compare it with the point cloud credibility threshold to determine whether the point cloud quality is qualified. If qualified, generate a standardized credible point cloud dataset; if not qualified, provide an adaptive optimization strategy for point cloud quality. Step 3: Perform keypoint detection and 3D coordinate mapping on the standardized reliable point cloud dataset to obtain the keypoint coordinate set and the normalized keypoint coordinate set; then perform keypoint topology connection and attitude feature extraction, and perform principal axis direction estimation and rigid body transformation on the point cloud to obtain the attitude-aligned point cloud data; then perform surface reconstruction and non-rigid correction processing to obtain the standard attitude point cloud model; based on the standard attitude point cloud model, calculate the body size parameters to obtain the standard body length parameter, standard body height parameter, and standard chest circumference parameter. Step 4: Calculate the posture standardization deviation index and compare it with the posture deviation threshold to determine whether the pig posture is qualified. If it is qualified, generate a set of posture standardization body size parameters. If it is not qualified, give a posture adaptive compensation optimization strategy. Step 5: Establish an initial dynamic weight prediction model; then perform feature vector extraction and model iteration optimization to obtain the optimized dynamic weight prediction model, and perform weight prediction calculation to obtain the current weight prediction value; Step 6: Calculate the current weight prediction stability index and compare it with the weight stability threshold to determine whether the current weight prediction result is qualified. If qualified, generate the final weight result dataset; if not qualified, provide an adaptive correction strategy for weight prediction.

[0007] Further, step one includes: S11. Real-time monitoring of the pig farming passage is carried out. A binocular structured light 3D camera is installed above the passage to collect 3D point cloud data and RGB image data of the pigs. An inertial measurement unit (IMU) is deployed at the camera mounting bracket to collect attitude change data. S12. Based on continuous acquisition, time-series frame data is generated, and time synchronization and spatial coordinate registration are performed on 3D point cloud data, RGB image data and attitude change data to construct the original multi-source dataset. S13. Based on the three-dimensional point cloud data in the original multi-source dataset, the point cloud space is discretized using voxel mesh generation technology, and the number of points in each voxel unit is statistically analyzed to calculate the point cloud distribution density per unit volume and obtain the point cloud density parameters. S14. Based on the 3D point cloud data and RGB image data in the original multi-source dataset, the point cloud surface texture mapping and neighborhood gray-level consistency analysis method is used to map the RGB image data to the corresponding point cloud surface and obtain the gray-level distribution information of the point cloud surface; the local variance of the neighborhood gray-level value of each point is calculated, and the global gray-level variance is normalized to obtain the reflection dispersion parameter. S15. Based on the 3D point cloud data in the original multi-source dataset, the point cloud projection and region integrity analysis method is used to map the point cloud data to a standard reference plane. By detecting the proportion of the missing region area to the overall region area, the occlusion ratio parameter is obtained. S16. Based on time series frame data, the iterative nearest point registration algorithm is used to spatially register the point clouds of adjacent frames. By calculating the displacement error and deformation degree of the point clouds between frames, motion blur parameters are obtained. S17. Based on the 3D point cloud data in the original multi-source dataset, the density space clustering algorithm is used to segment the point cloud into individuals, and the individual overlap rate parameter is obtained by calculating the proportion of spatial overlap between different individual point clouds.

[0008] Furthermore, step two includes: S21. After dimensionless processing of the obtained point cloud density parameters, surface reflection dispersion parameters, occlusion ratio parameters, motion blur parameters, and individual overlap rate parameters, a point cloud perception reliability index is constructed.

[0009] Furthermore, step two also includes: S22. By setting a preset point cloud credibility threshold, and comparing and analyzing the point cloud perception credibility index with the point cloud credibility threshold, the first evaluation result is obtained, including: When the point cloud perception confidence index is greater than or equal to the point cloud confidence threshold, it indicates that the point cloud quality is qualified, and a standardized confidence point cloud dataset is generated for continuous monitoring. When the point cloud perception confidence index is less than the point cloud confidence threshold, it indicates that the point cloud quality is unqualified, with risks of missing points, reflection interference, severe occlusion, motion blur, or multiple target overlap, leading to incomplete individual contours, structural distortion, or inaccurate segmentation. This triggers the first warning instruction and generates the first strategy: perform multi-frame fusion processing on the original point cloud data, superimposing point clouds from no less than 3 frames and no more than 7 frames in a continuous time series to improve the overall point cloud density, increasing the point cloud density parameter by 20% to 50%; simultaneously, use surface fitting to complete missing regions, reducing the occlusion ratio parameter by 15% to 40%; perform reflection intensity normalization and outlier removal processing on discrete reflection regions, reducing the reflection dispersion parameter by 10% to 30%; perform rigid body alignment of the point cloud based on inter-frame registration to suppress motion offset, reducing the motion blur parameter by 10% to 25%; and separate overlapping point clouds using spatial clustering methods, reducing the overlap parameter by 20% to 50%. After adjustment, recalculate until the point cloud perception confidence index is greater than or equal to the point cloud confidence threshold.

[0010] Furthermore, step three includes: S31. Based on a standardized and reliable point cloud dataset, an improved YOLO-pose key point detection algorithm is used to detect key parts of the pig's head, back, and buttocks. The key point coordinate set is obtained by combining depth information with 3D coordinate mapping. Based on the spatial rotation, translation, and non-rigid correction transformation parameters performed on the point cloud data during the pose normalization process, the key point coordinate set is synchronously transformed to obtain the normalized key point coordinate set. S32. By acquiring the set of key point coordinates and 3D point cloud data, the key points are transformed from the image coordinate system to the point cloud spatial coordinate system using the 3D coordinate mapping method to construct a set of key points in a unified space; then, the topology connection method is used to connect the key points of the pig's head, back and buttocks to extract the overall posture features of the pig. S33. Using 3D point cloud data and combining it with the overall posture characteristics of the pig, the principal axis direction estimation method is used to calculate the principal direction of the point cloud. Rigid body transformation is then used to rotate and translate the point cloud spatially, aligning the pig's principal axis direction with the preset standard coordinate axis, thus completing the initial posture unification processing of the point cloud. Using the point cloud data after rigid body registration as input, a surface reconstruction method based on moving least squares is used to perform continuous surface fitting on the discrete point cloud, constructing a continuous surface model of the pig's body. Parametric surface modeling technology is then combined to structurally express the body surface geometry. Furthermore, curve fitting and local deformation correction methods are used to non-rigidly adjust curved or tilted areas, making the pig's body shape tend towards a standard unfolded state, thus obtaining a standard posture point cloud model. S34. Based on the standard posture point cloud model, the curve length between the head key point and the buttock key point is calculated using the skeleton path fitting method to obtain the standard body length parameter; the vertical projection analysis method is used to calculate the vertical distance from the highest point of the pig's back to the ground reference plane to obtain the standard body height parameter; the cross-section slicing and contour fitting method is used to reconstruct the cross-section of the pig's chest region, calculate the cross-sectional perimeter, and obtain the standard chest circumference parameter.

[0011] Furthermore, step four includes: S41. Based on the set of key point coordinates and the normalized set of key point coordinates, the Euclidean distance calculation method is used to calculate the spatial difference of the corresponding key points and obtain the key point offset. S42. Based on the standard posture point cloud model, the skeleton curvature calculation method is used to perform curvature fitting and bending degree analysis on the back skeleton curve of pigs to obtain the spinal curvature parameters. S43. Based on three-dimensional point cloud data and combined with the overall posture characteristics of pigs, the principal axis direction estimation method is used to calculate the principal direction of the point cloud, and further calculate the spatial angle between the principal direction of the point cloud and the preset standard coordinate axis to obtain the body tilt angle. S44. Based on time-series frame data, Kalman filtering combined with a multi-target tracking algorithm is used to perform cross-frame association of individual pigs. By calculating the change in the position of the target centroid between consecutive frames and performing time-series smoothing, trajectory offset parameters are obtained.

[0012] Furthermore, step four also includes: S45. After dimensionless processing of the obtained key point offset, spinal curvature parameter, body tilt angle and trajectory offset parameter, calculate the posture standardization deviation index. S46. By setting a preset attitude deviation threshold and comparing the attitude standardized deviation index with the attitude deviation threshold, the second evaluation result is obtained, including: When the posture standardization deviation index is less than or equal to the posture deviation threshold, it indicates that the pig's posture meets the standardization requirements, the posture is deemed qualified, a set of posture standardization body size parameters is generated, and continuous monitoring is performed. When the posture standardization deviation index exceeds the posture deviation threshold, it indicates that the pig's posture does not meet the standardization requirements and is deemed unqualified. The pig exhibits non-standard postures such as bending, tilting, head-down, walking, or shaking, which may lead to structural deviations in the calculation of body length, body height, and chest circumference. This triggers a second warning instruction and generates a second strategy: initiate posture compensation on the current point cloud data, use a non-rigid transformation method to perform local deformation correction on the curved area, reducing the spinal curvature by 20%–40%; simultaneously, select three or more consecutive stable frames in the time series to replace the current abnormal frame, reducing the trajectory offset parameter by 15%–35%; perform spatial repositioning correction on the abnormal keypoint offset area, reducing the keypoint offset by 10%–30%; and reduce the body tilt angle by 10%–25% by reestimating the principal axis to keep it within the standard range. After adjustment, recalculate until the posture standardization deviation index is ≤ the posture deviation threshold.

[0013] Furthermore, step five includes: S51. By extracting the standard body length, standard body height, and standard chest circumference parameters from the standardized body size parameter set, along with the corresponding historical sequence data, the data undergoes time alignment, outlier removal, and dimensionless normalization to form a model input dataset of uniform scale. Temporal features are then extracted to obtain the rates of change in body length, body height, and chest circumference. Combined with historical predicted weight, the coupling relationship between changes in pig body shape and weight evolution is analyzed. A multivariate time series modeling method is then used to construct the initial structure of the dynamic weight prediction model. The rates of change in body length, body height, and chest circumference, along with historical predicted weight, are used as input variables to train and test the model, resulting in the initial dynamic weight prediction model. S52. During model training, the output of the intermediate layer of the dynamic weight prediction model is extracted as a feature vector to characterize the deep mapping relationship between body size changes and weight gain. Based on the feature vector, the model is iteratively trained and the parameters are optimized to obtain the optimized dynamic weight prediction model. Using the optimized dynamic weight prediction model, the body size change data at the current moment is input for calculation to obtain the current weight prediction value.

[0014] Furthermore, step six includes: S61. Using the current predicted weight value and its corresponding historical predicted sequence data, the historical predicted weight is statistically analyzed using the time window moving average method to obtain the historical average weight; at the same time, the changes in body length, body height, and chest circumference are weighted and fused to construct a comprehensive parameter of body size change rate; and the actual weighing data obtained from the periodic sampling in the breeding management system is matched with time and associated with individuals to obtain the actual weight of the sampling. S62. After dimensionless processing of each parameter, the current predicted weight, historical average weight, body size change rate, and sampled actual weight, the weight prediction stability index is calculated.

[0015] Furthermore, step six also includes: S63. By setting a preset weight stability threshold and comparing the predicted weight stability index with the weight stability threshold, the third evaluation results are obtained, including: When the weight prediction stability index is less than or equal to the weight stability threshold, it indicates that the current weight prediction result is stable and reliable. The weight prediction result is deemed qualified, and the final weight result dataset is generated and stored for growth status assessment and breeding decision analysis. When the weight prediction stability index exceeds the weight stability threshold, it indicates that the current weight prediction result is unstable and is deemed unqualified, posing a risk of inaccurate weight assessment and misjudgment of growth status. This triggers a third early warning instruction and generates a third strategy: An online correction mechanism is initiated for the dynamic weight prediction model. This involves incorporating the actual weight of the current sample to perform error feedback correction on the model, reducing the deviation between the current weight prediction value and the actual sample weight by 15%–40%. Simultaneously, the mapping relationship between body size parameters and weight is updated, allowing the influence weight of the comprehensive parameter of body size change rate on weight prediction to adaptively adjust, improving the model's adaptability to the current growth stage. Furthermore, the sampling frequency of time series data is increased by 30%–100% on the original sampling basis to enhance the model's response to short-term fluctuations. After adjustment, weight prediction is re-performed and the weight prediction stability index is recalculated until the weight prediction stability index is ≤ the weight stability threshold.

[0016] Compared with the prior art, the beneficial effects of the present invention are: This invention acquires real-time 3D point cloud data, RGB images, and posture change data of pigs by installing a binocular structured light 3D camera and IMU sensor above the pig breeding channel. Parameters such as point cloud density, occlusion ratio, motion blur, reflection dispersion, and individual overlap rate are obtained through methods such as voxel mesh generation, point cloud surface texture mapping, projection integrity analysis, and inter-frame registration. Based on the point cloud perception reliability index, evaluation is performed, and combined with multi-frame fusion, surface completion, and outlier removal strategies, significantly improving point cloud quality and individual contour integrity, thus achieving high-precision, non-contact acquisition of pig body shape data.

[0017] This invention also constructs a standard posture point cloud model by performing key point detection and three-dimensional coordinate mapping on standardized reliable point clouds, combined with methods such as principal axis direction estimation, rigid body registration, surface reconstruction, and non-rigid correction; based on skeleton path, vertical projection, and cross-section reconstruction technology, it accurately extracts the standard body length, body height, and chest circumference parameters of pigs; at the same time, it effectively eliminates structural measurement errors caused by body bending, tilting, head lowering, or movement by evaluating the posture deviation index and implementing posture compensation optimization strategies, thereby improving the stability and reliability of body size calculation.

[0018] This invention also combines posture-standardized body size parameters and historical weight sequences, and uses a multivariate time series modeling method to construct a dynamic weight prediction model. Through iterative optimization of intermediate feature vectors, a deep mapping between body size changes and weight gain is achieved. When the weight prediction stability index exceeds a threshold, an online correction strategy is activated, introducing sampled actual weights for error feedback correction. At the same time, the mapping weights between body size and weight are adaptively adjusted and the sampling density is increased, thereby significantly improving the accuracy, stability, and adaptability to growth stages of weight prediction, and realizing online, real-time, and reliable pig weight monitoring. Attached Figure Description

[0019] Figure 1 This is a schematic diagram of the overall method flow of the present invention. Detailed Implementation

[0020] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.

[0021] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.

[0022] Example 1 Please see Figure 1This invention provides a technical solution: a non-contact online detection method for pig body size and weight based on 3D machine vision, the specific steps of which include: Step 1: Collect 3D point cloud data, RGB image data, and posture change data of pigs, and perform time synchronization and spatial coordinate registration processing; and obtain point cloud density parameters, occlusion ratio parameters, motion blur parameters, reflection dispersion parameters, and individual overlap rate parameters. Step 2: Calculate the point cloud perception credibility index and compare it with the point cloud credibility threshold to determine whether the point cloud quality is qualified. If qualified, generate a standardized credible point cloud dataset; if not qualified, provide an adaptive optimization strategy for point cloud quality. Step 3: Perform keypoint detection and 3D coordinate mapping on the standardized reliable point cloud dataset to obtain the keypoint coordinate set and the normalized keypoint coordinate set; then perform keypoint topology connection and attitude feature extraction, and perform principal axis direction estimation and rigid body transformation on the point cloud to obtain the attitude-aligned point cloud data; then perform surface reconstruction and non-rigid correction processing to obtain the standard attitude point cloud model; based on the standard attitude point cloud model, calculate the body size parameters to obtain the standard body length parameter, standard body height parameter, and standard chest circumference parameter. Step 4: Calculate the posture standardization deviation index and compare it with the posture deviation threshold to determine whether the pig posture is qualified. If it is qualified, generate a set of posture standardization body size parameters. If it is not qualified, give a posture adaptive compensation optimization strategy. Step 5: Establish an initial dynamic weight prediction model; then perform feature vector extraction and model iteration optimization to obtain the optimized dynamic weight prediction model, and perform weight prediction calculation to obtain the current weight prediction value; Step 6: Calculate the current weight prediction stability index and compare it with the weight stability threshold to determine whether the current weight prediction result is qualified. If qualified, generate the final weight result dataset; if not qualified, provide an adaptive correction strategy for weight prediction.

[0023] In this embodiment, the present invention constructs a non-contact online detection method for pig body size and weight based on multi-source data fusion. By introducing a triple closed-loop control mechanism of point cloud quality assessment, posture standardization correction and weight prediction stability judgment, the invention achieves adaptive optimization of the entire process from data acquisition, quality screening, posture correction to weight prediction, which significantly improves the accuracy, stability and robustness of pig body size measurement and weight prediction.

[0024] Example 2 Please see Figure 1 In this embodiment, as explained in Embodiment 1, specifically, step one includes: S11. Real-time monitoring of the pig farming passage is carried out. A binocular structured light 3D camera is installed above the passage to collect 3D point cloud data and RGB image data of the pigs. An inertial measurement unit (IMU) is deployed at the camera mounting bracket to collect attitude change data. S12. Based on continuous acquisition, time-series frame data is generated, and time synchronization and spatial coordinate registration are performed on 3D point cloud data, RGB image data and attitude change data to construct the original multi-source dataset. S13. Based on the three-dimensional point cloud data in the original multi-source dataset, the point cloud space is discretized using voxel mesh generation technology, and the number of points in each voxel unit is statistically analyzed. The point cloud distribution density per unit volume is calculated, and the point cloud density parameter is obtained, denoted as Dp. S14. Based on the 3D point cloud data and RGB image data in the original multi-source dataset, the point cloud surface texture mapping and neighborhood gray-level consistency analysis method is used to map the RGB image data to the corresponding point cloud surface and obtain the gray-level distribution information of the point cloud surface; the local variance of the neighborhood gray-level value of each point is calculated, and the global gray-level variance is normalized to obtain the reflection dispersion parameter, denoted as Rs. S15. Based on the 3D point cloud data in the original multi-source dataset, the point cloud projection and region integrity analysis method is used to map the point cloud data to the standard reference plane. By detecting the proportion of the missing region area to the overall region area, the occlusion ratio parameter is obtained and denoted as Oc. S16. Based on time series frame data, the iterative nearest point registration algorithm is used to spatially register the point clouds of adjacent frames. By calculating the displacement error and deformation degree of the point clouds between frames, the motion blur parameter is obtained and denoted as Mb. S17. Based on the 3D point cloud data in the original multi-source dataset, the density space clustering algorithm is used to segment the point cloud into individuals, and the individual overlap rate parameter is obtained by calculating the proportion of spatial overlap between different individual point clouds, denoted as Ov.

[0025] In this embodiment, by fusing three-dimensional point cloud data, RGB image data, and posture change data, and combining multi-dimensional parameters such as point cloud density, reflection dispersion, occlusion ratio, motion blur, and individual overlap rate, a multi-dimensional quantitative characterization of the data quality of individual pigs is achieved. This improves the comprehensiveness and reliability of data collection in complex farming environments and provides a high-quality input foundation for subsequent processing.

[0026] Example 3 Please see Figure 1 In the explanation of Example 2, this embodiment specifically includes the following steps: S21. After obtaining the point cloud density parameter Dp, surface reflection dispersion parameter Rs, occlusion ratio parameter Oc, motion blur parameter Mb, and individual overlap rate parameter Ov, a point cloud perception reliability index, denoted as PCI, is constructed after dimensionless processing: ; In the formula, w1, w2, w3, w4 and w5 represent weighting coefficients.

[0027] This factor, representing the influence of point cloud density, carries a high weight. Point cloud density directly determines the completeness of the 3D structural representation and is a core factor affecting the accuracy of target contour reconstruction. Insufficient density can lead to structural defects and errors in volumetric calculation; therefore, it is given a high weight to reflect its dominant role. : Characterizes the influence of reflection dispersion, accounting for medium weight. Reflection dispersion reflects the gray-scale consistency of the point cloud surface and the measurement stability. Excessive dispersion is usually caused by reflection or material inhomogeneity, which will affect the accuracy of the point cloud. Therefore, it is given medium weight as one of the important influencing factors. : Characterizes the impact of the occlusion ratio, with medium weight. The occlusion ratio reflects the integrity of the point cloud. Occlusion areas will cause local information loss and affect the overall structure judgment, which has a direct impact on volume scale extraction. Therefore, it is given medium weight. : Characterizes the impact of motion blur, with a medium to low weight. Motion blur comes from target movement or acquisition delay, which can lead to point cloud registration errors, but its impact can be partially compensated by multi-frame fusion, so it is given an auxiliary weight. The influence of individual overlap rate is represented by a medium to low weight. Individual overlap rate reflects the degree of multi-target interference. Although it will affect individual segmentation, it can be mitigated to some extent under an effective segmentation algorithm. Therefore, it is given an auxiliary weight. Through the above weighted fusion, the Point Cloud Perception Trust Index (PCI) can comprehensively reflect the integrity, stability, and divisibility of point clouds. The higher the PCI value, the better the point cloud quality and the higher the data trustworthiness.

[0028] In this embodiment, by constructing a point cloud perception credibility index, multiple factors affecting point cloud quality are uniformly quantified and integrated to achieve a comprehensive evaluation of point cloud data quality, avoiding the one-sidedness caused by a single indicator, thereby improving the accuracy and scientific nature of point cloud screening.

[0029] Example 4 Please see Figure 1 In the explanation of Embodiment 3, specifically, step two further includes: S22. Using a preset point cloud credibility threshold, denoted as Pth, the point cloud perception credibility index (PCI) is compared and analyzed with the point cloud credibility threshold Pth to obtain the first evaluation result, including: When the Point Cloud Perception Trust Index (PCI) is greater than or equal to the Point Cloud Trust Thres (Pth), it indicates that the point cloud quality is qualified, and a standardized trustworthy point cloud dataset is generated for continuous monitoring. When the Point Cloud Perception Credibility Index (PCI) is less than the Point Cloud Credibility Threshold (Pth), it indicates that the point cloud quality is unqualified, with risks of missing points, reflection interference, severe occlusion, motion blur, or multiple target overlap, leading to incomplete individual contours, structural distortion, or inaccurate segmentation. This triggers the first warning instruction and generates the first strategy: perform multi-frame fusion processing on the original point cloud data, superimposing point clouds from no less than 3 frames and no more than 7 frames within a continuous time series to improve the overall point cloud density, increasing the point cloud density parameter by 20% to 50%; simultaneously, using curved surfaces to address missing regions... The occlusion ratio parameter is reduced by 15%–40% by using surface fitting to complete the occlusion. Reflection intensity normalization and outlier removal are performed on the discrete reflection regions to reduce the reflection dispersion parameter by 10%–30%. Rigid body alignment of the point cloud is performed based on inter-frame registration to suppress motion offset, reducing the motion blur parameter by 10%–25%. Individual points in the overlapping point cloud are separated by spatial clustering to reduce the overlap parameter by 20%–50%. After adjustment, the calculation is repeated until the point cloud perception confidence index PCI is greater than or equal to the point cloud confidence threshold Pth.

[0030] Method for obtaining the point cloud credibility threshold Pth: The goal of the point cloud credibility threshold Pth calibration process is to determine a critical point cloud perception credibility index value that can effectively distinguish between "point cloud quality acceptable state" and "point cloud quality unacceptable state". First, a 3D point cloud quality standard data database for pigs is constructed. This database is formed by continuously collecting point cloud data in actual breeding channel environments, with a sample size of no less than 600 sets, covering various situations such as high-quality point clouds, slightly defective point clouds, and severely defective point clouds. Each sample in the database includes point cloud density parameters, reflection dispersion parameters, occlusion ratio parameters, motion blur parameters, and individual overlap rate parameters.

[0031] Meanwhile, three or more technicians with experience in machine vision and intelligent aquaculture, combined with the point cloud integrity assessment results, individual segmentation accuracy, and body size calculation errors, labeled each group of samples with a "gold standard" and classified them as "point cloud quality qualified" or "point cloud quality unqualified". Subsequently, a point cloud perception reliability index was uniformly calculated for all samples in the database to obtain the corresponding quantitative index value.

[0032] Next, statistical analysis was performed on the index distribution of the two types of samples, and probability density function curves were plotted. These curves typically exhibit a bimodal distribution, with the overall index for qualified samples being higher and the overall index for unqualified samples being lower. Based on this, ROC curves were constructed to evaluate classification performance, and the point with the highest Youden index was selected as the optimal segmentation point to achieve the best recognition accuracy. Simultaneously, engineering experience was incorporated; for example, when the index falls below a certain value, there are significant gaps, occlusions, or overlaps in the point cloud, leading to inaccurate shape extraction, thus requiring engineering corrections.

[0033] Based on statistical analysis and engineering experience, the optimal point cloud confidence threshold Pth is determined to be 0.62. When the point cloud perception confidence index is not lower than this threshold, it indicates that the point cloud quality meets the analysis requirements; when it is lower than this threshold, the point cloud quality is deemed unqualified.

[0034] In this embodiment, by setting a point cloud credibility threshold and introducing a point cloud quality adaptive optimization strategy, multi-frame fusion, missing data completion, reflection correction and overlap separation are automatically performed when the point cloud quality is substandard. This effectively improves the integrity and clarity of the point cloud, reduces the impact of data defects on subsequent volumetric calculations, and enhances the system's stable operation capability in complex scenarios.

[0035] Example 5 Please see Figure 1 In the explanation of Embodiment 4, specifically, step three includes: S31. Based on a standardized and reliable point cloud dataset, an improved YOLO-pose key point detection algorithm is used to detect key parts of the pig's head, back, and buttocks. Combined with depth information, three-dimensional coordinate mapping is performed to obtain a set of key point coordinates, denoted as K. Based on the spatial rotation, translation, and non-rigid correction transformation parameters performed on the point cloud data during pose normalization, a synchronous spatial transformation is performed on the key point coordinate set K to obtain a normalized set of key point coordinates, denoted as Kg. S32. Using the acquired key point coordinate set K and 3D point cloud data, the key points are transformed from the image coordinate system to the point cloud spatial coordinate system using the 3D coordinate mapping method to construct a key point set in a unified space; then, the topology connection method is used to connect the key points of the pig's head, back, and buttocks to extract the overall posture features of the pig. S33. Using 3D point cloud data and combining it with the overall posture characteristics of the pig, the principal axis direction estimation method is used to calculate the principal direction of the point cloud. Rigid body transformation is then used to rotate and translate the point cloud spatially, aligning the pig's principal axis direction with the preset standard coordinate axis, thus completing the initial posture unification processing of the point cloud. Using the point cloud data after rigid body registration as input, a surface reconstruction method based on moving least squares is used to perform continuous surface fitting on the discrete point cloud, constructing a continuous surface model of the pig's body. Parametric surface modeling technology is then combined to structurally express the body surface geometry. Furthermore, curve fitting and local deformation correction methods are used to non-rigidly adjust curved or tilted areas, making the pig's body shape tend towards a standard unfolded state, thus obtaining a standard posture point cloud model. S34. Based on the standard posture point cloud model, the curve length between the head key point and the buttock key point is calculated using the skeleton path fitting method to obtain the standard body length parameter, denoted as Ls; the vertical projection analysis method is used to calculate the vertical distance from the highest point of the pig's back to the ground reference plane to obtain the standard body height parameter, denoted as Hs; the cross-section slicing and contour fitting method is used to reconstruct the cross-section of the pig's chest region, calculate the cross-sectional perimeter, and obtain the standard chest circumference parameter, denoted as Cs.

[0036] In this embodiment, a standard posture point cloud model is constructed through key point detection, 3D mapping, principal axis alignment, surface reconstruction and non-rigid correction. Based on this model, body length, body height and chest circumference parameters are accurately extracted, effectively eliminating the influence of posture differences on measurement results and improving the accuracy and consistency of body size parameter calculation.

[0037] Example 6 Please see Figure 1 In the explanation of Example 5, specifically, step four includes: S41. Based on the key point coordinate set K and the normalized key point coordinate set Kg, the Euclidean distance calculation method is used to calculate the spatial difference of the corresponding key points and obtain the key point offset, denoted as ΔK. S42. Based on the standard posture point cloud model, the skeleton curvature calculation method is used to perform curvature fitting and bending degree analysis on the back skeleton curve of pigs to obtain the spinal curvature parameter, denoted as Bs. S43. Based on three-dimensional point cloud data and combined with the overall posture characteristics of pigs, the principal axis direction estimation method is used to calculate the principal direction of the point cloud, and further calculate the spatial angle between the principal direction of the point cloud and the preset standard coordinate axis to obtain the body tilt angle, denoted as θ. S44. Based on time-series frame data, Kalman filtering combined with a multi-target tracking algorithm is used to perform cross-frame association of individual pigs. By calculating the change in the position of the target centroid between consecutive frames and performing time-series smoothing, the trajectory offset parameter is obtained, denoted as Td.

[0038] In this embodiment, by introducing multi-dimensional posture feature parameters such as key point offset, spinal curvature, body tilt angle and trajectory offset, a comprehensive characterization of the pig's posture state is achieved, improving the precision and accuracy of posture abnormality identification and providing a reliable basis for posture assessment.

[0039] Example 7 Please see Figure 1 In the explanation of Example Six, specifically, step four further includes: S45. After dimensionless processing of the obtained key point offset ΔK, spinal curvature parameter Bs, body tilt angle θ, and trajectory offset parameter Td, the posture standardization deviation index, denoted as ZPI, is calculated. The formula is as follows:

[0040] In the formula, a1, a2, a3, and a4 represent weighting coefficients; The keypoint offset represents the influence of the keypoint offset and has a high weight. The keypoint offset directly reflects the spatial position deviation of various parts of the body and is the most direct geometric manifestation of posture abnormalities. It has a significant impact on body size calculation and is therefore given a high weight. The influence of spinal curvature is characterized by a high weight. Spinal curvature reflects the degree of overall body shape deformation and is an important factor affecting body length and body shape development. It is closely related to posture standardization and is therefore given an equally high weight. : Characterizes the influence of body tilt angle, with medium weight. Body tilt reflects the overall posture deviation and has a certain impact on parameters such as body height, but it can be partially corrected through coordinate alignment, so it is given medium weight. The influence of trajectory deviation is characterized by a medium weight. Trajectory deviation reflects the individual's motion state and stability, mainly affecting the accuracy of instantaneous measurements. It is a dynamic auxiliary factor and is therefore assigned a medium weight. Through the above weighted fusion, the attitude standardization deviation index ZPI can comprehensively characterize the influence of structural deformation and dynamic disturbance on attitude. The larger the attitude standardization deviation index ZPI value, the more serious the attitude deviation.

[0041] S46. By setting a preset attitude deviation threshold, denoted as Zth, and comparing the attitude standardized deviation index ZPI with the attitude deviation threshold Zth, the second evaluation results are obtained, including: When the posture standardization deviation index ZPI ≤ posture deviation threshold Zth, it indicates that the pig posture meets the standardization requirements, the posture is deemed qualified, a set of posture standardization body size parameters is generated, and continuous monitoring is performed. When the posture standardization deviation index ZPI > posture deviation threshold Zth, it indicates that the pig's posture does not meet the standardization requirements and is judged as unqualified. The pig exhibits non-standard postures such as bending, tilting, head down, walking, or shaking, which may lead to structural deviations in the calculation of body length, body height, and chest circumference. This triggers a second warning instruction and generates a second strategy: initiate posture compensation on the current point cloud data, use a non-rigid transformation method to perform local deformation correction on the curved area, and reduce the spinal curvature by 20% to 40%; at the same time, select three or more consecutive stable frames in the time series to replace the current abnormal frame, and reduce the trajectory offset parameter by 15% to 35%; perform spatial repositioning correction on the abnormal area of ​​key point offset, and reduce the key point offset by 10% to 30%; and reduce the body tilt angle by 10% to 25% by reestimating the principal axis to keep it within the standard range. After adjustment, recalculate until the posture standardization deviation index ZPI ≤ posture deviation threshold Zth.

[0042] Method for obtaining the posture deviation threshold Zth: The goal of the posture deviation threshold Zth calibration process is to determine a critical posture deviation index value that can effectively distinguish between "standard posture state" and "abnormal posture state". First, a standardized assessment database for pig posture is constructed. This database is formed by collecting multi-temporal point cloud and keypoint data in actual breeding environments. The database has no fewer than 600 sample groups, covering various states such as standard standing posture, mild posture deviation, and severe posture abnormality. Each sample group in the database includes parameters such as keypoint offset, spinal curvature, body tilt, and movement trajectory deviation.

[0043] Meanwhile, three or more experts with experience in livestock and poultry behavior analysis and 3D visual processing, combined with body size measurement error analysis and posture recognition results, labeled each group of samples with a "gold standard" and classified them as "acceptable posture" or "unacceptable posture". Subsequently, the posture standardization deviation index was calculated for all samples to obtain the corresponding quantitative index value.

[0044] Next, statistical distribution analysis was performed on the two types of samples, and probability density curves were plotted. These curves typically exhibited distributional separation, with the overall low percentage for acceptable postures and the overall high percentage for abnormal postures. Based on this, the maximum Youden index was selected as the optimal segmentation threshold by constructing an ROC curve, achieving a balance between sensitivity and accuracy in posture recognition. Furthermore, practical experience was incorporated; for example, when the index exceeded a certain level, pigs exhibited obvious bending, tilting, or movement, leading to significant deviations in body size calculations, thus requiring engineering corrections.

[0045] Through comprehensive analysis, the optimal attitude deviation threshold Zth is determined to be 0.35. When the attitude deviation index is not higher than this threshold, it indicates that the attitude meets the standardization requirements; when it exceeds this threshold, the attitude is deemed unqualified.

[0046] In this embodiment, by constructing a posture standardization deviation index and setting a threshold judgment mechanism, compensation strategies such as non-rigid correction, key point relocation, and stable frame screening are automatically executed when the posture is unqualified, which effectively reduces the measurement error caused by posture deviation and improves the standardization degree and measurement stability of body size data.

[0047] Example 8 Please see Figure 1 In the explanation of Example 7, specifically, step five includes: S51. By extracting the standard body length parameter Ls, standard body height parameter Hs, and standard chest circumference parameter Cs from the posture-standardized body size parameter set, and the corresponding historical sequence data, the data is processed for time alignment, outlier removal, and dimensionless normalization to form a model input dataset with a uniform scale. Temporal features are then extracted to obtain the body length change rate, denoted as ΔLt, the body height change rate, denoted as ΔHt, and the chest circumference change rate, denoted as ΔCt. Combined with historical predicted weight, this is denoted as Wt. 1. The coupling relationship between changes in pig body shape and weight evolution was analyzed; then, a multivariate time series modeling method was used to construct the initial structure of a dynamic weight prediction model, incorporating the rate of change in body length ΔLt, the rate of change in body height ΔHt, and the rate of change in chest circumference ΔCt, along with historical predicted weight Wt. 1 is used as an input variable to train and test the model, resulting in an initial dynamic weight prediction model; S52. During the model training process, the output of the intermediate layer of the dynamic weight prediction model is extracted as a feature vector to characterize the deep mapping relationship between body size changes and weight gain. Based on the feature vector, the model is iteratively trained and the parameters are optimized to obtain the optimized dynamic weight prediction model. Using the optimized dynamic weight prediction model, the body size change data at the current moment is input to calculate the current weight prediction value, denoted as Wt.

[0048] In this embodiment, a multivariate time series dynamic weight prediction model is constructed by introducing body size change rate and historical weight data. Combined with feature vector extraction and iterative optimization mechanism, a deep modeling of the relationship between body size change and weight gain is achieved, thereby improving the accuracy of weight prediction and the ability to characterize growth trends.

[0049] Example 9 Please see Figure 1 In the explanation of Embodiment Eight, specifically, step six includes: S61. Using the obtained current predicted weight value Wt and its corresponding historical predicted sequence data, a time window moving average method is used to statistically analyze the historical predicted weight to obtain the historical average weight, denoted as Wt. Simultaneously, by acquiring the body length change rate ΔLt, body height change rate ΔHt, and chest circumference change rate ΔCt, the three are weighted and fused to construct a comprehensive parameter of body size change rate, denoted as Gt; and by using the actual weighing data obtained from regular sampling in the breeding management system, time matching and individual correspondence are performed to obtain the actual weight of the sampled individuals, denoted as Wr. S62. Using the obtained current weight prediction value Wt and historical average weight The comprehensive parameter of body size change rate Gt and the actual weight of the sampled individuals Wr are used to calculate the weight prediction stability index, denoted as WSI, after dimensionless processing of each parameter. The formula is as follows:

[0050] In the formula, s1, s2 and s3 represent weighting coefficients.

[0051] This represents the impact of the deviation between the current forecast and the historical mean, and has a high weight. This item reflects the time stability of the forecast result. If the current value deviates significantly from the historical trend, it usually means that the forecast is abnormal, so it is given a high weight. The influence of the comprehensive parameter characterizing the rate of change in body size is given a medium weight. The rate of change in body size reflects the growth trend and has an explanatory role in weight changes, but it is an indirect influencing factor, so it is given a medium weight. This term represents the impact of the deviation between the predicted value and the actual measurement, and has a high weight. This term directly reflects the prediction error and is the core indicator for evaluating the accuracy of the model. Therefore, it is given a high weight and together with the historical deviation term, it constitutes the dominant factor. Through the above weight fusion, the Weight Prediction Stability Index (WSI) can comprehensively reflect the temporal consistency, growth rationality, and actual deviation of the prediction results. When the WSI value is larger, it indicates that the prediction instability is stronger and the error risk is higher.

[0052] In this embodiment, a weight prediction stability assessment mechanism is established by integrating current predicted weight, historical average weight, body size change rate, and actual sampled weight information to achieve dynamic judgment of the reliability of prediction results and improve the credibility and application value of weight assessment results.

[0053] Example 10 Please see Figure 1 In the explanation of Embodiment Nine, specifically, step six further includes: S63. By setting a preset weight stability threshold, denoted as Wth, and comparing the predicted weight stability index (WSI) with the weight stability threshold (Wth), the third evaluation results are obtained, including: When the weight prediction stability index WSI is less than or equal to the weight stability threshold Wth, it indicates that the current weight prediction result is stable and reliable. The weight prediction result is deemed qualified, and the final weight result dataset is generated and stored for growth status assessment and breeding decision analysis. When the Weight Prediction Stability Index (WSI) exceeds the Weight Stability Threshold (Wth), it indicates that the current weight prediction result is unstable and is deemed unqualified, posing a risk of inaccurate weight assessment and misjudgment of growth status. This triggers a third early warning instruction and generates a third strategy: An online correction mechanism is initiated for the dynamic weight prediction model. This involves incorporating the actual weight of the current sampled data to perform error feedback correction on the model, reducing the deviation between the current weight prediction value and the actual sampled weight by 15%–40%. Simultaneously, the mapping relationship between body size parameters and weight is updated, allowing the influence weight of the comprehensive parameter of body size change rate on weight prediction to adaptively adjust, improving the model's adaptability to the current growth stage. Furthermore, the sampling frequency of time series data is increased by 30%–100% on the original sampling basis to enhance the model's response to short-term fluctuations. After adjustment, weight prediction is re-performed and the Weight Prediction Stability Index is recalculated until the Weight Prediction Stability Index (WSI) is ≤ the Weight Stability Threshold (Wth).

[0054] The method for obtaining the weight stability threshold Wth: The goal of the weight stability threshold Wth calibration process is to determine a critical weight prediction stability index value that can effectively distinguish between a "steady weight prediction state" and a "stable weight prediction state." First, a weight prediction stability assessment database is constructed. This database is formed by continuously collecting body size parameters, predicted weight, and sampled weight data during actual breeding operations. The database has a sample size of no less than 600 groups, covering various situations such as prediction stability, slight fluctuations, and significant deviations. Each sample in the database includes the current predicted weight, historical average weight, body size change rate, and corresponding actual weighing data.

[0055] Meanwhile, three or more technicians with experience in aquaculture management and data analysis, combined with the prediction error level, consistency of growth trends, and actual weighing results, labeled each group of samples with a "gold standard" and classified them as either "predicted stable state" or "predicted unstable state." Subsequently, a weight prediction stability index was uniformly calculated for all samples to obtain the corresponding quantitative index value.

[0056] Next, statistical analysis was performed on the two types of samples, and probability density distribution curves were plotted. These curves typically exhibit a bimodal structure, with the index generally lower in the stable state and higher in the unstable state. Based on this, an ROC curve was constructed, and the point of maximum Youden's index was selected as the optimal threshold to achieve the best predictive stability. Furthermore, practical experience was incorporated; for example, when the index exceeds a certain level, the predicted results deviate significantly from the actual weight or exhibit abnormal fluctuations, thus requiring engineering corrections.

[0057] Based on statistical analysis and engineering experience, the optimal weight stability threshold Wth is determined to be 0.42. When the weight prediction stability index is not higher than this threshold, the prediction result is considered stable and reliable; when it exceeds this threshold, the prediction result is considered unstable.

[0058] In this embodiment, by introducing an online correction strategy when weight prediction is unstable, combined with error feedback, adaptive weight adjustment and sampling frequency enhancement mechanisms, the prediction bias is effectively reduced and the model's adaptability to short-term fluctuations and different growth stages is enhanced, thereby significantly improving the stability, accuracy and real-time performance of weight prediction results.

[0059] It should be noted that all calculation formulas in this application employ regression analysis, including but not limited to machine learning algorithms, to deeply analyze the collected parameters and identify their natural trends and interrelationships. Specialized software, such as Python's Scikit-learn library or the R language, is used to automatically generate mathematical models that match the data. Then, cross-validation and other methods are used to objectively evaluate the model performance, and continuous feedback and optimization are combined to ensure that the created formulas truly reflect the inherent laws of the data, thereby guaranteeing their effectiveness and accuracy. In all calculation formulas in this application, the parameters in each formula undergo dimensionless processing within a consistent range to ensure that different physical quantities are compared on the same scale; dimensionless processing techniques include, but are not limited to, min-max-normalization and Z-score standardization. The algorithm of this invention is implemented as a Python script. Before executing the core logic, the program first executes a data loading module (e.g., using the widely used pandas library in Python) configured to read the aforementioned spreadsheet file and load its contents into the program's working memory (e.g., a DataFrame data structure). Subsequent algorithm steps will directly query and retrieve the required configuration parameters from this in-memory data structure.

[0060] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.

Claims

1. A non-contact online detection method for pig body size and weight based on 3D machine vision, characterized in that: The specific steps include: Step 1: Collect 3D point cloud data, RGB image data, and posture change data of pigs, and perform time synchronization and spatial coordinate registration processing; and obtain point cloud density parameters, occlusion ratio parameters, motion blur parameters, reflection dispersion parameters, and individual overlap rate parameters. Step 2: Calculate the point cloud perception credibility index and compare it with the point cloud credibility threshold to determine whether the point cloud quality is qualified. If qualified, generate a standardized credible point cloud dataset; if not qualified, provide an adaptive optimization strategy for point cloud quality. Step 3: Perform keypoint detection and 3D coordinate mapping on the standardized reliable point cloud dataset to obtain the keypoint coordinate set and the normalized keypoint coordinate set; then perform keypoint topology connection and attitude feature extraction, and perform principal axis direction estimation and rigid body transformation on the point cloud to obtain the attitude-aligned point cloud data; then perform surface reconstruction and non-rigid correction processing to obtain the standard attitude point cloud model; based on the standard attitude point cloud model, calculate the body size parameters to obtain the standard body length parameter, standard body height parameter, and standard chest circumference parameter. Step 4: Calculate the posture standardization deviation index and compare it with the posture deviation threshold to determine whether the pig posture is qualified. If it is qualified, generate a set of posture standardization body size parameters. If it is not qualified, give a posture adaptive compensation optimization strategy. Step 5: Establish an initial dynamic weight prediction model; then perform feature vector extraction and model iteration optimization to obtain the optimized dynamic weight prediction model, and perform weight prediction calculation to obtain the current weight prediction value; Step 6: Calculate the current weight prediction stability index and compare it with the weight stability threshold to determine whether the current weight prediction result is qualified. If qualified, generate the final weight result dataset; if not qualified, provide an adaptive correction strategy for weight prediction.

2. The non-contact online detection method for pig body size and weight based on 3D machine vision according to claim 1, characterized in that: Step one includes: S11. Real-time monitoring of the pig farming passage is carried out. A binocular structured light 3D camera is installed above the passage to collect 3D point cloud data and RGB image data of the pigs. An inertial measurement unit (IMU) is deployed at the camera mounting bracket to collect attitude change data. S12. Based on continuous acquisition, time-series frame data is generated, and time synchronization and spatial coordinate registration are performed on 3D point cloud data, RGB image data and attitude change data to construct the original multi-source dataset. S13. Based on the three-dimensional point cloud data in the original multi-source dataset, the point cloud space is discretized using voxel mesh generation technology, and the number of points in each voxel unit is statistically analyzed to calculate the point cloud distribution density per unit volume and obtain the point cloud density parameters. S14. Based on the 3D point cloud data and RGB image data in the original multi-source dataset, the point cloud surface texture mapping and neighborhood gray-level consistency analysis method is used to map the RGB image data to the corresponding point cloud surface and obtain the gray-level distribution information of the point cloud surface; the local variance of the neighborhood gray-level value of each point is calculated, and the global gray-level variance is normalized to obtain the reflection dispersion parameter. S15. Based on the 3D point cloud data in the original multi-source dataset, the point cloud projection and region integrity analysis method is used to map the point cloud data to a standard reference plane. By detecting the proportion of the missing region area to the overall region area, the occlusion ratio parameter is obtained. S16. Based on time series frame data, the iterative nearest point registration algorithm is used to spatially register the point clouds of adjacent frames. By calculating the displacement error and deformation degree of the point clouds between frames, motion blur parameters are obtained. S17. Based on the 3D point cloud data in the original multi-source dataset, the density space clustering algorithm is used to segment the point cloud into individuals, and the individual overlap rate parameter is obtained by calculating the proportion of spatial overlap between different individual point clouds.

3. The non-contact online detection method for pig body size and weight based on 3D machine vision according to claim 2, characterized in that: Step two includes: S21. After dimensionless processing of the obtained point cloud density parameters, surface reflection dispersion parameters, occlusion ratio parameters, motion blur parameters, and individual overlap rate parameters, a point cloud perception reliability index is constructed.

4. The non-contact online detection method for pig body size and weight based on 3D machine vision according to claim 3, characterized in that: Step two also includes: S22. By setting a preset point cloud credibility threshold, and comparing and analyzing the point cloud perception credibility index with the point cloud credibility threshold, the first evaluation result is obtained, including: When the point cloud perception confidence index is greater than or equal to the point cloud confidence threshold, it indicates that the point cloud quality is qualified, and a standardized confidence point cloud dataset is generated for continuous monitoring. When the point cloud perception confidence index is less than the point cloud confidence threshold, it indicates that the point cloud quality is unqualified, with risks of missing points, reflection interference, severe occlusion, motion blur, or multiple target overlap, leading to incomplete individual contours, structural distortion, or inaccurate segmentation. This triggers the first warning instruction and generates the first strategy: perform multi-frame fusion processing on the original point cloud data, superimposing point clouds from no less than 3 frames and no more than 7 frames in a continuous time series to improve the overall point cloud density, increasing the point cloud density parameter by 20% to 50%; simultaneously, use surface fitting to complete missing regions, reducing the occlusion ratio parameter by 15% to 40%; perform reflection intensity normalization and outlier removal processing on discrete reflection regions, reducing the reflection dispersion parameter by 10% to 30%; perform rigid body alignment of the point cloud based on inter-frame registration to suppress motion offset, reducing the motion blur parameter by 10% to 25%; and separate overlapping point clouds using spatial clustering methods, reducing the overlap parameter by 20% to 50%. After adjustment, recalculate until the point cloud perception confidence index is greater than or equal to the point cloud confidence threshold.

5. The non-contact online detection method for pig body size and weight based on 3D machine vision according to claim 4, characterized in that: Step three includes: S31. Based on a standardized and reliable point cloud dataset, an improved YOLO-pose key point detection algorithm is used to detect key parts of the pig's head, back, and buttocks. The key point coordinate set is obtained by combining depth information with 3D coordinate mapping. Based on the spatial rotation, translation, and non-rigid correction transformation parameters performed on the point cloud data during the pose normalization process, the key point coordinate set is synchronously transformed to obtain the normalized key point coordinate set. S32. By acquiring the set of key point coordinates and 3D point cloud data, the key points are transformed from the image coordinate system to the point cloud spatial coordinate system using the 3D coordinate mapping method to construct a set of key points in a unified space; then, the topology connection method is used to connect the key points of the pig's head, back and buttocks to extract the overall posture features of the pig. S33. Using 3D point cloud data and combining it with the overall posture characteristics of the pig, the principal axis direction estimation method is used to calculate the principal direction of the point cloud. Rigid body transformation is then used to rotate and translate the point cloud spatially, aligning the pig's principal axis direction with the preset standard coordinate axis, thus completing the initial posture unification processing of the point cloud. Using the point cloud data after rigid body registration as input, a surface reconstruction method based on moving least squares is used to perform continuous surface fitting on the discrete point cloud, constructing a continuous surface model of the pig's body. Parametric surface modeling technology is then combined to structurally express the body surface geometry. Furthermore, curve fitting and local deformation correction methods are used to non-rigidly adjust curved or tilted areas, making the pig's body shape tend towards a standard unfolded state, thus obtaining a standard posture point cloud model. S34. Based on the standard posture point cloud model, the curve length between the head key point and the buttock key point is calculated using the skeleton path fitting method to obtain the standard body length parameter; the vertical projection analysis method is used to calculate the vertical distance from the highest point of the pig's back to the ground reference plane to obtain the standard body height parameter; the cross-section slicing and contour fitting method is used to reconstruct the cross-section of the pig's chest region, calculate the cross-sectional perimeter, and obtain the standard chest circumference parameter.

6. The non-contact online detection method for pig body size and weight based on 3D machine vision according to claim 5, characterized in that: Step four includes: S41. Based on the set of key point coordinates and the normalized set of key point coordinates, the Euclidean distance calculation method is used to calculate the spatial difference of the corresponding key points and obtain the key point offset. S42. Based on the standard posture point cloud model, the skeleton curvature calculation method is used to perform curvature fitting and bending degree analysis on the back skeleton curve of pigs to obtain the spinal curvature parameters. S43. Based on three-dimensional point cloud data and combined with the overall posture characteristics of pigs, the principal axis direction estimation method is used to calculate the principal direction of the point cloud, and further calculate the spatial angle between the principal direction of the point cloud and the preset standard coordinate axis to obtain the body tilt angle. S44. Based on time-series frame data, Kalman filtering combined with a multi-target tracking algorithm is used to perform cross-frame association of individual pigs. By calculating the change in the position of the target centroid between consecutive frames and performing time-series smoothing, trajectory offset parameters are obtained.

7. The non-contact online detection method for pig body size and weight based on 3D machine vision according to claim 6, characterized in that: Step four also includes: S45. After dimensionless processing of the obtained key point offset, spinal curvature parameter, body tilt angle and trajectory offset parameter, calculate the posture standardization deviation index. S46. By setting a preset attitude deviation threshold and comparing the attitude standardized deviation index with the attitude deviation threshold, the second evaluation result is obtained, including: When the posture standardization deviation index is less than or equal to the posture deviation threshold, it indicates that the pig's posture meets the standardization requirements, the posture is deemed qualified, a set of posture standardization body size parameters is generated, and continuous monitoring is performed. When the posture standardization deviation index exceeds the posture deviation threshold, it indicates that the pig's posture does not meet the standardization requirements and is deemed unqualified. The pig exhibits non-standard postures such as bending, tilting, head-down, walking, or shaking, which may lead to structural deviations in the calculation of body length, body height, and chest circumference. This triggers a second warning instruction and generates a second strategy: initiate posture compensation on the current point cloud data, use a non-rigid transformation method to perform local deformation correction on the curved area, reducing the spinal curvature by 20%–40%; simultaneously, select three or more consecutive stable frames in the time series to replace the current abnormal frame, reducing the trajectory offset parameter by 15%–35%; perform spatial repositioning correction on the abnormal keypoint offset area, reducing the keypoint offset by 10%–30%; and reduce the body tilt angle by 10%–25% by reestimating the principal axis to keep it within the standard range. After adjustment, recalculate until the posture standardization deviation index is ≤ the posture deviation threshold.

8. The non-contact online detection method for pig body size and weight based on 3D machine vision according to claim 7, characterized in that: Step five includes: S51. By extracting the standard body length, standard body height, and standard chest circumference parameters from the standardized body size parameter set, along with the corresponding historical sequence data, the data undergoes time alignment, outlier removal, and dimensionless normalization to form a model input dataset of uniform scale. Temporal features are then extracted to obtain the rates of change in body length, body height, and chest circumference. Combined with historical predicted weight, the coupling relationship between changes in pig body shape and weight evolution is analyzed. A multivariate time series modeling method is then used to construct the initial structure of the dynamic weight prediction model. The rates of change in body length, body height, and chest circumference, along with historical predicted weight, are used as input variables to train and test the model, resulting in the initial dynamic weight prediction model. S52. During model training, the output of the intermediate layer of the dynamic weight prediction model is extracted as a feature vector to characterize the deep mapping relationship between body size changes and weight gain. Based on the feature vector, the model is iteratively trained and the parameters are optimized to obtain the optimized dynamic weight prediction model. Using the optimized dynamic weight prediction model, the body size change data at the current moment is input for calculation to obtain the current weight prediction value.

9. The non-contact online detection method for pig body size and weight based on 3D machine vision according to claim 8, characterized in that: Step six includes: S61. Using the current predicted weight value and its corresponding historical predicted sequence data, the historical predicted weight is statistically analyzed using the time window moving average method to obtain the historical average weight; at the same time, the changes in body length, body height, and chest circumference are weighted and fused to construct a comprehensive parameter of body size change rate; and the actual weighing data obtained from the periodic sampling in the breeding management system is matched with time and associated with individuals to obtain the actual weight of the sampling. S62. After dimensionless processing of each parameter, the current predicted weight, historical average weight, body size change rate, and sampled actual weight, the weight prediction stability index is calculated.

10. The non-contact online detection method for pig body size and weight based on 3D machine vision according to claim 9, characterized in that: Step six also includes: S63. By setting a preset weight stability threshold and comparing the predicted weight stability index with the weight stability threshold, the third evaluation results are obtained, including: When the weight prediction stability index is less than or equal to the weight stability threshold, it indicates that the current weight prediction result is stable and reliable. The weight prediction result is deemed qualified, and the final weight result dataset is generated and stored for growth status assessment and breeding decision analysis. When the weight prediction stability index exceeds the weight stability threshold, it indicates that the current weight prediction result is unstable and is deemed unqualified, posing a risk of inaccurate weight assessment and misjudgment of growth status. This triggers a third early warning instruction and generates a third strategy: An online correction mechanism is initiated for the dynamic weight prediction model. This involves incorporating the actual weight of the current sample to perform error feedback correction on the model, reducing the deviation between the current weight prediction value and the actual sample weight by 15%–40%. Simultaneously, the mapping relationship between body size parameters and weight is updated, allowing the influence weight of the comprehensive parameter of body size change rate on weight prediction to adaptively adjust, improving the model's adaptability to the current growth stage. Furthermore, the sampling frequency of time series data is increased by 30%–100% on the original sampling basis to enhance the model's response to short-term fluctuations. After adjustment, weight prediction is re-performed and the weight prediction stability index is recalculated until the weight prediction stability index is ≤ the weight stability threshold.