Livestock body dimension measurement method, system, computer device and medium
By using the SCSNet model and 3D skeleton modeling technology, the accuracy and stability problems of traditional livestock body size measurement have been solved, realizing high-precision, low-cost automated body size measurement that is adaptable to various breeding environments.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NORTHWEST A & F UNIV
- Filing Date
- 2026-05-29
- Publication Date
- 2026-07-31
AI Technical Summary
Traditional methods for measuring the body size of livestock rely on manual operation, which is cumbersome, inaccurate, and may affect the health of animals. Existing non-contact measurement technologies are not accurate enough under obstruction and posture changes.
The SCSNet model is used for feature extraction, combined with the StarBlock module and the slim-Neck network. Multi-view color and depth images are used to detect body scale key points, construct a 3D skeleton model and perform pose correction, thereby reducing hardware complexity and cost.
It enables high-precision, low-cost automated body size measurement in various aquaculture environments, reducing measurement errors and improving measurement stability and adaptability.
Smart Images

Figure CN122312741B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of livestock measurement, specifically relating to a method, system, computer equipment, and medium for measuring the body size of livestock. Background Technology
[0002] In livestock production, measuring animal body size is a key indicator for assessing animal growth, health, genetic improvement effects, and production performance. Accurate body size data not only improves animal management efficiency but also significantly impacts breeding profitability, animal welfare, and breeding decisions. However, traditional methods of measuring animal body size often rely on manual contact with tools such as rulers and calipers. This method typically requires experienced personnel and is cumbersome, time-consuming, and labor-intensive. Furthermore, the measurement results are easily affected by factors such as human experience and environmental changes, leading to poor accuracy. More importantly, traditional contact-based measurement methods may cause discomfort or stress to animals, affecting their physical and mental health.
[0003] To address the aforementioned shortcomings, with advancements in computer vision and sensing technologies, non-contact methods for measuring livestock body size have gradually become a research hotspot. These methods utilize 3D reconstruction techniques to provide detailed depth information of livestock while minimizing interference from external factors such as lighting, thereby ensuring the accuracy of body size measurements. For example, by acquiring image data of the target object using multi-view images or depth sensors, key points are extracted from the image. Pixel matching calculations of these key points are then performed to reconstruct a dense point cloud or mesh model of the target object, thus obtaining its 3D morphological information. However, in existing 3D reconstruction techniques, key point extraction is typically achieved through target detection algorithms. However, the livestock's breeding environment often involves significant occlusion, and the livestock's posture changes frequently during body size measurement, leading to insufficient accuracy and stability in key point extraction and resulting in substantial errors in the measurement results. Summary of the Invention
[0004] To address the problem of large errors in existing livestock body size measurements, this invention provides a livestock body size measurement method, system, computer equipment, and medium.
[0005] To achieve the above objectives, the present invention provides the following technical solution: A method for measuring the body size of livestock, comprising: Color and depth images of the livestock to be measured were acquired from multiple perspectives. The SCSNet model was used to process the color images from multiple perspectives to obtain body size keypoints from multiple perspectives. The SCSNet model is based on the YOLOv11 model, replacing the stacked standard convolutional layers in the YOLOv11 backbone network with Star Block modules, and replacing the neck network of the YOLOv11 model with a slim-Neck network. The Star Block module of each layer is used to receive the feature map output by the downsampled convolution of the layer. Local spatial features are extracted from the feature map through 7×7 depthwise separable convolution. The local spatial features are channel-expanded through two parallel 1×1 convolutions. The two channel-expanded features are multiplied and fused element-wise through a star operation to obtain fused features. The parameters of the fused features are compressed by the ReLU activation function in conjunction with 1×1 convolutions to obtain the output features of the corresponding layer. The slim-Neck network processes the feature maps of multiple different scales output by the backbone network to obtain multi-scale feature maps for predicting body size keypoints. The two-dimensional coordinates of each body scale key point in the color image and the depth information of the body scale key point in the depth image are fused to obtain the three-dimensional coordinates of each body scale key point in the camera coordinate system. The three-dimensional coordinates of each body scale key point in the camera coordinate system are determined by combining the three-dimensional coordinates of each body scale key point in the camera coordinate system with the corresponding camera extrinsic parameters. A three-dimensional skeleton model of the livestock to be measured is constructed using the three-dimensional coordinates of key points of the individual size in the world coordinate system; based on the spatial distance between key points in the three-dimensional skeleton model, the body size measurement results of the livestock to be measured are obtained.
[0006] Optionally, in the livestock body size measurement method provided by the present invention, a C2PSM module is also embedded after the SPPF module in the backbone network of the SCSNet model. The C2PSM module splits the output features of the SPPF module into multiple branch features. After performing multiple feature transformations on one branch feature, it merges it with the features of another branch to obtain the output features of the deepest layer of the backbone network.
[0007] Optionally, the method for measuring the body size of livestock provided by the present invention further includes: When the depth information of the body scale key points in the depth image is within a preset range, the two-dimensional coordinates and depth information in the color image are mapped to the camera coordinate system according to the camera intrinsic parameters corresponding to the color image, so as to obtain the three-dimensional coordinates of the body scale key points in the camera coordinate system.
[0008] Optionally, in the livestock body size measurement method provided by the present invention, the body size key points include body size key points from a side view and body size key points from a top view. Key body scale points in a lateral view include the eyes, midpoint of the neck, highest point of the shoulder, root of the left forelimb, left foreknee, left forehoof, root of the right forelimb, right foreknee, right forehoof, highest point of the hip, root of the left hindlimb, left hindknee, left hindhoof, root of the right hindlimb, right hindknee, right hindhoof, sternal prominence, and posterior margin of the ischial tuberosity. Key body dimensions from a top-down view include the widest point of the left scapula, the widest point of the right scapula, the widest point of the left hip joint, and the widest point of the right hip joint.
[0009] Optionally, the body size measurement results include the chest depth, body length, rump width, shoulder width, rump height, and shoulder height parameters of the livestock to be measured. The livestock body size measurement method provided by this invention also includes: Based on the three-dimensional spatial coordinates between the highest point of the shoulder, the root of the left forelimb, the left foreknee, and the left forehoof of the livestock to be measured, the Euclidean distances between the highest point of the shoulder and the root of the left forelimb, the root of the left forelimb and the left foreknee, and the left forehoof and the left forehoof are determined; the shoulder height parameter is determined by the sum of the Euclidean distances between the highest point of the shoulder and the root of the left forelimb, the root of the left forelimb and the left foreknee, and the left foreknee and the left forehoof. Based on the three-dimensional spatial coordinates between the highest point of the hip, the root of the left hind limb, the left hind knee, and the left hind hoof, the Euclidean distances between the highest point of the hip and the root of the left hind limb, the root of the left hind limb and the left hind knee, and the left hind hoof are determined; the hip height parameter is determined by the sum of the Euclidean distances between the highest point of the hip and the root of the left hind limb, the root of the left hind limb and the left hind knee, and the left hind knee and the left hind hoof. The Euclidean distance of the scapula is determined based on the three-dimensional spatial coordinates between the widest points of the left and right scapulae, and the shoulder width parameter is determined based on the Euclidean distance of the scapula. The Euclidean distance between the widest points of the left and right hip joints is determined based on the three-dimensional spatial coordinates between them, and the hip width parameter is determined based on the Euclidean distance between the hip joints. The body length Euclidean distance is determined based on the three-dimensional spatial coordinates between the sternal prominence and the posterior edge of the ischial tuberosity, and the body length parameters are determined based on the body length Euclidean distance. The Euclidean distance of the chest depth is determined based on the three-dimensional spatial coordinates between the highest point of the shoulder and the root of the left forelimb, and the chest depth parameters are determined based on the Euclidean distance of the chest depth.
[0010] Optionally, the method for measuring the body size of livestock provided by the present invention further includes: Pose features are extracted from a 3D skeleton model using a pre-trained regression model, and the pose error of the livestock to be measured is determined from the pose features. The corrected body size measurement results of the livestock to be measured are determined based on the body size measurement results and posture errors.
[0011] Optionally, the regression model is a stacked ensemble regression model, which includes a basic regression model for predicting the head and neck posture of livestock, a basic regression model for predicting the trunk orientation of livestock, a basic regression model for predicting the limb support state of livestock, and a meta-regression model. The livestock body size measurement method provided by this invention also includes: The head and neck posture error of the livestock to be measured is predicted by a three-dimensional skeleton model using a basic regression model for predicting the head and neck posture of livestock. The trunk orientation posture error of the livestock to be measured is predicted by a three-dimensional skeleton model using a basic regression model for predicting the trunk orientation of livestock. The limb support posture error of the livestock to be measured is predicted by a three-dimensional skeleton model using a basic regression model for predicting the limb support status of livestock. The posture errors of the livestock to be measured were determined by using a meta-regression model, which included head and neck posture errors, trunk orientation posture errors, and limb support posture errors.
[0012] The present invention also provides a livestock body size measurement system, comprising: The key point extraction module is used to acquire color and depth images of the livestock to be measured from multiple perspectives. The SCSNet model processes the color images from multiple perspectives to obtain body size key points. The SCSNet model is based on the YOLOv11 model, replacing the stacked standard convolutional layers in the YOLOv11 backbone with Star Block modules and the neck network with a slim-Neck network. Each Star Block module receives the feature map output from the downsampled convolution of its layer, extracts local spatial features from the feature map using 7×7 depthwise separable convolutions, expands the channels of the local spatial features using two parallel 1×1 convolutions, and fuses the two expanded features element-wise using a star operation to obtain fused features. The ReLU activation function combined with 1×1 convolutions compresses the parameters of the fused features to obtain the output features of the corresponding layer. The slim-Neck network processes the feature maps of multiple different scales output from the backbone network to obtain multi-scale feature maps for predicting body size key points. The 3D coordinate determination module is used to fuse the 2D coordinates of each body scale key point in the color image and the depth information of the body scale key point in the depth image to obtain the 3D coordinates of each body scale key point in the camera coordinate system. The 3D coordinates of each body scale key point in the camera coordinate system are combined with the corresponding camera extrinsic parameters to determine the 3D coordinates of the body scale key point in the world coordinate system. The results calculation module is used to construct a three-dimensional skeleton model of the livestock to be measured from the three-dimensional coordinates of the key points of the individual size in the world coordinate system; based on the spatial distance between the key points in the three-dimensional skeleton model, the body size measurement results of the livestock to be measured are obtained.
[0013] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory, wherein the processor executes the computer program to implement any of the steps in a method for measuring the body size of livestock.
[0014] The present invention also provides a computer-readable storage medium storing a computer program that, when loaded by a processor, can execute any of the steps in a method for measuring the body size of livestock.
[0015] The method for measuring the body size of livestock provided by this invention has the following beneficial effects: The livestock body size measurement method provided by this invention uses the SCSNet model for feature extraction. The StarBlock module forces non-linear interactions between features from different branches. Even when livestock may have some key points invisible due to body twisting, fence occlusion, etc., the model can still infer the location of occluded key points from the associated features of the visible area, ensuring the accuracy of body size key point extraction. Furthermore, the depthwise separable convolution in the StarBlock module compresses the number of parameters in the fused features, preventing the model from overfitting to specific occlusion patterns and improving generalization ability for unknown occlusion scenarios. Based on this, the slim-Neck network in the SCSNet model can simultaneously extract large-scale features representing the overall posture and small-scale features representing detailed key points, and complete multi-scale feature fusion. Even when livestock experience drastic changes in the scale and position of key points in the image due to different postures such as standing and walking, the multi-scale feature fusion method still ensures that the model adapts to multiple different postures simultaneously, avoiding missed or false detections of key points due to posture changes, thereby reducing body size measurement errors.
[0016] Furthermore, this invention relies solely on acquired color-depth image pairs and camera parameters, eliminating the need to deploy and calibrate a large number of dedicated cameras to generate dense point clouds, and avoiding complex 3D surface reconstruction processes. This greatly simplifies the required hardware, significantly reducing system complexity and cost while maintaining the advantages of non-contact measurement. Attached Figure Description
[0017] To more clearly illustrate the embodiments and design schemes of the present invention, the accompanying drawings required for this embodiment will be briefly described below. The drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0018] Figure 1 This is a schematic diagram of a method for measuring the body size of livestock provided in an embodiment of the present invention; Figure 2 This is a schematic diagram of the SCSNet model structure provided in an embodiment of the present invention; Figure 3 This is a schematic diagram of the Star Block module structure provided in an embodiment of the present invention; Figure 4 This is an example of a procedure for measuring the body size of livestock provided in an embodiment of the present invention; Figure 5 This is a visualization example of key point detection results provided in an embodiment of the present invention, wherein... Figure 5 (1) is a visualization example of the key point structure of an adult ewe. Figure 5 (2) is a visualization example of the key point structure of a young ewe. Figure 5 (3) is a visualization example of the key point structure of a young ram. Figure 5 (4) is a visualization example of the key point structure of an adult ram. Detailed Implementation
[0019] To enable those skilled in the art to better understand and implement the technical solutions of the present invention, the present invention will be described in detail below with reference to the accompanying drawings and specific embodiments. The following embodiments are only used to more clearly illustrate the technical solutions of the present invention and should not be construed as limiting the scope of protection of the present invention.
[0020] To address the shortcomings of contact-based measurement, existing technologies often employ non-contact methods to measure livestock body size. While two-dimensional image analysis is relatively simple and low-cost, its accuracy often falls short of practical requirements due to limitations in image resolution and lighting conditions. Three-dimensional reconstruction technology can provide more detailed depth information and reduce interference from external factors such as lighting, thereby improving measurement accuracy. However, it typically requires expensive equipment and multiple cameras, resulting in high costs and difficulties in equipment maintenance and application flexibility. Furthermore, existing measurement methods often rely on manual calibration or complex algorithms to extract key points, which not only increases operational complexity but also makes them susceptible to external interference, leading to measurement errors. Therefore, there is an urgent need for a livestock body size measurement method that can maintain high accuracy while providing automation, low cost, and adaptability to various farming environments. To address these needs, this invention provides a livestock body size measurement and error correction method based on RGBD images, multi-view acquisition, and deep learning. Through key point detection, three-dimensional skeleton modeling, and posture error prediction, it achieves accurate and rapid measurement of livestock body size.
[0021] Example 1 This invention provides a method for measuring the body size of livestock, specifically as follows: Figure 1 As shown, it includes the following steps: Step 11: Collect color and depth images of the livestock to be measured from multiple perspectives; extract the body size key points of the livestock to be measured from the color images from multiple perspectives.
[0022] Specifically, the SCSNet model is used to process color images from multiple viewpoints to obtain body scale key points from multiple viewpoints; among them, such as Figure 2 As shown, the SCSNet model is an improved model based on the YOLOv11 model. It is constructed by replacing the standard stacked convolutional layers in the backbone network of the YOLOv11 model with Star Block modules and replacing the neck network of the YOLOv11 model with a slim-Neck network. The Star Block module of each layer is used to receive the feature map output by the downsampled convolution of the layer. Local spatial features are extracted from the feature map through 7×7 depthwise separable convolution. The local spatial features are channel-expanded through two parallel 1×1 convolutions. The two channel-expanded features are multiplied and fused element-wise through star operation to obtain fused features. The parameters of the fused features are compressed by ReLU activation function in conjunction with 1×1 convolution to obtain the output features of the corresponding layer. The slim-Neck network processes the feature maps of multiple different scales output by the backbone network to obtain multi-scale feature maps for predicting body scale key points.
[0023] Furthermore, after the SPPF module in the backbone network of the SCSNet model, a C2PSM module is also embedded. The C2PSM module splits the output features of the SPPF module into multiple branch features, performs multiple feature transformations on one branch feature, and then fuses it with the features of another branch to obtain the output features of the deepest layer of the backbone network.
[0024] Specifically, before image acquisition, each depth camera is calibrated to obtain the camera's intrinsic parameters and the extrinsic parameter relationships between different cameras. This ensures that the images acquired by each camera have a clear spatial correspondence within a unified world coordinate system, achieving spatial registration. Then, RGBD images (color images and depth images) of livestock such as pigs, cattle, and sheep are simultaneously acquired from different perspectives using two or more depth cameras. For example, an image acquisition channel is set up for single-animal passage. As the livestock walks naturally through the acquisition area, images are acquired from multiple perspectives using depth cameras positioned along the image acquisition channel. These perspectives can include side views and top views. With appropriately set camera placement parameters such as installation height, pitch angle, and field of view, the acquired images can completely cover the key body surface areas of the livestock, ensuring the integrity and reliability of subsequent key point detection and body size measurement. Specific perspectives and placement parameters can be set by those skilled in the art based on actual needs; this invention does not impose any limitations.
[0025] After obtaining color and depth images of the livestock to be measured from multiple perspectives, a target detection algorithm is used to identify key points in the color images to determine the key points related to body size measurement, and the two-dimensional pixel coordinates of each key point in the corresponding color image are obtained. .
[0026] Specifically, such as Figure 2 As shown, the target detection algorithm used in this invention is based on the YOLOv11 pose estimation framework. It introduces Star Block, C2PSM modules, and a Slim-Neck structure to construct a lightweight feature extraction network, namely the SCSNet model. The overall network structure still follows the three-stage design of the YOLO series Backbone-Neck-Head. By improving the backbone feature extraction module and feature fusion structure, the number of model parameters and computational complexity are significantly reduced while ensuring detection accuracy.
[0027] In the SCSNet backbone, the input image first undergoes initial feature extraction and spatial downsampling through a 3×3 Stem convolutional layer with a stride of 2. This maps the original image to a higher-dimensional feature space, obtaining basic low-level visual information such as edges, textures, and color variations. The network then enters a hierarchical feature extraction stage consisting of multiple stages. Each stage first reduces the spatial resolution of the feature map and increases the channel dimension through a 3×3 downsampling convolution, and then stacks multiple Star Block modules for deep feature learning. Compared to traditional convolutional structures, StarBlock introduces a lightweight deep convolutional structure and feature interaction mechanism, effectively reducing computation while maintaining expressive power.
[0028] Specifically, the architecture of the Star Block module is as follows: Figure 3 As shown, each Star Block module first uses 7×7 depthwise convolution to extract local spatial information and expand the receptive field. Then, it expands the features through two parallel 1×1 convolution branches, forming two different feature representations. The core Star Operation is then performed, which involves element-wise multiplication and fusion of the output features from the two branches, creating a non-linear feature interaction under the ReLU6 activation function. This multiplicative fusion structure explicitly models the coupling relationship between features, enabling the network to achieve more comprehensive information interaction in both channel and spatial dimensions. After the Star Operation, the features are further compressed through 1×1 convolutions and combined with 7×7 depthwise convolutions to extract spatial information. Finally, the output and input features are added through a residual connection structure, thereby enhancing gradient propagation capabilities and preserving original information. Through the stacked Star Block modules, the network can progressively extract multi-level information from low-level texture features to high-level semantic features.
[0029] In the deeper layers of the backbone network, the SCSNet model introduces a C2PSM module (C2PSA_MLCA) to further enhance feature representation capabilities. This module embeds a Mixed Local Channel Attention (MLCA) mechanism into the Cross-Stage Partial (CSP) network structure. It extracts local and global features separately through adaptive average pooling and learns the dependencies between different channels using one-dimensional convolution, thereby dynamically generating channel attention weights. Subsequently, the local and global attention are weighted and fused, and mapped back to the original feature map size, achieving adaptive enhancement of important feature regions. Simultaneously, the module employs parallel convolutional paths and residual connection structures to synergistically enhance local detail information and high-level semantic information, thereby improving the network's ability to represent complex target structures and key feature points.
[0030] In the neck network, the SCSNet model employs a Slim-Neck architecture for multi-scale feature fusion. First, upsampling operations are used to progressively restore high-level semantic features to higher resolution, which are then concatenated with feature maps of corresponding scales in the backbone network to achieve information fusion across different levels. During the fusion process, the network introduces a Ghost-Shuffle Convolution (GSConv) module to optimize cross-scale feature interactions. GSConv combines ordinary convolutions with depthwise convolutions and utilizes a channel rearrangement mechanism to achieve thorough mixing of feature information, thereby reducing computational complexity while maintaining strong feature representation capabilities. Subsequently, a lightweight cross-stage feature pyramid structure is constructed using the VoV-GSCSP module, a one-time aggregation cross-stage partial connection module. Partial channel residual connections and multi-branch convolutional paths further refine the fused features, achieving efficient integration of multi-scale semantic and detailed information.
[0031] Through the above structural design, the SCSNet model ultimately outputs feature maps of three different scales (P3, P4, and P5) in the Neck network, which are used for the detection of small, medium, and large targets, respectively. The detection head predicts these feature maps within the YOLOv11 pose estimation framework, outputting target category, bounding box location, and keypoint coordinates, achieving multi-scale target detection and pose estimation. Furthermore, during the training phase, the SCSNet model uses manually labeled body-size keypoints as supervision signals. The model parameters are optimized by minimizing the regression error between predicted and true keypoints, thereby obtaining a keypoint detection model suitable for actual livestock farming environments. This allows for the automatic and stable acquisition of the two-dimensional pixel coordinates of each keypoint of the livestock being measured, providing reliable input for subsequent three-dimensional mapping. For example, during the training phase, the SCSNet model is used to detect target images and predict the predicted body size keypoints of livestock, such as measurement points representing the livestock's body length, chest depth, body width, hip width, and chest width. Based on the error between the predicted and actual body size keypoints, the SCSNet model is trained using gradient descent to obtain the keypoint detection model. Gradient descent is used to optimize the parameters of the SCSNet model to minimize the prediction error of the predicted body size keypoints.
[0032] Step 12: Fuse the two-dimensional coordinates of each body scale keypoint in the color image and its depth information in the depth image to obtain the three-dimensional coordinates of each body scale keypoint in the camera coordinate system. For example, when the depth information of the body scale keypoint in the depth image is within a preset range, map the two-dimensional coordinates and depth information in the color image to the camera coordinate system according to the camera intrinsic parameters corresponding to the color image to obtain the three-dimensional coordinates of the body scale keypoint in the camera coordinate system. Combine the three-dimensional coordinates of each body scale keypoint in the camera coordinate system with the corresponding camera extrinsic parameters to determine the three-dimensional coordinates of each body scale keypoint in the world coordinate system.
[0033] Specifically, for the two-dimensional pixel coordinates of body size key points extracted by object detection algorithms, such as the SCSNet model... This is combined with depth information from the corresponding depth image and mapped to three-dimensional spatial coordinates. For example, for each keypoint, based on its two-dimensional pixel coordinates... Read its depth value from the corresponding depth image. When the depth value Within the effective measurement range, the two-dimensional pixel coordinates and depth values are mapped to three-dimensional spatial coordinates in the camera coordinate system based on the camera intrinsic parameter matrix. ,at this time Coordinates corresponding to the depth direction, and These represent the horizontal and vertical positions in space corresponding to the pixel plane, respectively. Furthermore, when the depth value... Not within the effective measurement range, such as depth values If the depth value is empty, the Y-axis is searched on the mask image with the location of the two-dimensional body size data as the center. The first non-empty coordinate data obtained by the search is used as the coordinate of the body size measurement point. Then, the depth value is mapped to the three-dimensional space to obtain the three-dimensional body size data, thereby improving the robustness of subsequent livestock body size measurement.
[0034] For example, the camera intrinsic parameters in this invention describe the inherent characteristic properties of the camera, including focal length ( ), principal point coordinates The distortion parameters can be represented by a 3×3 matrix K. The transformation from the camera coordinate system to the image pixel coordinate system requires projecting points in the camera coordinate system onto the image plane using camera intrinsic parameters. The transformation from a point in the 2D image coordinate system to a point in the world coordinate system is shown in formula (1): (1) in, In three-dimensional space coordinates, and These represent the focal lengths of the camera in the x and y directions, respectively. Represents the position of a pixel in a two-dimensional image plane. This represents the depth value corresponding to each pixel. After transformation, in a unified world coordinate system, the three-dimensional spatial coordinates of each key point are used as skeleton nodes. Based on the anatomical structure and body size measurement requirements of livestock, connections are established between the corresponding nodes to form a three-dimensional skeleton topology reflecting the structure of the livestock's head, torso, and limbs. This describes the relative positional relationships of the key body parts of the livestock to be measured in space, while maintaining the geometric continuity and structural rationality between the body segments of the livestock to be measured, providing a unified data carrier for subsequent body size parameter calculation and posture analysis.
[0035] Step 13: Construct a three-dimensional skeleton model of the livestock to be measured using the three-dimensional coordinates of the key points of the individual size in the world coordinate system; based on the spatial distance between the key points in the three-dimensional skeleton model, obtain the body size measurement results of the livestock to be measured.
[0036] The body size key points include those from the side view and those from the top view. The side view key points include the eyes, midpoint of the neck, highest point of the shoulder, root of the left forelimb, left foreknee, left forehoof, root of the right forelimb, right foreknee, right forehoof, highest point of the hip, root of the left hindlimb, left hindknee, left hindhoof, root of the right hindlimb, right hindknee, right hindhoof, sternal prominence, and posterior edge of the ischial tuberosity. The top view key points include the widest points of the left and right scapulae, the widest points of the left and right hip joints. The body size measurement results include the chest depth, body length, hip width, shoulder width, hip height, and shoulder height parameters of the animal being measured. Step 13 includes: Step 131: Based on the three-dimensional spatial coordinates between the highest point of the shoulder, the root of the left forelimb, the left foreknee, and the left forehoof of the livestock to be measured, determine the Euclidean distances between the highest point of the shoulder and the root of the left forelimb, the root of the left forelimb and the left foreknee, and the left foreknee and the left forehoof; determine the shoulder height parameter by the sum of the Euclidean distances between the highest point of the shoulder and the root of the left forelimb, the root of the left forelimb and the left foreknee, and the left foreknee and the left forehoof.
[0037] Step 132: Based on the three-dimensional spatial coordinates between the highest point of the hip, the root of the left hind limb, the left hind knee, and the left hind hoof, determine the Euclidean distances between the highest point of the hip and the root of the left hind limb, the root of the left hind limb and the left hind knee, and the left hind hoof; determine the hip height parameter by summing the Euclidean distances between the highest point of the hip and the root of the left hind limb, the root of the left hind limb and the left hind knee, and the left hind knee and the left hind hoof.
[0038] Step 133: Determine the Euclidean distance between the widest points of the left and right scapulae based on their three-dimensional spatial coordinates, and then determine the shoulder width parameters based on the Euclidean distance between the scapulae.
[0039] Step 134: Determine the Euclidean distance of the hip joints based on the three-dimensional spatial coordinates between the widest points of the left and right hip joints, and then determine the hip width parameters based on the Euclidean distance of the hip joints.
[0040] Step 135: Determine the Euclidean distance of the body length based on the three-dimensional spatial coordinates between the sternal prominence and the posterior edge of the ischial tuberosity, and determine the body length parameters based on the Euclidean distance of the body length.
[0041] Step 136: Determine the Euclidean distance of the chest depth based on the three-dimensional spatial coordinates between the highest point of the shoulder and the root of the left forelimb, and determine the chest depth parameters based on the Euclidean distance of the chest depth.
[0042] Specifically, once the three-dimensional skeleton is constructed, various body size indicators of the livestock can be obtained by calculating the three-dimensional Euclidean distance between different key points in the skeleton model. For example, the shoulder height of the livestock to be measured is obtained by accumulating the spatial distances between adjacent skeleton nodes such as the highest point of the shoulder to the root of the forelimb, the root of the forelimb to the foreknee, and the foreknee to the forehoof. The hip height of the livestock to be measured is obtained by accumulating the spatial distances between the highest point of the hip to the root of the hindlimb, the root of the hindlimb to the hindknee, and the hindknee to the hindhoof. The shoulder width of the livestock to be measured is obtained by the distance between the widest points of the left and right scapulae in three-dimensional space. The hip width of the livestock to be measured is obtained by the distance between the widest points of the left and right hip joints in three-dimensional space. The body length of the livestock to be measured is obtained by the spatial distance between the protruding point of the sternum and the posterior edge of the ischial tuberosity. The chest depth of the livestock to be measured is obtained by the spatial distance between the highest point of the shoulder and the root of the forelimb. Since all the above-mentioned body size indicators are calculated directly based on three-dimensional spatial coordinates, they can effectively eliminate measurement errors caused by changes in viewing angle, perspective scaling and posture offset under two-dimensional imaging conditions, and improve the consistency and objectivity of body size measurement results.
[0043] Step 14: Extract posture features from the 3D skeleton model using a pre-trained regression model, and determine the posture error of the livestock to be measured based on the posture features; determine the corrected body size measurement results of the livestock to be measured based on the body size measurement results and posture error.
[0044] The regression model is a stacked ensemble regression model, which includes a basic regression model for predicting the head and neck posture of livestock, a basic regression model for predicting the trunk orientation of livestock, a basic regression model for predicting the limb support state of livestock, and a meta-regression model. Step 14 includes: Step 141: Predict the head and neck posture error of the livestock to be measured from the three-dimensional skeleton model using the basic regression model used to predict the head and neck posture of livestock.
[0045] Step 142: Predict the posture error of the trunk orientation of the livestock to be measured from the three-dimensional skeleton model using the basic regression model used to predict the trunk orientation of the livestock.
[0046] Step 143: Predict the limb support posture error of the livestock to be measured from the three-dimensional skeleton model using the basic regression model used to predict the limb support state of livestock.
[0047] Step 144: Determine the posture error of the livestock to be measured by using a meta-regression model, based on the head and neck posture error, trunk orientation posture error, and limb support posture error.
[0048] Specifically, while calculating the Euclidean distance, the posture parameters of the livestock to be measured in the image are determined by analyzing key points in the three-dimensional skeleton. For example, by analyzing the relative positions and orientations of the head, neck, and torso key points in three-dimensional space, posture features reflecting the head and neck pitch and yaw are extracted; by analyzing the spatial distribution relationship between the torso key points, posture features reflecting the overall orientation and tilt of the torso are extracted; and by analyzing the spatial relationship between the limb key points and the ground plane, posture features reflecting the limb support state, standing stability, and force distribution of the livestock are extracted. Thus, the body position of the livestock during body size measurement is depicted from multiple dimensions.
[0049] Then, these posture features are input into a pre-trained stacked ensemble regression model to predict the measurement error caused by the animal's posture in the body size measurement results. Based on the predicted measurement error, the posture correction is performed on the body size measurement results calculated based on Euclidean distance to obtain the corrected body size measurement results.
[0050] The stacked ensemble regression model employed in this invention consists of multiple basic regression models and a meta-regression model used to fuse the outputs of the basic models. Each basic regression model learns the mapping relationship between different posture features and body size measurement errors. The meta-regression model weights and fuses the prediction results of each basic model to obtain more stable and accurate error prediction values. After fusing the prediction error output by the model with the original body size measurement results, the final corrected body size data is obtained. Through the aforementioned stacked ensemble regression model, measurement deviations introduced by posture factors such as head and neck deflection, trunk tilting, or uneven limb support in livestock can be effectively reduced, thereby significantly improving the applicability and robustness of the body size measurement system in actual breeding environments.
[0051] Based on the above implementation methods, such as Figure 4 As shown, this invention also provides a complete procedure for measuring the body size of livestock: First, color and depth images of livestock are acquired from different viewpoints using two or more pre-registered spatial cameras. Then, keypoint detection is performed on the color images from multiple viewpoints to obtain the two-dimensional pixel coordinates of each attachment point in the color image. An example of the keypoint detection results is shown below. Figure 5 As shown, Figure 5(1), (2), (3), and (4) are examples of key point structure visualizations for adult ewes, young ewes, young rams, and adult rams, respectively. Figure 5 It is known that the present invention can accurately extract key body size points for livestock of different sexes and ages, thereby completing the construction of a three-dimensional skeleton, avoiding the complexity of manual calibration and extraction of key points, as well as measurement errors caused by external factors.
[0052] By combining depth information from depth images, 2D pixel coordinates are mapped to 3D spatial coordinates in the camera coordinate system of that viewpoint. Based on the spatial registration relationship between different viewpoint camera coordinate systems, these 3D spatial coordinates are transformed into a unified world coordinate system. Then, a 3D skeleton model of the livestock is constructed from the 3D spatial coordinates of key points from each viewpoint in the world coordinate system, and body size parameters are calculated using the spatial geometric relationships between key points in the 3D skeleton model. Simultaneously, posture parameters representing the livestock's head and neck posture, trunk direction, and limb support state are extracted from the 3D skeleton model. These posture parameters are input into a pre-trained stacked ensemble regression model to predict body size measurement errors. The body size measurement results are corrected based on the predicted body size measurement errors, thus obtaining the posture-corrected body size measurement parameters of the livestock.
[0053] Example 2 The present invention also provides a livestock body size measurement system, comprising: The key point extraction module is used to acquire color and depth images of the livestock to be measured from multiple perspectives. The SCSNet model processes the color images from multiple perspectives to obtain body size key points. The SCSNet model is based on the YOLOv11 model, replacing the stacked standard convolutional layers in the YOLOv11 backbone with Star Block modules and the neck network with a slim-Neck network. Each Star Block module receives the feature map output from the downsampled convolution of its layer, extracts local spatial features from the feature map using 7×7 depthwise separable convolutions, expands the channels of the local spatial features using two parallel 1×1 convolutions, and fuses the two expanded features element-wise using a star-shaped operation to obtain fused features. The ReLU activation function combined with 1×1 convolutions compresses the parameters of the fused features to obtain the output features of the corresponding layer. The slim-Neck network processes the feature maps of multiple different scales output from the backbone network to obtain multi-scale feature maps for predicting body size key points.
[0054] The 3D coordinate determination module is used to fuse the 2D coordinates of each body scale key point in the color image and the depth information of the body scale key point in the depth image to obtain the 3D coordinates of each body scale key point in the camera coordinate system. The 3D coordinates of each body scale key point in the camera coordinate system are combined with the corresponding camera extrinsic parameters to determine the 3D coordinates of each body scale key point in the world coordinate system.
[0055] The results calculation module is used to construct a three-dimensional skeleton model of the livestock to be measured from the three-dimensional coordinates of the key points of the individual size in the world coordinate system; based on the spatial distance between the key points in the three-dimensional skeleton model, the body size measurement results of the livestock to be measured are obtained.
[0056] The present invention also provides a computer device, including a memory, a processor, and a computer program stored in the memory. The processor executes the computer program to implement the steps in an embodiment of a method for measuring the body size of livestock. Specific implementation methods can be found in the method embodiments, and will not be repeated here.
[0057] Furthermore, the present invention also provides a non-transitory computer-readable storage medium containing instructions, on which a computer program is stored. For example, a memory containing instructions that can be executed by a processor of a computer device to perform the above-described method. For example, the non-transitory computer-readable storage medium may be a ROM, random access memory (RAM), CD-ROM, magnetic tape, floppy disk, and optical data storage device, etc. When the computer program is executed by the processor, it can implement the steps in an embodiment of a method for measuring the body size of livestock. Specific implementation methods can be found in the method embodiments, which will not be repeated here.
[0058] Those skilled in the art will understand that embodiments of the present invention can provide methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0059] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart. Figure 1One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.
[0060] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0061] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0062] It should be noted that the specific embodiments described above enable those skilled in the art to more fully understand the present invention, but do not limit the present invention in any way. Therefore, although the present invention has been described in detail in this specification and embodiments, those skilled in the art should understand that modifications or equivalent substitutions can still be made to the present invention; and all technical solutions and improvements that do not depart from the spirit and scope of the present invention are covered within the protection scope of the present invention patent. No reference numerals in the claims should be construed as limiting the scope of the claims. Any simple variations or equivalent substitutions of technical solutions that can be readily obtained by those skilled in the art within the scope of the technology disclosed in the present invention are within the protection scope of the present invention.
Claims
1. Livestock body dimension measuring method, characterized in that, include: Collect color and depth images of the livestock to be measured from multiple perspectives; The SCSNet model processes color images from multiple viewpoints to obtain body scale keypoints from various perspectives. The SCSNet model is based on the YOLOv11 model, replacing the stacked standard convolutional layers in the YOLOv11 backbone with StarBlock modules and the neck network with a slim-Neck network. Each StarBlock module receives the feature map output from the downsampled convolution of its layer, extracts local spatial features from the feature map using a 7×7 depthwise separable convolution, expands the channels of these local spatial features using two parallel 1×1 convolutions, and fuses the two expanded features element-wise using a star-shaped operation to obtain fused features. The ReLU activation function combined with 1×1 convolutions compresses the parameters of the fused features to obtain the output features of the corresponding layer. The slim-Neck network processes the feature maps of multiple different scales output from the backbone network to obtain multi-scale feature maps for predicting body scale keypoints. The two-dimensional coordinates of each body scale key point in the color image and the depth information of the body scale key point in the depth image are fused to obtain the three-dimensional coordinates of each body scale key point in the camera coordinate system. The three-dimensional coordinates of each body scale key point in the camera coordinate system are determined by combining the three-dimensional coordinates of each body scale key point in the camera coordinate system with the corresponding camera extrinsic parameters. A three-dimensional skeleton model of the livestock to be measured is constructed using the three-dimensional coordinates of the key points of the individual body size in the world coordinate system; based on the spatial distance between the key points in the three-dimensional skeleton model, the body size measurement results of the livestock to be measured are obtained.
2. A method of measuring the dimensions of a domestic animal body according to claim 1, characterized in that, A C2PSM module is also embedded after the SPPF module in the backbone network of the SCSNet model. The C2PSM module splits the output features of the SPPF module into multiple branch features, performs multiple feature transformations on one branch feature, and then merges it with the features of another branch to obtain the output features of the deepest layer of the backbone network.
3. A method of measuring the dimensions of a domestic animal body according to claim 1, characterized in that, By fusing the two-dimensional coordinates of each body scale keypoint in the color image and the depth information of the keypoint in the depth image, the three-dimensional coordinates of each keypoint in the camera coordinate system are obtained, including: When the depth information of the body scale key point in the depth image is within a preset range, the two-dimensional coordinates and depth information in the color image are mapped to the camera coordinate system according to the camera intrinsic parameters corresponding to the color image, so as to obtain the three-dimensional coordinates of the body scale key point in the camera coordinate system.
4. A method of measuring the dimensions of a domestic animal body according to claim 1, characterized in that, The key points of the scale include key points of the scale from the side view and key points of the scale from the top view. The key body scale points in the lateral view include the eyes, the midpoint of the neck, the highest point of the shoulder, the root of the left forelimb, the left foreknee, the left forehoof, the root of the right forelimb, the right foreknee, the right forehoof, the highest point of the hip, the root of the left hindlimb, the left hindknee, the left hindhoof, the root of the right hindlimb, the right hindknee, the right hindhoof, the sternal prominence, and the posterior edge of the ischial tuberosity. The key body dimensions from the top view include the widest point of the left scapula, the widest point of the right scapula, the widest point of the left hip joint, and the widest point of the right hip joint.
5. A method for measuring the body size of livestock according to claim 4, characterized in that, The body size measurement results include the chest depth, body length, hip width, shoulder width, hip height, and shoulder height parameters of the livestock to be measured. Based on the spatial distance between key points in the three-dimensional skeleton model, the body size measurement results of the livestock to be measured are as follows: Based on the three-dimensional spatial coordinates between the highest point of the shoulder, the root of the left forelimb, the left foreknee, and the left forehoof of the livestock to be measured, the Euclidean distances between the highest point of the shoulder and the root of the left forelimb, the root of the left forelimb and the left foreknee, and the left foreknee and the left forehoof are determined; the shoulder height parameter is determined by the sum of the Euclidean distances between the highest point of the shoulder and the root of the left forelimb, the root of the left forelimb and the left foreknee, and the left foreknee and the left forehoof. Based on the three-dimensional spatial coordinates between the highest point of the hip, the root of the left hind limb, the left hind knee, and the left hind hoof, the Euclidean distances between the highest point of the hip and the root of the left hind limb, the root of the left hind limb and the left hind knee, and the left hind hoof are determined; the hip height parameter is determined by the sum of the Euclidean distances between the highest point of the hip and the root of the left hind limb, the root of the left hind limb and the left hind knee, and the left hind knee and the left hind hoof. The Euclidean distance between the widest points of the left and right scapulae is determined based on the three-dimensional spatial coordinates between them, and the shoulder width parameter is determined based on the Euclidean distance between the scapulae. The hip joint Euclidean distance is determined based on the three-dimensional spatial coordinates between the widest point of the left hip joint and the widest point of the right hip joint, and the hip width parameter is determined based on the hip joint Euclidean distance. The body length Euclidean distance is determined based on the three-dimensional spatial coordinates between the sternal prominence and the posterior edge of the ischial tuberosity, and the body length parameter is determined based on the body length Euclidean distance. The chest depth Euclidean distance is determined based on the three-dimensional spatial coordinates between the highest point of the shoulder and the root of the left forelimb, and the chest depth parameter is determined based on the chest depth Euclidean distance.
6. A method of measuring the dimensions of a domestic animal body according to claim 1, characterized in that, After obtaining the body size measurement results of the livestock to be measured, the method further includes: Posture features are extracted from the 3D skeleton model using a pre-trained regression model, and the posture error of the livestock to be measured is determined from the posture features. The corrected body size measurement results of the livestock to be measured are determined based on the body size measurement results and posture errors of the livestock to be measured.
7. A method of measuring the dimensions of a domestic animal body according to claim 6, characterized in that, The regression model is a stacked ensemble regression model, which includes a base regression model for predicting the head and neck posture of livestock, a base regression model for predicting the trunk orientation of livestock, a base regression model for predicting the limb support state of livestock, and a meta-regression model. Posture features are extracted from the 3D skeleton model using the pre-trained regression model, and the posture error of the livestock to be measured is determined from these features, including: The head and neck posture error of the livestock to be measured is predicted by the three-dimensional skeleton model using the basic regression model for predicting livestock head and neck posture. The trunk orientation posture error of the livestock to be measured is predicted by the three-dimensional skeleton model using the basic regression model used to predict the trunk orientation of the livestock. The three-dimensional skeleton model predicts the limb support posture error of the livestock to be measured using the basic regression model used to predict the limb support state of livestock. The posture error of the livestock to be measured is determined by the meta-regression model based on the head and neck posture error, trunk orientation posture error, and limb support posture error.
8. Livestock body dimension measuring system, characterized in that include: The key point extraction module is used to acquire color and depth images of the livestock to be measured from multiple perspectives; The SCSNet model processes color images from multiple viewpoints to obtain body scale keypoints from various perspectives. The SCSNet model is based on the YOLOv11 model, replacing the stacked standard convolutional layers in the YOLOv11 backbone with Star Block modules and the neck network with a slim-Neck network. Each Star Block module receives the feature map output from the downsampled convolution of its layer, extracts local spatial features from the feature map using a 7×7 depthwise separable convolution, expands the channels of these local spatial features using two parallel 1×1 convolutions, and fuses the two expanded features element-wise using a star operation to obtain fused features. The ReLU activation function combined with 1×1 convolutions compresses the parameters of the fused features to obtain the output features of the corresponding layer. The slim-Neck network processes the feature maps of multiple different scales output from the backbone network to obtain multi-scale feature maps for predicting body scale keypoints. The three-dimensional coordinate determination module is used to fuse the two-dimensional coordinates of each body scale key point in the color image and the depth information of the body scale key point in the depth image to obtain the three-dimensional coordinates of each body scale key point in the camera coordinate system. The three-dimensional coordinates of each body scale key point in the camera coordinate system are combined with the corresponding camera extrinsic parameters to determine the three-dimensional coordinates of the body scale key point in the world coordinate system. The result calculation module is used to construct a three-dimensional skeleton model of the livestock to be measured from the three-dimensional coordinates of the key points of the individual size in the world coordinate system; and to obtain the body size measurement results of the livestock to be measured based on the spatial distance between the key points in the three-dimensional skeleton model.
9. A computer device comprising a memory, a processor, and a computer program stored on the memory, wherein the computer program comprises instructions that, when executed by the processor, cause the processor to perform the method of any one of claims 1-8. The processor executes the computer program to implement the steps of the livestock body size measurement method according to any one of claims 1 to 7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, When the computer program is loaded by the processor, it is able to perform the steps of the livestock body size measurement method according to any one of claims 1 to 7.