Cow weight rapid measurement system based on overlooking two-dimensional point cloud
Through a fast cow weight measurement system based on a two-dimensional point cloud overhead viewing, machine learning and convolutional neural networks are used to identify key points of cow's back characteristics, calculate body rule information and predict weight, the problems of complex operation, long measurement time and low accuracy in the existing technology are solved, and efficient and accurate cow weight measurement is achieved.
Patent Information
- Application Number
- CN202411687133.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-25
- Publication Date
- 2025-03-14
AI Technical Summary
The existing methods of dairy cow weight measurement have problems such as complex operation, long measurement time and low measurement accuracy, especially in large-scale ranches.
A cow weight rapid measurement system based on a two-dimensional point cloud is adopted. The system includes a preprocessing module, a feature extraction module, a body ruler calculation module and a weight prediction module. Through machine learning and convolutional neural network, a key body ruler information is calculated and the weight is predicted.
It significantly saves time and labor costs, improves measurement efficiency and accuracy, reduces stress response to dairy cows, and meets the high requirements for accuracy in modern breeding industry.
Smart Images

Figure CN119625782A_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of rapid measurement of dairy cow weight. Background Art
[0002] In the dairy farming industry, cow weight is a key indicator for assessing health status and production capacity, and accurate and rapid weight assessment is essential for optimizing management. However, traditional contact measurement methods are not only time-consuming and labor-intensive, but may also trigger stress responses in dairy cows, which in turn affects their health and productivity. Although non-contact measurement methods have gradually gained attention in recent years, existing technologies still face problems such as high complexity, strict equipment requirements, and insufficient prediction accuracy, which limits their application in large-scale ranches. Therefore, it is urgent to explore new solutions to improve the efficiency and accuracy of weight measurement to meet the needs of modern farming.
[0003] Using artificial intelligence, computer vision and 3D reconstruction technology to predict cow weight can improve prediction accuracy and reduce stress responses to cows. Although existing methods have made some progress in non-contact weight prediction, there are still significant defects. Many technologies rely on complex 3D reconstruction and point cloud completion, which increases the complexity of data processing and has high requirements for the installation environment of hardware equipment, limiting their application in large-scale pastures. In addition, the prediction accuracy of these methods is often insufficient, the absolute error range is large, and it is difficult to meet the accuracy requirements of modern breeding industry. At the same time, many technologies need to collect point cloud data from multiple perspectives, which is complicated to operate and takes a long time to process, increasing labor costs and reducing measurement efficiency. Therefore, there is an urgent need for a novel and simplified data processing method to improve the efficiency and accuracy of measurement. Summary of the invention
[0004] The invention aims to solve the problems of complicated operation and long measurement time in the existing manual measurement of dairy cow weight and the problem of low measurement accuracy in the existing automatic measurement of dairy cow weight.
[0005] A cow weight rapid measurement system based on a two-dimensional point cloud viewed from above, comprising:
[0006] Preprocessing module: obtaining two-dimensional point cloud data based on the three-dimensional point cloud data of the cow from the top view;
[0007] Feature extraction module: Based on the two-dimensional point cloud data, the characteristic key points of the cow's back are detected by machine learning, and the characteristic key points include key points for determining the shoulder width, key points for determining the abdominal width, and key points for determining the hip width;
[0008] Body size calculation module: calculates the key body size information of the cow based on the feature key point data, and the key body size information includes shoulder width, abdominal width, and hip width;
[0009] Weight prediction module: Based on key body size information, the weight of dairy cows is predicted through machine learning.
[0010] Furthermore, the system also includes an image acquisition module, which is used to obtain three-dimensional point cloud data of the cow from a top-down perspective.
[0011] Furthermore, in the processing process of the preprocessing module, before obtaining the two-dimensional point cloud data based on the three-dimensional point cloud data, data quality optimization is also performed on the three-dimensional point cloud data of the cow. The quality optimization process includes:
[0012] Perform pass-through filtering, downsampling, and Euclidean clustering on 3D point cloud data of dairy cows.
[0013] Furthermore, the process of obtaining two-dimensional point cloud data based on three-dimensional point cloud data includes the following steps:
[0014] Based on formulas (1) and (2), we can get the exact coordinates of the cow in the image: image points x[i] and image points y[i]:
[0015]
[0016]
[0017] Among them, f x represents the focal length of the camera in the x direction, f y represents the focal length of the camera in the y direction, x i Represents the x coordinate, y coordinate in the 3D point cloud i Represents the y coordinate in the 3D point cloud, z i represents the z coordinate in the 3D point cloud, c x Indicates the focal length of the principal point coordinate in the x direction, c y Indicates the focal length of the principal point in the y direction.
[0018] Furthermore, the feature extraction module uses a convolutional neural network to detect the characteristic key points of the cow's back.
[0019] Furthermore, the processing process of the convolutional neural network includes:
[0020] The input first gradually extracts image features through two layers of convolution operations, both of which include convolution layer, batch normalization layer, ReLU activation function and maximum pooling layer processing;
[0021] After the maximum pooling operation of the second convolution layer, the model is divided into two parallel branches; the first branch first performs an Unsqueeze operation on the feature map for concatenation by Concat; the second branch first performs a Shape operation, then extracts key features through Gather, then performs an Unsqueeze operation, and concatenates the features of the first branch through Concat;
[0022] After Concat concatenation, Reshape is performed and then input into the fully connected layer for matrix multiplication. The final output is processed by the Sigmoid activation function to obtain the vector corresponding to the feature key point.
[0023] Furthermore, there are two key points for determining the abdominal width, two key points for determining the hip width, and two or three key points for determining the shoulder width.
[0024] Furthermore, the process of calculating the key body size information of the dairy cow by the body size calculation module includes:
[0025] The body size calculation module directly detects the characteristic key points on the cow's back through machine learning and corresponds them to the shoulder width, abdominal width, and hip width indicators, and calculates the key body size information of the cow, including the shoulder width, abdominal width, and hip width values.
[0026] Alternatively, in the case where there are three key points for determining the shoulder width, a line is connected based on the seven key points to ensure that the angle between the line segment and the horizontal line does not exceed the angle threshold, and three feature key points that are close to each other and whose connecting angle is less than the threshold are determined according to the position information of the seven key points as the feature key points corresponding to the shoulder width, and then the feature key points are corresponded to the shoulder width, abdominal width, and hip width indicators, and the key body size information of the dairy cow is calculated, including the shoulder width, abdominal width, and hip width values.
[0027] Furthermore, the weight prediction module predicts the weight of the cow by machine learning, including the following steps:
[0028] The input data is represented as a matrix X(n×p), where n represents the number of samples and p represents the number of features, including shoulder width, abdominal width, and hip width;
[0029] The input data are input into two basic models, namely GBR and Elastic Net respectively; the outputs of the two basic models are concatenated into a new feature matrix Z(n×2) in the merging layer, and then input into the Ridge regression model as a meta-learner, and finally the cow weight prediction result is output.
[0030] The technical solution of the invention has the following beneficial effects:
[0031] The present invention significantly saves time and labor costs through automated data processing and feature extraction. Compared with traditional manual measurement, the automated process reduces operational complexity and makes cow weight measurement more efficient.
[0032] The weight prediction results obtained by using mathematical analysis and machine learning methods are highly objective. The three key points related to weight extracted by the present invention are obtained through a large number of test results on cattle body parts using the statistical software SPSS, and it is proved that the correlation between hip width and weight is higher than the commonly used hip width and buttocks width, which further improves the accuracy of the prediction.
[0033] The technical framework combining convolutional neural network (CNN) and integrated regression model significantly improves the accuracy and robustness of weight prediction, making the application effect better in different environments and conditions, and meeting the high requirements of modern breeding industry for accuracy.
[0034] The non-contact measurement method effectively reduces interference to cows and reduces the stress response caused by traditional contact measurement, which helps maintain the health of cows and improve productivity.
[0035] The system is designed to be highly practical and provides an efficient and accurate weight measurement solution for large-scale ranch management, helping to improve overall farming efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Figure 1 Processing flow chart for the measurement system.
[0037] Figure 2 The comparison chart of the original point cloud of the cow and the point cloud after preprocessing.
[0038] Figure 3 This is the effect after reducing the cow's back point cloud into two-dimensional point cloud (front view appearance).
[0039] Figure 4 This is the effect after reducing the cow's back point cloud into two-dimensional point cloud (side view appearance).
[0040] Figure 5 This is a diagram showing the body size of a dairy cow's back.
[0041] Figure 6 Schematic diagram of the convolutional neural network (CNN) architecture for automatic detection of cow key points.
[0042] Figure 7 Schematic diagram of body size calculation module.
[0043] Figure 8 The wiring algorithm specifies that only horizontal points should be connected.
[0044] Fig. 9Schematic diagram of the integrated model for predicting dairy cow weight. DETAILED DESCRIPTION
[0045] The present invention aims to solve the problems of time-consuming and labor-intensive methods, low prediction accuracy, and the challenges of cumbersome operation, high computational cost, and potential error accumulation in the reconstruction of multi-view point clouds in traditional dairy cow weight measurement methods, as well as the challenges of cumbersome operation, high computational cost, and potential error accumulation in the process of multi-view point cloud reconstruction. These problems limit the practical application of existing technologies in large-scale pastures, and effective solutions are urgently needed to improve measurement efficiency and accuracy and reduce stress responses to dairy cows. In the present invention, the image acquisition module first acquires the top-down view dairy cow point cloud data, and transmits it to the preprocessing module to optimize the data quality and convert the three-dimensional point cloud into a two-dimensional point cloud. Next, the feature learning module uses a convolutional neural network to identify key points on the back of the dairy cow. Subsequently, the body size calculation module calculates relevant body size information based on these key points. Finally, the weight prediction module infers the weight of the dairy cow through the body size information.
[0046] The following describes it in detail in conjunction with specific implementation methods.
[0047] Specific implementation method 1: Combination Figure 1 This embodiment will be described.
[0048] This embodiment is a fast cow weight measurement system based on a two-dimensional point cloud from a bird's-eye view. Figure 1 As shown, it includes an image acquisition module, a preprocessing module, a feature learning module, a body size calculation module and a weight prediction module.
[0049] Image acquisition module: used to obtain the three-dimensional point cloud data of the cow from a bird's-eye view;
[0050] Preprocessing module: optimizes the data quality of the cow's 3D point cloud data and converts the 3D point cloud into a 2D point cloud;
[0051] Feature extraction module: detects key parts of the cow’s back through convolutional neural networks;
[0052] Body size calculation module: calculates the key body size information of dairy cows;
[0053] Weight prediction module: Calculate the cow's weight based on body size information.
[0054] More specifically,
[0055] The processing process of the image acquisition module is as follows:
[0056] The image acquisition module is used to collect the point cloud image of the cow's back from a top-down perspective. In this embodiment, a ZED2 camera is set up above the cowshed as an image acquisition module to obtain three-dimensional point cloud data, and the point cloud data is saved in PCD format and transmitted to the preprocessing module.
[0057] The processing process of the preprocessing module is as follows:
[0058] In a pasture environment, due to the cluttered background around, the captured point cloud data is often interfered by noise. Therefore, in order to improve data quality and reduce processing burden, the preprocessing module receives data from the image acquisition module and performs straight-through filtering, downsampling and Euclidean clustering. Among them: the straight-through filtering method removes background noise to ensure that only valid cattle data is retained; downsampling is responsible for reducing the amount of data and improving the efficiency of subsequent processing; Euclidean clustering technology further identifies and segments the surrounding environment and cattle for individual analysis. Comparison of data before and after processing Figure 2 As shown, the positive impact of preprocessing on data quality is demonstrated.
[0059] In order to further simplify the analysis steps of the processed image, improve the computational efficiency, and reduce the error caused by the Z-axis fluctuation, we perform dimensionality reduction on the preprocessed 3D point cloud data and assign the Z coordinate of the point cloud to 0, thereby converting it into a 2D point cloud. Figure 3 As shown, the camera's intrinsic parameters are used for coordinate transformation, and the intrinsic parameters are shown in Table 1. Specifically, the x-coordinate and y-coordinate on the image plane are calculated by formulas (1) and (2), and these parameters are used in the formula to map the 3D point cloud to the 2D image. Figure 4 and Figure 5 The image after dimensionality reduction is shown.
[0060] Table 1 Camera internal parameters
[0061]
[0062] Based on the camera intrinsic parameters and the coordinate transformation formulas (1) and (2), we get the exact coordinates of the cow in the image: imagepoints x[i] and image points y[i], which can ensure that the actual distance of the cow when the three-dimensional point cloud is converted into a two-dimensional image does not change.
[0063]
[0064]
[0065] Among them, f x Indicates the focal length of the camera in the x direction, x i Indicates the x coordinate in the point cloud, z i represents the z coordinate in the point cloud, c x Indicates the focal length of the principal point coordinate in the x direction, f y Indicates the focal length of the camera in the y direction, y i represents the y coordinate in the point cloud, c y Indicates the focal length of the principal point in the y direction.
[0066] The processing of the feature extraction module is as follows:
[0067] Key parts selection:
[0068] In the prediction of dairy cow weight, the key part information of different anatomical positions on the back of the cow is the core step to obtain the body size information of the cow, and it is also one of the direct factors affecting the accuracy of weight prediction. Therefore, selecting appropriate key points and performing accurate detection is crucial to improving the prediction accuracy. The present invention selects three groups of key parts of shoulder width, abdominal width, and hip width from the back of the cow as the basis for calculating the subsequent body size information. The three key parts of shoulder width, abdominal width, and hip width are selected by manually calculating their maximum correlation with body weight. In the early stage of training the convolutional neural network model, the positions of these points are manually marked, and then the convolutional neural network is used to perform feature learning on them to determine the specific positions of the points. After the convolutional network model is learned, the key points of each cow are automatically marked through the convolutional network model.
[0069] The process of manually marking the locations of these points is as follows:
[0070] Shoulder width: located in the forequarters of the cow, specifically the line determined by the key points on both sides of the shoulder blade, such as Figure 5 As shown in (a) in the figure. The shoulder width measurement reflects the width of the front skeleton and is usually used as an important indicator to measure the volume of the forequarters of dairy cows. Due to the prominent position of the shoulder blade, its width measurement is relatively stable and is not easily affected by the movement posture of the dairy cow.
[0071] Abdomen width: The line determined by the key points at the widest part of the cow's midsection, such as Figure 5 As shown in (b) in the figure. It is usually closely related to the mid-section distribution of volume and weight. Abdominal width not only reflects the volume of the cow's abdominal area, but also indicates the body fat storage, and is closely related to the cow's nutritional status, body condition score (BCS) and health status. Therefore, abdominal width, as an important body size parameter, has important reference value for accurately estimating overall weight.
[0072] Hip width: This is a key part parameter of dairy cows proposed by the present invention, such as Figure 5As shown in (c) in the figure, it is the width of the area between the hip width (green line) and the rump width (blue line). In the annotation, it specifically refers to the distance between the midpoint of the hip tail on the left side of the cow and the midpoint of the hip tail on the right side. The midpoint of the hip tail specifically refers to the midpoint between the hip bone point (left or right) and the coccyx point (same side as the hip bone point). In fact, the rump width is the width of the coccyx. If the coccyx point on one side is not photographed, the midpoint of one side is taken as a line parallel to the hip width. The hip width refers to the distance between the hip bones of the cow. The hip bone is located above the buttocks, while the rump width measures the width on both sides of the tail root. In the actual annotation and detection process, we found that the hip width and rump width of some cows were not significant enough, which brought challenges to the subsequent automatic recognition and weight calculation, while the rump width can better describe the back characteristics of the cow. In order to verify the effectiveness of the rump width, we conducted bivariate correlation analysis on the rump width, hip width and rump width, and systematically evaluated the correlation between these key body dimensions and the weight of the cow. The results are shown in Table 2, indicating that the correlation between hip width and body weight proposed by the present invention is higher than that between hip width and rump width. Hip width and rump width are specific regulations for the body parts of cattle in animal husbandry. Hip width is the widest width of the buttocks of the cattle, and rump width is the width of the buttocks of the cattle. The present invention selects a line between hip width and rump width as a parameter for measuring body weight. "Hip width" does not need to be parallel to hip width and rump width. Figure 5 The "hip width" and "buttocks width" are marked in (c) just to better illustrate the position of "hip width". In the actual annotation (including manual annotation during early training and later model automatic annotation), these two lines (hip width and buttocks width) will not appear.
[0073] It should be noted that the calibration of hip width is carried out within a certain range between the hip bone and the tail root. The deep learning model can automatically learn the optimal position in this area, thereby minimizing the impact caused by inconsistency in labeling. Although hip width does not have a clear physical reference point like shoulder width or abdominal width, the feature extraction capability of the convolutional neural network has been verified through experiments to effectively identify this parameter, and combined with other body size information, the accuracy of the prediction can be effectively improved. In addition, multiple rounds of experiments have shown that the hip width and buttocks width, which are relatively easy to find, do indeed have a low accuracy in predicting weight. The present invention has found the "hip width" predictive weight factor after in-depth research. According to the experimental results in the early stage, it has been proved to have a high accuracy. After that, whether it is to add other body size factors (body size refers to the general term for body size, which can represent a series of body parameter information such as shoulder width, abdominal width, hip width, body height, oblique length, etc.), or to change the experimental environment, such as transferring from the scale to the cowshed where the cow is eating, it can be applied.
[0074] Table 2 Correlation between various tail dimensions and body weight of dairy cows.
[0075]
[0076] The positions of these points are manually marked, and the convolutional neural network model is trained. The convolutional neural network learns the features of the key points to determine the specific positions of the points. After the convolutional network model is learned, the key points of each cow are automatically marked through the network model, that is, the convolutional network model is used to realize the automatic extraction of key points. It should be noted that: this embodiment adopts the following convolutional network model, and other neural network models with other structures can also be used in other embodiments. Convolutional neural network model.
[0077] Automatic extraction of key points:
[0078] In order to improve the level of automation and processing speed, the present invention designs a convolutional neural network (CNN) model specifically for cow key point detection, aiming to realize automatic recognition of key points. The model takes a two-dimensional point cloud image of the cow's back with a size (channel, height, width) of (3,336,570) as input, and gradually extracts image features through two layers of convolution operations. First, the first layer of convolution generates 64 feature maps. After batch normalization, ReLU activation function and 2x2 maximum pooling, the spatial dimension of the feature map is reduced to (64,168,285). Subsequently, the second layer of convolution increases the number of channels to 128. After the same processing, the feature map is further reduced to (128,84,142). Figure 6 The connection relationship between each module is shown in detail. Figure 6 The three convs corresponding to the first layer of convolution refer to 3 channels, and 64×3×3×3 means that this layer uses 64 convolution kernels, each of which is 3x3 in size and processes a network with 3 channels. The second layer of convolution uses the same representation as the first layer of convolution.
[0079] After the maximum pooling operation corresponding to the second layer of convolution, the model is divided into two parallel branches. The first branch first performs an Unsqueeze operation on the feature map to add a new dimension; then it is concatenated with other features through the Concat operation. The second branch first performs a Shape operation to adjust the feature map to a format suitable for the subsequent Gather and Concat, then extracts key features from specific channels through Gather (indices = 0), then adds a new dimension through the Unsqueeze operation, and concatenates it with the features of the first branch through Concat, and finally reshapes it to meet the input requirements of the fully connected layer. After Reshaping, it is input to the fully connected layer for matrix multiplication (Gemm). The final output is processed by the Sigmoid activation function to obtain a vector of 14 values. The trained neural network model is used to identify key points in the test set, and red dots are automatically marked at the key points in the image.
[0080] The network takes a top view of a cow with a size of (3,336,570) as input and gradually extracts image features through two layers of convolution. Figure 6 The various operation processes are shown in Figure 1, including convolution, batch normalization, ReLU activation, maximum pooling, and parallel branches for feature extraction. Finally, these branches converge to predict 14 values, which represent the (x, y) coordinates of the 7 key points predicted by the model, and automatically mark the key point positions on the test image for subsequent calculation of shoulder width, abdominal width, and hip width.
[0081] It should be noted that in addition to the six points used to indicate the shoulder width, abdominal width, and hip width, two points used to indicate the shoulder width ( Figure 8 The midpoint of point 4 and point 6) in Figure 8 Point 5, 4, 5, and 6 may not be on a straight line, but the angle (acute angle) between the line 4 and 5 and the line 5 and 6 between them will never exceed 45 degrees. The role of the middle point is that when taking photos and measuring data, some cattle have a stress response, which causes them to swap their heads and tails. The invention adds a point in the middle of the shoulder width to ensure that the shoulder width is always at the top, so that the numbering will not be messy when connecting the body scale later, otherwise the shoulder width and hip width will be swapped. The middle point here plays a "safety" role. When marking, the mark of the middle point (point 5) is relatively random, and the midpoint of the shoulder width is generally taken. Even if the convolution network is not accurately recognized in the later stage, it will basically have no effect, because the selected connection line will only be the maximum value of the connection between the two lines, so the position of the shoulder width is certain. In fact, the middle point (point 5) is to determine the direction. As long as the three points are on one side, then this direction is the shoulder width direction. Therefore, it has no effect on the result of the convolution network recognition that the three points 4, 5, and 6 are not on a straight line. In addition, in the early stage of research, point 5 was only set during the data collection stage. When it is applied to practice later, since the direction of eating in the cowshed is fixed, there will be no situation where the heads and tails of cows are reversed. At that time, the setting of point 5 will be canceled according to the actual situation.
[0082] In addition, the present invention focuses on converting the captured 3D point cloud into a 2D image without changing the real body size distance (usually, the real distance will be lost in the process of converting the 3D point cloud to 2D pixels, and the image will be distorted, similar to the appearance of a wide-angle lens, so its body size parameters will be inaccurate), and then through convolution, the manually marked body size points are learned, and the cloudcompare software is used to find the shoulder width, abdominal width, and hip width in the 3D point cloud in advance. Taking the shoulder width as an example, specifically: when taking pictures in advance, people use a cattle measuring stick to measure and record the real distance of the cow. Calibrating the two points in cloudcompare will directly display the real spatial distance. In this way, the shoulder width is accurately found, and the index values of the two end points corresponding to the shoulder width are recorded (in space). Each point has a unique index value), which is saved in the notebook. When learning, the convolution is based on the position of these index values in the image. After finding these positions, the corresponding width is calculated. Because the scale is a rectangle, the cow can move in a small range inside, but the head is fixed in one direction overall, but some of the bodies are a little crooked. In addition, a few individuals have a stress response when entering the scale, so the head and tail are swapped. Therefore, a point is added in the middle of the shoulder width so that the camera can always find the direction of the head facing up to name the number of each point for connection (this problem will not occur when it is applied to the real cowshed later, because the direction of eating in the cowshed is fixed. This step is added here only because of the rules set in the experiment due to very few special cases). After obtaining the corresponding connection, the predicted value of the connection is linearly + nonlinearly regressed with the actual weight, and finally the weight prediction model is obtained. Then call this model to get the weight information.
[0083] We used the collected data of 50 cows to train the above convolutional neural network model. The training was carried out on the Windows 11 operating system, using the deep learning framework PyTorch 1.10.2, Python version 3.6.13, CUDA version 12.1, and cuDNN 8.2 library for acceleration. In terms of hardware, the NVIDIA GeForce RTX4060Laptop GPU was used. The GPU has 8GB of video memory, supports CUDA parallel computing, provides excellent matrix computing capabilities, and significantly accelerates the training process of the model. During the training process, the model was set to 500 training rounds (epochs), 25 images were processed in each batch (batch size = 25), the initial learning rate was set to 1e-4, and the Adam optimizer was used for parameter updates. To ensure the efficiency and stability of training, the NVIDIA-smi tool was used to monitor the GPU utilization and video memory usage in real time.
[0084] In order to optimize the model training process, we use Mean Squared Error (MSE) as the loss function, as shown in Formula 3. MSE is a commonly used regression loss function that can effectively measure the difference between the model prediction value and the true value, especially suitable for regression tasks of continuous variables. In this study, MSE is used to quantify the error in the prediction of cow body size (shoulder width, abdominal width, hip width). The advantage of MSE is that it is more sensitive to larger prediction errors and can significantly penalize large deviations, thereby improving the accuracy of the overall model prediction.
[0085] The loss during training is:
[0086]
[0087] in, It represents the model's predicted value for the coordinates of the i-th key point, y i is the real coordinate label of the key point, base i is a constant used for normalization, and n represents the number of samples in the batch. During each training process, the losses of all key points are calculated and summed to obtain a total loss value, which is used for back propagation to update the model parameters.
[0088] The Adam optimization algorithm is used as the parameter update rule, and the first-order momentum is combined to estimate m t and the second-order momentum estimate v t , realize the gradient descent update of adaptive learning rate, as shown in formula (4), by introducing v t The square root of is used as the denominator and a small constant ∈ is added to avoid numerical instability. This formula ensures that the learning rate is adaptively adjusted, allowing the model to converge more effectively in the parameter space.
[0089]
[0090] Among them, m t represents the exponentially weighted moving average of the gradient, which is used to smooth the gradient information; v t is the exponentially weighted moving average of the squared gradient, which adjusts the size of each parameter update step; θ t represents the model parameters at the current iteration step t, θ t+1 represents the updated model parameters at the next iteration t+1, and η represents the learning rate.
[0091] The processing process of the body size calculation module is as follows:
[0092] Based on the feature extraction module, the body size calculation module connects the identified key points in pairs according to the connection algorithm to complete the calculation of the real physical dimensions of shoulder width, abdominal width, and hip width, such as Figure 7As shown in the figure, when collecting the point cloud, the hips are set at the bottom and the head is set at the top for processing. Therefore, the points extracted by the feature extraction module are marked from bottom to top as 0 to 6 according to the direction of the point cloud. Figure 7 From bottom to top, they are numbered 0 to 6 and are used to calculate the cow's hip width (points 0 and 1), abdominal width (points 2 and 3), and shoulder width (points 4, 5, and 6). When connecting, ensure that the angle between the line segment and the horizontal line does not exceed 45° and that it is the farthest line segment to obtain the physical dimensions of the key body dimensions.
[0093] To ensure the accuracy of the body measurement results, the present invention has formulated a strict line connection algorithm: only horizontal points are connected, that is, the angle between the connecting line and the horizontal line does not exceed 45 degrees. According to the anatomical structure and projection rules of cattle, the points from bottom to top are numbered 0 to 6 in sequence, such as Figure 8 The specific algorithm is as follows:
[0094] Points 0 and 1 represent the hip width, and these two points are located at the bottom.
[0095] Points 2 and 3 represent the abdominal width, and these two points are located in the middle.
[0096] Points 4, 5, and 6 are used to measure shoulder width, where the shoulder width measurement connects only the two farthest points (usually points 4 and 6).
[0097] Figure 8 The display connection algorithm stipulates that only horizontal points are connected, and the angle between the connecting line and the horizontal line does not exceed 45 degrees. According to the anatomical structure and projection law of dairy cows, the key points are numbered from 0 to 6 from bottom to top: points 0 and 1 are used to calculate hip width, points 2 and 3 are used to calculate abdominal width, and points 4, 5 and 6 (the two farthest points) are used to calculate shoulder width.
[0098] The connection algorithm is set to have the three points in the direction of the top. Since the scale's rails form an approximate rectangle, some cows may stand slightly tilted, so the numbering algorithm is set to ensure consistency in different body positions.
[0099] The calculation formula for a single body size is shown in formula (5), where 0.22 is a scaling factor obtained by the pixel distance between the actual position in the point cloud and the image.
[0100]
[0101] Among them, (x1, y1) and (x1, y2) are the coordinates of the two points for calculating body size.
[0102] The processing of the weight prediction module is as follows:
[0103] The weight prediction module predicts the weight of cows based on body size information. In order to cope with the complex challenges in predicting cow weight, we proposed an integrated model for predicting cow weight based on body size information. This model aims to overcome the limitations of a single regression model in predicting cow weight, especially its shortcomings in capturing nonlinear relationships and preventing overfitting. Fig. 9 As shown in Figure 1, the model consists of Gradient Boosting Regressor (GBR), Elastic Net, and Ridge Regression to synergistically improve the prediction performance. To achieve effective training of the model, the input data is reasonably preprocessed and organized.
[0104] Specifically, the input layer data is represented by a matrix X(n×p), where n represents the number of samples (usually corresponding to different individual cows) and p represents the number of features, covering the body size parameters of key parts, such as shoulder width, abdominal width, and hip width. In the case of a single or a small number of samples (for example, n=1 or n=2), the input data will become a 1×p or 2×p row vector format, so that the model can still receive and process the input normally, while ensuring consistency under different input scales.
[0105] After preprocessing steps such as standardization, the above features are input into two basic models, namely GBR and ElasticNet. GBR gradually corrects errors by iteratively constructing weak learners, which is particularly suitable for capturing complex nonlinear relationships in weight prediction; Elastic Net combines L1 and L2 regularization, which can effectively deal with multicollinearity problems and enhance the robustness of the model through the dual mechanisms of feature selection and regularization. Feature selection: The Elastic Net model combines the advantages of L1 regularization (Lasso) and L2 regularization (Ridge); L1 regularization shrinks some unimportant feature coefficients to zero by introducing sparsity, thereby playing a role in feature selection. Feature selection reduces the redundancy of features, helps to improve the interpretability of the model and prevent overfitting. Regularization: L2 regularization imposes penalties on feature coefficients to avoid excessively large coefficient values, which can reduce the model's excessive dependence on specific features, reduce the variance of the model, and enhance its robustness; by introducing regularization terms, Elastic Net can deal with multicollinearity problems (i.e., high correlation between features), which is particularly effective when there is large noise or a small number of samples. The synergy of the dual mechanisms: Elastic Net can filter features while using L1 and L2, while also preventing the model from overfitting due to a small number of key features. This combination not only optimizes the prediction accuracy, but also enhances the stability of the model on different data sets.
[0106] The outputs of the two basic models are concatenated into a new feature matrix Z(n×2) in the merging layer, and then input into the Ridge regression model as a meta-learner to further optimize the stability and accuracy of the prediction, especially in small data sets or noisy scenarios, and finally output the weight. This integrated model not only overcomes the limitations of a single model, but also effectively prevents overfitting problems through regularization technology, thus providing a more robust and efficient solution for dairy cow weight prediction. In practical applications, this integrated model significantly improves the prediction accuracy and has good generalization ability, demonstrating its potential for wide application in large-scale ranch weight monitoring.
[0107] The model is based on body size information and combines Gradient Boosting Regressor (GBR), ElasticNet and Ridge regression models to synergistically improve weight prediction performance. After the input data is standardized, it enters the GBR and Elastic Net models respectively. GBR is used to capture complex nonlinear relationships, while Elastic Net uses regularization to deal with multicollinearity problems. The outputs of the two models are spliced in the merging layer and input into Ridge regression as a meta-learner to improve the robustness and accuracy of the prediction, and finally output the predicted results of dairy cow weight.
[0108] The present invention converts three-dimensional point cloud data into two-dimensional images for the first time and applies them to cow weight prediction, which significantly improves data processing efficiency and prediction accuracy.
[0109] Convolutional neural network (CNN) is used to automatically extract body size information related to cow weight, which optimizes the feature extraction process and improves the reliability of prediction.
[0110] The integrated model built by combining Ridge regression, gradient boosting regression (GBR) and elastic network regression (Elastic Net) enhances the accuracy and robustness of prediction and can adapt to data changes under different conditions.
[0111] The present invention may also have many other embodiments. Without departing from the spirit and essence of the present invention, those skilled in the art may make various corresponding changes and modifications based on the present invention, but these corresponding changes and modifications should all fall within the scope of protection of the claims attached to the present invention.
Claims
1. A fast cow weight measurement system based on a two-dimensional point cloud from a bird's-eye view, characterized in that: include: Preprocessing module: obtaining two-dimensional point cloud data based on the three-dimensional point cloud data of the cow from the top view; Feature extraction module: Based on the two-dimensional point cloud data, the characteristic key points of the cow's back are detected by machine learning, and the characteristic key points include key points for determining the shoulder width, key points for determining the abdominal width, and key points for determining the hip width; Body size calculation module: calculates the key body size information of the cow based on the feature key point data, and the key body size information includes shoulder width, abdominal width, and hip width; Weight prediction module: Based on key body size information, the weight of dairy cows is predicted through machine learning.
2. The system for rapid measurement of cow weight based on top-view two-dimensional point cloud according to claim 1, characterized in that: The system also includes an image acquisition module, which is used to acquire three-dimensional point cloud data of the cow from a top-down perspective.
3. The system for rapid measurement of cow weight based on top-view two-dimensional point cloud according to claim 1, characterized in that: In the processing process of the preprocessing module, before obtaining the two-dimensional point cloud data based on the three-dimensional point cloud data, data quality optimization is also performed on the three-dimensional point cloud data of the cow. The quality optimization process includes: Perform pass filtering, downsampling and Euclidean clustering on 3D point cloud data of dairy cows.
4. The system for rapid measurement of cow weight based on top-view two-dimensional point cloud according to claim 1, characterized in that: The process of obtaining two-dimensional point cloud data based on three-dimensional point cloud data includes the following steps: Based on formulas (1) and (2), we can get the exact coordinates of the cow in the image: image points x[i] and image points y[i]: Among them, f x represents the focal length of the camera in the x direction, f y represents the focal length of the camera in the y direction, x i Represents the x coordinate, y coordinate in the 3D point cloud i Represents the y coordinate in the 3D point cloud, z i represents the z coordinate in the 3D point cloud, c x Indicates the focal length of the principal point coordinate in the x direction, c y Indicates the focal length of the principal point in the y direction.
5. The system for rapid measurement of cow weight based on top-view two-dimensional point cloud according to claim 1, characterized in that: The feature extraction module uses a convolutional neural network to detect the key feature points on the back of the cow.
6. The system for rapid measurement of cow weight based on top-view two-dimensional point cloud according to claim 5, characterized in that: The processing process of the convolutional neural network includes: The input first gradually extracts image features through two layers of convolution operations, both of which include convolution layer, batch normalization layer, ReLU activation function and maximum pooling layer processing; After the maximum pooling operation of the second convolution layer, the model is divided into two parallel branches; the first branch first performs an Unsqueeze operation on the feature map for concatenation by Concat; the second branch first performs a Shape operation, then extracts key features through Gather, then performs an Unsqueeze operation, and concatenates the features of the first branch through Concat; After Concat concatenation, Reshape is performed and then input into the fully connected layer for matrix multiplication. The final output is processed by the Sigmoid activation function to obtain the vector corresponding to the feature key point.
7. The system for rapid measurement of cow weight based on top-view two-dimensional point cloud according to claim 1, characterized in that: There are two key points for determining abdominal width, two key points for determining hip width, and two or three key points for determining shoulder width.
8. The system for rapid measurement of cow weight based on top-view two-dimensional point cloud according to claim 7, characterized in that: The process of calculating the key body size information of dairy cows by the body size calculation module includes: The body size calculation module directly detects the characteristic key points on the cow's back through machine learning and corresponds them to the shoulder width, abdominal width, and hip width indicators, and calculates the key body size information of the cow, including the shoulder width, abdominal width, and hip width values.
9. The system for rapid measurement of cow weight based on top-view two-dimensional point cloud according to claim 7, characterized in that: The process of calculating the key body size information of dairy cows by the body size calculation module includes: In the case where there are three key points for determining the shoulder width, a line is connected based on the seven key points to ensure that the angle between the line segment and the horizontal line does not exceed the angle threshold, and three feature key points that are close to each other and whose connecting angle is less than the threshold are determined according to the position information of the seven key points. These are used as the feature key points corresponding to the shoulder width, and then the feature key points are corresponded to the shoulder width, abdominal width, and hip width indicators, and the key body size information of the dairy cow, including the shoulder width, abdominal width, and hip width values, is calculated.
10. A cow weight rapid measurement system based on top-view two-dimensional point cloud according to any one of claims 1 to 9, characterized in that: The weight prediction module predicts the weight of dairy cows through machine learning. The process includes: The input data is represented as a matrix X(n×p), where n represents the number of samples and p represents the number of features, including shoulder width, abdominal width, and hip width; The input data are input into two basic models, namely GBR and Elastic Net respectively; the outputs of the two basic models are concatenated into a new feature matrix Z(n×2) in the merging layer, and then input into the Ridge regression model as a meta-learner, and finally the cow weight prediction result is output.