Non-contact in-vivo pig eye muscle area determination method based on point cloud and deep learning
By employing a non-contact method based on point cloud and deep learning, utilizing the Azure Kinect DK camera and PointNet++ model, we have solved the problems of high cost, cumbersome operation, and unstable accuracy in pig eye muscle area measurement using traditional contact measurement methods. This method achieves efficient and accurate pig eye muscle area measurement, which is suitable for modern large-scale farming scenarios.
Patent Information
- Application Number
- CN202510917778.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-07-03
- Publication Date
- 2025-10-17
AI Technical Summary
Existing contact measurement methods, such as ultrasonic measurement and computed tomography, have problems such as high cost, cumbersome operation, unstable accuracy, and potential to induce stress in the measurement of pig eye muscle area, making them difficult to widely apply in breeding and farming.
A non-contact method based on point cloud and deep learning was adopted. Images of pig backs were acquired using an Azure Kinect DK camera, and the eye muscle area was predicted by combining the deep learning model PointNet++. This included image segmentation, point cloud processing, and regression model training, achieving non-contact and automated measurement.
It enables efficient and accurate measurement of pig eye muscle area, is suitable for large-scale farming scenarios, improves measurement efficiency and animal welfare, reduces equipment costs, and has good potential for industrial application.
Smart Images

Figure FT_1 
Figure SMS_4 
Figure SMS_5
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the field of pig measurement, and particularly relates to a non-contact method for measuring the eye muscle area of a live pig based on point cloud and deep learning. BACKGROUND
[0002] The eye muscle area is one of the important indicators in the genetic improvement and performance identification of pigs. The eye muscle area is not only closely related to the lean meat rate, meat quality, fattening performance, and reproduction, but also has an important influence on the breeding efficiency and economic benefits of pigs. With the continuous development of pig breeding and breeding technology, the eye muscle area has become one of the important indicators in the genetic improvement and performance identification of pigs.
[0003] Animal phenotype is related to internal structure: the body surface morphology of animals (such as body width, back curvature, waist-to-hip ratio, etc.) is closely related to fat deposition and muscle development in genetics. The back fat thickness and eye muscle area of pigs are statistically significantly linearly or nonlinearly related to the overall body structure. Previous studies have shown that there is a significant correlation between the eye muscle area of pigs and body size parameters (body length, body height, body width), which makes it possible to predict internal indicators through surface features. In the field of human health, some studies have used human face images or body shape photos to predict human BMI (Body Mass Index), which is significantly related to human fat ratio. For example, the "Face-to-BMI" study proposed by Kocabey et al. (2017) shows that the degree of human obesity can be estimated only through facial images. This study fully demonstrates the predictability between apparent signs and body composition, and similarly, the eye muscle area and back fat thickness of pigs are significantly related to the lean meat rate and fat content of pig carcasses, so similar methods can also be used in the field of animal phenotype measurement.
[0004] In current breeding practices, there are mainly two methods for measuring the eye muscle area in live pigs: ultrasonic measurement technology and computed tomography (CT) technology. The commonly used methods for ultrasonic measurement technology are A-mode or B-mode. The core principle of ultrasonic measurement technology is that when ultrasonic waves propagate in the body, the acoustic impedance of different tissues differs, and reflection waves (echoes) are generated at the interface. By analyzing the intensity, distribution, and propagation characteristics of the echoes, the positions and shapes of the tissues in the body can be inferred, and further measurements of their length, area, and other parameters can be made. Computed tomography (CT) technology is an imaging method that uses X-ray imaging technology to generate cross-sectional images of the internal structure of the human or animal body through computer reconstruction algorithms.
[0005] Although both ultrasonic measurement and computer tomography technology can achieve non-invasive in vivo measurement, both technologies require specific trained measurement personnel and corresponding instruments, and the CT device is expensive, with high maintenance and single scan costs, which is beyond the affordability of breeding companies. In addition, both methods require the pig to be fixed during measurement, and the measurement process is cumbersome. In terms of measurement accuracy, studies have shown that there are significant differences in the measurement results of different operators using B-ultrasound, and the smoothness of the pig's body surface is also required when using ultrasonic measurement. In the case of hair coverage, the ultrasonic measurement result is not accurate. Although CT technology can accurately measure the internal composition indicators of pigs, its high price and harsh measurement conditions, as well as the need for pig anesthesia, determine that this technology cannot be applied to pig breeding and breeding work. In addition, both measurement methods are contact measurement methods, which may cause stress reactions in pigs, and biosecurity issues during the measurement process cannot be ignored.
[0006] And most of the studies using computer vision to measure eye muscle area are limited to using ultrasound images, and still cannot achieve non-contact automatic measurement. SUMMARY
[0007] To solve the above problems, the present application provides a method for predicting the eye muscle area of pigs in vivo based on computer vision and deep learning, which is an innovative method for measuring the eye muscle area of pigs. It can quickly and accurately obtain the surface information of animals without direct contact with them. It solves the problem of accurate measurement of eye muscle area in pig breeding, especially in large-scale breeding environments, where traditional measurement methods are not only cumbersome but also difficult to obtain high-quality data, and the phenotype is difficult to measure. By using point cloud data and combining deep learning models for prediction, this study effectively solves this problem, thereby providing an efficient and convenient means of phenotype measurement for the breeding industry.
[0008] The present application provides a method for establishing a non-contact in vivo measurement model for measuring the eye muscle area of pigs based on point cloud and deep learning, including depth image acquisition, image screening, image segmentation, depth image to point cloud, point cloud preprocessing, model training, including the following steps: S1, automatically collect images: two Azure Kinect DK cameras are respectively erected above and beside the pig activity channel to collect pig back images, the depth images and RGB images captured are named using timestamps accurate to microseconds, and the start and end times of capturing specific pig individuals are recorded at the same time. Subsequently, the photos and pig individuals are matched according to the capture time and photo timestamp; S2, image quality screening: screen out pictures containing complete pig individuals, normal posture and clear shooting from the captured RGB images, and match them with the corresponding depth images; S3, depth image segmentation: first, convert the depth image into a pseudo-color image; then, use SAM (Segment Anything Model) for interactive image segmentation; S4, depth image conversion to three-dimensional point cloud: based on the camera intrinsic parameters, use the Open3D library to convert the segmented foreground depth image into point cloud data; S5, point cloud preprocessing: first, use the radius filtering method to remove points with fewer than 5 adjacent points within 1 cm, then replace the z coordinates in the point cloud with the camera height minus the original value for the pig back point cloud, thereby mapping to the actual height; S6, eye muscle area phenotype acquisition: after slaughter, cut the eye muscle at the back of the longest muscle between the 3rd and 4th ribs, then use sulfuric acid paper to print the eye muscle outline, and use the planimeter to measure the outline area.
[0009] S7, training set and validation set division: use the phenotype value-based partitioning method to divide the dataset; preferably, standardize the phenotype value: standardize the eye muscle area phenotype value, and the standardization process is to divide the original phenotype value by the standard deviation: ; S8, model construction and training: construct a PointNet++ regression model, standardize the phenotype value, and use the training dataset to train the eye muscle area phenotype value, training data: pig back point cloud obtained in S5 and standardized eye muscle area obtained in S7.
[0010] Specifically, in S2, the depth image and RGB image are collected synchronously, and the image resolution is 512x512; In S7, all samples are divided into small intervals according to the phenotype value of the pig, and all samples are grouped according to the pre-defined phenotype value interval in the data preprocessing stage, and the eye muscle area cm 2 The dataset is divided into 6 intervals: 35-45, 45-55, 55-65, 65-75, 75-85, and 85-95; then, within each interval, further randomly divide it into a training set and a validation set according to a 4:1 ratio of individuals.
[0011] Further, in S8, the specific method is as follows: (1) Regression model construction: Construct a three-dimensional point cloud regression model based on the PointNet++ framework; specifically, this model uses a multi-scale feature extraction structure, combines local and global information fusion mechanisms, performs hierarchical feature learning on input point cloud data, and outputs the target phenotype value through a multi-layer perceptron (MLP). (2) Training data loading and down-sampling To improve the processing efficiency of point cloud data and maintain the uniformity of the spatial distribution of points, the original point cloud data is read and preprocessed. Data loading is implemented through a custom dataset class ModelNetDataLoader, which has the following functions: reading training set and test set data files from a specified path; performing necessary preprocessing on each point cloud sample, including downsampling operations; The following downsampling strategies are supported: With the uniform_sample option enabled, Farthest Point Sampling (FPS) is performed on the point cloud to retain uniformly distributed sampling points in space.
[0012] Through downsampling operations, the number of points in each point cloud sample is unified to npoints (1024), ensuring consistency in input data dimensions and effectively preserving the geometric distribution information of the point cloud, thereby improving the stability and generalization ability of model training.
[0013] Specifically, in S8, standardized hyperparameter configurations are used during model training to ensure stable convergence and good performance of the model. The specific settings are as follows: the number of training epochs is set to 200, and the batch size is 64. The optimizer is Adam, the initial learning rate is set to 0.01, and the learning rate is dynamically adjusted using the CosineAnnealingWarmRestarts strategy. The scheduler parameters are set to restart every 50 epochs, and the period length remains unchanged. In terms of loss functions, Mean Squared Error (MSE) is used as the optimization objective for regression tasks to measure the deviation between the model output and the true phenotype value.
[0014] Preferably, the input processing module of the PointNet++ regression model in S8 includes: Input format: point cloud tensor xyz with shape [B, C, N], B: batch size, C: channel number, including coordinates (x, y, z) and optional normal vectors (nx, ny, nz), N: number of points in each point cloud (e.g., 1024); Normal vector judgment logic: the model supports input with or without normal vectors, and adjusts the input channels dynamically based on the normal_channel parameter; The hierarchical feature extraction module based on the PointNet++ regression model includes: SA1: First multi-scale feature extraction layer: sample the farthest points from the original point cloud, retain 512 key points, sample neighbor points (16, 32, 128) within 3 different radii (0.1, 0.2, 0.4) for each point, respectively process each scale through an independent MLP and then splice to form a 320-dimensional multi-scale local feature.
[0015] Output: sample point coordinates l1_xyz: [B, 3, 512]; feature tensor l1_points: [B, 320, 512]; SA2: Second multi-scale feature extraction layer: sample 128 points again, and still use 3 radii for neighborhood extraction (0.2, 0.4, 0.8) for each point. The output feature dimension is 128 + 256 + 256 = 640; Output: sample point coordinates l2_xyz: [B, 3, 128]; feature tensor l2_points: [B, 640, 128]; SA3: Global feature aggregation layer: no sampling is performed on l2_points, and the entire point set is directly aggregated into a single global feature vector. The MLP outputs a 1024-dimensional feature; Output: feature tensor l3_points: [B, 1024, 1] -> reshape to [B, 1024]; The feature fusion module based on the PointNet++ regression model includes: Perform maximum pooling on l1_points in the spatial dimension, thereby converting the local feature matrix with a shape of [B, 320, 512] into a global pooled feature with a shape of [B, 320], where B is the batch size, 320 represents the feature dimension of each sampling point, and 512 is the number of points for each point cloud; Concatenate the pooled l1_points and the global feature l3_points, where l3_points is a global feature with a shape of [B, 1024, 1], which is transformed to [B, 1024] through a squeeze operation, and the two are concatenated into the final fusion feature with a shape of [B, 1344]; Where l1_points is a local feature from the first layer (sa1); l3_points is a global feature from the third layer (sa3).
[0016] By setting multiple neighborhood radii, local feature information is extracted at multiple scales for each key point and fused into a unified representation vector to enhance the network's perception of the pig's surface geometry at different scales. This module can consider both coarse-grained body structure and fine-grained surface texture or local protrusions, significantly improving the model's prediction accuracy and robustness for eye muscle area.
[0017] More preferably, the output of the multi-scale feature fusion of the PointNet++ regression model in S8 will be further subjected to feature dimensionality reduction and regression prediction through a three-layer fully connected network MLP: The first layer (fc1) uses a linear transformation to reduce the dimensionality of the input 1344-dimensional features and standardizes them through batch normalization to ensure training stability. The subsequent ReLU activation function enables the network to capture nonlinear features. To prevent overfitting, this layer also introduces dropout technology, outputting a 512-dimensional intermediate feature representation. The main function of this layer is to reduce the dimensionality of the fused multi-scale features while maintaining sufficient information for subsequent processing.
[0018] The second layer (fc2) takes the 512-dimensional features from the first layer and normalizes them using linear transformations and batch normalization. Reluctant Unit (ReLU) activation is then performed to enhance the model's nonlinear representation capabilities. This layer also uses dropout for regularization, outputting a 256-dimensional intermediate feature representation. This process further reduces feature dimensionality, helping the model focus on more important high-level features. The third layer (fc3) uses a linear transformation to map the 256-dimensional intermediate features to a 1-dimensional output, resulting in a regression prediction. The output of this layer represents the final regression result (eye muscle area). This output layer does not use an activation function to ensure the continuity and accuracy of the regression task.
[0019] Furthermore, the loss function module of the PointNet++ regression model in S8 includes: Mean Squared Error Loss (MSE Loss) is used to measure the error between the predicted value and the true value. Specifically, the loss function evaluates the prediction accuracy of the model by calculating the mean of the squared difference between the regression prediction value output by the model and the actual target value: The mathematical form is: .
[0020] The method initiatively constructs a point cloud deep learning regression model applied to pig live body phenotype prediction, provides a new feasible way for large-scale, automatic and low-stress genetic evaluation and breeding selection, and has high industrial application value.
[0021] The application further provides a model obtained by the establishing method, and specifically, the model is verified or tested, and specifically, the model is used for phenotype prediction: using the trained point cloud deep learning regression model to predict the phenotype value of the back point cloud file, inputting the pig back surface point cloud as the input information and outputting the standardized eye muscle area phenotype value as the output information, and comparing with the actual situation.
[0022] The application further provides a non-contact live pig eye muscle area determination method based on point cloud and deep learning, which uses the model to determine the pig eye muscle area, and specifically comprises the following steps: (1) collecting and preprocessing: collecting a depth image in real time on the back of a target pig; (2) model inference: inputting the point cloud obtained in the step (1) into the model to perform a forward inference to obtain an eye muscle area prediction value in a standardized form; (3) reverse standardization output: performing a reverse standardization operation on the model output according to the same standard deviation σA used in the training stage to restore the actual pig eye muscle area value in square centimeter units; (4) result recording: storing or displaying the pig eye muscle area value in association with the individual identification of the target pig.
[0023] The application realizes non-contact and efficient phenotype determination: by using the Azure Kinect DK camera to collect the point cloud data of the back and side of the pig, and combining point cloud reconstruction and a deep learning model, the application breaks through the limitations of traditional ultrasonic measurement methods, such as strong contact, low efficiency and complex operation, realizes non-contact and automatic measurement of the eye muscle area of the pig, and significantly improves the determination efficiency and animal welfare level.
[0024] The application significantly improves the prediction accuracy and stability: based on the point cloud deep learning model, the application performs systematic comparison and optimization, establishes a deep learning regression model based on PointNet++, and proposes an optimal training strategy, achieves high correlation and low error index in eye muscle area prediction, verifies the accuracy and robustness of the method, and is particularly suitable for precise prediction tasks in complex environments.
[0025] The application realizes automatic prediction and is suitable for large-scale breeding: by developing an automatic process from image collection to point cloud processing and model prediction, the application can realize batch and efficient prediction of pig phenotypes. The method is particularly suitable for modern large-scale and intelligent breeding scenes, and helps to improve breeding efficiency and production management level.
[0026] It has practical popularization and application value: the method provided by the application can be embedded in the video acquisition system of the existing breeding farm without increasing too much equipment investment, realizes real-time, batch and low-cost body shape phenotype determination, greatly improves the efficiency of pig genetic evaluation and breeding, and has good industrial transformation potential and economic benefits. BRIEF DESCRIPTION OF DRAWINGS
[0027] Figure 1 , a deep learning model architecture schematic diagram. DETAILED DESCRIPTION
[0028] The application will be described in detail through specific embodiments in order to better understand the application, but it does not constitute a limitation on the application.
[0029] Example 1 Live prediction was performed on 692 pigs from pig population A (394 pigs) from Henan and pig population B (298 pigs) from Beijing, and the effects of using population A and population B data respectively and the effect of using combined population data were compared using the method, wherein the original phenotype values were used during training and prediction, including the following steps: S1, automatically collecting images: two Azure Kinect DK cameras are respectively erected above and on the side of the pig activity channel to collect pig back images, the depth images and RGB images captured are named using time stamps accurate to microseconds, and the start and end times of capturing specific pig individuals are recorded at the same time. Subsequently, the correspondence between the photos and the pig individuals is realized according to the capture time and photo timestamp; S2, image quality screening: screening out pictures containing complete pig individuals, normal posture and clear shooting from the captured RGB images, and matching with the corresponding depth images; S3, depth image segmentation: first, convert the depth image to a pseudo-color image; then, use the Segment Anything Model (SAM) for interactive image segmentation; S4, converting the depth image to a three-dimensional point cloud: based on the camera intrinsic parameters, use the Open3D library to convert the segmented foreground depth image to point cloud data; S5, point cloud preprocessing: first, use the radius filtering method to remove points with less than 5 adjacent points within 1cm, and then replace the z coordinate in the point cloud with the camera height minus the original value for the pig back point cloud, thereby mapping to the actual height.
[0030] S6, eye muscle area phenotype acquisition: after slaughtering, the eye muscle is cut across the back of the longest muscle between the 3rd and 4th ribs, then the eye muscle profile is printed on the sulfuric acid paper, and the profile area is measured using the planimeter.
[0031] S7. Training and Validation Set Division: The dataset was partitioned using a combination of phenotypic value-based partitioning and 5-fold cross-validation. All samples were divided into small intervals based on their phenotypic values. During data preprocessing, all samples were grouped according to predefined phenotypic value intervals. For the eye muscle area (cm2) dataset, the phenotypic values were divided into six intervals: 35–45, 45–55, 55–65, 65–75, 75–85, and 85–95. Within each interval, the data were further randomly divided into training and validation sets in a 4:1 ratio using 5-fold cross-validation.
[0032] S8, Model Construction and Training: Build a regression model based on PointNet++ and train the phenotype using the original phenotypic values. Use the training dataset to train the eye muscle area phenotypic values. The training data includes the pig back point cloud obtained in S5 and the eye muscle area obtained in S7. The details are as follows: S8.1. Regression model construction: like Figure 1 As shown in the figure, a 3D point cloud regression model based on the PointNet++ framework is constructed. Specifically, the model adopts a multi-scale feature extraction structure, combines local and global information fusion mechanisms, performs hierarchical feature learning on the input point cloud data, and regresses the target phenotypic value through a multi-layer perceptron (MLP). (1) Input processing module: Input format: point cloud tensor xyz, shape [B, C, N], B: batch size, C: number of channels, including coordinates (x, y, z) and optional normal vectors (nx, ny, nz), N: number of points in each point cloud (e.g. 1024); Normal vector judgment logic: whether the model supports input containing normal vectors, and dynamically adjusts the input channel according to the normal_channel parameter; (2) Hierarchical feature extraction module: SA1: First-level multi-scale feature extraction layer: The farthest point of the original point cloud is sampled, 512 key points are retained, and for each point, 16, 32, and 128 neighboring points are sampled within three different radii (0.1, 0.2, and 0.4). Each scale is processed by an independent MLP and then spliced to form a 320-dimensional multi-scale local feature.
[0033] Output: sampling point coordinates l1_xyz: [B, 3, 512]; feature tensor l1_points: [B, 320,512]; SA2: Second level multi-scale feature extraction layer: resample 128 points, and use 3 radii (0.2, 0.4, 0.8) to extract neighborhood features for each point. The output feature dimension is 128 + 256 + 256 = 640; Output: coordinates of the sampling points l2_xyz: [B, 3, 128]; feature tensor l2_points: [B, 640, 128]; SA3: Global feature aggregation layer: no resampling is performed on l2_points, and the entire point set is aggregated into a single global feature vector. The MLP outputs a 1024-dimensional feature; Output: feature tensor l3_points: [B, 1024, 1] -> reshape to [B, 1024]; (3) Feature fusion module: Max-pooling is performed on l1_points in the spatial dimension, thereby converting the local feature matrix with a shape of [B, 320, 512] into a global pooled feature with a shape of [B, 320], where B is the batch size, 320 represents the feature dimension of each sampling point, and 512 is the number of points for each point cloud; The pooled l1_points and the global feature l3_points are concatenated, where l3_points is a global feature with a shape of [B, 1024, 1], which is transformed to [B, 1024] through the squeeze operation, and the two are concatenated into the final fusion feature with a shape of [B, 1344]; where l1_points is a local feature from the first layer (sa1); l3_points is a global feature from the third layer (sa3).
[0034] (4) MLP regression module: First layer (fc1): This layer uses linear transformation (Linear) to reduce the dimension of the input 1344-dimensional feature, and performs standardization through batch normalization (Batch Normalization) to ensure the stability of the training process. The subsequent ReLU activation function enables the network to capture nonlinear features. To prevent overfitting, this layer also introduces Dropout technology, outputting a 512-dimensional intermediate feature representation. The main role of this layer is to reduce the fused multi-scale features while maintaining sufficient information for subsequent processing.
[0035] Second layer (fc2): In the second layer, the 512-dimensional features from the first layer are further normalized by linear transformation and batch normalization, and activated by ReLU to improve the non-linear representation ability of the model. This layer also uses Dropout technology for regularization, and the output is a 256-dimensional intermediate feature representation. This process further reduces the feature dimension, helping the model focus on more important high-level features; The third layer (fc3): The last layer uses linear transformation to map the 256-dimensional intermediate features to a 1-dimensional output, obtaining the regression prediction value. The output of this layer represents the final regression result (eye muscle area). This output layer does not use an activation function to ensure the continuity and accuracy of the regression task.
[0036] (5) Loss function module: Mean Squared Error Loss (MSE Loss) is used to measure the error between the predicted value and the true value. Specifically, the loss function calculates the mean of the squared difference between the regression prediction value output by the model and the actual target value, to evaluate the prediction accuracy of the model: Mathematically, it is: ; S8.2, Training data loading and downsampling (1) Data loading is implemented through a custom dataset class ModelNetDataLoader, which includes the following functions: reading training set and test set data files from the specified path; performing necessary preprocessing on each point cloud sample, including downsampling operation; The following downsampling strategies are supported: Enable the uniform_sample option to perform Farthest Point Sampling (FPS) on the point cloud to retain uniformly spaced sampling points.
[0037] Through the downsampling operation, the number of points in each point cloud sample is unified to npoints (1024), ensuring the consistency of input data dimensions and effectively preserving the geometric distribution information of the point cloud, improving the stability and generalization ability of the model training.
[0038] (2) Training parameters: The training epoch is set to 200, and the batch size is 64. The optimizer is Adam, the initial learning rate is set to 0.01, and the learning rate is dynamically adjusted by combining the cosine annealing warm restart strategy (CosineAnnealingWarmRestarts), and the scheduler parameters are set to restart once every 50 epochs, and the period length is unchanged. In terms of loss function, mean squared error (MSE) is used as the optimization target of the regression task to measure the deviation between the model output and the true phenotype value. S9, phenotype prediction: using the trained deep learning model to predict the phenotype value of the back point cloud file, the model prediction input information is the pig back surface point cloud, and the output information is the pig eye muscle area.
[0039] The prediction effect output format of the trained model on the original eye muscle area phenotype value back point cloud dataset is shown in Table 1 (part of the individual example), and the prediction effect on different populations is shown in Table 2: Table 1
[0040] Table 2
[0041] The results show that the expansion of the training population significantly improves the prediction accuracy (determination coefficient R 2 from 0.539 and 0.149 to 0.643, and the correlation coefficient r from 0.763 and 0.439 to 0.808).
[0042] Example 2 The combined pig population from Henan and Hebei, which has 692 pigs with eye muscle area phenotype, is standardized (the standardization process is to divide the original phenotype value by the standard deviation: Then the deep learning model of the application is constructed for training and live prediction, including the following steps: S1-S6 are the same as the steps described in Example 1 S7, dataset division and phenotype value standardization: S7.1, The data set was divided by combining the method of partitioning based on phenotype value and 5-fold cross-validation. All samples were divided into small intervals according to the phenotype value of pigs. In the data preprocessing stage, all samples were grouped according to the pre-defined phenotype value interval. For the eye muscle area (cm2) data set, the phenotype value was divided into 6 intervals: 35-45, 45-55, 55-65, 65-75, 75-85 and 85-95. Then, within each interval, the data was further randomly divided into training set and validation set in the ratio of 4:1 using 5-fold cross-validation.
[0043] S7.2, The eye muscle area phenotype value was standardized. The standardization process was to divide the original phenotype value by the standard deviation: ; S8-S9 are the same as the steps of Example 1.
[0044] The prediction effect of the trained model on the standardized eye muscle area phenotype value back point cloud data set: The root mean square error (RMSE) of the individual mean value calculated from all file prediction values for each individual and the true phenotype value was 7.424±0.693 cm 2 , the mean absolute error (MAE) was 5.982±0.480 cm 2 , the mean absolute percentage error (MAPE) was 9.781±0.830%, the determination coefficient (R2) R 2 ) was 0.681±0.039, and the correlation coefficient (r) r ) was 0.832±0.023.
[0045] After standardizing the phenotype value, the prediction accuracy of training and prediction was compared with that of training and prediction using the original phenotype value (Example 1 combined population prediction results). The error indicators (RMSE, MAE, MAPE) were reduced, and the determination coefficient and correlation coefficient were improved. This indicates that standardizing the phenotype value is beneficial to improving the prediction accuracy.
[0046] Comparative Example 1: For pig population A from a pig farm in Henan, a total of 394 pigs, the body length, body height and body width three body size parameters were collected, as well as the corresponding eye muscle area phenotype data after slaughter. A regression method based on traditional multi-layer perceptron (MLP, Multi-Layer Perceptron) was used to predict the eye muscle area phenotype value using the body size parameters (body length, body height, body width). The overall process is as follows: S1, raw data preparation: The measured data of 394 pigs were sorted to form a structured data table containing three body size parameters (body length, body height, body width) and their true eye muscle area phenotypes for each individual, and saved as a.txt file, with each line representing a sample and fields including individual number, three body size parameter values and phenotype value.
[0047] S2, training set and validation set division: The data set was divided into 5 groups of training set and validation set files according to the 5-fold cross-validation method. Each fold validation set accounted for about 20% of the total data.
[0048] S3, feature and label extraction: Define a custom dataset class (CustomDataset) to read the data in each file, use body length, body height and body width as input feature vector, and eye muscle area phenotype as label value.
[0049] S4, model construction: A 3-layer MLP model was used for regression prediction. The network structure is input layer (3 nodes) → hidden layer 1 (64 nodes, ReLU activation) → hidden layer 2 (64 nodes, ReLU activation) → output layer (1 node), using mean square error loss function (MSELoss) for regression fitting, optimizer for Adam, initial learning rate set to 0.001.
[0050] S5, model training and validation: Each fold training set was trained for 200 iterations, and the validation set was predicted and performance evaluated at the end of each epoch. Performance evaluation indicators include root mean square error (RMSE), mean absolute error (MAE), mean absolute percentage error (MAPE), coefficient of determination (R²) and Pearson correlation coefficient (r). Each fold training records training loss, validation loss and related indicators, and saves the optimal model weight of each fold.
[0051] S6, prediction performance: The MLP model was used to predict the body size parameter data set of 394 pigs.
[0052] Using the body size parameter regression method based on MLP model, the body length, body height and body width of 394 pigs were modeled, and the eye muscle area phenotype value was predicted. The prediction performance of the model in five-fold cross-validation is as follows (statistical results of 5-fold average): the root mean square error (RMSE) calculated from the predicted value and the true phenotype value is 9.371 ± 0.442 cm², the mean absolute error (MAE) is 7.620 ± 0.302 cm², the mean absolute percentage error (MAPE) is 11.640 ± 0.634%, the coefficient of determination (R²) is 0.248 ± 0.037, and the correlation coefficient (r) is 0.507 ± 0.038.
[0053] The prediction accuracy of eye muscle area using body size parameter information is larger error and lower accuracy compared with the prediction of eye muscle area using point cloud information (prediction result of embodiment 1 group A). It shows that the prediction method using point cloud and the point cloud deep learning model of the present application have great potential in the determination of live pig eye muscle area.
[0054] Comparative example 2: The eye muscle area phenotype values of 692 pigs from a combined pig population from Henan and Hebei, which had eye muscle area phenotype, were standardized (the standardization process was to divide the original phenotype value by the standard deviation: Then a deep learning network based on PointNet++ without multi-scale feature fusion module was used for training and live prediction, including the following steps: S1-S7 are the same as the steps described in embodiment 2; S8, use a deep learning network based on PointNet++ without multi-scale feature fusion module for training, specifically as follows: S8.1, model construction: A three-dimensional point cloud regression model based on the PointNet++ framework is constructed. Specifically, the model uses a multi-scale feature extraction structure to learn hierarchical features from the input point cloud data, and uses a multi-layer perceptron (MLP) to regress and output the target phenotype value. (1) Input processing module: Input format: point cloud tensor xyz, shape [B, C, N], B: batch size, C: channel number, including coordinates (x, y, z) and optional normal vector (nx, ny, nz), N: number of points for each point cloud (such as 1024); Normal vector judgment logic: the model supports input with or without normal vector, and adjusts the input channel dynamically according to the normal_channel parameter; (2) Hierarchical feature extraction module: SA1: First multi-scale feature extraction layer: sample the farthest points from the original point cloud, retain 512 key points, sample neighbor points (16, 32, 128) within 3 different radii (0.1, 0.2, 0.4) for each point, and then concatenate the 320-dimensional multi-scale local features after processing by independent MLP for each scale.
[0055] Output: sampled point coordinates l1_xyz: [B, 3, 512]; feature tensor l1_points: [B, 320, 512] SA2: Second-level multi-scale feature extraction layer: resample 128 points, and use 3 radii (0.2, 0.4, 0.8) to extract neighborhood features for each point. The output feature dimension is 128 + 256 + 256 = 640 Output: coordinates of the sampled points l2_xyz: [B, 3, 128]; feature tensor l2_points: [B, 640, 128] SA3: Global feature aggregation layer: no resampling is performed on l2_points, and the entire point set is aggregated into a single global feature vector. The MLP outputs a 1024-dimensional vector Output: feature tensor l3_points: [B, 1024, 1] -> reshape to [B, 1024]; (3) MLP regression module: First layer (fc1): This layer uses linear transformation (Linear) to reduce the dimension of the input 1024-dimensional feature, and performs standardization through batch normalization (Batch Normalization). The subsequent ReLU activation function enables the network to capture non-linear features. To prevent overfitting, this layer also introduces Dropout technology, outputting a 512-dimensional intermediate feature representation. The main role of this layer is to reduce the fused multi-scale features while maintaining sufficient information for subsequent processing.
[0056] Second layer (fc2): In the second layer, the input is a 512-dimensional feature from the first layer, which is further standardized through linear transformation (Linear) and batch normalization (Batch Normalization), and is activated by ReLU to improve the non-linear expression ability of the model. This layer also uses Dropout technology for regularization, outputting a 256-dimensional intermediate feature representation. Third layer (fc3): The last layer uses linear transformation (Linear) to map the 256-dimensional intermediate feature to a 1-dimensional output, obtaining the regression prediction value. The output of this layer represents the final regression result (eye muscle area). This output layer does not use an activation function to ensure the continuity and accuracy of the regression task.
[0057] (4) Loss function module: Mean Squared Error Loss (MSE Loss) is used to measure the error between the predicted value and the true value. Specifically, the loss function calculates the mean of the squared differences between the regression prediction value output by the model and the actual target value, thereby evaluating the prediction accuracy of the model: Mathematically, it is:
[0058] S8.2 same as the step described in Example 2 S9 same as the step described in Example 2.
[0059] The prediction effect of the trained model on the back point cloud data set using the standardized eye muscle area phenotype value: The root mean square error (RMSE) calculated by the individual mean of all file prediction values of each individual and the true phenotype value is 8.262±0.755 cm 2 , the mean absolute error (MAE) is 6.495±0.524 cm 2 , the mean absolute percentage error (MAPE) is 10.901±0.784%, the determination coefficient (R R 2 ) is 0.610±0.055, and the correlation coefficient (R r ) is 0.784±0.033.
[0060] The results show that the deep learning network without the multi-scale feature fusion module has larger prediction error (RMSE, MAE, MAPE) and lower prediction accuracy (R R 2 , r ) compared with the deep learning network described in the present application.
Claims
1. A method for establishing a detection model for non-contact in vivo measurement of pig eye muscle area based on point cloud and deep learning, characterized in that: Including depth image acquisition, image screening, image segmentation, depth image to point cloud, point cloud preprocessing, model training, including the following steps: S1. Automatic image acquisition: Two Azure Kinect DK cameras were set up directly above and to the side of the pig's activity channel to capture images of the pig's back. The captured depth and RGB images were named with microsecond-accurate timestamps, and the start and end times of the capture of a specific pig were also recorded. Subsequently, the photos were associated with the individual pigs based on the capture time and the photo timestamp. S2. Image quality screening: Filter out the images of complete pigs with normal postures and clear shots from the captured RGB images, and match them with the corresponding depth images; S3. Depth image segmentation: First, the depth image is converted into a pseudo-color image; then, SAM (Segment Anything Model) is used to perform interactive image segmentation; S4. Depth image conversion to 3D point cloud: Based on the camera intrinsic parameters, the segmented foreground depth image is converted into point cloud data using the Open3D library; S5. Point cloud preprocessing: First, use the radius filtering method to remove points with less than 5 adjacent points within 1 cm. Then, for the pig's back point cloud, replace the z coordinate in the point cloud with the camera height minus the original z value, thereby mapping it to the actual height; S6. Obtaining the eye muscle area phenotype: After slaughter, the eye muscle was transversely cut at the longissimus dorsi between the third and fourth ribs. The muscle outline was then engraved on sulfuric acid paper, and the outline area was measured using a planimeter. S7. Training set and validation set division: The data set is divided using a partitioning method based on phenotypic values; preferably, the phenotypic values are standardized: the eye muscle area phenotypic values are standardized, and the standardization process is to divide the original phenotypic values by the standard deviation: ; S8. Model construction and training: Build a PointNet++ regression model and standardize the phenotypic values. Use the training dataset to train the eye muscle area phenotypic values. Training data: the pig back point cloud obtained in S5 and the standardized eye muscle area obtained in S7.
2. The establishment method according to claim 1, characterized in that In S2, image acquisition synchronously collects depth images and RGB images, and the image resolution is 512×512; In S7, all samples were divided into small intervals according to the phenotypic values of the pigs. In the data preprocessing stage, all samples were grouped according to the predefined phenotypic value intervals. 2 The dataset divides the phenotypic values into six intervals: 35–45, 45–55, 55–65, 65–75, 75–85, and 85-95; then, within each interval, individuals are further randomly divided into training and validation sets at a ratio of 4:
1.
3. The establishment method according to claim 1, characterized in that The specific method in S8 is as follows: (1) Regression model construction: A 3D point cloud regression model based on the PointNet++ framework was constructed. Specifically, the model uses a multi-scale feature extraction structure, combined with a local and global information fusion mechanism, to perform hierarchical feature learning on the input point cloud data and regress the target phenotypic values through a multi-layer perceptron (MLP). (2) Training data loading and downsampling To improve point cloud data processing efficiency and maintain uniform spatial distribution of points, the raw point cloud data is read and preprocessed. Data loading is implemented using the custom dataset class ModelNetDataLoader. Its functions include: reading training and test set data files from the specified path; performing necessary preprocessing on each point cloud sample, including downsampling; The following sampling strategies are supported: Enable the uniform_sample option to perform Farthest Point Sampling (FPS) on the point cloud to retain sampling points with uniform spatial coverage; Through the downsampling operation, the number of points in each point cloud sample is unified to npoints (1024), ensuring the consistency of the input data dimension and effectively retaining the geometric distribution information of the point cloud, thereby improving the stability and generalization ability of model training.
4. The establishment method according to claim 3, characterized in that: In S8, during the model training process, standardized hyperparameter configuration is used to ensure stable convergence and good performance of the model; The specific settings are as follows: the number of training epochs is set to 200, and the batch size is 64. Adam is selected as the optimizer, with an initial learning rate of 0.01, and a cosine annealing warm restart strategy (CosineAnnealingWarmRestarts) for dynamic learning rate adjustment. The scheduler parameters are set to restart every 50 epochs, with a constant cycle length. For the regression task, the mean squared error (MSE) is used as the optimization objective, measuring the deviation between the model output and the true phenotypic value.
5. The establishment method according to claim 1, characterized in that: The input processing modules of the PointNet++ regression model in S8 include: Input format: point cloud tensor xyz, shape [B, C, N], B: batch size, C: number of channels, including coordinates (x, y, z) and optional normal vectors (nx, ny, nz), N: number of points in each point cloud (e.g. 1024); Normal vector judgment logic: whether the model supports input containing normal vectors, and dynamically adjusts the input channel according to the normal_channel parameter; The hierarchical feature extraction module based on the PointNet++ regression model includes: SA1: First-level multi-scale feature extraction layer: The original point cloud is sampled at the farthest point, 512 key points are retained, and for each point, 16, 32, and 128 neighboring points are sampled within three different radii (0.1, 0.2, and 0.4). Each scale is processed by an independent MLP and then spliced to form 320-dimensional multi-scale local features; Output: sampling point coordinates l1_xyz: [B, 3, 512]; feature tensor l1_points: [B, 320, 512]; SA2: Second-level multi-scale feature extraction layer: 128 points are sampled again, and each point is still extracted using 3 radii (0.2, 0.4, and 0.8); the output feature dimension is 128 + 256 + 256 = 640; Output: sampling point coordinates l2_xyz: [B, 3, 128]; feature tensor l2_points: [B, 640, 128]; SA3: Global feature aggregation layer: no longer samples l2_points, and directly aggregates the entire point set into a single global feature vector; MLP output is 1024 dimensions; Output: Feature tensor l3_points: [B, 1024, 1] → reshape to [B, 1024]; The feature fusion module based on the PointNet++ regression model includes: Perform maximum pooling on l1_points in the spatial dimension, thereby converting the local feature matrix of shape [B, 320, 512] into a global pooling feature of shape [B, 320], where B is the batch size, 320 represents the feature dimension of each sampling point, and 512 is the number of points in each point cloud; Concatenate the pooled l1_points with the global feature l3_points, where l3_points is a global feature with a shape of [B, 1024, 1]. It is transformed to [B, 1024] through the squeeze operation. The two are concatenated into the final fusion feature with a shape of [B, 1344]. Among them, l1_points is the local feature from the first layer (sa1); l3_points is the global feature from the third layer (sa3).
6. The establishment method according to claim 5, characterized in that: In S8, the output of the multi-scale feature fusion of the PointNet++ regression model will be further processed through a three-layer fully connected network MLP for feature dimensionality reduction and regression prediction: The first layer (fc1) uses a linear transformation to reduce the dimensionality of the input 1344-dimensional features and standardizes them through batch normalization to ensure training stability. The subsequent ReLU activation function enables the network to capture nonlinear features. To prevent overfitting, this layer also introduces dropout technology, outputting a 512-dimensional intermediate feature representation. The main function of this layer is to reduce the dimensionality of the fused multi-scale features while maintaining sufficient information for subsequent processing. The second layer (fc2): Inputs the 512-dimensional features from the first layer, further normalizes them through linear transformation and batch normalization, and performs ReLU activation to improve the nonlinear expression ability of the model. This layer also uses Dropout for regularization, outputting a 256-dimensional intermediate feature representation. This process further reduces the feature dimensionality, helping the model focus on more important high-level features. The third layer (fc3) uses a linear transformation to map the 256-dimensional intermediate features to a 1-dimensional output, resulting in a regression prediction. The output of this layer represents the final regression result (eye muscle area). This output layer does not use an activation function to ensure the continuity and accuracy of the regression task.
7. The establishment method according to claim 1, characterized in that: The loss function module of the PointNet++ regression model in S8 includes: Mean Squared Error Loss (MSE Loss) is used to measure the error between the predicted value and the true value. Specifically, the loss function evaluates the prediction accuracy of the model by calculating the mean of the squared difference between the regression prediction value output by the model and the actual target value: The mathematical form is: .
8. A model obtained by the method according to any one of claims 1 to 7.
9. The model according to claim 8, characterized in that It also includes validation or testing of the model, specifically using it for phenotypic prediction: using the trained point cloud deep learning regression model to predict the phenotypic value of the back point cloud file. The input information for the prediction is the pig's back surface point cloud, and the output information is the standardized eye muscle area phenotypic value, which is compared with the actual situation.
10. A method for non-contact in vivo measurement of pig eye muscle area based on point cloud and deep learning, characterized in that: The model of claim 9 is used to measure the area of pig eye muscles, specifically comprising: (1) Acquisition and preprocessing: real-time acquisition of depth images of the target pig's back; (2) Model reasoning: Input the point cloud obtained in step (1) into the model and perform a forward reasoning to obtain the predicted value of eye muscle area in a standardized form; (3) Denormalization of output: Denormalization of the model output is performed according to the same standard deviation σA used in the training phase to restore the actual pig eye muscle area value in square centimeters; (4) Result recording: The pig eye muscle area value is associated with the individual identification of the target pig and then stored or displayed.
Citation Information
Patent Citations
Pig carcass eye muscle area intelligent real-time measurement method and system based on deep learning
CN118968603A
Method and system for rapidly detecting eye muscle area based on deep learning technology
CN119107352A
Point cloud self-supervised learning network model based on comparative learning and training method
CN119131518A
A method, system and storage medium for measuring pig backfat value based on depth image
CN119762569A
Living pig rating method and system based on three-dimensional point cloud and storage medium
CN119851308A