Large-pigsty pig herd weight estimation grading method and device

By obtaining multi-round video inspection information from the weight estimation and grading of large-scale pig herds, calculating the average weight estimation value of pigs across multiple frames, and performing clustering and data fusion, the problems of mean deviation and poor stability caused by data imbalance were solved, thus achieving accurate grading of pigs.

CN120931971APending Publication Date: 2025-11-11HEFEI JIANGXIN DUZHI INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511098887.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-08-06
Publication Date
2025-11-11

AI Technical Summary

Technical Problem

Existing technologies for weight estimation and grading of large-scale pig herds suffer from problems such as data imbalance leading to mean deviation, poor stability of weight estimation results, and inability to achieve individual correlation and grading.

Method used

By acquiring multiple rounds of video inspection information, the average weight estimate of the same pig in a single inspection and the average weight estimate of the same pig in multiple inspections are determined. The pigs are then clustered together with the number of pigs to obtain the clustered weight estimate. The clustered weight estimate and the individual weight estimate are then fused to achieve weight grading of the pigs.

Benefits of technology

It effectively addressed the problem of uneven testing frequency among pigs, improved the accuracy and stability of weight estimation, and enabled individual correlation and classification of pigs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120931971A_ABST
    Figure CN120931971A_ABST
Patent Text Reader

Abstract

The invention provides a large-pigsty pig herd weight estimation grading method and device, relates to the field of weight estimation grading, and solves the technical problems of mean value deviation, poor weight estimation result stability and incapability of realizing individual association and grading caused by data imbalance in large-pigsty pig herd weight estimation grading in the prior art. The method specifically comprises the following steps: acquiring video information acquired in a multi-round video inspection process of a target field in a hog house; determining a plurality of first weight estimation values, the number N of pigs in the target field, and a second weight estimation value of each pig; clustering based on the number N of pigs and the first weight estimation values to obtain N clusters, and determining N cluster weight estimation values according to the first weight estimation value in each cluster; performing data fusion on the N clustering weight estimation values and the second weight estimation value to obtain a fusion weight estimation value of the target field; and performing weight estimation grading on the pigs in the target field based on the fusion weight estimation value of the target field. The method is used for weight estimation and grading of the large-pigsty swinery.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of weight estimation and grading technology, and in particular to a method and apparatus for weight estimation and grading of large pen pig herds. Background Technology

[0002] In the field of weight estimation and grading of large-scale pig herds, existing technologies can achieve pig weight estimation through tracked robot inspections and multimodal technology. This avoids stress on pigs, improves estimation efficiency, and can integrate multimodal information to improve the accuracy of individual pig weight estimation. However, existing technologies have limited field of view for depth cameras, making it difficult to cover the entire pen. When collecting data through multiple inspections and random sampling, the same pig may be included in the mean calculation multiple times, while some pigs are only inspected 1-2 times. This data imbalance directly leads to deviations in the average weight of the entire pen. Furthermore, calculating the mean indiscriminately for pigs in different inspection images without considering the difference in the number of inspections results in poor stability of the weight estimation results. Because it is impossible to identify individual pigs across inspections, it is impossible to associate the weight estimation results with specific pigs, thus failing to complete the weight estimation and grading of large-scale pigs and failing to meet the needs of refined farming management. Therefore, existing technologies in large-scale pig herd weight estimation and grading suffer from technical problems such as data imbalance leading to mean deviation, poor stability of weight estimation results, and the inability to achieve individual association and grading. Summary of the Invention

[0003] This application provides a method and apparatus for estimating and classifying the weight of large pen pigs, which solves the technical problems of data imbalance leading to mean deviation, poor stability of weight estimation results, and inability to achieve individual correlation and classification in the existing technology for estimating and classifying the weight of large pen pigs.

[0004] To achieve the above objectives, this application adopts the following technical solution:

[0005] Firstly, a method for estimating and classifying the weight of large-scale pig herds is provided, comprising: acquiring video information collected during multiple rounds of video inspections of target pens within a pigsty; determining multiple first weight estimates for each round of video inspections based on the video information; the first weight estimate being the average of the weight estimates for the same pig across multiple video frames in a single inspection; determining the number of pigs N in the target pen and a second weight estimate for each of the N pigs based on the video information and the first weight estimates; clustering the multiple first weight estimates from the multiple rounds of video inspections based on the number of pigs N to obtain N clusters, and determining N cluster weight estimates based on the first weight estimates in each cluster; fusing the N cluster weight estimates and the N second weight estimates to obtain N fused weight estimates for the target pen; and classifying the pigs in the target pen based on the N fused weight estimates for the target pen.

[0006] In conjunction with the first aspect mentioned above, in one possible implementation, based on video information, multiple first weight estimates for each round of video inspection are determined, including: extracting the RGB image of the pigs in the target pen from the video information; obtaining the detection box for each pig and continuously tracking the detection box based on the BoT-SORT tracking algorithm to select the effective tracking frames for each pig in this round of inspection; the detection box is a rectangular bounding box surrounding the main body of the pig, output by a segmentation algorithm based on the RGB image of the pig; the weight of the same pig in each effective tracking frame is determined by a multimodal weight estimation method, and the average weight of the same pig in each effective tracking frame is used as the first weight estimate of the pig.

[0007] In conjunction with the first aspect mentioned above, in one possible implementation, the first estimated weight of the pig satisfies the following formula:

[0008]

[0009] Wherein, weight_id represents the first estimated weight of the pig, track_id_num represents the number of valid tracking frames, and weight_id_x represents the weight of the pig in the xth valid tracking frame, where x is the index of the valid tracking frame.

[0010] In conjunction with the first aspect mentioned above, in one possible implementation, determining the second estimated weight value for each pig based on video information includes: inputting video information into a pig back recognition network training model to obtain the feature vector of each pig in the target pen; obtaining a historical feature vector database of pigs; the historical feature vector database contains historical feature vectors, historical pig weights, and corresponding historical effective tracking frame counts of pigs stored during historical inspections of the target pen; for each pig's feature vector, if a first historical feature vector with a feature similarity exceeding a threshold exists in the historical feature vector database, then the historical pig weight corresponding to the first historical feature vector is updated based on the pig's first estimated weight value; the updated historical pig weight is used as the second estimated weight value; if no first historical feature vector exists, then the feature vector, the pig's first estimated weight value, and the pig's effective tracking frame count are added to the historical feature database, and the first estimated weight value is used as the second estimated weight value.

[0011] In conjunction with the first aspect mentioned above, in one possible implementation, updating the historical pig weight corresponding to the first historical feature vector based on the first estimated weight of the pig satisfies the following formula:

[0012]

[0013] track_id_new=track_num_u+track_id_num

[0014] Wherein, weight_id_new is the updated weight of the pig, track_id_new is the updated number of valid tracking frames, weight_u is the first estimated weight of the currently inspected pig, and track_num_u is the number of valid tracking frames corresponding to the first estimated weight of the currently inspected pig.

[0015] In conjunction with the first aspect mentioned above, in one possible implementation, data fusion is performed on N cluster weight estimates and N second weight estimates to obtain N fused weight estimates for the target field, including: sorting the second weight estimates and cluster weight estimates separately according to their weight estimates; and fusing the second weight estimates and cluster weight estimates of the same sorted values ​​according to a preset weight ratio to obtain the fused weight estimates.

[0016] In conjunction with the first aspect mentioned above, in one possible implementation, the second weight estimate and the cluster weight estimate of the same ranking are fused according to a preset weight ratio to obtain a fused weight estimate that satisfies the following formula:

[0017] fused_weight_list=[w f0 ,w f1 ,...,w fi ,...,w fN ]

[0018] Where fused_weight_list represents the fused weight estimates, w fi =w i *r i +w ci *(1-r i ), r i Let r be the weighting factor, and r i <1, w i w is the i-th second weight estimate after sorting. ci This represents the weight estimate of the i-th cluster after sorting, where i is the index of the number of pigs.

[0019] In conjunction with the first aspect mentioned above, in one possible implementation, the pigs in the target pen are classified by weight estimation based on N fused weight estimates of the target pen, including: calculating the average weight of the pigs in the target pen based on the N fused weight estimates of the target pen; dividing the fused weight estimates of the target pen into multiple levels based on a preset weight threshold range for the average weight of the pigs in the target pen, and counting the number of pigs in each level.

[0020] In conjunction with the first aspect mentioned above, in one possible implementation, after determining multiple first weight values ​​for each round of video inspection based on video information, the method further includes: implementing column switching through a column boundary switching algorithm, performing multiple rounds of inspection on multiple columns based on column switching; determining that if the target column is the last column, a single round of inspection is completed; if it is not the last column, switching to the next column to continue inspection; when the number of inspections reaches a set number, the inspection ends; if the set number has not been reached, the next round of inspection continues.

[0021] Secondly, a device for estimating and grading the weight of large-pen pigs is provided, comprising: a communication unit and a processing unit; the communication unit is used to acquire video information collected during multiple rounds of video inspections of target pens in a pigsty; the processing unit is used to determine multiple first weight estimates for each round of video inspections based on the video information; the first weight estimate is the average of the weight estimates of the same pig in multiple video frames during a single inspection; based on the video information and the first weight estimates, the number N of pigs in the target pen and the second weight estimate of each of the N pigs are determined; the multiple first weight estimates in the multiple rounds of video inspections are clustered based on the number N of pigs to obtain N clusters, and N cluster weight estimates are determined based on the first weight estimates in each cluster; the N cluster weight estimates and N second weight estimates are fused to obtain N fused weight estimates for the target pen; and the pigs in the target pen are weight-graded based on the N fused weight estimates for the target pen.

[0022] Thirdly, this application provides a weight grading device for large-scale pig herds, comprising: a processor and a storage medium; the storage medium includes instructions, and the processor is configured to execute the instructions to implement the method described in the first aspect and any possible implementation thereof. This weight grading device for large-scale pig herds can be an electronic device or a chip within an electronic device.

[0023] Fourthly, this application provides a large-pen pig herd weight estimation and grading system, including: a video acquisition device and a large-pen pig herd weight estimation and grading device; wherein, the video acquisition device is used to acquire video information collected during multiple rounds of video inspections of target pens in the pigsty, and the large-pen pig herd weight estimation and grading device is used to determine multiple first weight estimates for each round of video inspections based on the video information; the first weight estimate is the average of the weight estimates of the same pig in multiple video frames during a single inspection; based on the video information... The system calculates the first estimated weight value, the number of pigs N in the target pen, and the second estimated weight value for each of the N pigs. Based on the number of pigs N, it clusters the multiple first estimated weight values ​​from multiple rounds of video inspections to obtain N clusters. Based on the first estimated weight value in each cluster, it determines N cluster estimated weight values. It then fuses the N cluster estimated weight values ​​and the N second estimated weight values ​​to obtain N fused estimated weight values ​​for the target pen. Finally, it classifies the pigs in the target pen based on the N fused estimated weight values ​​for the target pen.

[0024] Fifthly, this application provides a computer-readable storage medium storing instructions that, when executed on a pen pig herd weight grading device, cause the pen pig herd weight grading device to perform the method described in the first aspect and any possible implementation thereof.

[0025] Sixthly, this application provides a computer program product containing instructions that, when the computer program product is run on a pen pig herd weight grading device, causes the pen pig herd weight grading device to perform the method as described in the first aspect and any possible implementation thereof.

[0026] This application provides a method and apparatus for weight estimation and grading of large-scale pig herds. By acquiring multi-round video inspection information, it determines the average weight estimation values ​​of the same pig across multiple frames in a single inspection and the average weight estimation values ​​across multiple inspections, effectively addressing the problem of uneven pig detection times in single and multi-round inspections. Clustering is performed based on the number of pigs and the first weight estimation value to obtain a clustered weight estimation value. Combining the advantages of individual identification and group clustering improves the accuracy of weight estimation. The clustered weight estimation value and the second weight estimation value are fused to obtain a fused weight estimation value, enhancing the stability of the weight estimation results. Finally, pig weight grading is achieved based on the fused weight estimation value, solving the problem of inability to grade due to missing individual associations. Therefore, this application solves the technical problems of data imbalance leading to mean deviation, poor stability of weight estimation results, and inability to achieve individual association and grading in existing large-scale pig herd weight estimation and grading technologies.

[0027] It should be understood that the descriptions of technical features, technical solutions, beneficial effects, or similar language in this application do not imply that all features and advantages can be achieved in any single embodiment. Rather, it is understood that the description of a feature or beneficial effect means that a specific technical feature, technical solution, or beneficial effect is included in at least one embodiment. Therefore, the descriptions of technical features, technical solutions, or beneficial effects in this specification do not necessarily refer to the same embodiment. Furthermore, the technical features, technical solutions, and beneficial effects described in this embodiment can be combined in any suitable manner. Those skilled in the art will understand that embodiments can be implemented without one or more specific technical features, technical solutions, or beneficial effects of a particular embodiment. In other embodiments, additional technical features and beneficial effects may be identified in specific embodiments that do not embody all embodiments. Attached Figure Description

[0028] Figure 1 A system architecture diagram of a large-scale pig herd weight estimation and grading system provided in this application embodiment;

[0029] Figure 2 A flowchart illustrating a method for estimating and grading the weight of large pen pigs, provided for an embodiment of this application;

[0030] Figure 3 A flowchart illustrating another method for estimating and grading the weight of large pen pigs provided in this application embodiment;

[0031] Figure 4 A flowchart illustrating another method for estimating and grading the weight of large pen pigs provided in this application embodiment;

[0032] Figure 5 A flowchart illustrating another method for estimating and grading the weight of large pen pigs provided in this application embodiment;

[0033] Figure 6 A flowchart illustrating another method for estimating and grading the weight of large pen pigs provided in this application embodiment;

[0034] Figure 7 A schematic diagram of a weight grading device for large-scale pig herds provided in this application embodiment;

[0035] Figure 8 This is a schematic diagram of the hardware structure of a weight grading device for large-scale pig herds provided in an embodiment of this application. Detailed Implementation

[0036] In the description of this application, unless otherwise stated, " / " means "or," for example, A / B can mean A or B. The "and / or" in this document is merely a description of the relationship between related objects, indicating that three relationships can exist. For example, A and / or B can represent: A alone, A and B simultaneously, and B alone. Furthermore, "at least one" means one or more, and "multiple" means two or more. The terms "first," "second," etc., do not limit the quantity or order of execution, and "first," "second," etc., do not necessarily imply differences.

[0037] It should be noted that, in this application, the terms "exemplary" or "for example" are used to indicate that something is being described as an example, illustration, or illustration. Any embodiment or design described as "exemplary" or "for example" in this application should not be construed as being more preferred or advantageous than other embodiments or design solutions. Specifically, the use of terms such as "exemplary" or "for example" is intended to present the relevant concepts in a concrete manner.

[0038] The weight grading method for large-scale pig herds provided in this application embodiment can be applied to, for example... Figure 1 The large-pen pig herd weight estimation and grading system shown includes: a video acquisition device 101 and a large-pen pig herd weight estimation and grading device 102.

[0039] The video acquisition device 101 is used to acquire video information collected during multiple rounds of video inspections of target pens within the pigsty. The large-pen pig herd weight estimation and grading device 102 is used to determine multiple first weight estimates for each round of video inspections based on the video information; the first weight estimate is the average of the weight estimates of the same pig across multiple video frames in a single inspection; based on the video information and the first weight estimates, the number of pigs N in the target pen and the second weight estimate for each of the N pigs are determined; based on the number of pigs N, the multiple first weight estimates from the multiple rounds of video inspections are clustered to obtain N clusters, and N cluster weight estimates are determined based on the first weight estimates in each cluster; the N cluster weight estimates and N second weight estimates are fused to obtain N fused weight estimates for the target pen; and the pigs in the target pen are weight-graded based on the N fused weight estimates for the target pen.

[0040] To address the technical problems of data imbalance leading to mean bias, poor stability of weight estimation results, and inability to achieve individual association and classification in existing technologies for weight estimation and classification of large-scale pig herds, this application provides a method for weight estimation and classification of large-scale pig herds. This method uses the average of multiple video frames from a single round of inspections for the same pig as a first weight estimate, and the average of multiple video frames from multiple inspections for the same pig as a second weight estimate. The first weight estimate is then clustered with the number of pigs to obtain a clustered weight estimate. Finally, the clustered weight estimate and the second weight estimate are fused to achieve pig weight estimation and classification. Because this application addresses the data imbalance of a single round of inspections with the first weight estimate, balances the differences in the number of individual inspections by fusing data from multiple rounds with the second weight estimate, improves the stability of weight estimation through clustering and recognition fusion, and achieves pig association based on individual recognition, it effectively balances data distribution, improves the stability of weight estimation results, and achieves individual association and classification in the weight estimation and classification of large-scale pig herds. This technology solves the technical problems of data imbalance leading to mean deviation, poor stability of weight estimation results, and inability to achieve individual correlation and grading in the weight estimation and grading of large-scale pig herds in existing technologies.

[0041] Figure 2 This is a flowchart illustrating the method for estimating and grading the weight of large-scale pig herds provided in an embodiment of this application, as shown below. Figure 2 As shown, the method includes:

[0042] Step 201: The large-pen pig herd weight estimation and grading device acquires video information collected during multiple rounds of video inspections of the target pens in the pigsty.

[0043] The target pen refers to a specific pen in the pig house that needs to be weighted and graded; the video information includes, but is not limited to, dynamic images of pigs in the target pen and data on the pen's environment.

[0044] In this embodiment, the large-pen pig herd weight estimation and grading device can obtain video information by establishing a communication connection with a video acquisition device, which is mounted on a track-mounted mobile platform and installed above the center of the pen. The number of rounds of video inspections can be set according to the size of the target pen and the activity characteristics of the pigs. For example, the number of inspections can be increased for pens with frequent pig activity to ensure that video information of pigs at different times and in different activity states can be collected. The collected video information must clearly reflect the appearance and posture characteristics of the pigs to provide a basis for subsequent pig identification, tracking, and weight estimation.

[0045] It should be noted that this application does not limit the specific type of video acquisition equipment, the inspection path planning, or the specific format of video information, as long as it can achieve multi-round video data acquisition of the target field. Different implementation methods are all within the protection scope of this application.

[0046] As an example, there are 20 target pens in the pigsty. The large pen pig weight estimation and grading device is connected to a track robot equipped with a 3D camera. The track robot inspects each target pen 5 times a day along a preset track. During each inspection, the 3D camera continuously captures video streams of the target pen, including RGB images and depth information of the pigs. The large pen pig weight estimation and grading device receives and stores this video information in real time via wireless communication.

[0047] Based on the above steps, the video information collected through multiple rounds of video inspections can comprehensively cover the different activity states and time periods of pigs in the target pen, providing rich and representative data support for subsequent accurate identification of pigs, calculation of estimated weight and grading, and avoiding the data bias that may be caused by a single or small number of inspections.

[0048] Step 202: Based on the video information, the large-pen pig herd weight estimation and grading device determines multiple first weight estimates for each round of video inspections.

[0049] The first estimated weight value refers to the average of the estimated weight values ​​of the same pig obtained from multiple valid video frames during a single inspection.

[0050] In this embodiment of the application, when the large-pen pig herd weight estimation and grading device determines the first estimated weight value based on video information, it is necessary to first identify and track multiple video frames of the same pig in a single inspection from the video information: by detecting the pigs in the video frames, filtering out the valid frames containing clear pig features, and then calculating the estimated weight value of each frame for the same pig and taking the average value to obtain the first estimated weight value of the pig.

[0051] Based on the above steps, by calculating the first estimated weight value, multiple estimated weight data of the same pig in a single round of inspection are effectively integrated, which alleviates the problem of uneven number of individual inspections within a single round caused by the randomness of pig activity, and improves the accuracy and stability of pig weight estimation in a single round of inspection.

[0052] Step 203: Based on the video information and the first estimated weight value, the large pen pig herd weight estimation and grading device determines the number N of pigs in the target pen, and the second estimated weight value of each of the N pigs.

[0053] The second estimated weight value refers to the average of the estimated weight values ​​obtained from multiple valid video frames during multiple inspections of the same pig.

[0054] In this embodiment of the application, the number of pigs is determined by individual identification and deduplication of pigs in video information; by extracting the feature information of pigs and associating the estimated weight data of the same pig in multiple inspections, the same pig is matched in different inspection rounds, and the first estimated weight value of the pig in all inspections is summarized and the average is taken to obtain the second estimated weight value.

[0055] Based on the above steps, by calculating the second estimated weight value, the multiple estimated weight data of the same pig in multiple rounds of inspections are effectively integrated, balancing the differences in detection frequency of different pigs in multiple rounds of inspections, and reducing the estimation deviation caused by the one-sidedness of a single or a few detection data.

[0056] Step 204: The large-pen pig herd weight estimation and grading device clusters multiple first weight estimates from multiple rounds of video inspections based on the number of pigs N, obtaining N clusters, and determining N cluster weight estimates based on the first weight estimate in each cluster.

[0057] Here, a cluster refers to a group of pigs with similar first estimated weight values ​​formed by aggregating data through a clustering algorithm. Each cluster corresponds to a pig in the target column. The cluster estimated weight value is a value extracted from each cluster that can represent the overall weight level of the cluster.

[0058] In this embodiment, the large-pen pig herd weight estimation and grading device can employ the K-Means algorithm when clustering based on the number of pigs N and the first estimated weight value of each pig. Specifically, firstly, all first estimated weight values ​​obtained from multiple rounds of inspections of the target pen are collected to form a dataset containing multiple detection data of the same pig. Subsequently, this dataset is used as the input to the K-Means algorithm, while setting the number of clusters to the number of pigs N to ensure that the clustering results accurately correspond to each pig. When running the K-Means algorithm, the distance between each first estimated weight value and the initial cluster center is calculated, and first estimated weight values ​​with close distances are grouped into the same cluster. The cluster centers are iteratively updated until convergence, ultimately resulting in N clusters. The center value of each cluster is used as the cluster estimated weight value of the pig corresponding to that cluster, which comprehensively reflects the central tendency of all first estimated weight values ​​within the cluster.

[0059] It should be noted that as long as the data can be divided into N clusters based on the feature similarity of the first weight estimate, such as distance-based clustering algorithms or density-based clustering algorithms, it is acceptable. At the same time, the calculation method of the cluster weight estimate can also be adjusted according to actual needs. It can be the mean of the data within the cluster or the center value output by the clustering algorithm. This application does not impose any specific limitations.

[0060] As an example, the target pen was identified with a number of pigs, N=5, and the first set of estimated weight values ​​was collected as [82,83,81,105,107,104,70,72,69,93,95,92,118,120,117]. The device used the K-Means algorithm to cluster this set, setting the number of clusters to 5. After iterative calculation, 5 clusters were obtained: Cluster 1: [82,83,81], Cluster 2: [105,107,104], Cluster 3: [70,72,69], Cluster 4: [93,95,92], and Cluster 5: [118,120,117]. The center values ​​of each cluster, i.e., the estimated weight values ​​of the clusters, were 82kg, 105.3kg, 70.3kg, 93.3kg, and 118.3kg, respectively.

[0061] Based on the above steps, the K-Means algorithm, combined with the number of pigs N, is used for clustering. This effectively aggregates the multiple first weight estimates of the same pig in multiple rounds of inspections, eliminating the interference of repeated detection data on individual weight representation. At the same time, the clustered weight estimates obtained can be used as a reference for pig weight from the perspective of the group, complementing the second weight estimates based on individual identification, thereby improving the overall weight estimation accuracy and anti-interference ability.

[0062] Step 205: The large-pen pig herd weight estimation and grading device fuses the N cluster weight estimates and N second weight estimates to obtain the N fused weight estimates for the target pen.

[0063] Among them, the fusion weight estimate refers to the final weight value obtained by combining the weight estimates of N clusters with the second weight estimate, which can integrate weight information from both individual identification and group clustering.

[0064] In this embodiment of the application, when the large-pen pig herd weight estimation and grading device fuses the cluster weight estimate and the second weight estimate, it first forms a cluster weight estimate list by combining the N cluster weight estimates obtained through clustering, and forms a second weight estimate list by combining the N second weight estimates obtained based on individual identification. By establishing the correspondence between the elements in the two lists, the cluster weight estimate and the second weight estimate at the corresponding position are fused and calculated using a preset weight ratio to obtain the fused weight estimate for each position. Finally, a target pen fused weight estimate list containing N fused weight estimates is formed, that is, N fused weight estimates are obtained.

[0065] Based on the above steps, by fusing the clustering weight estimate and the second weight estimate, the limitations of a single weight estimate method can be overcome, so that the final fused weight estimate has both the stability of the group data and the continuity of individual identification.

[0066] Step 206: The large-pen pig herd weight estimation and grading device estimates and grades the pigs in the target pen based on the N fused weight estimates of the target pen.

[0067] Weight estimation and grading refers to the process of classifying pigs into different growth grades based on the integrated weight estimation value of pigs in the target pen and in combination with a preset weight threshold range. This is used to visually present the individual growth differences and overall grade distribution within the pig herd.

[0068] In this embodiment, when the large-pen pig herd weight estimation and grading device performs weight estimation and grading based on the integrated weight estimation value, it comprehensively considers the breeding needs of the target pen and determines the applicable grading standard; the integrated weight estimation value and the grading standard are input into the weight estimator and the grader, which matches the integrated weight estimation value of each pig to the grade; finally, by counting the number of pigs corresponding to each grade, the weight estimation and grading result of the target pen is formed.

[0069] It should be noted that the specific implementation method of the weight grading device, the number of grading standards, and the weight range corresponding to each grade in this step are not fixed. As long as the grade classification and quantity statistics of pigs can be completed based on the fused weight estimate, different implementation methods are all within the scope of protection of this application.

[0070] Based on the above steps, the weight grading achieved by integrating the estimated weight values ​​can accurately reflect the growth differences among individuals within the pig herd, providing clear data support for farmers to formulate differentiated management strategies and effectively improving the efficiency and precision of breeding management.

[0071] Based on the above technical solutions, the weight estimation and grading method for large-scale pig herds provided in this application effectively addresses the problem of uneven pig detection times in single and multiple inspections by acquiring multi-round video inspection information and determining the average weight estimation values ​​of the same pig across multiple frames in a single inspection and across multiple inspections. Clustering based on the number of pigs and the first weight estimation value yields a clustered weight estimation value, combining the advantages of individual identification and group clustering to improve the accuracy of weight estimation. The fusion of the clustered weight estimation value and the second weight estimation value enhances the stability of the weight estimation results. Finally, pig weight grading is achieved based on the fusion weight estimation value, solving the problem of inability to grade due to missing individual associations. Therefore, this application solves the technical problems of data imbalance leading to mean deviation, poor stability of weight estimation results, and inability to achieve individual association and grading in existing large-scale pig herd weight estimation and grading technologies.

[0072] In one possible implementation, combining the above... Figure 2 ,like Figure 3 As shown, the process of determining multiple first weight values ​​for each round of video inspection based on video information in step 202 above can be specifically implemented through the following steps 301-303:

[0073] Step 301: The large-pen pig herd weight estimation and grading device extracts the RGB images of pigs in the target pen from the video information.

[0074] In this embodiment, the large-scale pig herd weight estimation and grading device extracts RGB three-channel information from a single frame image based on video information, performs preliminary preprocessing on the RGB image, and retains only the image area corresponding to the target pen to reduce the interference of non-target information on subsequent processing.

[0075] Based on the above steps, the pre-processed RGB image fully preserves the pig's appearance features and dynamic state, providing raw data for subsequent steps and ensuring the accuracy and effectiveness of subsequent processing.

[0076] Step 302: The large-pen pig herd weight estimation and grading device acquires the detection frame of each pig and continuously tracks the detection frame based on the BoT-SORT tracking algorithm to select the effective tracking frames of each pig in this round of inspection.

[0077] Among them, the detection box is a rectangular bounding box that surrounds the main body of the pig, output by the segmentation algorithm based on the RGB image of the pig; the BoT-SORT tracking algorithm is a multi-target tracking algorithm that combines bounding box prediction and feature matching, which can achieve stable tracking of the same pig in consecutive frames; the effective tracking frame refers to the tracking frame that, after screening, has clear pig features, no occlusion or low degree of occlusion.

[0078] In this embodiment, the large-scale pig herd weight estimation and grading device first classifies the pixels in the RGB image using a segmentation algorithm to distinguish between pigs and the background, extracts the outline of the pig's main body, and then circumscribes the outline as a rectangular bounding box to obtain the detection box for each pig. The BoT-SORT tracking algorithm is then used to track the detection boxes in consecutive frames: by calculating the positional overlap and appearance feature similarity between the detection box in the current frame and the detection box in the previous frame, detection boxes of the same pig are associated and assigned a unique ID, ensuring that all detection boxes of the same pig are bound to the same ID in a single round of inspection.

[0079] It should be noted that the specific type of segmentation algorithm used in this step, such as U-Net or YOLO series, and the parameters of the BoT-SORT tracking algorithm, such as the position overlap threshold, feature matching threshold, and the selection criteria for effective tracking frames, such as the occlusion area threshold, are not specifically limited.

[0080] As an example, the RGB image of the target field contains 5 pigs. The device outputs 5 detection boxes using the YOLOv12 segmentation algorithm, each of which accurately surrounds the main body of the pig. After tracking the detection boxes in 200 consecutive frames of images, the BoT-SORT algorithm assigns ID1 to ID5 to the 5 pigs respectively. Through the pose estimation algorithm, the pig with ID1 is filtered out in 200 frames, with 15 frames of severe occlusion removed, and 185 effective tracking frames are retained. The other pigs also retain a different number of effective tracking frames.

[0081] Based on the above steps, continuous association of individual pigs in a single round of inspection was achieved through detection frame localization and BoT-SORT tracking, and the selection of effective tracking frames ensured the reliability of subsequent weight estimation data.

[0082] Step 303: The large-pen pig herd weight estimation and grading device determines the weight of the same pig in each effective tracking frame through a multimodal weight estimation method, and takes the average weight of the same pig in each effective tracking frame as the first estimated weight value of the pig.

[0083] Among them, multimodal weight estimation refers to the method of calculating the weight of a pig in a single frame by integrating multiple data modalities, which can comprehensively utilize the advantages of different modalities to improve the weight estimation accuracy of a single frame.

[0084] In this embodiment, the large-scale pig herd weight estimation and grading device extracts the RGB image features and depth map features of the pigs for each valid tracking frame in step 302, inputs these features into a pre-trained multimodal weight estimation model, and outputs the weight of the pig corresponding to that frame. Based on each valid tracking frame and the weight of the corresponding pig, the first estimated weight value of the pig is calculated.

[0085] Optionally, the first estimated weight of the pig is calculated according to the following formula:

[0086]

[0087] Wherein, weight_id represents the first estimated weight of the pig, track_id_num represents the number of valid tracking frames, and weight_id_x represents the weight of the pig in the xth valid tracking frame, where x is the index of the valid tracking frame.

[0088] It should be noted that the process of obtaining the weight of a single pig in an effective tracking frame using a multimodal weight estimation model in this application is a pre-trained deep learning-based regression model, and this application does not impose any specific limitations on it.

[0089] As an example, in a single round of inspection, the pigs of ID1 retain 185 valid tracking frames. The weight of each frame is obtained through multimodal weight estimation. After removing 3 outliers, the weights of the remaining 182 frames are summed and then divided by 182 to calculate the first estimated weight value.

[0090] Based on the above steps, multimodal weight estimation integrates the advantages of various data, improves the accuracy of single-frame weight, and the first estimated weight value is calculated by the effective frame mean, which smooths the random fluctuation of single-frame weight and solves the problem of unstable weight estimation caused by changes in pig posture during single-round inspection.

[0091] Based on the above technical solution, RGB images are used to provide the basic appearance features of pigs. Segmentation algorithms and BoT-SORT tracking algorithms are used to achieve accurate positioning and continuous association of individual pigs in a single round of inspection. The problem of individual identification is solved by binding with a unique ID, and noise data is effectively filtered out by tracking frames. Then, the first weight estimate is obtained by multimodal weight estimation combined with mean calculation, which balances the difference in the number of pig detections in a single round and improves the stability of weight estimation in a single round.

[0092] In one possible implementation, combining the above... Figure 2 ,like Figure 4 As shown, the process of determining the second estimated weight of each pig based on video information in step 202 above can be specifically implemented through the following steps 401-404:

[0093] Step 401: The large-pen pig herd weight estimation and grading device inputs video information into the pig back recognition network training model to obtain the feature vector of each pig in the target pen.

[0094] Among them, the feature vector refers to a high-dimensional numerical vector that can uniquely represent the individual differences of pigs, extracted from pig images through feature extraction algorithms; the pig back recognition network training model is a deep learning network used for pig back feature extraction. Through training, it can learn the unique features of the pig's back and achieve accurate extraction of individual features.

[0095] In this embodiment, the large-scale pig herd weight estimation and grading device first preprocesses the valid tracking frames obtained in step 302 to obtain an image focusing on the pig's back features; then, the preprocessed image is input into the trained pig back recognition network training model. The network extracts local and global features of the pig's back layer by layer through its structure, and finally outputs a 128-dimensional feature vector. Each vector is bound to the unique ID of the pig assigned in step 302 to achieve associated storage.

[0096] It should be noted that the process of obtaining the feature vector of pigs in the target column by using the pig back recognition network training model in this application is a deep learning network for pig back feature extraction that has been trained. The specific number of network layers, convolution kernel size, feature vector dimension and specific recognition process are not specifically limited in this application.

[0097] As an example, pigs with ID1 in the target pen exhibit unique back textures in the effective tracking frames. After preprocessing, the pig back recognition network training model is input into the pig herd weight estimation and grading device, which outputs a 128-dimensional feature vector [0.21, 0.35, ..., 0.18]. This vector is temporarily stored after being bound to ID1 and used for subsequent comparison with historical features.

[0098] Based on the above steps, the feature vectors extracted by the pig back recognition network training model provide the core basis for cross-inspection identification of individual pigs, solving the problem that IDs cannot be associated across rounds in single-round inspections.

[0099] Step 402: The large-pen pig herd weight estimation and grading device acquires the historical feature vector database of pigs.

[0100] The historical feature vector database is a collection containing the historical feature vectors of pigs saved during historical inspections of the target pen, the historical weight of the pigs, and the corresponding number of historical valid tracking frames.

[0101] In this embodiment, the large-pen pig herd weight estimation and grading device retrieves the historical feature vector database of the target pen from the storage unit before each inspection. This database is divided by pen and contains only the historical data of the target pen, avoiding cross-pen interference.

[0102] As an example, the historical feature vector database of the target stall contains three data entries: [[feature_0,[80kg,200 frames]],[feature_1,[95kg,180 frames]],[feature_2,[72kg,220 frames]]], which correspond to the historical feature vectors, historical pig weights, and corresponding historical valid tracking frame numbers of the three pigs in the target stall during past inspections.

[0103] Based on the above steps, the historical feature vector database is called to provide a historical benchmark for matching the individual pigs currently being inspected, enabling the large-pen pig herd weight estimation and grading device to associate cross-inspection data of the same pig through feature comparison.

[0104] Step 403: For each pig's feature vector, if there is a first historical feature vector in the historical feature vector database with a feature similarity exceeding a threshold, the historical pig weight corresponding to the first historical feature vector is updated based on the first estimated weight of the pig; the updated historical pig weight is used as the second estimated weight.

[0105] Among them, feature similarity refers to the cosine feature similarity between the feature vector and the historical feature vector; the threshold is a preset feature similarity critical value, and if it exceeds the value, it is determined to be the same pig; if there is no first historical feature vector, the feature vector, the first estimated weight value of the pig, and the number of effective tracking frames of the pig are added to the historical feature database, and the first estimated weight value is used as the second estimated weight value.

[0106] In this embodiment, the large-pen pig herd weight estimation and grading device compares the feature similarity of the feature vector obtained in step 401 with the historical feature vector obtained in step 402 with a threshold. If the highest feature similarity of the historical feature vector with the feature vector exceeds the threshold, it is determined to be the same pig. Based on the first estimated weight of the current pig, the historical pig weight and valid tracking frames of the pig in the historical database are updated, and the updated historical pig weight is used as the second estimated weight. If the feature similarity of the historical feature vector and the feature vector is lower than the threshold, it is determined to be a new pig. The feature vector of the pig in the target pen of this inspection, the first estimated weight of the pig, and the corresponding number of valid tracking frames are added as new entries to the historical database. At this time, the added first estimated weight is used as the second estimated weight.

[0107] Optionally, the historical pig weight corresponding to the first historical feature vector is updated based on the first estimated weight of the pig, satisfying the following formula:

[0108]

[0109] track_id_new=track_num_u+track_id_num

[0110] Wherein, weight_id_new is the updated weight of the pig, track_id_new is the updated number of valid tracking frames, weight_u is the first estimated weight of the currently inspected pig, and track_num_u is the number of valid tracking frames corresponding to the first estimated weight of the currently inspected pig.

[0111] It should be noted that cosine similarity is a commonly used method for calculating feature vector similarity. It measures the similarity between two feature vectors by calculating the cosine of the angle between them; the closer the value is to 1, the more consistent the vector directions. Furthermore, the weight estimation method used in this inspection adopts the tracking weight estimation method described in step 303.

[0112] As an example, if the first historical feature vector, feature_1, has the highest feature similarity among the historical feature vectors of a pig, with a feature similarity of 0.85 (threshold set to 0.8), it is determined to be the same pig; the weight corresponding to the first historical feature vector, feature_1, is 95kg and the number of frames is 180, meaning the historical database for this pig is [feature_1, [95kg, 180 frames]]; the first estimated weight in this inspection is 98kg and the effective number of frames is 20, then the updated weight is (95×180+98×20) / (180+ 20) = 95.3kg is the second estimated weight value, the frame number is updated to 200 frames, and the entry corresponding to feature_1 in the database is synchronously updated to [feature_1, [95.3kg, 200 frames]]. If there is no first historical feature vector that meets the threshold requirement, the feature vector feature_2 of this inspection, and its corresponding first estimated weight value of 90kg and the set of effective frames of 25 frames [feature_2, [90kg, 50 frames]] are added to the historical database as a new entry. At this time, the first estimated weight value of 90kg is used as the second estimated weight value.

[0113] Based on the above steps, cross-inspection association of individual pigs was achieved through feature comparison, and the accumulation and fusion of multi-round inspection data was ensured through database updates and additions, thus solving the problem that pigs could not be associated across rounds in the existing technology.

[0114] Based on the above technical solution, a 128-dimensional feature vector of pigs is extracted by training a pig back recognition network model. This vector is then compared with a historical feature database to achieve cross-inspection pig individual association, solving the problem of uneven detection frequency caused by the inability to reuse single-round inspection IDs across rounds. Database entries are updated or added based on feature similarity, and multi-round inspection data is integrated to update weight using a weighted average, balancing the differences in detection frequency among different pigs and improving the accuracy and stability of weight estimation.

[0115] In one possible implementation, combining the above... Figure 2 ,like Figure 5 As shown, in step 204 above, the process of clustering multiple first weight values ​​from multiple rounds of video inspection based on the number of pigs N to obtain N clusters, and determining N cluster weight values ​​based on the first weight values ​​in each cluster, can be specifically implemented through the following steps 501-502:

[0116] Step 501: The large-pen pig herd weight estimation and grading device sorts the second estimated weight value and the cluster estimated weight value according to the estimated weight value.

[0117] In this embodiment, the large-pen pig herd weight estimation and grading device extracts the second estimated weight values ​​of all pigs in the target pen from the historical feature vector database to form a second estimated weight list; simultaneously, it extracts N cluster estimated weight values ​​from the clustering results to form a cluster estimated weight list. The two lists are sorted in ascending (or descending) order of value, ensuring that the elements in the two lists correspond one-to-one according to their estimated weight values.

[0118] As an example, if the number of pigs in the target pen is N=3, the second estimated weight list is [80kg, 95kg, 72kg], and the cluster estimated weight list is [78kg, 93kg, 70kg]. After sorting them in ascending order, the second estimated weight list becomes [72kg, 80kg, 95kg], and the cluster estimated weight list becomes [70kg, 78kg, 93kg].

[0119] Based on the above steps, the sorting ensures that the second weight estimate and the cluster weight estimate correspond accurately according to the size of the weight estimate, avoiding fusion bias caused by mismatch in data order.

[0120] Step 502: The large-pen pig herd weight estimation and grading device merges the second weight estimate and the cluster weight estimate of the same sorting according to the preset weight ratio to obtain the merged weight estimate.

[0121] In this embodiment of the application, the large-scale pig herd weight estimation and grading device performs a fusion calculation on the sorted second weight estimation list and the clustered weight estimation list using a preset weight factor to form a fusion weight estimation list containing N fusion weight estimation values.

[0122] Optionally, the second weighted value and the cluster weighted value of the same sorting are fused according to a preset weight ratio to obtain a fused weighted value that satisfies the following formula:

[0123] fused_weight_list=[w f0 ,w f1 ,...,w fi ,...,w fN ]

[0124] Where fused_weight_list represents the fused weight estimates, w fi =w i *r i +w ci *(1-r i ), r i Let r be the weighting factor, and r i <1, w i w is the i-th second weight estimate after sorting. ci This represents the weight estimate of the i-th cluster after sorting, where i is the index of the number of pigs.

[0125] It should be noted that r in the preset weight ratio i As a learnable parameter, r can be dynamically adjusted based on the error levels of the two weight estimation methods. For example, when the second weight estimation value is more stable, r... i It can be set to a larger value, and vice versa.

[0126] As an example, the second estimated weight list after sorting is [72kg, 80kg, 95kg], the cluster estimated weight list is [70kg, 78kg, 93kg], and the weight factor r = [0.7, 0.6, 0.5]. Then, the first element after fusion is 72×0.7+70×(1-0.7)=71.4kg, the second element is 80×0.6+78×0.4=79.2kg, and the third element is 95×0.5+93×0.5=94kg. The fused estimated weight list is [71.4kg, 79.2kg, 94kg].

[0127] Based on the above steps, the sorting ensures the accurate correspondence between the two weight estimates, while the fusion of the preset weight ratios combines the continuity of individual identification with the stability of group clustering, effectively compensating for the bias of a single weight estimation method and improving the reliability of the weight estimation results.

[0128] In one possible implementation, such as Figure 5 As shown, the process of fusing N cluster estimates and N second estimates in step 205 to obtain N fused estimates for the target field can be specifically implemented through the following steps 503-504, which are explained in detail below:

[0129] Step 503: The large-pen pig herd weight estimation and grading device calculates the average weight of pigs in the target pen based on the N fused weight estimates of the target pen.

[0130] In this embodiment of the application, the large-pen pig herd weight estimation and grading device extracts the integrated weight estimate of all pigs in the target pen from the integrated weight estimate list, counts the number of pigs N in the list, and obtains the average weight of the pigs in the target pen by calculating the sum of all integrated weight estimates and dividing by N.

[0131] It should be noted that the average weight is calculated based on the fused estimated weight, rather than a single second estimated weight or cluster estimated weight, to ensure that the average weight can comprehensively reflect the advantages of individual identification and group clustering, and reduce the impact of single data bias.

[0132] As an example, the target pen fusion weight estimate list is [71.4kg, 79.2kg, 94kg], the number of pigs N=3, and the average weight is (71.4+79.2+94) / 3≈81.5kg.

[0133] Based on the above steps, by integrating the average weight calculated from the estimated weight values, the continuity of individual identification and the stability of group clustering are combined. Compared with the traditional method of directly taking the average of the detection values, this method is closer to the true weight level of the pig herd.

[0134] Step 504: The large pen pig herd weight estimation and grading device is based on the average weight of pigs in the target pen and presets a weight threshold range. It divides the fused weight estimation value of the target pen into multiple levels and counts the number of pigs in each level.

[0135] The weight threshold range refers to different weight ranges set according to the pig's age, breeding standards, and average weight of the target pen, used to distinguish the differences in the pig's growth status; the weight grading module is a module that matches weight values ​​with grades, and can automatically traverse and merge estimated weight values ​​and classify them.

[0136] In this embodiment, the large-pen pig herd weight estimation and grading device combines the growth age of pigs in the target pen with the average weight calculated in step 603, and presets a weight threshold range, such as T1~T2 for premium pigs, Y1~T1 for first-grade pigs, E1~Y1 for second-grade pigs, and greater than T2 or less than E1 for third-grade pigs. The preset weight threshold range and the fused weight estimate are input into the weight estimation and grading device. The grading device iterates through each fused weight estimate, determines its grade range, and finally counts the number of pigs corresponding to each grade.

[0137] It should be noted that the preset weight threshold range can be flexibly adjusted according to the breeding stage (such as the early, middle and late fattening stages) and is not a fixed value, in order to adapt to the weight characteristics of pigs at different growth stages; and the number of grades can be set as needed, not limited to a specific number of grades.

[0138] As an example, the average weight of the target pen is 81.5 kg, with preset thresholds: premium grade pigs 85-90 kg, grade 1 pigs 80-85 kg, grade 2 pigs 75-80 kg, and grade 3 pigs <75 kg or >90 kg. The merged weight estimate list is [71.4 kg, 79.2 kg, 94 kg]. After traversing the grading system, 71.4 kg belongs to grade 3, 79.2 kg belongs to grade 2, and 94 kg belongs to grade 3. Therefore, the target pen contains 2 grade 3 pigs and 1 grade 2 pig.

[0139] Based on the above steps, the average weight calculated by integrating the estimated weight values ​​provides a reasonable benchmark for threshold setting. Combined with preset levels, it realizes automated grading and statistics, replacing manual weighing and grading, reducing labor costs, and accurately reflecting the growth differences of pig herds.

[0140] Based on the above technical solution, by orderly integrating the weight estimation data of individual identification and group clustering, and combining mean calculation and automated grading, the accuracy and stability of the weight estimation results are improved, and precise grading of individual pigs is achieved. This provides full-process data support for refined large-scale pig farming, effectively solves the limitations of traditional methods, and significantly improves the efficiency of farming management and cost control.

[0141] In one possible implementation, combining the above... Figure 2 ,like Figure 6 As shown, after step 202 above, the process of hurdling and determining the end of the inspection can be implemented through the following steps 601-603:

[0142] Step 601: The large-pen pig herd weight estimation and grading device realizes pen switching through the pen boundary switching algorithm, and performs inspections on multiple pens based on the pen switching.

[0143] Among them, the column boundary switching algorithm refers to the algorithm that uses a target detection algorithm to locate the boundary of a large column in real time and determines whether to switch to the next column based on the boundary position coordinates.

[0144] In this embodiment, the large-pen pig herd weight estimation and grading device acquires images through an onboard 3D camera and uses the YOLOv12 target detection algorithm to locate the pen boundary in real time. When the boundary point is determined to be reached, it will switch to the next pen. At the same time, the new field of view and the old field of view when entering and leaving the pen both belong to the current pen, ensuring the integrity of the inspection data.

[0145] Optionally, the following formula is used to determine whether the boundary point is reached:

[0146]

[0147] Where abs(·) is the absolute value, y_center is the ordinate of the center point of the large column boundary, h_img is the height of the image, and thd_switch is the switching pixel threshold.

[0148] As an example, during inspection, YOLOv12 detects that the boundary center point y_center of the second large column reaches the switching threshold of the image height h_img, and determines to switch to the third large column, and the transition field of view data during the switch is still classified as the second large column.

[0149] Based on the above steps, the algorithm eliminates the need for traditional point card settings, reducing hardware costs, while enabling automatic and accurate switching of fields, improving the efficiency of multi-field inspection, and ensuring the integrity of data collection.

[0150] Step 602: If the target pen is the last pen, the single-round inspection is completed. If it is not the last pen, the next pen is switched to continue the inspection.

[0151] In this embodiment of the application, the large-pen pig weight grading device is preset to have a total of M large pens. The pens are inspected sequentially according to the numbers 1 to M. After each pen is inspected, it is determined whether the current pen number is equal to M. If it is equal, the single round of inspection is completed. Otherwise, the device switches to the next pen number to continue the inspection process.

[0152] As an example, a pigsty has 20 pens. Once the inspection of the 20th pen is completed, it is considered the last pen, and the single round of inspection ends. If the inspection of the 5th pen is completed, the inspection will switch to the 6th pen.

[0153] Based on the above steps, by using clear field numbering logic, we can ensure that all fields are covered in sequence during a single round of inspection, avoiding missed or duplicate inspections and ensuring the comprehensiveness of the data in a single round.

[0154] Step 603: When the number of inspections for the large pen pig herd weight estimation and grading device reaches the set number, the inspection ends. If the set number of inspections has not been reached, the next round of inspections continues.

[0155] In this embodiment of the application, the number of daily inspections is preset to P. After each round of inspections of all columns is completed, the current number of inspections is counted. If the number is greater than or equal to P, the inspection for the day ends; if it is less than P, the next round of inspections is started after a preset interval, and the column inspection process is repeated.

[0156] As an example, the system is set to perform 5 inspections per day. Once the 5th round of inspections of all columns is completed, the inspection for the day ends. If only 2 rounds are completed, the 3rd round of inspections will begin after an interval of 1 hour.

[0157] Based on the above steps, by setting the number of inspections and strictly implementing them, we can ensure that we obtain enough inspection data from multiple rounds to balance the data differences caused by the randomness of pig activities.

[0158] Based on the above technical solution, automatic pen switching is achieved through a pen boundary switching algorithm. YOLOv12 target detection is used to locate the boundary, replacing traditional point card settings, reducing hardware costs and improving inspection efficiency, while ensuring complete field-of-view data during entry and exit. By determining whether a pen is the last one, it ensures that a single round of inspection covers all pens sequentially, avoiding missed or duplicate inspections and ensuring comprehensive data for each round. By setting the number of inspections and executing multiple rounds of inspections, the data discrepancies caused by the randomness of pig activity are balanced.

[0159] The above primarily describes the solutions of the embodiments of this application from the perspective of device implementation. It is understood that each device, such as a large-scale pig herd weight estimation and grading device, includes at least one of the hardware structures and software modules corresponding to each function in order to achieve the above-mentioned functions. Those skilled in the art should readily recognize that, in conjunction with the units and algorithm steps of the various examples described in the embodiments disclosed herein, this application can be implemented in hardware or a combination of hardware and computer software. Whether a function is executed in hardware or by computer software driving hardware depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.

[0160] This application embodiment can divide the large-pen pig herd weight estimation and grading device into functional units according to the above method example. For example, each function can be divided into its own functional unit, or two or more functions can be integrated into one processing unit. The integrated unit can be implemented in hardware or software. It should be noted that the unit division in this application embodiment is illustrative and only represents one logical functional division; other division methods may be used in actual implementation.

[0161] When using integrated units, Figure 7 A possible structural schematic diagram of the pen pig weight grading device (referred to as pen pig weight grading device 70) involved in the above embodiments is shown. The pen pig weight grading device 70 includes a processing unit 701 and a communication unit 702, and may also include a storage unit 703. Figure 7 The schematic diagram shown can be used to illustrate the structure of the large-pen pig herd weight estimation and grading device involved in the above embodiments.

[0162] when Figure 7 The schematic diagram shown illustrates the structure of the large-pen pig weight grading device involved in the above embodiments. The processing unit 701 is used to control and manage the operation of the large-pen pig weight grading device, the communication unit 702 is used for the large-pen pig weight grading device to communicate with other devices, and the storage unit 703 is used to store the program code and data of the large-pen pig weight grading device.

[0163] For example, communication unit 702 is used to acquire video information collected during multiple rounds of video inspections of target pens in the pigsty;

[0164] The processing unit 701 is used to determine multiple first weight estimates for each round of video inspection in a multi-round video inspection based on video information; the first weight estimate is the average of the weight estimates of the same pig in multiple video frames in a single inspection; based on the video information and the first weight estimates, determine the number N of pigs in the target pen, and the second weight estimate of each of the N pigs; cluster the multiple first weight estimates in the multi-round video inspection process based on the number N of pigs to obtain N clusters, and determine N cluster weight estimates based on the first weight estimates in each cluster; fuse the N cluster weight estimates and the N second weight estimates to obtain N fused weight estimates for the target pen; and classify the pigs in the target pen by weight estimate based on the N fused weight estimates for the target pen.

[0165] In one possible implementation, the processing unit 701 is further configured to determine multiple first weight estimates for each round of video inspection based on video information, including: extracting the RGB image of the pigs in the target pen from the video information; obtaining the detection box for each pig and continuously tracking the detection box based on the BoT-SORT tracking algorithm, and filtering out the effective tracking frames for each pig in this round of inspection; the detection box is a rectangular bounding box surrounding the main body of the pig, output by a segmentation algorithm based on the RGB image of the pig, determining the weight of the same pig in each effective tracking frame through a multimodal weight estimation method, and taking the average weight of the same pig in each effective tracking frame as the first weight estimate of the pig.

[0166] In one possible implementation, the initial estimated weight of the pig satisfies the following formula:

[0167]

[0168] Wherein, weight_id represents the first estimated weight of the pig, track_id_num represents the number of valid tracking frames, and weight_id_x represents the weight of the pig in the xth valid tracking frame, where x is the index of the valid tracking frame.

[0169] In one possible implementation, the processing unit 701 is further configured to determine a second estimated weight value for each pig based on video information, including: inputting video information into a pig back recognition network training model to obtain a feature vector for each pig in the target pen; obtaining a historical feature vector database for pigs; the historical feature vector database contains historical feature vectors, historical pig weights, and corresponding historical effective tracking frame counts of pigs saved during historical inspections of the target pen; for each pig's feature vector, if a first historical feature vector with a feature similarity exceeding a threshold exists in the historical feature vector database, then the historical pig weight corresponding to the first historical feature vector is updated based on the pig's first estimated weight value; the updated historical pig weight is used as the second estimated weight value; if no first historical feature vector exists, then the feature vector, the pig's first estimated weight value, and the pig's effective tracking frame count are added to the historical feature database, and the first estimated weight value is used as the second estimated weight value.

[0170] In one possible implementation, updating the historical pig weight corresponding to the first historical feature vector based on the first estimated weight of the pig satisfies the following formula:

[0171]

[0172] track_id_new=track_num_u+track_id_num

[0173] Wherein, weight_id_new is the updated weight of the pig, track_id_new is the updated number of valid tracking frames, weight_u is the first estimated weight of the currently inspected pig, and track_num_u is the number of valid tracking frames corresponding to the first estimated weight of the currently inspected pig.

[0174] In one possible implementation, the processing unit 701 is further configured to perform data fusion on N clustered weight estimates and N second weight estimates to obtain N fused weight estimates for the target field, including: sorting the second weight estimates and clustered weight estimates according to their weight values; and fusing the second weight estimates and clustered weight estimates of the same sorted values ​​according to a preset weight ratio to obtain fused weight estimates.

[0175] In one possible implementation, the second weighted value and the cluster weighted value of the same sorting are fused according to a preset weight ratio to obtain a fused weighted value that satisfies the following formula:

[0176] fused_weight_list=[w f0 ,w f1 ,...,w fi ,...,w fN ]

[0177] Where fused_weight_list represents the fused weight estimates, w fi =w i *r i +w ci *(1-r i ), r i Let r be the weighting factor, and r i <1, w i w is the i-th second weight estimate after sorting. ci This represents the weight estimate of the i-th cluster after sorting, where i is the index of the number of pigs.

[0178] In one possible implementation, the processing unit 701 is further configured to perform weight grading of pigs in the target pen based on N fused weight estimates of the target pen, including: calculating the average weight of pigs in the target pen based on the N fused weight estimates of the target pen; dividing the fused weight estimates of the target pen into multiple levels based on a preset weight threshold range for the average weight of pigs in the target pen, and counting the number of pigs in each level.

[0179] In one possible implementation, the processing unit 701 is further configured to, after determining multiple first weight values ​​for each round of video inspection based on video information, the method further includes: implementing column switching through a column boundary switching algorithm, performing multiple rounds of inspection on multiple columns based on column switching; determining that if the target column is the last column, a single round of inspection is completed; if it is not the last column, switching to the next column to continue inspection; when the number of inspections reaches a set number, the inspection ends; if the set number has not been reached, the next round of inspection continues.

[0180] The processing unit 701 can be a processor or a controller, and the communication unit 702 can be a communication interface, transceiver, transceiver circuit, transceiver device, etc. The term "communication interface" is a general term and may include one or more interfaces. The storage unit 703 can be a memory. When the large-scale pig herd weight grading device 70 is a chip, the processing unit 701 can be a processor or a controller, and the communication unit 702 can be an input interface and / or an output interface, pins, or circuits, etc. The storage unit 703 can be a storage unit within the chip (e.g., a register, cache, etc.) or a storage unit located outside the chip (e.g., read-only memory (ROM), random access memory (RAM, etc.)).

[0181] The communication unit can also be called a transceiver unit. The antenna and control circuit with transceiver functions in the large-pen pig weight grading device 70 can be considered as the communication unit 702 of the large-pen pig weight grading device 70, and the processor with processing functions can be considered as the processing unit 701 of the large-pen pig weight grading device 70. Optionally, the device in the communication unit 702 used to implement the receiving function can be considered as the communication unit, which is used to execute the receiving steps in the embodiments of this application. The communication unit can be a receiver, a receiver circuit, etc. The device in the communication unit 702 used to implement the transmitting function can be considered as the transmitting unit, which is used to execute the transmitting steps in the embodiments of this application. The transmitting unit can be a transmitter, a transmitter, a transmitting circuit, etc.

[0182] Figure 7 If the integrated units in the process are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of software products. These computer software products are stored in a storage medium and include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of this application. Storage media for storing computer software products include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory, random access memory, magnetic disks, or optical disks.

[0183] Figure 7 The units in the process can also be called modules; for example, a processing unit can be called a processing module.

[0184] This application embodiment also provides a hardware structure diagram of a pen pig herd weight estimation and grading device (denoted as pen pig herd weight estimation and grading device 80), see [link to diagram]. Figure 8 The large-scale pig herd weight grading device 80 includes a processor 801, and optionally, a memory 802 connected to the processor 801.

[0185] In the first possible implementation, see Figure 8The large-scale pig herd weight grading device 80 also includes a transceiver 803. The processor 801, memory 802, and transceiver 803 are connected via a bus. The transceiver 803 is used to communicate with other devices or communication networks. Optionally, the transceiver 803 may include a transmitter and a receiver. The device in the transceiver 803 that implements the receiving function can be considered as a receiver, which is used to perform the receiving steps in the embodiments of this application. The device in the transceiver 803 that implements the transmitting function can be considered as a transmitter, which is used to perform the transmitting steps in the embodiments of this application.

[0186] Based on the first possible implementation method Figure 8 The schematic diagram shown can be used to illustrate the structure of the large-pen pig herd weight estimation and grading device involved in the above embodiments.

[0187] in, Figure 8 The diagram can also illustrate the system chip in the large-pen pig herd weight estimation and grading device. In this case, the actions performed by the aforementioned large-pen pig herd weight estimation and grading device can be implemented by this system chip. The specific actions performed can be found above and will not be repeated here.

[0188] In implementation, each step of the method provided in this embodiment can be completed by integrated logic circuits in the processor or by instructions in software form. The steps of the method disclosed in the embodiments of this application can be directly manifested as being executed by a hardware processor, or being executed by a combination of hardware and software modules in the processor.

[0189] The processor in this application may include, but is not limited to, at least one of the following: a central processing unit (CPU), a microprocessor, a digital signal processor (DSP), a microcontroller unit (MCU), or an artificial intelligence processor, etc., which are various computing devices that run software. Each computing device may include one or more cores for executing software instructions to perform calculations or processing. The processor may be a separate semiconductor chip or integrated with other circuits into a single semiconductor chip. For example, it may be integrated with other circuits (such as encoding / decoding circuits, hardware acceleration circuits, or various bus and interface circuits) to form a SoC (System-on-a-Chip), or it may be integrated as a built-in processor within an ASIC. The ASIC with the integrated processor may be packaged separately or together with other circuits. In addition to the cores for executing software instructions to perform calculations or processing, the processor may further include necessary hardware accelerators, such as field-programmable gate arrays (FPGAs), PLDs (programmable logic devices), or logic circuits that implement dedicated logic operations.

[0190] The memory in the embodiments of this application may include at least one of the following types: read-only memory (ROM) or other types of static storage devices capable of storing static information and instructions; random access memory (RAM) or other types of dynamic storage devices capable of storing information and instructions; or electrically erasable programmable-only memory (EEPROM). In some scenarios, the memory may also be a compact disc read-only memory (CD-ROM) or other optical disc storage, optical disc storage (including compressed optical discs, laser discs, optical discs, digital universal optical discs, Blu-ray discs, etc.), magnetic disk storage media, or other magnetic storage devices, or any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto.

[0191] This application also provides a computer-readable storage medium including instructions that, when run on a computer, cause the computer to perform any of the methods described above.

[0192] This application also provides a computer program product containing instructions that, when run on a computer, cause the computer to perform any of the methods described above.

[0193] This application also provides a chip including a processor and an interface circuit. The interface circuit is coupled to the processor. The processor is used to run computer programs or instructions to implement the above-described method. The interface circuit is used to communicate with other modules outside the chip.

[0194] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software programs, implementation can be, in whole or in part, in the form of a computer program product. This computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to a computer or a data storage device containing one or more servers, data centers, etc., that can be integrated with the medium. The available media can be magnetic media (e.g., floppy disks, hard disks, magnetic tapes), optical media (e.g., DVDs), or semiconductor media (e.g., solid-state disks (SSDs)).

[0195] Although this application has been described herein in conjunction with various embodiments, those skilled in the art, by reviewing the accompanying drawings, the disclosure, and the appended claims, will understand and implement other variations of the disclosed embodiments in carrying out the claimed application. In the claims, the word "comprising" does not exclude other components or steps, and "a" or "an" does not exclude multiple instances. A single processor or other unit can implement several functions listed in the claims. While different dependent claims may recite certain measures, this does not mean that these measures cannot be combined to produce good results.

[0196] Although this application has been described in conjunction with specific features and embodiments, it is obvious that various modifications and combinations can be made thereto without departing from the spirit and scope of this application. Accordingly, this specification and drawings are merely exemplary illustrations of this application as defined by the appended claims, and are considered to cover any and all modifications, variations, combinations, or equivalents within the scope of this application. Clearly, those skilled in the art can make various alterations and modifications to this application without departing from the spirit and scope of this application. Thus, if such modifications and modifications of this application fall within the scope of the claims of this application and their equivalents, this application is also intended to include such modifications and modifications.

Claims

1. A method for estimating and grading the weight of large-scale pig herds, characterized in that, include: Acquire video information collected during multiple rounds of video inspections of target pens within the pigsty; Based on the video information, multiple first weight estimates are determined for each round of video inspection in the multi-round video inspection. The first estimated weight value is the average of the estimated weight values ​​of the same pig in multiple video frames during a single inspection. Based on the video information and the first estimated weight value, the number of pigs N in the target column is determined, and the second estimated weight value of each of the N pigs is determined. Based on the number of pigs N, multiple first weight values ​​in the multi-round video inspection process are clustered to obtain N clusters, and N cluster weight values ​​are determined according to the first weight value in each cluster. The N clustered weight estimates and the N second weight estimates are fused to obtain N fused weight estimates for the target field. The pigs in the target pen are weighted and graded based on N fused weight estimates of the target pen.

2. The method according to claim 1, characterized in that, The step of determining multiple first weight values ​​for each round of video inspection based on the video information includes: Extract the RGB image of the pig in the target column from the video information; Obtain the detection box for each pig and continuously track the detection box based on the BoT-SORT tracking algorithm to filter out the valid tracking frames for each pig in this round of inspection; the detection box is a rectangular bounding box surrounding the main body of the pig, output by a segmentation algorithm based on the RGB image of the pig. The weight of the same pig in each valid tracking frame is determined by a multimodal weight estimation method, and the average weight of the same pig in each valid tracking frame is taken as the first estimated weight value of the pig.

3. The method according to claim 2, characterized in that, The first estimated weight of the pigs satisfies the following formula: Wherein, weight_id represents the first estimated weight of the pig, track_id_num represents the number of valid tracking frames, weight_id_x represents the weight of the pig in the xth valid tracking frame, and x is the index of the valid tracking frame.

4. The method according to claim 1, characterized in that, The step of determining a second estimated weight for each pig based on the video information includes: The video information is input into the pig back recognition network training model to obtain the feature vector of each pig in the target column; Obtain a historical feature vector database of pigs; the historical feature vector database contains the historical feature vectors of pigs saved during the historical inspection of the target pen, the historical weight of pigs, and the corresponding number of historical valid tracking frames. For each pig's feature vector, if there is a first historical feature vector in the historical feature vector database whose feature similarity to the feature vector exceeds a threshold, then the historical pig weight corresponding to the first historical feature vector is updated based on the pig's first estimated weight value; the updated historical pig weight is used as the second estimated weight value. If the first historical feature vector does not exist, the feature vector, the first estimated weight of the pig, and the number of valid tracking frames of the pig are added to the historical feature database, and the first estimated weight is used as the second estimated weight.

5. The method according to claim 4, characterized in that, The historical pig weight corresponding to the first historical feature vector, updated based on the first estimated weight of the pig, satisfies the following formula: track_id_new=track_num_u+track_id_num Wherein, weight_id_new is the updated weight of the pig, track_id_new is the updated number of valid tracking frames, weight_u is the first estimated weight of the currently inspected pig, and track_num_u is the number of valid tracking frames corresponding to the first estimated weight of the currently inspected pig.

6. The method according to claim 1, characterized in that, The process of fusing the N clustering weight estimates and the N second weight estimates to obtain N fused weight estimates for the target field includes: Based on the magnitude of the estimated weight values, the second estimated weight value and the cluster estimated weight value are sorted respectively; The second weighted value and the cluster weighted value of the same sorting are merged according to the preset weight ratio to obtain the merged weighted value.

7. The method according to claim 6, characterized in that, The second weighted value and the cluster weighted value of the same sorting are fused according to a preset weight ratio to obtain a fused weighted value that satisfies the following formula: fused_weight_list=[w f0 ,w f1 ,...,w fi ,...,w fN ] Where fused_weight_list represents the fused weight estimate, w fi =w i *r i +w ci *(1-r i ), r i Let r be the weighting factor, and r i <1, w i For the i-th second weight estimate after sorting, w ci The weight estimate of the i-th cluster after sorting is given, where i is the index of the number of pigs.

8. The method according to claim 7, characterized in that, The step of weight grading the pigs in the target pen based on N fused weight estimates includes: The average weight of the pigs in the target pen is calculated based on the N fused weight estimates of the target pen. Based on the average weight of pigs in the target pen and a preset weight threshold range, the fused weight estimate of the target pen is divided into multiple levels, and the number of pigs in each level is counted.

9. The method according to claim 1, characterized in that, After determining multiple first weight values ​​for each round of video inspection based on the video information, the method further includes: The column switching is achieved through a column boundary switching algorithm, and multiple rounds of inspection are performed on multiple columns based on the column switching. If the target column is the last column, the single-round inspection is completed; if it is not the last column, the next column is switched to continue the inspection. When the set number of inspections is reached, the inspection ends; if the set number of inspections is not reached, the next round of inspections continues.

10. A weight grading device for large-scale pig herds, characterized in that, include: Communication unit and processing unit; The communication unit is used to acquire video information collected during multiple rounds of video inspections of target pens in the pigsty. The processing unit is configured to: determine multiple first weight estimates for each round of video inspection in the multi-round video inspection based on the video information; the first weight estimate is the average of the weight estimates of the same pig in multiple video frames in a single inspection; determine the number N of pigs in the target pen and the second weight estimate for each of the N pigs based on the video information and the first weight estimates; cluster the multiple first weight estimates in the multi-round video inspection process based on the number N of pigs to obtain N clusters, and determine N cluster weight estimates based on the first weight estimates in each cluster; fuse the N cluster weight estimates and the N second weight estimates to obtain N fused weight estimates for the target pen; and classify the pigs in the target pen by weight estimate based on the N fused weight estimates for the target pen.