Training method of live pig key point detection model, body size measurement method and device

By performing key point annotation and geodesic distance calculation of the pig point cloud data, combined with Gaussian smooth mapping and PointNet++ network training, accurate detection of pig key points is achieved, and the problem of difficult to balance high precision, automation and efficiency in the existing technology is solved.

CN119919961APending Publication Date: 2025-05-02BEIJING RES CENT FOR INFORMATION TECH & AGRI
View PDF 0 Cites 4 Cited by

Patent Information

Application Number
CN202411811139.4
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-12-10
Publication Date
2025-05-02

AI Technical Summary

Technical Problem

In the prior art, it is difficult to balance the positioning of live pig key points and body rule measurement methods to achieve high accuracy, automation and efficiency, and there are problems of high cost, low accuracy and high computational complexity.

Method used

By marking the key point cloud data of the pig point cloud, the geodesic distance between each point and the manifold structure corresponding to multiple key points is calculated, and Gaussian smooth mapping is performed to obtain the key point heat map. Then, the target loss function is determined based on the key point heat map and mean square error loss function, and the PointNet++ network is regression training to obtain the pig key point detection model.

Benefits of technology

Accurate detection of key points of live pigs has been achieved, the efficiency and accuracy of key points of live pigs have been improved, and the problem of poor balance in the existing technology has been solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119919961A_ABST
    Figure CN119919961A_ABST
Patent Text Reader

Abstract

The invention provides a training method of a live pig key point detection model and a body size measurement method and device.The training method of the live pig key point detection model comprises the steps that key point labeling is conducted on live pig point cloud data, and multiple key points are obtained; calculating geodesic distances between each point in the live pig point cloud data and the manifold structures corresponding to the plurality of key points, and performing Gaussian smooth mapping on the plurality of geodesic distances to obtain a key point heat map; determining a target loss function based on the key point heat map and the mean square error loss function; and performing regression training on the PointNet + + network by taking the live pig point cloud data as a training sample and the target loss function as a training loss function to obtain a live pig key point detection model. According to the method, the surface morphology and space structure information of the point cloud are fully utilized, multiple features such as the position, the normal vector and the curvature are fused, accurate detection of the semantic key points is achieved, and the live pig key point detection efficiency and accuracy are improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of deep learning and body size information collection, and in particular to a training method for a pig key point detection model, and a body size measurement method and device. Background Art

[0002] The body size of livestock not only reflects their body shape, structure and development, but also reveals their physiological functions, production performance, disease resistance and adaptability to the external environment. Therefore, body size measurement has been widely used in livestock identification, breeding and sales.

[0003] With the continuous improvement of information perception technology and refined breeding level, the method of acquiring pig body size data is developing in the direction of non-contact, high precision and high automation; the automatic measurement of animal body size is highly dependent on the precise positioning of key points or areas in the point cloud. The position of body size key points is closely related to various parts of the body, so the specific position of these key points can be indirectly determined by determining the body parts.

[0004] In the related technologies, the method of attaching markers to animals and then searching for the positions of these markers in the three-dimensional point cloud increases labor costs and increases the risk of contact with animals; the method of locating animal key points based on three-dimensional vision has high requirements on animal posture and data integrity, and is easily affected by complex posture and data missing; the method of indirectly determining the position of key points by segmenting or fusing RGB images still needs to use local extreme value, clustering, curve fitting and other algorithms after segmentation, which has complex processes, high computational complexity and is time-consuming. These key point positioning and body size measurement methods have a poor balance between achieving complete high precision, automation and efficiency. Summary of the invention

[0005] The present invention provides a training method for a pig key point detection model, a body size measurement method and a device, so as to solve the defect of poor balance between key point positioning and body size measurement methods in the prior art in achieving complete high precision, automation and high efficiency, thereby improving the efficiency and accuracy of pig key point detection.

[0006] The present invention provides a training method for a pig key point detection model, comprising: Label the key points of the pig point cloud data to obtain multiple key points; Calculating the geodesic distance between each point in the pig point cloud data and the manifold structure corresponding to the multiple key points, and performing Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; the key point heat map is used to represent the association between each point in the pig point cloud data and the multiple key points; The target loss function is determined based on the key point heat map and the mean square error loss function; the PointNet++ network is regressed and trained using the live pig point cloud data as training samples and the target loss function as the training loss function, and a live pig key point detection model is obtained when the PointNet++ network converges; wherein each point in the live pig point cloud data includes a normal vector, at least one of the curvatures and spatial coordinate information.

[0007] According to a training method for a pig key point detection model provided by the present invention, the PointNet++ network includes an encoding module and a decoding module; The encoding module includes a plurality of set abstraction layers, each set abstraction layer includes a sampling module, a grouping module and a feature extraction module; The sampling module is used to select the centroid of a local area from the pig point cloud data; the grouping module is used to construct a local area based on the neighborhood points around the centroid; the feature extraction module is used to encode the information in the local area into multiple feature vectors, and fuse the multiple feature vectors through a weighted feature aggregation mechanism to obtain a global feature; The decoding module includes multiple feature propagation layers.

[0008] According to a training method for a pig key point detection model provided by the present invention, the geodesic distance between each point in the pig point cloud data and the manifold structures corresponding to the multiple key points is calculated, and the multiple geodesic distances are Gaussian smoothed to obtain a key point heat map, which includes: Performing popular learning based on the pig point cloud data to obtain the manifold structure; Calculate the geodesic distances between any point on the manifold structure and the multiple key points based on a heat map method; The geodesic distance on the manifold structure is mapped to a radial basis function based on a Gaussian kernel to obtain the key point heat map.

[0009] According to a training method for a pig key point detection model provided by the present invention, the target loss function includes: ; in, is the target loss function, is the number of points in the pig point cloud data, is the number of key points, is the first Point and The true value of the radial basis function of the geodesic distance map between key points, Represents the predicted value.

[0010] The present invention also provides a training method for a pig key point detection model, wherein the pig point cloud data is obtained by the following steps: In the case where at least three depth cameras with different viewing angles are installed in a pig breeding scene, a plurality of depth images of pigs are collected, wherein the pig breeding scene includes at least one pig, a railing, and the ground; The multiple live pig depth images are sequentially subjected to multi-view fusion, denoising, coordinate system transformation, ground segmentation, railing segmentation and normalization processes to obtain the live pig point cloud data.

[0011] The present invention also provides a method for measuring the body size of a pig, comprising: Obtain the point cloud data of the pigs to be tested; The pig point cloud data to be tested is processed based on the pig key point detection model to obtain the target key point position information; wherein the pig key point detection model is trained by the training method of the pig key point detection model; The target body size data of the live pig is calculated based on the obtained target key point position information; wherein the target body size data includes at least one of waist circumference, chest circumference, hip circumference, body height, body width and body length.

[0012] The present invention also provides a training device for a pig key point detection model, comprising: The key point labeling module is used to label the key points of the pig point cloud data and obtain multiple key points; A heat map calculation module, used to calculate the geodesic distance between each point in the pig point cloud data and the manifold structure corresponding to the multiple key points, and perform Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; the key point heat map is used to represent the association between each point in the pig point cloud data and the multiple key points; A training module is used to determine a target loss function based on the key point heat map and the mean square error loss function; the pig point cloud data is used as a training sample, and the target loss function is used as a training loss function to perform regression training on the PointNet++ network, and when the PointNet++ network converges, a pig key point detection model is obtained; wherein each point in the pig point cloud data includes a normal vector, at least one of the curvatures and spatial coordinate information.

[0013] The present invention also provides a body measurement device, comprising: Point cloud acquisition module, used to obtain point cloud data of the pigs to be tested; A key point recognition module is used to process the pig point cloud data to be tested based on a pig key point detection model to obtain target key point position information; wherein the pig key point detection model is trained by the training method of the pig key point detection model; The body size calculation module is used to calculate the target body size data of the pig based on the obtained target key point position information; wherein the target body size data includes at least one of waist circumference, chest circumference, hip circumference, body height, body width and body length.

[0014] The present invention also provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the training method for the key point detection model of live pigs or the body size measurement method as described above is implemented.

[0015] The present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a training method for a pig key point detection model or a body size measurement method as described in any one of the above.

[0016] The present invention also provides a computer program product, comprising a computer program, wherein when the computer program is executed by a processor, the training method of the key point detection model of live pigs or the body size measurement method as described above is implemented.

[0017] The training method, body size measurement method and device of the pig key point detection model provided by the present invention obtain multiple key points by labeling the key points of pig point cloud data, calculate the geodesic distance between each point in the pig point cloud data and the manifold structures corresponding to the multiple key points, and perform Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; finally, the PointNet++ network is regressed and trained by using the target loss function determined based on the key point heat map as the training loss function to obtain the pig key point detection model, which makes full use of the surface morphology and spatial structure information of the point cloud, and integrates multiple features such as position, normal vector, curvature, etc., to achieve accurate detection of semantic key points, thereby improving the efficiency and accuracy of pig key point detection. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions in the present invention or the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0019] Figure 1 It is one of the flow charts of the training method of the pig key point detection model provided by the present invention.

[0020] Figure 2 It is a schematic diagram of the marked positions of 8 key points of the pig point cloud provided by the present invention.

[0021] Figure 3It is a schematic diagram of a process for solving geodesic distance and a heat map of key points of a pig's tail based on a heat map method provided by the present invention.

[0022] Figure 4 It is a schematic diagram of a key point heat map of a pig point cloud provided by the present invention.

[0023] Figure 5 It is a flow chart of the weighted feature aggregation (WFA) mechanism provided by the present invention.

[0024] Figure 6 This is the second flow chart of the training method of the pig key point detection model provided by the present invention.

[0025] Figure 7 This is one of the flow charts of the body size measurement method provided by the present invention.

[0026] Figure 8 It is a schematic diagram of the interface of the pig abdominal girth slice provided by the present invention.

[0027] Fig. 9 It is a schematic diagram of the interface of pig chest and hip circumference slices provided by the present invention.

[0028] Fig.10 It is a schematic diagram of the interface of a wide slice of a pig body provided by the present invention.

[0029] Fig.11 It is a schematic diagram of the interface of the third-order B-spline curve fitting body length provided by the present invention.

[0030] Fig.12 This is the second flow chart of the body size measurement method provided by the present invention.

[0031] Fig.13 It is a structural schematic diagram of a training device for a pig key point detection model provided by the present invention.

[0032] Fig.14 It is a structural schematic diagram of the body size measuring device provided by the present invention.

[0033] Fig.15 It is a structural schematic diagram of the electronic device provided by the present invention. DETAILED DESCRIPTION

[0034] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0035] Combine the following Figure 1-Figure 10 The invention describes a training method for a pig key point detection model, a body size measurement method and a device.

[0036] Figure 1 This is one of the flow charts of the training method of the pig key point detection model provided by the present invention, such as Figure 1 As shown, the method comprises the following steps: Step 110: annotate the key points of the pig point cloud data to obtain a plurality of key points.

[0037] In this step, the experimental data comes from a pig farm. The point cloud acquisition equipment installed in the pig farm is an arch-type multi-depth camera device. When the pigs pass through the railing channel, the infrared device is triggered and the point cloud acquisition program is activated.

[0038] In this embodiment, 38 healthy fattening pigs were randomly selected for point cloud data collection. The weight of the pigs was mainly concentrated in the range of 30kg to 100kg, and in some cases the weight was greater than this range. The body length, height, chest circumference, abdominal circumference and hip circumference of each pig were obtained through manual measurement. 20 to 30 groups of point cloud data were collected for each pig, totaling 809 groups.

[0039] In this embodiment, pig point cloud data is acquired through the following steps: installing at least three depth cameras with different perspectives in a pig breeding scene, collecting multiple pig depth images, the pig breeding scene including at least one pig, a railing and the ground; performing multi-perspective fusion, denoising, coordinate system transformation, ground segmentation, railing segmentation and normalization on the multiple pig depth images in turn to obtain pig point cloud data.

[0040] Specifically, five depth cameras with different perspectives are installed in the pig farm to ensure that these perspectives can cover the entire pig farm, especially the activity area of ​​​​live pigs; before installation, each depth camera is calibrated to ensure that the data they collect can be accurately aligned in subsequent processing; when the pigs pass through the railing channel, all depth cameras are started, the infrared device is triggered and the point cloud acquisition program is activated to start collecting depth images of live pigs, railings and the ground.

[0041] In this embodiment, a synchronization signal is used to ensure that all cameras capture images at the same time point to reduce errors caused by time differences. Depth images from different perspectives are registered using methods such as feature point matching to align them in the same coordinate system. The registered depth images are then merged into a global depth map using weighted averaging or other fusion algorithms.

[0042] In this embodiment, after the depth map is acquired, a denoising algorithm such as a Gaussian filter or a median filter is used to remove noise points in the depth image; and an interpolation algorithm may be used to fill in the missing areas in the depth image.

[0043] In this embodiment, the completed depth image is converted to the same coordinate system for subsequent processing, and then the points in the depth image are converted to three-dimensional coordinates in the global coordinate system according to the position and posture of the camera.

[0044] Specifically, the coordinate system of the pig point cloud is set as follows: the z-axis is perpendicular to the ground, the x-axis is parallel to the railing channel, and the y-axis is parallel to the ground and perpendicular to the railing direction.

[0045] In this embodiment, after converting the points in the depth image into three-dimensional coordinates in the global coordinate system, the plane of the ground is fitted in the point cloud using algorithms such as random sampling consistency RANSAC, and the ground points are segmented from the point cloud based on the fitted plane, and the edges and contours of the railings are extracted using the geometric features of the point cloud (such as normals, curvatures, etc.); after completing the segmentation of the ground and railings, these irrelevant points are removed from the global point cloud to obtain point cloud data containing only pigs; finally, the retained pig point cloud data is scaled to a uniform scale range, and the point cloud data is aligned to a specific reference position to achieve normalization of the point cloud data.

[0046] Figure 2 It is a schematic diagram of the annotated positions of 8 key points of the pig point cloud provided by the present invention. Figure 2 In the embodiment shown, key points of the pig point cloud data are specifically annotated in the following manner: 8 different key points are annotated according to the body length, body height, chest circumference, abdominal circumference and hip circumference that need to be measured: : The midpoint of the ear root; : The point at the base of the tail; , : The junction of the back of the pig's front leg and abdomen; , : The junction of the front side of the pig's hind leg and the abdomen; : The highest point of the largest part of the abdomen; : Apex of scapula.

[0047] It should be noted that since manually labeled data may be affected by subjective factors and differences in pig posture, there may be slight deviations in the positioning of each key point. In order to minimize these differences, all labeling work in this embodiment is completed by the same person, and the key point labeling is performed using CloudCompare software. Eight key points are selected in sequence according to the serial number, and the results are saved as a CSV file, in which the row number of each row corresponds to the serial number of the key point.

[0048] Step 120, calculate the geodesic distance between each point in the pig point cloud data and the manifold structure corresponding to the multiple key points, and perform Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; the key point heat map is used to represent the association between each point in the pig point cloud data and the multiple key points.

[0049] In this step, the heat map method is used to calculate the geodesic distance on the manifold structure from each point in the pig point cloud data to multiple key points.

[0050] In this embodiment, the geodesic distance between each point in the pig point cloud data and the manifold structures corresponding to the multiple key points is calculated, and Gaussian smoothing mapping is performed on the multiple geodesic distances to obtain the key point heat map including: (1) Perform popular learning based on pig point cloud data to obtain the manifold structure.

[0051] In this embodiment, the pig point cloud manifold regards the pig point cloud data as a point set in a high-dimensional space and constructs a low-dimensional manifold structure on these point sets. The manifold structure can reflect the intrinsic characteristics and laws of the pig point cloud data.

[0052] In this embodiment, the method for constructing a pig point cloud manifold generally includes the steps of data preprocessing, feature extraction, manifold learning, etc.; first, the pig point cloud data is preprocessed by denoising, registration, segmentation, etc., and then the feature information of the point cloud data (such as shape features, texture features, etc.) is extracted from the preprocessed point cloud data; finally, the high-dimensional point cloud data is mapped to a low-dimensional space using manifold learning technology (such as ISOMAP, LLE, Laplace eigenmap, etc.) to construct the manifold structure of the pig point cloud.

[0053] (2) Based on the heat map method, the geodesic distance between any point on the manifold structure and multiple key points is calculated.

[0054] In this embodiment, the geodesic distance refers to the shortest path length between two points on a surface or manifold. The geodesic distance can characterize the geometric shape and curvature characteristics of the pig body surface or manifold, and reflects the actual geometric distance.

[0055] Specifically, the heat map method is used to calculate the first Point and The geodesic distance between key points ,in Indicates a OK A matrix of columns used to store all the points in the point cloud Points to The geodesic distance of the key points.

[0056] Figure 3 is a schematic diagram of a process for solving geodesic distance and heat map of key points of pig tail based on heat map method provided by the present invention, Figure 3 In the embodiment shown, the method of calculating the geodesic distance based on the heat map can be analogized by the heat conduction process: Figure 3 As shown in (a1) - (a4) in the figure, imagine that a hot needle touches a certain point on the manifold. As time goes by, the heat gradually diffuses from the high-temperature area to the low-temperature area. By calculating the temperature gradient and normalizing and negating the gradient, the unit vector field along the geodesic direction can be obtained. Finally, by recording the temperature changes of different points at a specific time, the manifold distance between the points can be estimated.

[0057] In this embodiment, the process of heat diffusion from the high temperature region to the low temperature region can be described by the heat kernel function To describe, From the source point In time Then transfer to the target point By transforming the heat kernel function point by point, any two points on the manifold can be restored and The geodesic distance between , Calculated by the following formula: .

[0058] In this embodiment, the calculation of geodesic distance on the point cloud is achieved by calculating the Laplacian operator on the data structure based on the heat map method.

[0059] For example, this embodiment uses clustered Laplace to calculate geodesic distance, which is more robust to noise data and is suitable for point clouds generated by depth cameras. The key point heat map of the pig point cloud calculated based on this method is as follows: Figure 3 As shown in (b).

[0060] (3) Map the geodesic distance on the manifold structure to the radial basis function based on the Gaussian kernel to obtain the key point heat map.

[0061] In this embodiment, the geodesic distance on the manifold structure is mapped to a radial basis function (RBF) with a Gaussian kernel to obtain a Gaussian distance, that is, a key point heat map, which is used to represent the probability of a point in the point cloud being a key point after the geodesic distance is converted by the Gaussian radial basis function. The key point heat map is expressed by the following formula: ; in, Control the clarity of annotations, The value of can be adjusted by the scale of the point cloud.

[0062] It should be noted that the value of RBF depends only on the geodesic distance on the manifold between the input point and the center point, and has nothing to do with the direction. Mapping geodesic distance to RBF has multiple uses: (1) Using geodesic distance may lead to discontinuity or non-smoothness in probability distribution, while RBF with Gaussian kernel can map slight changes in local distance to gradual changes in probability value; even if there are some discontinuities in the original distance, the exponential decay characteristics of RBF make these distances compressed to values ​​close to 0 at a distance, while small differences in the local range are smoothly amplified, so that the distribution of the entire space shows a certain smoothness; (2) The above mapping method simplifies the learning process and reduces the number of distances that need to be learned, that is, only the distance in the local area needs to be considered without considering the entire shape, and the geodesic distance in the local area is smoothly converted into a probability value, so that the closer the point is to the key point, the higher its probability value, thereby better capturing the positional relationship of the point in space.

[0063] Figure 4 is a schematic diagram of a key point heat map of a pig point cloud provided by the present invention. Figure 4 In the embodiment shown, the geodesic distance from each point in the pig point cloud data to the manifold of 8 annotated key points is calculated to obtain 8 distance vectors of size n, and then the probabilistic relationship between the distance and the key points is established through these distance vectors to predict the key points.

[0064] Step 130, determine the target loss function based on the key point heat map and the mean square error loss function; use the pig point cloud data as training samples, and use the target loss function as the training loss function to perform regression training on the PointNet++ network, and when the PointNet++ network converges, obtain the pig key point detection model; wherein each point in the pig point cloud data includes a normal vector, at least one of the curvatures and spatial coordinate information.

[0065] It should be noted that the perception of key points in the spatial information of live pig point clouds relies on the representation of 3D data. Since point cloud data essentially only contains spatial coordinate information, if more geometric features can be provided to the network model to help the model better distinguish the possibility of each point as a key point, its accuracy is expected to be significantly improved.

[0066] In this embodiment, the input features of the model are enhanced by adding normal vectors and curvature to the point cloud data, that is, each point in the pig point cloud data has three types of feature information: spatial coordinates, normal vectors and curvature; this is specifically achieved through the following steps: (1) In order to calculate the normal vector and curvature of each point, it is necessary to first find the nearest neighbor point set for each point in the point cloud.

[0067] Specifically, select The nearest neighbor points constitute the local neighborhood of the point, and then the principal component analysis (PCA) of the point set in the neighborhood is performed to evaluate the geometric structure of the area; in the PCA process, the covariance matrix of the neighboring points , calculated by the following formula: ; in, is each point in the neighborhood, is the centroid of the neighborhood.

[0068] (2) By the covariance matrix Perform eigenvalue decomposition and obtain three eigenvalues and its corresponding eigenvector.

[0069] In this embodiment, since the minimum eigenvalue describes the change in the local area perpendicular to the local surface, that is, the normal vector of the point, the minimum eigenvalue can be found by The corresponding eigenvector determines the normal vector.

[0070] In this embodiment, the curvature is defined as the ratio of the minimum eigenvalue to the sum of all three eigenvalues. The curvature can be estimated by the eigenvalues. This method effectively captures the changes in the local geometric structure. Finally, the original The pig point cloud is enhanced to generate information including the coordinates, normal vectors and curvature of the points. Point cloud, this feature enhancement provides richer local feature information for subsequent geometric analysis and shape description.

[0071] In this embodiment, given Source data with 7 attributes, including coordinates , normal vector and curvature; the source data is used as the input of the PointNet++ network, and the PointNet++ network outputs a matrix, each column of which represents the probability distribution of each point as the corresponding key point; the input and output can be expressed as The input matrix and The output matrix The mapping between , this embodiment uses the mapping relationship to implement the modeling of the encoder-decoder architecture of PointNet++.

[0072] In this embodiment, during the PointNet++ network training phase, a standard mean square error (MSE) loss function is used for supervision. The loss function is used to penalize the deviation between the predicted value of each layer of the decoder and the true value.

[0073] Specifically, the objective loss function includes: ; in, is the target loss function, is the number of points in the pig point cloud data, is the number of key points, The manifold structure Point and The true value of the radial basis function of the geodesic distance map between key points, Represents the predicted value, which is the key point heat map mentioned above.

[0074] In this embodiment, the source data with multiple attributes is used as the input feature of the PointNet++ network, and the target loss function is used as the target loss function. Calculate the loss value of the PointNet++ network in the current iteration, compare it with the loss value threshold (which can be set according to user needs), and then update the network parameters. When the loss value of the current iteration is less than the loss value threshold or the network reaches the maximum number of iterations, a usable pig key point detection model is obtained.

[0075] The training method of the pig key point detection model provided by the embodiment of the present invention obtains multiple key points by labeling the key points of the pig point cloud data, calculates the geodesic distance between each point in the pig point cloud data and the manifold structure corresponding to the multiple key points, and performs Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; finally, the PointNet++ network is regressed and trained using the target loss function determined based on the key point heat map as the training loss function to obtain the pig key point detection model, which makes full use of the surface morphology and spatial structure information of the point cloud, and integrates multiple features such as position, normal vector, curvature, etc., to achieve accurate detection of semantic key points, thereby improving the efficiency and accuracy of pig key point detection.

[0076] In some embodiments, the PointNet++ network includes an encoding module and a decoding module; the encoding module includes multiple set abstraction layers, each set abstraction layer includes a sampling module, a grouping module and a feature extraction module; the sampling module is used to select the centroid of a local area from the pig point cloud data; the grouping module is used to construct a local area based on the neighborhood points around the centroid; the feature extraction module is used to encode the information in the local area into multiple feature vectors, and fuse the multiple feature vectors through a weighted feature aggregation mechanism to obtain a global feature; the decoding module includes multiple feature propagation layers.

[0077] In this embodiment, the encoding module includes four set abstraction layers (SA), each of which is used to recursively extract multi-scale features of the input point cloud.

[0078] In this embodiment, the sampling module in each set abstraction layer selects a group of points as the centroid of the local area through an iterative farthest point sampling (FPS) algorithm, and uses the grouping module to search for neighborhood points around the centroid through a ball query algorithm to construct the corresponding local area. Finally, the feature extraction module is used to encode the information of these local areas into feature vectors, and recursively extract and aggregate features to obtain global features.

[0079] In this embodiment, the feature extraction layer of the encoding module better balances the fusion of multiple useful information in the local area through the weighted feature aggregation (WFA) mechanism, and retains the pig body point cloud features that are more important for locating key points.

[0080] In this embodiment, it is assumed that is the number of input points, and the set of sampling points is , each sampling point The neighborhood point set of Each neighborhood point Has the features vector extracted from the previous layer , where the coordinate dimension is , the feature dimension is ; When the input of the feature extraction layer is , extract each neighborhood point by of new Dimensional Features : ; in, Represents the coordinate difference between the neighborhood point and the sampling point, that is, in each spherical neighborhood, the coordinates of the point are standardized relative to the center point; extract features These features are then aggregated into global features of the local area.

[0081] Figure 5 is a flow chart of the weighted feature aggregation (WFA) mechanism provided by the present invention. Figure 5 In the embodiment shown, the weighted feature aggregation (WFA) mechanism used includes: selecting the centroid of the local area from the pig point cloud data through the sampling module (Subsample) and the grouping module (Grouping) of the encoder of the PointNet++ network, and constructing the local area according to the neighborhood points around the centroid, and then calculating the feature weight (Weight) of each encoded feature in the local area, and performing weighted summation on each feature; specifically, using each point in the local area through the multi-layer perceptron MLP Coordinates and features learned Come learn with Weight vectors of the same dimension : ; in, Represents all features in the area The average value of is the summation symbol.

[0082] In this embodiment, the global features of the local area By point feature and weight vector Obtained through the following aggregation method: ; in, It is calculated by the Hadamard product of the weight vector and the point feature. It is a weighted sum operation.

[0083] The weighted feature aggregation method used in this embodiment weights each point feature according to its contribution to the global feature, and retains features that are more useful for key point detection.

[0084] In this embodiment, the decoding module includes four feature propagation layers (FP) for gradually recovering the semantically rich feature representation of the hog point cloud.

[0085] Figure 6 This is the second flow chart of the training method of the pig key point detection model provided by the present invention. Figure 6In the illustrated embodiment, the encoding module of the PointNet++ network includes four set abstraction layers (SA1-4), each of which includes a sampling module (Subsample), a grouping module (Grouping) and a feature extraction module (Feature extraction); the decoding module includes four feature propagation layers (FP1-4), each of which includes an interpolation module (Interpolate) and a UnitPointNet module; the input of the PointNet++ network is pig point cloud data with 7-dimensional features, and the sampling module is used to select the centroid of the local area from the pig point cloud data, and the grouping module is used to construct the local area according to the neighborhood points around the centroid; the feature extraction module is used to encode the information in the local area into multiple feature vectors, and the multiple feature vectors are fused through a weighted feature aggregation mechanism to obtain global features; the interpolation module (for example, the inverse distance weighted interpolation module) is used to perform feature propagation in the feature propagation module (FP), the interpolated points are spliced ​​with the features extracted from the set abstraction module (SA) through jump connections, and then the Unit PointNet module is used to process the features of the point cloud point by point; finally, the decoding module reduces the aggregated features to 8 dimensions through four FP layers Dimension, indicating the probability of each point being one of the eight key points; then the target loss function is constructed by combining the key point heat map calculated based on the heat map. L MSE , and with the L MSE The PointNet++ network is iteratively trained to obtain the pig key point detection model.

[0086] Specifically, let the key point be (in is the identifier of the key point, ), each dimension is (in ); It can be determined by the following formula: ; in, For the predicted Key points, For the Dimensions at point The probability value at ; For the dimensions, find The smallest point , for each dimension , select the point with the largest probability value on this dimension as the key point for prediction .

[0087] The training method of the pig key point detection model provided by the embodiment of the present invention includes an encoding module and a decoding module by setting a PointNet++ network; the encoding module includes multiple set abstraction layers, each set abstraction layer includes a sampling module, a grouping module and a feature extraction module; the decoding module includes multiple feature propagation layers, which can better retain important point cloud features useful for key point detection, so as to improve the prediction accuracy of the pig key point detection model.

[0088] In some embodiments, the performance of the pig key point detection model is evaluated by calculating the average RMSE of multiple key points.

[0089] Specifically, the keypoint coordinates output by the pig keypoint detection model are compared with the real keypoints marked by human scorers, and the root mean square error (RMSE) of the Euclidean distance of each type of keypoint is calculated by the following formula: ; Among them, The key point of the class is The predicted coordinates of an instance are , No. The key point of the class is The real coordinates of the instance are , is the total number of instances in the point cloud; the smaller the RMSE, the more accurate the model prediction results.

[0090] In this embodiment, the average of eight key points is calculated by the following formula: ,Right now : .

[0091] The following is a description of the pig body size measurement method provided by the present invention. The pig body size measurement method described below and the pig key point detection model training method described above can be referenced to each other.

[0092] Figure 7 FIG. 1 is one of the flow charts of the body measurement method provided by the present invention, such as Figure 7 As shown, the method for measuring the body size of pigs comprises the following steps: Step 710: Obtain the point cloud data of the pig to be tested.

[0093] In this step, the point cloud data of the pig to be tested can be obtained by extracting the depth image of the pig to be tested; for example, a plurality of depth images of the pig to be tested are sequentially subjected to multi-perspective fusion, denoising, coordinate system transformation, ground segmentation, railing segmentation and normalization processing to obtain the point cloud data of the pig to be tested.

[0094] In this embodiment, the depth image of the live pig to be tested may be captured in real time or acquired from a public database.

[0095] Step 720: Process the pig point cloud data to be tested based on the pig key point detection model to obtain the target key point position information; wherein the pig key point detection model is trained by the pig key point detection model training method.

[0096] In this step, the pig key point detection model is trained through the following steps: (1) Label the key points of pig point cloud data to obtain multiple key points; (2) Calculate the geodesic distance between each point in the pig point cloud data and the corresponding manifold structure of multiple key points, and perform Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; the key point heat map is used to represent the association between each point in the pig point cloud data and multiple key points; (3) Map the geodesic distance on the manifold structure to the radial basis function based on the Gaussian kernel to obtain the key point heat map.

[0097] In this embodiment, the implementation of steps (1) to (3) corresponds one-to-one to the above-mentioned embodiment of steps 110 to 130, and will not be described in detail in this embodiment.

[0098] In this embodiment, the performance of the pig key point detection model is evaluated by calculating the average RMSE of multiple key points, which will not be described in detail in this embodiment.

[0099] Step 730: Calculate the target body size data of the live pig based on the obtained target key point position information; wherein the target body size data includes at least one of waist circumference, chest circumference, hip circumference, body height, body width and body length.

[0100] In this embodiment, after obtaining the position information of the target key points, body size measurement can be performed according to the positions of these key points.

[0101] The following is an example of measuring six types of body measurements: abdominal circumference (AC), chest circumference (TC), hip circumference (RC), body height (BH), body width (BW) and body length (BL).

[0102] (1) In this embodiment, abdominal circumference is determined by measuring around the largest part of the pig's abdomen.

[0103] Figure 8 is a schematic diagram of the interface of the pig abdominal girth slice provided by the present invention, Figure 8 In the embodiment shown, Figure 8 In (a), at point At, along with 2 cm sections were made in the direction parallel to the plane; Figure 8 In (b), the farthest point sampling (FPS) is performed on the point cloud in the slice to reduce the number of point clouds and make their distribution more uniform; Figure 8 In (c), the nearest neighbor algorithm is used to connect the edges. Starting from a point, the nearest unvisited point is selected as the next point, and this process is repeated until all points are visited. Each edge connects adjacent points in the path, and the last edge connects the last point of the path to the first point, thus forming a closed loop. The Euclidean distance of each edge (i.e., the length of the edge) is then calculated, and the lengths of all edges are accumulated to obtain an estimate of the waist circumference.

[0104] Specifically, represents the set of abdominal circumference sampling points, where Indicates the number of abdominal circumference sampling points, Indicates The coordinate vector of the sampling points; the order of the points in the above path is ,in Indicates path points, the last point of the path With the first point The Euclidean distance between For closed path; the calculation formula of abdominal circumference is: ; (2) In this embodiment, a circular measurement is performed around the pig's body from the junction of the back of the front legs and the abdomen to determine the chest circumference. In order to eliminate the influence of the leg point cloud on the chest circumference calculation, the leg point cloud needs to be removed.

[0105] Fig. 9 is a schematic diagram of the interface of the pig chest and hip circumference slices provided by the present invention, Fig. 9 In the embodiment shown, in the abdominal circumference slice, the lowest point position is selected , and in , , , , Among these five points, choose The point with the smallest value, through which a line parallel to Slice the plane and remove the point cloud below the slice, leaving only the torso.

[0106] It should be noted that the chest area is directly parallel to The planar slice may cause positional deviation, which is due to the possible bending of the pig's trunk. In order to solve this problem, the present embodiment adopts a method for measuring the chest circumference based on two key points at the rear of the front legs.

[0107] Specifically, in and Parallel to This ensures the accuracy of the chest measurement position because the posterior leg point will change in the same direction as the torso bends.

[0108] In this embodiment, it is assumed that Represents a set of chest sampling points. The order of points in the path is ,in Indicates path points; the calculation formula for chest circumference is as follows: .

[0109] (3) This example starts from the junction of the front of the hind leg and the abdomen and goes around the pig's body in a circle to determine the hip circumference.

[0110] exist Fig. 9 In the embodiment shown, similar to the calculation method of chest circumference, on the basis of removing the pig leg point cloud, and Parallel to axial 2 cm sectioning plane.

[0111] Specifically, Represents a set of hip sampling points. The order of points in the path is ,in Indicates path points; the calculation formula for hip circumference is as follows: .

[0112] (4) This embodiment calculates the vertical distance from the apex of the shoulder blade to the ground to determine the body height.

[0113] In this embodiment, it is assumed that Represents the Qijia point, and the height is of Value minus the ground Value; In this embodiment, the ground is defined as Plane, then of The value directly represents the body height; the body height calculation formula is as follows: .

[0114] (5) In this embodiment, the body width is determined by measuring the width of the widest part of the shoulder blade.

[0115] Fig.10 is a schematic diagram of the interface of a wide slice of a pig provided by the present invention, Fig.10In the embodiment shown, similar to the calculation of the mid-bust circumference, this embodiment uses the point cloud after removing the legs. Parallel to the vector The slice where is flat; let the vector exist The unit vector of the plane projection is , in this slice plane, the point cloud is along The maximum length covered in the direction is the body width; the calculation formula of the body width is as follows: ; in, is a point in a point cloud slice, is the number of slice points, for or The calculation result is not affected by the selected point. Indicate point In the direction The projection value on .

[0116] (6) Body length: In this embodiment, the midpoint of the ear root and the tail root of the pig are first determined, and then the midpoint of the ear root and the tail root are used as endpoints to calculate the body length of the pig along the spine.

[0117] Fig.11 is a schematic diagram of the interface of the third-order B-spline curve fitting body length provided by the present invention. Fig.11 In the embodiment shown, let vector exist The unit vector of the component in the plane direction is ,Pass and Draw a 2 cm line perpendicular to the midpoint The slice plane is the point with the largest z value in the slice point cloud. ; Let vector exist The unit vector of the component in the plane direction is ,Pass and Draw a 2 cm line perpendicular to the midpoint The slice plane is the point with the largest z value in the slice point cloud. ; Let vector exist The unit vector of the component in the plane direction is ,Pass and Draw a 2 cm line perpendicular to the midpoint The slice plane is the point with the largest z value in the slice point cloud. , there are 7 key points in three-dimensional space (Right now ); The B-spline curve can be expressed as: ; in, It is The third-order B-spline basis function of the control points; variable t Is a control parameter used to determine the position of each point on the B-spline curve. is the number of sampling points on the curve, then the body length It is expressed as: .

[0118] The body size measurement method provided by the embodiment of the present invention processes the point cloud data of the pig to be measured through the pig key point detection model to obtain the target key point position information, and then calculates at least one body size data of the pig's waist circumference, chest circumference, hip circumference, body height, body width and body length based on the obtained target key point position information, thereby improving the accuracy and efficiency of the pig's body size measurement.

[0119] In some embodiments, in the measurement of pig body size, the predicted results of the point cloud data are compared with the actual values ​​of manual measurement to evaluate the prediction accuracy of the model; in order to quantify the accuracy, this embodiment evaluates the accuracy of the pig body size prediction results by calculating the mean absolute error (MAE) and the mean absolute percentage error (MAPE).

[0120] Specifically, MAE reflects the average deviation between each prediction and the manual measurement value. The smaller the value, the more accurate the model's prediction. MAE is calculated by the following formula: ; MAPE expresses the error as a percentage of the true value. MAPE provides a scale-independent error metric and is suitable for comparing data in different measurement ranges. MAPE is calculated using the following formula: .

[0121] in, is the total number of point cloud samples, is the body size value predicted by the point cloud, It is the body size value measured manually.

[0122] It should be noted that, in this embodiment, 809 groups of pig point cloud data with key point labels are divided into three different sets, including 649 groups of training sets, 80 groups of validation sets and 80 groups of test sets; before training the point cloud key point detection model, the point cloud data of the pig is normalized, and the farthest point sampling (FPS) is 10,000 points, which are input into the point cloud key point detection model based on the heat map proposed in this paper for training, parameter adjustment is performed in the validation set, and model evaluation is performed on the test set; the model parameters with the best key point detection effect in the test set are saved and used for the pig point cloud data that needs to measure body size.

[0123] In this embodiment, the system environment of the experimental training model is: Intel Xeon Platinum 8375C CPU of Intel Corporation (Santa Clara, USA), NVIDIA RTX A6000 GPU of NVIDIA Corporation (Santa Clara, USA), equipped with 48GB video memory, deep learning framework is Pytorch 1.10.1, and Cuda 11.3 is used.

[0124] In this embodiment, the learning rate of the model is set to 0.001, and the epoch is set to 100. During the training process, as the number of training times increases, the training loss drops to a lower value and tends to be stable, and the verification loss also tends to be stable in the end, and there is no rising overfitting phenomenon.

[0125] It should be noted that this embodiment mainly calculates six types of conventional body size parameters of live pigs, but the body size measurement method provided in this embodiment is not limited to these body size parameters, and has strong scalability and can be extended to more body size measurement parameters; for example, the parameter of the forelimb tube circumference (i.e., the circumference of the thinnest part of the left forelimb tube) can be achieved by adding key points of this part; in addition, there is no unified standard for the definition of live pig body size parameters, and they can be adjusted as needed in specific applications. For example, the body width can also be subdivided into front body width, middle body width and rear body width, while the body height can be divided into front body height and rear body height. This measurement method requires adjustment of the corresponding body size calculation method or key points, where the definitions of the front body width and front body height are the same as the body width in this article, and the middle body width can be obtained by measuring the key points of the abdominal circumference. Calculation; the calculation of the rear body width and rear body height requires adding the key point of the highest point of the hips.

[0126] It should be noted that the training method of the pig key point detection model or the body size measurement method provided in this embodiment converts the problem of extracting semantic key points of point clouds into geodesic distance regression on radial basis functions (RBFs), adds a weighted feature aggregation (WFA) mechanism to the encoder feature extraction layer of PointNet++, and retains the pig point cloud features that are more important for locating key points. The pig key point detection model outputs the probability value of each point as each type of key point; this key point detection technology can efficiently and contactlessly obtain the key body size parameters of pigs, and provides data support for individual health monitoring, feed management, weight estimation, etc. in the breeding process; in addition, considering the potential application in the field of precision animal husbandry, the detection objects of the above method include but are not limited to pigs, cattle, sheep, horses and other similar quadrupeds.

[0127] Fig.12 This is the second flow chart of the body measurement method provided by the present invention. Fig.12 In the illustrated embodiment, a body size measurement method includes the following steps: point cloud collection, key point collection, body size measurement, and entering body size measurement data into a database.

[0128] The training device for the pig key point detection model provided by the present invention is described below. The training device for the pig key point detection model described below and the training method for the pig key point detection model described above can refer to each other.

[0129] Fig.13 : is a structural schematic diagram of a training device for a pig key point detection model provided by the present invention, such as Fig.13 As shown, the training device of the pig key point detection model includes: a key point labeling module 1310, a heat map calculation module 1320 and a training module 1330.

[0130] The key point marking module 1310 is used to mark the key points of the pig point cloud data to obtain multiple key points; The heat map calculation module 1320 is used to calculate the geodesic distance between each point in the pig point cloud data and the manifold structure corresponding to the multiple key points, and perform Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; the key point heat map is used to represent the association between each point in the pig point cloud data and the multiple key points; The training module 1330 is used to determine the target loss function based on the key point heat map and the mean square error loss function; the live pig point cloud data is used as the training sample, and the target loss function is used as the training loss function to perform regression training on the PointNet++ network, and when the PointNet++ network converges, a live pig key point detection model is obtained; wherein each point in the live pig point cloud data includes a normal vector, at least one of the curvatures and spatial coordinate information.

[0131] The training device of the pig key point detection model provided by the embodiment of the present invention obtains multiple key points by labeling the key points of the pig point cloud data, calculates the geodesic distance between each point in the pig point cloud data and the manifold structure corresponding to the multiple key points, and performs Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; finally, the PointNet++ network is regressed and trained using the target loss function determined based on the key point heat map as the training loss function to obtain the pig key point detection model, which makes full use of the surface morphology and spatial structure information of the point cloud, and integrates multiple features such as position, normal vector, curvature, etc., to achieve accurate detection of semantic key points, thereby improving the efficiency and accuracy of pig key point detection.

[0132] The body size measurement device provided by the present invention is described below. The body size measurement device described below and the body size measurement method described above can be referred to each other.

[0133] Fig.14 is a flow chart of the body size measurement method provided by the present invention, such as Fig.14 As shown, the body measurement device comprises: Point cloud acquisition module 1410, used to acquire point cloud data of the pig to be tested; The key point recognition module 1420 is used to process the pig point cloud data to be tested based on the pig key point detection model to obtain the target key point position information; wherein the pig key point detection model is trained by the training method of the pig key point detection model; The body size calculation module 1430 is used to calculate the target body size data of the pig based on the target key point position information; wherein the target body size data includes at least one of the waist circumference, chest circumference, hip circumference, body height, body width and body length.

[0134] The body size measurement device provided in the embodiment of the present invention processes the point cloud data of the pig to be measured through the pig key point detection model to obtain the target key point position information, and then calculates at least one body size data of the pig's waist circumference, chest circumference, hip circumference, body height, body width and body length based on the obtained target key point position information, thereby improving the accuracy and efficiency of the pig's body size measurement.

[0135] Fig.15 is a schematic diagram of the structure of the electronic device provided by the present invention, such as Fig.15As shown, the electronic device may include: a processor (processor) 1510 , a communication interface (Communications Interface) 1520 , a memory (memory) 1530 and a communication bus 1540 , wherein the processor 1510 , the communication interface 1520 , and the memory 1530 communicate with each other through the communication bus 1540 . The processor 1510 can call the logic instructions in the memory 1530 to execute the training method of the pig key point detection model, which includes: marking the key points of the pig point cloud data to obtain multiple key points; calculating the geodesic distance between each point in the pig point cloud data and the manifold structure corresponding to the multiple key points, and performing Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; the key point heat map is used to represent the association between each point in the pig point cloud data and the multiple key points; determining the target loss function based on the key point heat map and the mean square error loss function; using the pig point cloud data as a training sample and the target loss function as the training loss function to perform regression training on the PointNet++ network, and obtaining the pig key point detection model when the PointNet++ network converges; wherein each point in the pig point cloud data includes at least one of the normal vector and curvature and spatial coordinate information.

[0136] Or a body size measurement method is executed, the method comprising: obtaining point cloud data of a live pig to be measured; processing the point cloud data of the live pig to be measured based on a live pig key point detection model to obtain target key point position information; wherein the live pig key point detection model is trained by a live pig key point detection model training method; and calculating target body size data of the live pig based on the obtained target key point position information; wherein the target body size data comprises at least one of waist circumference, chest circumference, hip circumference, body height, body width and body length.

[0137] In addition, the logic instructions in the above-mentioned memory 1530 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc. Various media that can store program codes.

[0138] On the other hand, the present invention also provides a computer program product, which includes a computer program, which can be stored on a non-transitory computer-readable storage medium. When the computer program is executed by a processor, the computer can execute the training method of the pig key point detection model provided by the above methods, the method including: marking key points of pig point cloud data to obtain multiple key points; calculating the geodesic distance between each point in the pig point cloud data and the manifold structure corresponding to the multiple key points, and performing Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; the key point heat map is used to represent the association between each point in the pig point cloud data and the multiple key points; determining the target loss function based on the key point heat map and the mean square error loss function; using the pig point cloud data as a training sample and the target loss function as the training loss function to perform regression training on the PointNet++ network, and obtaining the pig key point detection model when the PointNet++ network converges; wherein each point in the pig point cloud data includes at least one of a normal vector and a curvature and spatial coordinate information.

[0139] Or a body size measurement method is executed, the method comprising: obtaining point cloud data of a live pig to be measured; processing the point cloud data of the live pig to be measured based on a live pig key point detection model to obtain target key point position information; wherein the live pig key point detection model is trained by a live pig key point detection model training method; and calculating target body size data of the live pig based on the obtained target key point position information; wherein the target body size data comprises at least one of waist circumference, chest circumference, hip circumference, body height, body width and body length.

[0140] On the other hand, the present invention also provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a training method for a pig key point detection model provided by the above methods, the method comprising: marking key points of pig point cloud data to obtain multiple key points; calculating the geodesic distance between each point in the pig point cloud data and the manifold structure corresponding to the multiple key points, and performing Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; the key point heat map is used to represent the association between each point in the pig point cloud data and the multiple key points; determining the target loss function based on the key point heat map and the mean square error loss function; using the pig point cloud data as training samples and the target loss function as the training loss function to perform regression training on the PointNet++ network, and obtaining a pig key point detection model when the PointNet++ network converges; wherein each point in the pig point cloud data includes at least one of a normal vector and a curvature and spatial coordinate information.

[0141] Or a body size measurement method is executed, the method comprising: obtaining point cloud data of a live pig to be measured; processing the point cloud data of the live pig to be measured based on a live pig key point detection model to obtain target key point position information; wherein the live pig key point detection model is trained by a live pig key point detection model training method; and calculating target body size data of the live pig based on the obtained target key point position information; wherein the target body size data comprises at least one of waist circumference, chest circumference, hip circumference, body height, body width and body length.

[0142] The device embodiments described above are merely illustrative, wherein the units described as separate components may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the scheme of this embodiment. Ordinary technicians in this field can understand and implement it without paying creative labor.

[0143] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.

[0144] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A training method for a pig key point detection model, characterized in that: include: Label the key points of the pig point cloud data to obtain multiple key points; Calculating the geodesic distance between each point in the pig point cloud data and the manifold structures corresponding to the multiple key points, and performing Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; The key point heat map is used to represent the association between each point in the pig point cloud data and the multiple key points; Determine a target loss function based on the key point heat map and the mean square error loss function; The pig point cloud data is used as a training sample, and the target loss function is used as a training loss function to perform regression training on the PointNet++ network. When the PointNet++ network converges, a pig key point detection model is obtained; wherein each point in the pig point cloud data includes a normal vector, at least one of the curvatures, and spatial coordinate information.

2. The training method of the pig key point detection model according to claim 1 is characterized in that: The PointNet++ network includes an encoding module and a decoding module; The encoding module includes a plurality of set abstraction layers, each set abstraction layer includes a sampling module, a grouping module and a feature extraction module; The sampling module is used to select the centroid of a local area from the pig point cloud data; the grouping module is used to construct a local area based on the neighborhood points around the centroid; the feature extraction module is used to encode the information in the local area into multiple feature vectors, and fuse the multiple feature vectors through a weighted feature aggregation mechanism to obtain a global feature; The decoding module includes multiple feature propagation layers.

3. The training method of the pig key point detection model according to claim 1 is characterized in that: The step of calculating the geodesic distance between each point in the pig point cloud data and the manifold structures corresponding to the multiple key points, and performing Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map includes: Performing popular learning based on the pig point cloud data to obtain the manifold structure; Calculate the geodesic distances between any point on the manifold structure and the multiple key points based on a heat map method; The geodesic distance on the manifold structure is mapped to a radial basis function based on a Gaussian kernel to obtain the key point heat map.

4. The training method of the pig key point detection model according to claim 1 is characterized in that: The objective loss function includes: ; in, is the target loss function, is the number of points in the pig point cloud data, is the number of key points, is the first Point and The true value of the radial basis function of the geodesic distance map between key points, Represents the predicted value.

5. The training method of the pig key point detection model according to claim 1, characterized in that: The pig point cloud data is obtained through the following steps: In the case where at least three depth cameras with different viewing angles are installed in a pig breeding scene, a plurality of depth images of pigs are collected, wherein the pig breeding scene includes at least one pig, a railing, and the ground; The multiple live pig depth images are sequentially subjected to multi-view fusion, denoising, coordinate system transformation, ground segmentation, railing segmentation and normalization processes to obtain the live pig point cloud data.

6. A method for measuring the body size of a pig, characterized in that: include: Obtain the point cloud data of the pigs to be tested; The pig point cloud data to be tested is processed based on the pig key point detection model to obtain the target key point position information; wherein the pig key point detection model is trained by the training method of the pig key point detection model according to any one of claims 1 to 5; The target body size data of the live pig is calculated based on the obtained target key point position information; wherein the target body size data includes at least one of waist circumference, chest circumference, hip circumference, body height, body width and body length.

7. A training device for a pig key point detection model, characterized in that: include: The key point labeling module is used to label the key points of the pig point cloud data and obtain multiple key points; A heat map calculation module, used to calculate the geodesic distance between each point in the pig point cloud data and the manifold structures corresponding to the multiple key points, and perform Gaussian smoothing mapping on the multiple geodesic distances to obtain a key point heat map; The key point heat map is used to represent the association between each point in the pig point cloud data and the multiple key points; A training module, used for determining a target loss function based on the key point heat map and the mean square error loss function; The pig point cloud data is used as a training sample, and the target loss function is used as a training loss function to perform regression training on the PointNet++ network. When the PointNet++ network converges, a pig key point detection model is obtained; wherein each point in the pig point cloud data includes a normal vector, at least one of the curvatures, and spatial coordinate information.

8. A body measurement device, characterized in that: include: Point cloud acquisition module, used to obtain point cloud data of the pigs to be tested; A key point recognition module, used for processing the pig point cloud data to be tested based on a pig key point detection model to obtain target key point position information; wherein the pig key point detection model is trained by the training method of the pig key point detection model according to any one of claims 1 to 5; The body size calculation module is used to calculate the target body size data of the pig based on the obtained target key point position information; wherein the target body size data includes at least one of waist circumference, chest circumference, hip circumference, body height, body width and body length.

9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 6 is implemented.

10. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 6 is implemented.

Citation Information

Cited By

  • Non-contact in-vivo pig eye muscle area determination method based on point cloud and deep learning

    CN120807615A

  • Pig weight estimation method, device, equipment, medium and computer program product

    CN121033260A

  • Pig weight estimation method, apparatus, device, medium, and computer program product

    CN121033260B

  • Livestock segmentation method based on multi-view point cloud reconstruction and segmentation network model improvement

    CN121120663A