Pig body size measuring method based on multi-view three-dimensional reconstruction

Through multi-view three-dimensional reconstruction technology, the efficiency and accuracy of pig body ruler measurement is achieved, the problem of time-consuming, labor-intensive and insufficient accuracy of traditional methods is solved, and a contactless and automated measurement solution is provided.

CN119949809APending Publication Date: 2025-05-09SOUTH CHINA AGRICULTURAL UNIVERSITY
View PDF 0 Cites 6 Cited by

Patent Information

Application Number
CN202510025825.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-08
Publication Date
2025-05-09

AI Technical Summary

Technical Problem

The traditional pig body ruler measurement method is time-consuming and labor-intensive, which can easily lead to pig stress response, and is insufficient in accuracy and efficiency.

Method used

Using a measurement method based on multi-view three-dimensional reconstruction, multi-view images are obtained through Hikvision surveillance cameras, and image processing and three-dimensional reconstruction are used to realize contactless pig body ruler measurement.

Benefits of technology

It improves measurement efficiency and accuracy, reduces manual intervention, reduces pig stress response, can accurately measure pig body length, body width and body height, and analyzes its skeletal structure.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119949809A_ABST
    Figure CN119949809A_ABST
Patent Text Reader

Abstract

The invention discloses a pig body size measuring method based on multi-view three-dimensional reconstruction. In order to overcome the flexibility limitation caused by standard geometric constraints in a traditional method, the method adopts a DUSt3R method to perform three-dimensional reconstruction on the pig, so that the three-dimensional reconstruction process is effectively simplified, and the accuracy and efficiency of three-dimensional reconstruction are also improved. However, the reconstructed point cloud has noise and loss due to self-shielding of the pig, and the method constructs a complete pig three-dimensional grid by fitting a pig shape model and point cloud data. And the body measurement value is extracted from the reconstructed three-dimensional grid, so that the measurement accuracy and reliability are further improved. Therefore, the method can flexibly deal with complex and changeable environments in a pig farm and various motion modes of pigs, and provides more flexible, comprehensive and accurate technical support for pig body size measurement.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the technical field of pig body measurement, and is specifically a method based on multi-view Figure 3 A method for measuring pig body size based on three-dimensional reconstruction. Background Art

[0002] The body size parameters of pigs can effectively reflect their growth and development, and are therefore considered important indicators for evaluating the growth and development of pigs. Generally speaking, body size parameters mainly include body length, body width and body height. At present, the measurement of pig body size mainly relies on manual means, usually with the help of tools such as measuring rods, circular measuring instruments and tape measures. However, this traditional measurement method is not only time-consuming and labor-intensive, but may also cause stress reactions in pigs, thereby affecting the accuracy of the measurement. In addition, manual tape measure measurement also has great limitations in accuracy and efficiency, and it is particularly difficult to measure complex traits. Researchers are exploring non-contact measurement technology to improve efficiency and accuracy. In recent years, with the development of three-dimensional depth camera technology, the application of three-dimensional reconstruction in pig body size measurement has become increasingly widespread. However, depth cameras have defects such as high equipment cost and poor light adaptability, prompting researchers to turn to multi-view Figure 3 Dimensional reconstruction method. Figure 3 The 3D-reconstructed pig body size measurement has the advantages of high precision, high efficiency, non-contact and strong adaptability. Summary of the invention

[0003] The purpose of the present invention is to provide a method based on multi-view Figure 3 A method for measuring pig body size based on three-dimensional reconstruction.

[0004] The technical solution adopted by the present invention is as follows: a multi-view Figure 3 The method for measuring the body size of pigs by three-dimensional reconstruction is characterized in that the method comprises the following steps:

[0005] S1: Build a pig body measurement platform. Hikvision surveillance cameras are used for data collection. These cameras are set up at the four corners of the pig pen at a height of 1.5 meters.

[0006] S2: After acquiring data and obtaining RGB images of different directions, angles and light intensities, labelimg is used to detect and roughly crop the pigs to obtain the approximate position of the pigs in the original image; then the pigs are masked and annotated using the eiseg annotation software, and the pig image size resolution is adjusted to 256×256 according to the mask position;

[0007] S3: Input a set of multi-view image data into the DUSt3R framework, and infer the multi-view point cloud data of the same pig and calibration object, as well as the camera parameters of each view. The obtained point cloud data is preprocessed. First, the background is removed by threshold segmentation to reduce the amount of data, and the radius filter in the PCL library is used to remove outliers; then the normal vector of the pig point cloud is estimated based on the principal component analysis method (PCA). And the scale factor is calculated based on the reconstructed calibration object point cloud and its known true length.

[0008] S4: Use the 2D key points extracted by DeepLabCut and the camera parameters restored by the DUSt3R algorithm to achieve the mapping of 2D key points to 3D key points;

[0009] S5: aligning the 3D key points of the preprocessed point cloud data with the 3D key points of the pig 3D mesh template, and performing a rough registration of the point cloud data and the pig 3D mesh template;

[0010] S6: Fitting the pig 3D mesh template to the point cloud data using the fitting-based method Smalify, which includes two optimization stages. The first stage includes optimizing the posture, translation and scaling parameters, and the second stage further adds the optimization of shape parameters;

[0011] S7: Use non-rigid registration (NICP) to optimize the fitting effect. Calculate an affine matrix for each point of the fitted pig 3D mesh, and smooth the mesh while optimizing the affine matrix;

[0012] S8: Extract key points from the 3D model and calculate the skeletal structure and position of the pig; in order to make the network pay more attention to the structural learning of the pig's trunk and the accuracy of body size estimation, calculate the midpoint of the y coordinate of the point cloud data, and filter out the points above the midpoint, find the points corresponding to the maximum and minimum values ​​of the z coordinates among these points, and set their x coordinates to 0 to ensure that they are on the symmetry axis, among which point A (x A ,y A ,z A ) was selected as one of the key points for calculating body length, accurately reflecting the posterior position of the pig; then, according to the required number of bones, the linear interpolation method was used to generate the joint positions from the front and rear points to the midpoint, and the parent-child relationship between the bones was established to form a complete motion chain.

[0013] In a preferred embodiment, in step S1, the platform is composed of a video recorder, four Hikvision surveillance cameras, a wireless local area network and a display.

[0014] In a preferred embodiment, in step S2, in order to improve efficiency and be suitable for real-time applications, a lightweight model static_hrnet18s_ocr48_cocolvis is selected; after completing the mask annotation, the image size is adjusted to 256×256 pixels.

[0015] In a preferred embodiment, in step S3, a group of images are input into the DUSt3R framework, and the three-dimensional point cloud data of the pigpen scene is inferred. In order to improve the efficiency and accuracy of subsequent processing, the point cloud data is first preprocessed. First, different views of the original point cloud data are threshold segmented to remove the background, retain the data within a certain range from the camera, and remove outliers through radius filtering in the PCL library, and set the search radius and the minimum number of field points according to the point cloud density. Then, the origin of the pig point cloud is estimated based on the principal component analysis method (PCA), and the normal vector is calculated by searching the N nearest points of each point and fitting the surface to ensure that the normal vector can be calculated for each point. The point cloud of the reconstructed calibration disk is compared with its known real body size information to obtain a scale factor for converting the pig point cloud body size into real body size information.

[0016] In a preferred embodiment, in step S4, in order to obtain an accurate three-dimensional mesh of the pig, the pig template mesh is fitted to the point cloud data, and in the model fitting process, the corresponding points are required as alignment constraints. First, the convolutional neural network is trained in DeepLabCut using RGB image data with 2D key points, and the 2D key points are obtained by post-inference; then the 2D key points are combined with the camera information restored by the DUSt3R algorithm to achieve 2D key point to 3D key point mapping.

[0017] In a preferred embodiment, in step S5, in order to avoid the fitting process falling into a local optimal solution, it is necessary to perform a rough registration of the pig template grid and the point cloud data. A quaternion-based alignment algorithm is used to achieve a rough alignment between the pig template grid and the point cloud data. First, the 3D key points of the template grid and the point cloud data are obtained. For each pair of key points, the alignment error is calculated, and the rotation matrix R, the translation vector b and the scaling factor a are solved by minimizing the square error and E(a, R, b) between the corresponding points.

[0018] In a preferred embodiment, in step S6, the input parameters of the pig template grid include 33-dimensional posture parameters, 41-dimensional shape parameters and displacement parameters. In the fitting process, parameter optimization is divided into two steps: the first step is to optimize the posture parameters, displacement parameters and scaling parameters, and generate an energy function by calculating the square error between corresponding key points. In this step, the initial values ​​of the posture parameters and displacement parameters are set to 0, and the scaling parameters are set to 1. It is iteratively solved to better fit the template grid to the point cloud data. The second step is to further optimize the shape parameters while ensuring the validity of the corresponding points. The validity is determined by calculating the angle between the nearest distance and the normal vector is less than 60°. The energy function that calculates the error between valid corresponding points continues to be optimized until the convergence condition is met. Through these two steps, the template grid is finally closely aligned with the point cloud data to obtain a better fitting effect.

[0019] In a preferred embodiment, in step S7, the L-BFGS-B algorithm is first used to optimize the affine matrix, the affine matrix is ​​initialized to the unit matrix, and parameters are set to perform initial alignment. In the initial optimization process, the corresponding points are fully utilized for registration, and then the affine matrix is ​​iteratively updated to gradually reduce the parameter value to increase the influence of the effective corresponding points on the fitting.

[0020] In a preferred embodiment, in step S7, the mesh surface is smoothed by the following three methods to ensure that the surface is smooth and consistent:

[0021] Extract edge information from the given 3D mesh vertex and patch data, compare the actual length of each edge with the target edge length, and calculate the loss. The specific calculation is as follows:

[0022]

[0023] Where E is the edge set, which contains n edges; M is the number of grids; L i is the actual length of the ith edge; L target is the target side length;

[0024] In order to reduce the irregularity and abruptness of the model surface and improve the robustness and accuracy of the model, the normal consistency loss is introduced as the optimization target; the specific calculation is as follows

[0025]

[0026] Where M is the number of grids, n i is the number of edges in the i-th grid, n0 and n1 are the normals of edge i;

[0027] In order to improve the smoothness of the mesh, Laplace smoothing is performed on the three-dimensional mesh. The specific calculation is as follows:

[0028]

[0029] Among them, N(i) is the set of vertices adjacent to vertex i, w ij is the weight between vertex i and vertex j, calculated using the cotangent value.

[0030] In a preferred embodiment, in step S8, in order to adapt to the data distribution, the quantile of the x coordinate is calculated, the four quadrants of the point on the xz plane are determined, and the soles of the legs are searched according to these quadrants to find the corresponding body joints and connect the leg bones to the body; considering the biological structure characteristics of the pig, adapting to different postures and reducing the error and noise in the calculation, the body length is calculated by the two points B (x B ,y B ,z B ) and C(x C ,y C ,z C ) and the difference between the z-value of point A. The body width passes through the uppermost joint D (x D ,y D ,z D ) and E(x E ,y E ,z E ), and the height is represented by the difference in the x-coordinates of the forelimbs and the z-values ​​of the forelimbs. B ,y B ,z B ) and C(x C ,y C ,z C ) in the z-coordinate range, find the point T(x T ,y T ,z T ), and calculate the difference between the y value of the point and the minimum y value of the forelimb sole. The specific calculation formula is as follows:

[0031]

[0032] W=|x D -x E |,

[0033] y T =argmax(y|z min ≤z≤z max ),

[0034] H=y T -min(y B -y C )

[0035] Among them, L represents body length, W represents body width, and H represents body width.

[0036] In summary, due to the adoption of the above technical solution, the beneficial effects of the present invention are:

[0037] 1. In the present invention, by fusing multi-view image information, the limitations of traditional methods are overcome, bringing revolutionary changes to the measurement of pig body size. First, the non-contact nature of this method greatly improves the measurement efficiency and convenience. Traditional measurement methods require manual operation, which is time-consuming and labor-intensive, and easily causes stress reactions in pigs, affecting the measurement accuracy. Figure 3 The method of three-dimensional reconstruction only needs to take images of pigs to automatically measure body dimensions without human intervention, saving a lot of time and labor costs. At the same time, it avoids direct contact with pigs, effectively reduces the stress response of pigs, and ensures the accuracy of measurement data.

[0038] 2. In the present invention, accurate measurement of pig body shape is achieved through multi-view image fusion and three-dimensional reconstruction technology. The traditional two-dimensional image measurement method is limited by the viewing angle and lighting conditions and is prone to errors. Figure 3 The 3D reconstruction method can obtain images of pigs from multiple perspectives, and fuse and reconstruct them through computer vision algorithms to generate a complete 3D model of the pig. The 3D model contains richer information and can more accurately reflect the body shape characteristics of the pig, including important parameters such as body length, body width and body height. In addition, this method can also analyze the skeletal structure of the pig, further improving the accuracy of body measurement.

[0039] 3. In the present invention, based on multi-view Figure 3 The method of 3D reconstruction for multi-view surveillance cameras can adapt to different scene requirements and effectively avoid occlusion problems. At the same time, RGB cameras have lower requirements for lighting conditions and are more applicable. Even under poor lighting conditions, high-quality images can be obtained to ensure the accuracy of the measurement results. In addition to being used for body size measurement of pigs, this method can also be applied to body size measurement and physical condition assessment of other livestock, as well as animal behavior analysis and kinematic research. In addition, this method can also be combined with artificial intelligence technology to achieve more intelligent animal monitoring and management, providing strong support for the development of animal husbandry. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 It is a schematic diagram of the collection platform 1 of the present invention;

[0041] Figure 2 It is a schematic diagram of the collection platform 2 in the present invention;

[0042] Figure 3 It is a flow chart of the overall method in the present invention;

[0043] Figure 4 is an example of a set of image data in the present invention;

[0044] Figure 5 The three-dimensional point cloud and three-dimensional mesh map of the pig reconstructed in the present invention;

[0045] Figure 6 This is a schematic diagram of measuring the body size of pigs in the present invention;

[0046] Figure 7 This is a diagram of the body size measurement results of pigs in the present invention. DETAILED DESCRIPTION

[0047] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention.

[0048] Reference Figure 3 ,

[0049] A multi-view based Figure 3 The method for measuring the body size of pigs reconstructed by the method comprises the following steps:

[0050] S1 platform construction:

[0051] The structural diagram of the pig body size data collection platform is as follows: Figure 1 As shown in the figure. In order to make the collected data more extensive, data collection was carried out twice in the pig farm. Each pig pen has an area of ​​about 6.9 meters by 3.5 meters, and the ground is all concrete to ensure that the pigs have enough space to move. Hikvision surveillance cameras were used for data collection, which were set up at the four corners of the pig pen at a height of about 1.5 meters. In this way, more comprehensive data can be obtained from multiple perspectives and different light intensities, enhancing the diversity and applicability of the data set. The platform mainly consists of a recorder, four Hikvision surveillance cameras (model: DS-IPC-T12H2-I, resolution of 1920×1080, frame rate of 25 frames / second), a display, a wireless LAN and a computer (Intel(R) Core(TM) i7-8750H CPU@2.20GHz). In order to avoid stress reactions in pigs, some feed was sprinkled on the ground of the pig pen to simulate their eating environment. This method effectively reduced the tension of the pigs and helped to record their behaviors and activities more naturally.

[0052] S2 data acquisition:

[0053] The image data obtained is as follows Figure 4As shown. This experiment was conducted in a farm in Meizhou City, Guangdong Province, China in May 2023 and January 2024. The data was mainly collected from 11 three-way hybrid pigs, aged 30 to 150 days. Each data collection will focus on a single pig and shoot from four different directions. Based on the data acquisition platform, a total of 7621 RGB images of individual pigs standing or walking were obtained and selected. When the pigs were in an upright state, a soft tape measure was used to measure the body length (the distance from the occipital bone to the base of the tail), body height (the distance from the highest point of the shoulder to the ground) and body width (the lateral distance at the widest part of the chest), and the real body size data of 3 pigs were obtained.

[0054] After obtaining RGB images of different directions, angles, and light intensities, labelimg was used to detect and roughly crop the pigs to obtain the approximate position of the pigs in the original image. The pigs were then labeled with masks using the eiseg annotation software. To improve efficiency and be suitable for real-time applications, the lightweight model static_hrnet18s_ocr48_cocolvis was selected. After completing the mask annotation, the image size was adjusted to 256×256 pixels.

[0055] S3 point cloud data acquisition and preprocessing:

[0056] A set of image data containing pig targets and calibration data is input into the DUSt3R framework, and the three-dimensional point cloud data of the pigpen scene is inferred. In order to improve the efficiency and accuracy of subsequent processing, a series of preprocessing steps are required for the point cloud data. First, the background noise is removed by threshold segmentation to filter out valid data within a specific range from the camera. Then the radius filtering technology in PCL is applied to remove outliers. By setting an appropriate search radius and the minimum number of field points, an area can be defined around each data point. Only when the number of neighboring points in the area reaches a certain size, the point is considered valid. Finally, the principal component analysis (PCA) technique is used to estimate the normal vector of the pig point cloud. Specifically, this step searches for the N nearest points of each point and uses these neighboring points for surface fitting to calculate the normal vector of each point. And a scaling factor for converting the pig point cloud body size to the real body size information is calculated based on the reconstructed calibration object point cloud and its known real length.

[0057] S4 keypoint mapping:

[0058] In order to obtain an accurate 3D mesh of the pig, the template mesh of the pig is fitted to the point cloud data, and in the model fitting process, the corresponding points are required as alignment constraints. First, the DeepLabCut model is trained using RGB image data with 2D key points, and the 2D key points of continuous multi-view videos are obtained by post-inference; then the 2D key points are combined with the camera information restored by the DUSt3R algorithm to achieve 2D key point to 3D key point mapping.

[0059] S5: Coarse registration and fitting of 3D mesh of pigs:

[0060] In order to avoid the fitting process falling into the local optimal solution, it is necessary to coarsely align the pig template mesh and point cloud data. The coarse alignment between the pig template mesh and the point cloud data is achieved using a quaternion-based alignment algorithm. First, the 3D key points of the template mesh and point cloud data are obtained. For each pair of key points, the alignment error is calculated, and the rotation matrix R, translation vector b, and scaling factor a are solved by minimizing the square error and E(a, R, b) between the corresponding points.

[0061] The input parameters of the pig SMAL template mesh include 33-dimensional posture parameters, 41-dimensional shape parameters and displacement parameters. In the fitting process, parameter optimization is divided into two steps: the first step is to optimize the posture parameters, displacement parameters and scaling parameters, and generate an energy function by calculating the square error between the corresponding key points. In this step, the initial values ​​of the posture parameters and displacement parameters are set to 0, and the scaling parameters are set to 1. It is solved iteratively to better fit the template mesh to the point cloud data. The second step is to further optimize the shape parameters while ensuring the validity of the corresponding points. The validity is determined by calculating the angle between the closest distance and the normal vector less than 60°. The energy function that calculates the error between the valid corresponding points continues to be optimized until the convergence condition is met. Through these two steps, the template mesh is finally closely aligned with the point cloud data, and a good fitting effect is obtained. Then, the L-BFGS-B algorithm is used to optimize the affine matrix, initialize the affine matrix to the unit matrix, and set the parameters for initial alignment. In the initial optimization process, the corresponding points are fully utilized for registration, and then the affine matrix is ​​iteratively updated to gradually reduce the value of the parameters to increase the influence of the valid corresponding points on the fitting. The reconstructed 3D point cloud and 3D mesh results of the pig are as follows: Figure 5 shown.

[0062] S6: Smooth mesh surface:

[0063] For the merged mesh, smooth the mesh surface using the following three methods to ensure that the surface is smooth and consistent.

[0064] (1) Extract edge information from the given 3D mesh vertex and patch data, compare the actual length of each edge with the target edge length, and calculate the loss. The specific calculation is as follows:

[0065]

[0066] Where E is the edge set, which contains n edges; M is the number of grids; L i is the actual length of the ith edge; L target is the target side length.

[0067] (2) In order to reduce the irregularity and abruptness of the model surface and improve the robustness and accuracy of the model, the normal consistency loss is introduced as the optimization objective. The specific calculation is as follows:

[0068]

[0069] Where M is the number of grids, n i is the number of edges in the i-th mesh, and n0 and n1 are the normals of edge i.

[0070] (3) To improve the smoothness of the mesh, Laplace smoothing is performed on the three-dimensional mesh. The specific calculation is as follows:

[0071]

[0072] Where N(i) is the set of vertices w adjacent to vertex i ij , is the weight between vertex i and vertex j, calculated using the cotangent value.

[0073] S7 Body Measurements:

[0074] To estimate the length, width and height of the pig, we first extracted point cloud data from the 3D model and calculated the pig's skeletal structure and position. To make the network focus more on the structure learning of the upper part of the pig and the accuracy of body size estimation, we calculated the midpoint of the y coordinate of the point cloud data, filtered out the points above the midpoint, found the points with the maximum and minimum z coordinates among these points, and set their x coordinates to 0 to ensure that they are on the symmetry axis. The point A (x A ,y A ,z A ) was selected as one of the key points for calculating body length, accurately reflecting the rear position of the pig. Then, based on the required number of bones, a linear interpolation method was used to generate the joint positions from the front and back points to the midpoint, and a parent-child relationship between the bones was established to form a complete kinematic chain. In order to adapt to the data distribution, the quantiles of the x-coordinate (95% and 5%) were calculated, the four quadrants of the point on the xz plane were determined, and the soles of the legs were searched according to these quadrants to find the corresponding body joints and connect the leg bones to the body. Considering the biological structure characteristics of the pig, adapting to different postures and reducing the error and noise in the calculation, the body length is calculated by the two points B (x B ,y B ,zB ) and C(x C ,y C ,z C ) and the difference between the z-value of point A. The body width passes through the uppermost joint D (x D ,y D ,z D ) and E(x E ,y E ,z E ), and the height is represented by the difference in the x-coordinates of the forelimbs and the z-values ​​of the forelimbs. B ,y B ,z B ) and C(x C ,y C ,z C ) in the z-coordinate range, find the point T(x T ,y T ,z T ), and calculate the difference between the y value of the point and the minimum y value of the forelimb sole. The specific expression is as follows:

[0075] Where L represents the body length W stands for body width and H stands for body width.

[0076] Experimental Results

[0077] The experimental results show the comparison and error analysis between the actual body length, height and width of three pigs and the predicted values. Among them, the predicted error range of body length is 3.3% to 5.4%, the error of body height is between 3.7% and 5.4%, and the error of body width is between 4.7% and 5%. This shows that this method has a high accuracy in assessing the body size of pigs, providing more reliable data support for breeding management and breeding decisions.

[0078] In this invention, by fusing multi-view image information, the limitations of traditional methods are overcome, bringing revolutionary changes to the measurement of pig body size. First, the non-contact nature of this method greatly improves the measurement efficiency and convenience. Traditional measurement methods require manual operation, which is time-consuming and labor-intensive, and easily causes stress reactions in pigs, affecting the measurement accuracy. Figure 3 The method of three-dimensional reconstruction only needs to take images of pigs to automatically measure body dimensions without human intervention, saving a lot of time and labor costs. At the same time, it avoids direct contact with pigs, effectively reduces the stress response of pigs, and ensures the accuracy of measurement data.

[0079] In the present invention, accurate measurement of pig body shape is achieved through multi-view image fusion and three-dimensional reconstruction technology. The traditional two-dimensional image measurement method is limited by the viewing angle and lighting conditions and is prone to errors. Figure 3 The 3D reconstruction method can obtain images of pigs from multiple perspectives, and fuse and reconstruct them through computer vision algorithms to generate a complete 3D model of the pig. The 3D model contains richer information and can more accurately reflect the body shape characteristics of the pig, including important parameters such as body length, body width and body height. In addition, this method can also analyze the skeletal structure of the pig, further improving the accuracy of body measurement.

[0080] In the present invention, based on multi-view Figure 3 The method of 3D reconstruction for multi-view surveillance cameras can adapt to different scene requirements and effectively avoid occlusion problems. At the same time, RGB cameras have lower requirements for lighting conditions and are more applicable. Even under poor lighting conditions, high-quality images can be obtained to ensure the accuracy of the measurement results. In addition to being used for body size measurement of pigs, this method can also be applied to body size measurement and physical condition assessment of other livestock, as well as animal behavior analysis and kinematic research. In addition, this method can also be combined with artificial intelligence technology to achieve more intelligent animal monitoring and management, providing strong support for the development of animal husbandry.

[0081] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the term "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0082] The above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for measuring pig body size based on multi-view three-dimensional reconstruction, characterized in that: The method comprises the following steps: S1: Build a pig body measurement platform. Hikvision surveillance cameras are used for data collection. These cameras are set up at the four corners of the pig pen at a height of 1.5 meters. S2: After acquiring data and obtaining RGB images of different directions, angles and light intensities, labelimg is used to detect and roughly crop the pigs to obtain the approximate position of the pigs in the original image; then the pigs are masked and annotated using the eiseg annotation software, and the pig image size resolution is adjusted to 256×256 according to the mask position; S3: Input a set of multi-view image data into the DUSt3R framework, and infer the multi-view point cloud data of the same pig and the calibration object, as well as the camera parameters of each view; preprocess the obtained point cloud data, first remove the background by threshold segmentation to reduce the data volume, and use radius filtering to remove outliers; then estimate the normal vector of the pig point cloud based on the principal component analysis method (PCA), and calculate the scale factor based on the reconstructed calibration object point cloud and the actual length of the calibration object; S4: Use the 2D key points extracted by DeepLabCut and the camera parameters restored by the DUSt3R algorithm to achieve the mapping of 2D key points to 3D key points; S5: aligning the 3D key points of the preprocessed point cloud data with the 3D key points of the pig 3D mesh template, and performing a rough registration of the point cloud data and the pig 3D mesh template; S6: Using the SMALify method, the pig 3D mesh template SMAL was fitted to the point cloud data, including two optimization stages; the first stage included the optimization of posture, translation and scaling parameters, and the second stage further added the optimization of shape parameters; S7: Optimize the fitting effect using non-rigid registration (NICP); calculate an affine matrix for each point of the fitted pig 3D grid, and smooth the grid while optimizing the affine matrix; S8: Extract key points from the 3D model and calculate the pig's skeletal structure and position; in order to make the network pay more attention to the structural learning of the pig's trunk and the accuracy of body size estimation, calculate the midpoint of the y coordinate of the point cloud data, and filter out the points above the midpoint, find the points corresponding to the maximum and minimum values ​​of the z coordinates among these points, and set their x coordinates to 0 to ensure that they are on the symmetry axis, among which point A (x A ,y A ,z A ) was selected as one of the key points for calculating body length, which accurately reflects the posterior position of the pig; then, according to the required number of bones, the linear interpolation method was used to generate the joint positions from the front and rear points to the midpoint, and the parent-child relationship between the bones was established to form a complete motion chain.

2. The method for measuring pig body size based on multi-view three-dimensional reconstruction according to claim 1, characterized in that: In step S1, the platform is composed of a video recorder, four Hikvision surveillance cameras, a wireless local area network, a display and a computer.

3. The method for measuring pig body size based on multi-view three-dimensional reconstruction according to claim 1, characterized in that: In the step S2, in order to improve efficiency and be suitable for real-time applications, a lightweight model static_hrnet18s_ocr48_cocolvis is selected; after completing the mask annotation, the image size is adjusted to 256×256 pixels.

4. The method for measuring pig body size based on multi-view three-dimensional reconstruction according to claim 1, characterized in that: In the step S3, a group of images are input into the DUSt3R framework, and the three-dimensional point cloud data of the pigpen scene is inferred; in order to improve the efficiency and accuracy of subsequent processing, the point cloud data is first preprocessed; first, different views of the original point cloud data are threshold segmented to remove the background, retain data within a certain range from the camera, and remove outliers through radius filtering, and the search radius and the minimum number of field points are set according to the point cloud density; then, the origin of the pig point cloud is estimated based on the principal component analysis method (PCA), and the normal vector is calculated by searching the N nearest points of each point and fitting the surface to ensure that the normal vector can be calculated for each point; and the reconstructed calibration object point cloud and its known true length are used to calculate the scale factor used to convert the pig point cloud body size into the true body size information.

5. The method for measuring pig body size based on multi-view three-dimensional reconstruction according to claim 1, characterized in that: In step S4, in order to obtain an accurate three-dimensional mesh of the pig, the pig template mesh is fitted to the point cloud data, and in the model fitting process, the corresponding points are required as alignment constraints; first, the DeepLabCut model is trained using RGB image data with 2D key points, and the 2D key points of the continuous multi-view video are acquired by post-inference; then the 2D key points are combined with the camera information restored by the DUSt3R algorithm to achieve 2D key point to 3D key point mapping.

6. The method for measuring pig body size based on multi-view three-dimensional reconstruction according to claim 1, characterized in that: In step S5, in order to avoid the fitting process falling into a local optimal solution, it is necessary to perform a rough alignment on the pig template grid and the point cloud data; a quaternion-based alignment algorithm is used to achieve a rough alignment between the pig template grid and the point cloud data; first, the 3D key points of the template grid and the point cloud data are obtained, and for each pair of key points, the alignment error is calculated, and the rotation matrix R, the translation vector b and the scaling factor a are solved by minimizing the square error and E(a, R, b) between the corresponding points.

7. The method for measuring pig body size based on multi-view three-dimensional reconstruction according to claim 1, characterized in that: In step S6, the input parameters of the pig template grid include 33-dimensional posture parameters, 41-dimensional shape parameters and displacement parameters; in the fitting process, parameter optimization is divided into two steps: the first step is to optimize the posture parameters, displacement parameters and scaling parameters, and generate an energy function by calculating the square error between corresponding key points; in this step, the initial values ​​of the posture parameters and displacement parameters are set to 0, and the scaling parameters are set to 1, and they are iteratively solved so as to better fit the template grid to the point cloud data. The second step is to further optimize the shape parameters while ensuring the validity of the corresponding points. The validity is determined by calculating that the angle between the nearest distance and the normal vector is less than 60°. The energy function that calculates the error between valid corresponding points continues to be optimized until the convergence condition is met. Through these two steps, the template grid is finally closely aligned with the point cloud data to obtain a better fitting effect.

8. The method for measuring pig body size based on multi-view three-dimensional reconstruction according to claim 1, characterized in that: In step S7, the L-BFGS-B algorithm is first used to optimize the affine matrix, the affine matrix is ​​initialized to a unit matrix, and parameters are set for initial alignment. In the initial optimization process, the corresponding points are fully utilized for registration, and then the affine matrix is ​​iteratively updated to gradually reduce the parameter values ​​to increase the influence of the effective corresponding points on the fitting.

9. The method for measuring pig body size based on multi-view three-dimensional reconstruction according to claim 1, characterized in that: In step S7, the mesh surface is smoothed by the following three methods to ensure that the surface is smooth and consistent; Extract edge information from the given 3D mesh vertex and patch data, compare the actual length of each edge with the target edge length, and calculate the loss. The specific calculation is as follows: Where E is the edge set, which contains n edges; M is the number of grids; L i is the actual length of the ith edge; L target is the target side length; In order to reduce the irregularity and abruptness of the model surface and improve the robustness and accuracy of the model, the normal consistency loss is introduced as the optimization target; the specific calculation is as follows Where M is the number of grids, n i is the number of edges in the i-th grid, n0 and n1 are the normals of edge i; In order to improve the smoothness of the mesh, Laplace smoothing is performed on the three-dimensional mesh. The specific calculation is as follows: Among them, N(i) is the set of vertices adjacent to vertex i, w ij is the weight between vertex i and vertex j, calculated using the cotangent value.

10. The method for measuring pig body size based on multi-view three-dimensional reconstruction according to claim 1, characterized in that: In step S8, in order to adapt to the data distribution, the quantile of the x coordinate is calculated, the four quadrants of the point on the xz plane are determined, and the soles of the legs are searched according to these quadrants to find the corresponding body joints and connect the leg bones to the body; considering the biological structure characteristics of the pig, adapting to different postures and reducing the error and noise in the calculation, the body length is calculated by the two points B (x B ,y B ,z B ) and C(x C ,y C ,z C ) and the difference between the z-value of point A. The body width passes through the uppermost joint D (x D ,y D ,z D ) and E(x E ,y E ,z E ), and the height is represented by the difference in the x-coordinates of the forelimbs and the z-values ​​of the forelimbs. B ,y B ,z B ) and C(x C ,y C ,z C ) in the z-coordinate range, find the point T(x T ,y T ,z T ), and calculate the difference between the y value of the point and the minimum y value of the forelimb sole. The specific calculation formula is as follows: W=|x D -x E |, y T =argmax(y|z min ≤z≤z max ), Hello T -min(and B -and C ) Among them, L represents body length, W represents body width, and H represents body width.

Citation Information

Cited By

  • Sheep body size measuring method and device based on three-dimensional reconstruction and point cloud segmentation, medium and program product

    CN120558098A

  • Pig hybridization breeding method, electronic equipment and program product

    CN121014576A

  • Pig body size automatic measuring method, device and equipment

    CN121080956A

  • Handheld non-contact livestock body size measuring equipment and livestock body size measuring method

    CN121304767A

  • Sheldrake body size automatic measurement method based on multi-modal fusion and parameterized grid reconstruction

    CN122368146A