CN-122024281-A - Body size and weight measuring method for detecting key points of live pigs under feed component optimization condition
Abstract
The invention belongs to the technical field of non-contact measurement of weight of live pigs, and particularly relates to a body ruler and a weight measurement method for detecting key points of live pigs under the condition of optimizing feed components. The method comprises the steps of firstly obtaining point clouds of pigs, denoising the point clouds through an improved NLM, namely shooting the pigs through a depth camera, performing three-dimensional reconstruction through depth information to obtain point cloud data of the pigs, denoising the point clouds based on the improved NLM, performing gesture recognition and phenotype key point recognition through SwinT-SimCC, obtaining point cloud coordinates of the phenotype key points through coordinate conversion to calculate corresponding phenotype parameters, obtaining camera coordinates according to the recognition result of the step 2, converting the camera coordinates into point cloud coordinates, outputting the body size data of the pigs according to the point cloud coordinates, inputting the body size data of the pigs obtained in the step S3, outputting the body weight through an M3 model, and finally finishing non-contact measurement of the body weight of the live pigs.
Inventors
- FANG YI
- ZHOU XIAOBO
- LI KE
- LI HUA
- XU ZHENGRONG
- JIAO JUN
- WANG GUANGYAO
- TAN CHAO
- WEI JIAN
Assignees
- 安徽农业大学
- 安徽喜乐佳生物科技有限公司
Dates
- Publication Date
- 20260512
- Application Date
- 20260128
Claims (6)
- 1. The body size and weight measuring method for detecting the key points of the live pigs under the condition of optimizing the feed components is characterized by comprising the following steps: Firstly, acquiring pig point cloud, denoising the pig point cloud by improving NLM (non-line model), namely, after shooting the pig by a depth camera, carrying out three-dimensional reconstruction by depth information to obtain pig point cloud data, and denoising the pig point cloud based on the improved NLM; Step 2, carrying out gesture recognition and phenotype key point recognition by using SwinT-SimCC, obtaining point cloud coordinates of the phenotype key point through coordinate conversion, and calculating corresponding phenotype parameters; Step 3, obtaining camera coordinates according to the identification result in the step 2, converting the camera coordinates into point cloud coordinates, and outputting the body ruler of the pig according to the point cloud coordinates; And step 4, inputting the body size data of the pigs obtained in the step 3, outputting the weight through an M3 model, and finally completing non-contact measurement of the weight of the live pigs.
- 2. The body size and weight measurement method for detecting key points of live pigs under the condition of optimizing feed components according to claim 1, wherein the step 1 of denoising the point cloud by improving NLM comprises the following steps: the core formula of NLM is as follows: (1) (2) (3) In the formula, Is a dot Denoising the three-dimensional coordinate vector; Is a dot Is a three-dimensional coordinate vector of the original; Is a dot Is a candidate point set; Is a dot Point-to-point Similarity weights of (2); Is a dot Is a local descriptor of (2); is the filtering strength; Is the normalized coefficient of the coefficient, Since the NLM algorithm may rely on simple geometric features for similarity calculation only, without considering more complex geometric features or higher-order structural information, it results in insufficient denoising, and the following two-point improvement strategy is given for this problem: 1) The abnormal point measurement characteristics are added, and the updated core steps and formulas are as follows: Step1.1.1, the three input channels are respectively noted as I, N, K, namely a point cloud projection intensity channel, a normal line channel and a curvature channel, and the intermediate characteristics obtained at the t-th layer are as follows (4) Wherein, K I (t) 、K N (t) 、K K (t) is the convolution kernel of the t layer three input channels respectively, F I (t) 、F N (t) 、F K (t) is the characteristic tensor of the t layer three input channels respectively; Step1.1.2, fusion is performed according to weighted summation, and the formula is as follows: (5) Where w I (t) 、w N (t) 、w K (t) is the weight of the t-th layer three input channels, b (t) is the bias term, σ is the activation function, Is the output characteristic tensor of the layer t network, and the rest variables are consistent with the formula (4); step1.1.3, the output layer adds residual terms, the formula is as follows: (6) In the formula, skip (t) is the residual error of the jump connection, prevents information from being lost, The intermediate characteristic tensor is obtained by the t-th layer network through multi-channel characteristic weighted fusion, and the rest variables are consistent with the formula (4-5); 2) Weighting the mean square error loss and the normal constraint loss and the curvature constraint loss to construct a new loss function, and improving the loss function The following is shown: (7) (8) (9) (10) Wherein L MSE 、L normal 、L curv is a mean square error constraint term, a normal constraint term and a curvature constraint term respectively, lambda mse 、λ n 、λ k is a weighting coefficient of L MSE 、L normal 、L curv respectively, The true three-dimensional coordinates and the predicted three-dimensional coordinates of the i-th point, The true normal vector and the predicted normal vector of the i-th point, The true curvature value and the predicted curvature value of the ith point are respectively, and the rest variables are consistent with the formulas (1-3).
- 3. The body size and weight measurement method for detecting key points of live pigs under the condition of optimizing feed components according to claim 1, wherein the point cloud data of the pigs in the step 1 comprises: in daily pig raising scenes, standing postures, prone postures and sitting postures are three postures which are most frequently presented by pigs, the spatial position difference of phenotype key points under different postures is obvious, the calculation precision of phenotype parameters is directly influenced, in order to ensure that a model can be accurately matched with common scenes in actual raising, model training is required to be carried out on the three common postures, therefore, firstly, pig images with clear and complete back contours are screened out, The key points of the pig phenotype are classified into 7 types, and the specific positions are as follows: The chest width starting point CW0 and the chest width ending point CW1 are respectively positioned at the joint of the left and right forelimbs and the trunk and are approximately 1/3 of the height of the forelegs; the two points are respectively positioned at the top of the hip joint of the left and right hind limbs connected with the trunk and at about the upper 1/2 of the height of the hind leg; the Length0 of the body Length starting point is the joint of the head and neck and the trunk, namely the junction point behind the auricle and the neck and back, and the Length of the body Length from the nose tip to the tail root of the pig is calculated to be about the first 1/4 of the whole body Length; The Length end point Length1 is positioned at the joint of the tail root and the hip, namely the upper edge of the tail starting part, and is approximately at the rear 1/6 of the whole Length from the whole Length of the body; a height measurement point H0, which is located at the highest position of the back spine, is usually near the midpoint of the connecting line of the two shoulder blades, and is approximately 1/2 of the Length of the body from Length0 to Length 1; and respectively completing the corresponding labeling of the gesture category and the phenotype key point in a Labelme labeling tool.
- 4. The body size and weight measurement method for live pig critical point detection under the feed composition optimization condition according to claim 1, wherein the step 2 comprises: construction of Swin-TSimCC model Step2.1, dividing an input image by non-overlapping image blocks according to a fixed size, flattening each block, mapping the flattened non-overlapping image block to embedding dimensions through a layer of linear projection to obtain an initial low-dimensional feature vector token sequence, and taking the initial low-dimensional feature vector token sequence as the input of a subsequent transducer-block, wherein the core formula is as follows: (14) Where patch p is the p-th image patch, vec is the column vector that flattens the patch, W e 、b e is the weight and bias of the linear projection, and z p is the token representation after projection; step2.2, maintaining the same number of token sequences for each stage, and making a plurality of Swin blocks, reducing the size of a down-sampling space between stages by PATCH MERGING by half and expanding the channel width, wherein the core formula is as follows: (15) In the formula, Is the first on the current characteristic diagram W merge 、b merge is a downsampled linear layer; Is the position characteristic after downsampling; Step2.3 to reduce computational complexity, swin performs multi-headed self-attention within a locally non-overlapping window, thereby reducing the complexity of global O (N 2 ) to linearly relate to input size, a "learnable relative position bias" is added to the similarity term of attention to encode relative position information, the core formula is as follows: (16) Wherein d is the dimension, Q, K, V is the value matrix, B is the relative position bias matrix, and Softmax is the normalization process; is a multi-headed output linear mapping matrix; Step2.4:swin alternately uses a conventional window division W-MSA and a shift window SW-MSA between two adjacent Transformer block:offset the window down/right in a spatially down half-round manner so that certain token falls in the same window as in a different window above, the core formula is: (17) wherein M mask is a mask matrix, and the remaining variables are consistent with equation (16); step2.5, swin uses a leachable relative position offset table, and fills B through the relative coordinate index values between the patches in the window so that attention can sense the relative position information in the local window; after the Swin transducer finishes feature extraction, the fused features are sent to SimCC coordinate coding branches, linear projection discretization processing is respectively carried out on three-dimensional coordinates of the phenotype key points of the live pigs, coordinate category probability distribution in three dimensions of x, y and z is respectively output through a full-connection layer and a Softmax activation function, so that coordinate prediction of each dimension has probability interpretation, the influence of position fluctuation of the key points in prone position and sitting position on prediction stability is effectively reduced, and finally the three-dimensional coordinates of the key points of the phenotype of each core are accurately restored through coordinate decoding and sub-pixel level interpolation calculation.
- 5. The body ruler and weight measurement method for detecting key points of live pigs under the feed ingredient optimization condition according to claim 1, wherein in order to realize accurate calculation of phenotype parameters, pixel coordinates in a depth map are required to be sequentially converted into camera coordinates and point cloud coordinates in step 3, and the specific steps and formulas are as follows: The coordinates of each pixel point in the depth map are represented by (u, v), u is a horizontal pixel index, v is a vertical pixel index, the corresponding depth value is Z, and the depth value is directly output by the depth camera, and according to a pinhole camera model, the conversion relation between the pixel coordinates (u, v) and the camera coordinates (X c , Y c , Z c ) is as follows: (19) Wherein, (X c , Y c , Z c ) is a three-dimensional coordinate under a camera coordinate system, (c x , c y ) is a principal point coordinate in a camera internal reference, (f x ,f y ) is horizontal and vertical focal lengths in the camera internal reference, and Z is a depth value corresponding to a pixel (u, v) in a depth map; The camera coordinates need to be further converted into world coordinates, the origin of the world coordinate system can be defined according to requirements, and the conversion relation is realized through a rotation matrix R and a translation vector T: (20) Wherein, (X w , Y w , Z w ) is a three-dimensional coordinate under a world coordinate system, R is a 3X 3 rotation matrix for describing the rotation gesture of the camera coordinate system relative to the world coordinate system, T is a 3X 1 translation vector for describing the translation amount of the origin of the camera coordinate system relative to the origin of the world coordinate system; chest width, hip width and body length are calculated according to a distance formula between two points in space, and the formula is as follows: (21) Wherein d 1 ,d 2 ,d 3 is chest width, hip width and body length respectively; 、 the X coordinates of the point cloud are respectively a chest width starting point, a hip width starting point and a body length starting point; the X coordinates of the point cloud of the chest width end point, the hip width end point and the body length end point are respectively; 、 The Y coordinates of the point cloud are respectively a chest width starting point, a hip width starting point and a body length starting point; the Y coordinates of the point cloud of the chest width end point, the hip width end point and the body length end point are respectively; 、 the point cloud Z coordinates of the chest width starting point, the hip width starting point and the body length starting point are respectively; the point cloud Z coordinates of the chest width end point, the hip width end point and the body length end point are respectively; The height is derived from depth information in the depth camera, and the formula is as follows: (22) Wherein H is three-dimensional height, v 0 is the pixel position of the image center on the Z axis, the value is 240, v is the Z axis pixel coordinate of the target point on the image, Z is the depth value of the target point measured by the depth camera, namely the Z coordinate in the point cloud coordinate, and f z is the focal length of the camera in the Z axis direction.
- 6. The body size and weight measurement method for live pig critical point detection under the feed composition optimization condition according to claim 1, wherein the step 4 comprises: m3 model uses the body length of pig Chest width Width of buttocks High body height To input characteristics, construct body weight The predictive formula of (2) is as follows: (23) A, b, c, d, e is a parameter to be estimated of the model; is the random error of the ith sample; The model parameters are solved by minimizing the error square sum of the predicted value and the true value, and the specific steps are as follows: step4.1, defining the residual error r i of the ith sample as the difference between the true body weight and the predicted body weight: (24) (25) wherein n is the number of samples, and the remaining variables are the same as described above; step4.2, solving an objective function minimum value by adopting a Levenberg-Marquardt algorithm, and calculating partial derivatives of residual errors to parameters through a jacobian matrix (J): (26) the parameter updating formula is as follows: (27) In the formula, Is a damping factor; Is a 5×5 identity matrix, and r is a residual vector.
Description
Body size and weight measuring method for detecting key points of live pigs under feed component optimization condition Technical Field The invention belongs to the technical field of non-contact measurement of weight of live pigs, and particularly relates to a body ruler and a weight measurement method for detecting key points of live pigs under the condition of optimizing feed components. Background In large-scale live pig breeding, the accurate phenotype parameters and weight information of pigs are acquired, and the method is important for growth monitoring, breeding management and disease prevention and control. The traditional contact type measurement mode has low efficiency and is easy to cause stress reaction of pigs, and along with technological progress, the non-contact type measurement technology becomes the key of intelligent transformation of pig breeding by virtue of the advantages of high efficiency, low stress and the like. In the research of a live pig key point identification method, liu Gang and the like improve YOLOv-pose, a CBAM module is fused firstly, then C3 is replaced by C3Ghost and DyHead is introduced, so that the key point detection precision (mAP reaches 92.6%) under the conventional gesture is remarkably improved, however, when a non-standard gesture (such as sit and sitting) occurs to a live pig, the edge measuring point identification of the live pig is easy to deviate, YOLOv DA-HRST of Wang Xiaopin and the like is enhanced by Mosaic9 and deformable convolution improves multi-target scene adaptability (mAP 81.5%), and certain error exists in the key point under the non-standard gesture. Deviations in these key point identifications will directly lead to miscalculation of subsequently extracted body length, body width, height, etc. phenotypic parameters. Kendall et al (2017) found in the CornerNet study that even with the most advanced convolutional neural networks, the accuracy of key point detection was reduced by about 23.7% in non-standard postures (e.g., lying, twisting) of farm animals such as cattle, pigs, etc. Pavllo et al (2019) further demonstrate in the study of 3D Pose Estimation that key point identification errors can occur with mainstream algorithms based on RGB-D cameras. Disclosure of Invention In order to solve the problems, an improved SimCC-based recognition model and a Non-contact live pig weight measurement method are provided, wherein firstly, normal and curvature distinguishing features are introduced on the basis of a noise distortion algorithm (Non-Local Means, NLM), so that the point cloud denoising effect is improved. Secondly, replacing an original feature network of a simple coordinate classification algorithm (Simple Coordinate Classification, simCC) with a Swin transducer, constructing a simple coordinate classification algorithm (Swin Transformer Simple Coordinate Classification, swinT-SimCC) based on an attention mechanism, enhancing the spatial topological association of body surface key points by utilizing window attention mechanism and relative position coding, improving the key point recognition rate, calculating phenotype parameters according to the phenotype key points, and outputting the weight through an M3 model. In order to achieve the above purpose, the invention adopts the following technical scheme: the body size and weight measuring method for detecting the key points of the live pigs under the condition of optimizing the feed components comprises the following steps: Firstly, acquiring pig point cloud, denoising the pig point cloud by improving NLM (non-line model), namely, after shooting the pig by a depth camera, carrying out three-dimensional reconstruction by depth information to obtain pig point cloud data, and denoising the pig point cloud based on the improved NLM; Step 2, carrying out gesture recognition and phenotype key point recognition by using SwinT-SimCC, obtaining point cloud coordinates of the phenotype key point through coordinate conversion, and calculating corresponding phenotype parameters; Step 3, obtaining camera coordinates according to the identification result in the step 2, converting the camera coordinates into point cloud coordinates, and outputting the body ruler of the pig according to the point cloud coordinates; And step 4, inputting the body size data of the pigs obtained in the step 3, outputting the weight through an M3 model, and finally completing non-contact measurement of the weight of the live pigs. According to the technical scheme, the method for denoising the NLM point cloud in the step 1 comprises the following steps: the core formula of NLM is as follows: (1) (2) (3) In the formula, Is a dotDenoising the three-dimensional coordinate vector; Is a dot Is a three-dimensional coordinate vector of the original; Is a dot Is a candidate point set; Is a dot Point-to-pointSimilarity weights of (2); Is a dot Is a local descriptor of (2); is the filtering strength; Is the normalized coefficien