Pig body weight estimation method and device, electronic equipment and storage medium

By applying segmentation model and key point detection model on pig body pictures, combining prior knowledge and trunk proportional coefficients, the problems of unstable and low accuracy of pig body weight estimation in the prior art are solved, and pigs with any weight range are realized Accurate weight estimation of the body.

CN119048575APending Publication Date: 2024-11-29PING AN TECH (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411107141.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-13
Publication Date
2024-11-29

AI Technical Summary

Technical Problem

In the case of a single pig body picture, it is difficult to accurately estimate the weight of the pig body of any weight range. Especially when shooting at multiple angles or when the reference object is different, the weight estimation results are unstable and are only applicable to certain Weight range, low accuracy.

Method used

By obtaining pig body pictures, input them to the pre-trained segmentation model and key point detection model, determine the outer contour curve, key points and actual physical length, combine prior knowledge and trunk proportional coefficients, adjust the body shape standard coefficients, and perform weight estimation.

Benefits of technology

The accurate weight estimation of pig bodies in any weight range under a single picture is achieved, which improves the stability and accuracy of the estimation results, and is suitable for pig bodies of different body types.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119048575A_ABST
    Figure CN119048575A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a pig weight estimation method and device, electronic equipment and a storage medium, and belongs to the technical field of artificial intelligence. The method comprises the following steps: inputting a pig body picture into a pig body segmentation model to obtain a pig body outer contour curve; inputting the pig body picture into a pig body key point detection model to obtain pig body key points; determining the corresponding actual physical length of each pixel on the pig body picture in the x-axis direction and the y-axis direction; according to the pig body outer contour curve, the pig body key points and the actual physical length, the pig body length, the chest circumference cross section linear length and the belly circumference variable quantity are determined; adjusting a standard coefficient of the body type of the target pig based on priori knowledge, the pig body trunk proportionality coefficient and the belly circumference variation; and performing weight estimation on the target pig according to the pig body length, the chest circumference cross section linear length and the standard coefficient to obtain a pig body weight estimation result. On the basis, the weight of the pig body in any weight range can be accurately estimated on the basis of a single pig body picture.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of artificial intelligence technology, and in particular to a method and device for estimating pig weight, an electronic device and a storage medium. Background Art

[0002] Based on a single picture, the existing methods for estimating the weight of a pig are basically to simply use machine learning to learn some key points of the pig body in a large sample, and then use these big data for regression analysis. One disadvantage of these solutions is that when the same pig is photographed from multiple angles, or when related reference objects are placed at different positions on the ground, the stability of the pig weight estimation results will decrease; another disadvantage is that in various scenarios of actual business, the existing methods are often only applicable to the weight estimation of pigs within a certain weight range, and the accuracy is not high. The fundamental reason is that one is that the features cannot remain unchanged with the 3D projection transformation; the other is that machine learning lacks the expression of stable domain knowledge and changes with the distribution of the training set. Since the training set cannot capture all shooting angles and fewer situations, it is impossible to learn the essential laws of which factors affect the weight of the pig itself. Therefore, how to accurately estimate the weight of pigs of any weight range based on a single pig picture has become a technical problem that needs to be solved urgently. Summary of the invention

[0003] The main purpose of the embodiments of the present application is to propose a pig weight estimation method and device, electronic device and storage medium, which can accurately estimate the weight of pigs in any weight range based on a single pig picture.

[0004] To achieve the above-mentioned purpose, a first aspect of an embodiment of the present application proposes a method for estimating pig weight, the method comprising:

[0005] Obtain a body image of the target pig;

[0006] Inputting the pig body image into a pre-trained pig body segmentation model to obtain a pig body contour curve of the target pig;

[0007] Inputting the pig body picture into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig;

[0008] Determine the actual physical length of each pixel on the pig body image in both the x-axis and y-axis directions;

[0009] Determine the pig body length, chest girth cross-section straight line length and belly girth change of the target pig according to the pig body contour curve, the pig body key points and the actual physical length;

[0010] Based on prior knowledge, the pig trunk ratio coefficient and the belly circumference change, the standard coefficient of the target pig corresponding to the pig body type is adjusted, and the pig body type includes breeding pigs, piglets and large pigs;

[0011] The weight of the target pig is estimated according to the pig body length, the straight-line length of the chest girth section and the standard coefficient to obtain a pig body weight estimation result.

[0012] In some embodiments, the key points of the pig body include the pig's ear point, tail point, intersection points of two front legs and the abdomen, four points of the abdomen, and intersection points of the hind legs and the abdomen.

[0013] In some embodiments, determining the actual physical length of each pixel on the pig body image in the x-axis and y-axis directions includes:

[0014] Performing corner point coordinate detection on the pig body image based on Harris checkerboard corner point detection algorithm to obtain a corner point detection result;

[0015] The actual physical length of each pixel on the pig body image in the x-axis and y-axis directions is calculated according to the corner point detection result.

[0016] In some embodiments, determining the pig body length, chest girth cross-section straight line length and belly girth change of the target pig according to the pig body contour curve, the pig body key points and the actual physical length includes:

[0017] Determine the pig body length according to the ear point, the tail point, the pig body contour curve and the actual physical length;

[0018] Determine the straight length of the chest girth section according to the intersection of the two front feet and the abdomen, the pig's external contour curve and the actual physical length;

[0019] The belly circumference change is determined based on the four points on the abdomen, the intersection of the hind legs and the abdomen, the pig's external contour curve and the actual physical length.

[0020] In some embodiments, determining the pig body length according to the ear point, the tail point, the pig body contour curve and the actual physical length includes:

[0021] Determine a first target point and a second target point of the pig's external contour curve that are closest to the ear point and the tail point respectively;

[0022] Fitting a curve between the first target point and the second target point using a polynomial curve to obtain a curve segment;

[0023] The curve length of the curve segment is calculated by integration according to the actual physical length to obtain the pig body length.

[0024] In some embodiments, determining the straight length of the chest circumference section according to the intersection of the two front feet and the abdomen, the pig's external contour curve and the actual physical length includes:

[0025] determining a first intersection point between the first front leg and the abdomen, and a second intersection point between the second front leg and the abdomen;

[0026] Calculating a distance value between the first intersection point and the second intersection point;

[0027] When the distance value is less than a preset threshold, the midpoint between the first intersection point and the second intersection point is determined as the first chest circumference section point, and the point from the first chest circumference section point to the pig's external contour curve is determined as the second chest circumference section point; or, when the distance value is greater than or equal to the preset threshold, the point from the first intersection point to the second intersection point that is closest to the hind leg is determined as the first chest circumference section point, and the point from the first chest circumference section point to the pig's external contour curve is determined as the second chest circumference section point;

[0028] The cross-sectional length between the first chest circumference cross-sectional point and the second chest circumference cross-sectional point is calculated by integration according to the actual physical length to obtain the chest circumference cross-sectional straight-line length.

[0029] In some embodiments, determining the belly circumference change amount according to the four points of the abdomen, the intersection of the hind legs and the abdomen, the pig's external contour curve, and the actual physical length includes:

[0030] Draw lines based on the four points on the abdomen and the intersection of the hind legs and the abdomen to obtain multiple parallel lines;

[0031] determining a maximum value and a minimum value among a plurality of said parallel lines;

[0032] calculating the difference between the maximum value and the minimum value;

[0033] Calculate the standard deviation of the length variation of multiple parallel lines;

[0034] The belly circumference change is determined according to the difference and the standard deviation.

[0035] To achieve the above-mentioned purpose, a second aspect of an embodiment of the present application provides a pig weight estimation device, the device comprising:

[0036] The first module is used to obtain the body image of the target pig;

[0037] The second module is used to input the pig body image into a pre-trained pig body segmentation model to obtain the pig body contour curve of the target pig;

[0038] The third module is used to input the pig body picture into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig;

[0039] The fourth module is used to determine the actual physical length of each pixel on the pig body image in the x-axis and y-axis directions;

[0040] A fifth module is used to determine the pig body length, chest girth cross-section straight line length and belly girth change of the target pig according to the pig body contour curve, the pig body key points and the actual physical length;

[0041] The sixth module is used to adjust the standard coefficient of the target pig corresponding to the pig body type based on prior knowledge, the pig body trunk ratio coefficient and the belly circumference change, and the pig body type includes breeding pigs, piglets and large pigs;

[0042] The seventh module is used to estimate the weight of the target pig according to the pig body length, the straight length of the chest circumference section and the standard coefficient to obtain the pig body weight estimation result.

[0043] To achieve the above objectives, a third aspect of an embodiment of the present application proposes an electronic device, which includes a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the method described in the first aspect is implemented.

[0044] To achieve the above-mentioned purpose, the fourth aspect of an embodiment of the present application proposes a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method described in the first aspect is implemented.

[0045] The pig weight estimation method and device, electronic device and storage medium proposed in the present application obtain a pig body image of a target pig; input the pig body image into a pre-trained pig body segmentation model to obtain a pig body external contour curve of the target pig; input the pig body image into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig; determine the actual physical length corresponding to each pixel on the pig body image in the x-axis and y-axis directions; determine the pig body length, chest circumference cross-section straight line length and belly circumference change of the target pig according to the pig body external contour curve, pig body key points and actual physical length; adjust the standard coefficient of the target pig corresponding to the pig body shape based on prior knowledge, pig body trunk proportion coefficient and belly circumference change, and the pig body shape includes breeding pigs, piglets and large pigs; estimate the weight of the target pig according to the pig body length, chest circumference cross-section straight line length and standard coefficient to obtain the pig weight estimation result. By inputting a single target pig's body picture into a pre-trained pig segmentation model and a pig key point detection model, the model outputs the target pig's external contour curve and pig key points, and then determines the target pig's body length, chest circumference section straight length and belly circumference change according to the pig's external contour curve, pig key points and actual physical length. And combined with expert prior knowledge, pig trunk ratio coefficient and belly circumference change, the standard coefficient corresponding to the pig's body shape is adjusted, and finally the target pig is estimated according to the pig's body length, chest circumference section straight length and standard coefficient. Since the pig's body length, chest circumference section straight length, belly circumference change and standard coefficient are all interpretable, stable, and in line with expert knowledge and physical common sense, these features can reflect the change law of pig weight, thereby enabling a more accurate weight estimation of the target pig. Based on this, the embodiment of the present application can be applied to the field of artificial intelligence, and can accurately estimate the weight of pigs of any weight range based on a single pig picture. BRIEF DESCRIPTION OF THE DRAWINGS

[0046] Figure 1 is a flow chart of a pig weight estimation method provided in an embodiment of the present application;

[0047] Figure 2 yes Figure 1 Flow chart of step S104 in FIG.

[0048] Figure 3 yes Figure 1 Flow chart of step S105 in FIG.

[0049] Figure 4 yes Figure 3 Flow chart of step S301 in FIG.

[0050] Figure 5 yes Figure 3 Flow chart of step S302 in FIG.

[0051] Figure 6 yes Figure 3 Flow chart of step S303 in FIG.

[0052] Figure 7 is a schematic diagram of the structure of a pig weight estimation device provided in an embodiment of the present application;

[0053] Figure 8 It is a schematic diagram of the hardware structure of the electronic device provided in the embodiment of the present application. DETAILED DESCRIPTION

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

[0055] It should be noted that, although the functional modules are divided in the device schematic diagram and the logical order is shown in the flowchart, in some cases, the steps shown or described may be performed in a different order than the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and the above drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence.

[0056] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by those skilled in the art to which this application belongs. The terms used herein are only for the purpose of describing the embodiments of this application and are not intended to limit this application.

[0057] First, some nouns involved in this application are analyzed:

[0058] Artificial intelligence (AI) is a new technical science that studies and develops theories, methods, technologies and application systems for simulating, extending and expanding human intelligence. AI is a branch of computer science that attempts to understand the essence of intelligence and produce a new type of intelligent machine that can respond in a similar way to human intelligence. Research in this field includes robotics, speech recognition, image recognition, natural language processing and expert systems. AI can simulate the information process of human consciousness and thinking. AI is also a theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0059] Harris corner detection algorithm: It is a widely used corner detection method, especially showing its unique advantages in the corner detection of black and white checkerboard. This algorithm is not only simple and easy to use, but also crucial for camera calibration technology. On the black and white checkerboard, each corner point is the corner point of four black and white squares, which makes the corner points very easy to detect and identify. The Harris algorithm identifies corner points by detecting local changes in the image. These local changes can be grayscale changes, color changes, or texture changes. On the black and white checkerboard, this change is manifested as a clear contrast at the junction of black and white. The execution process of the Harris corner detection algorithm includes the following steps: first, by analyzing the local features of the image, the degree of change of each pixel point in its neighborhood is calculated; second, according to the calculated degree of change, whether the pixel point is a corner point; finally, through threshold processing, the final set of corner points is determined. This process is particularly effective for black and white checkerboards because it can accurately identify the corner points of the checkerboard, which are widely used in computer vision and image processing, such as camera calibration, 3D reconstruction, etc.

[0060] YOLO (You Only Look Once) model: is a popular target detection algorithm that can identify and locate multiple objects in a picture, and predict the category and location of the objects at the same time. The YOLO model converts the target detection task into a regression problem, using a single neural network to complete the location and classification of objects at one time, thereby achieving real-time and efficient target detection.

[0061] EM (Expectation Maximum) algorithm: is an iterative algorithm used for maximum likelihood estimation or maximum a posteriori estimation of a model with latent variable probability parameters. With each iteration of the model parameters, the likelihood function of the model with latent variable probability parameters will increase. When the likelihood function no longer increases or the increased value is less than the set threshold, the iteration ends. The EM algorithm has a wide range of applications in the field of data clustering in machine learning and computer vision. As long as it involves the application of posterior probability, we can consider using the EM algorithm to solve the problem.

[0062] Based on a single picture, the existing methods for estimating the weight of a pig are basically to simply use machine learning to learn some key points of the pig body in a large sample, and then use these big data for regression analysis. One disadvantage of these solutions is that when the same pig is photographed from multiple angles, or when related reference objects are placed at different positions on the ground, the stability of the pig weight estimation results will decrease; another disadvantage is that in various scenarios of actual business, the existing methods are often only applicable to the weight estimation of pigs within a certain weight range, and the accuracy is not high. The fundamental reason is that one is that the features cannot remain unchanged with the 3D projection transformation; the other is that machine learning lacks the expression of stable domain knowledge and changes with the distribution of the training set. Since the training set cannot capture all shooting angles and fewer situations, it is impossible to learn the essential laws of which factors affect the weight of the pig itself. Therefore, how to accurately estimate the weight of pigs of any weight range based on a single pig picture has become a technical problem that needs to be solved urgently.

[0063] Based on this, the embodiments of the present application provide a method and device for estimating pig weight, an electronic device and a storage medium, which obtain a pig body image of a target pig; input the pig body image into a pre-trained pig body segmentation model to obtain a pig body external contour curve of the target pig; input the pig body image into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig; determine the actual physical length corresponding to each pixel on the pig body image in the x-axis and y-axis directions; determine the pig body length, chest circumference cross-section straight line length and belly circumference variation of the target pig according to the pig body external contour curve, the pig body key points and the actual physical length; adjust the standard coefficient of the target pig corresponding to the pig body shape based on prior knowledge, the pig body trunk proportion coefficient and the belly circumference variation, and the pig body shape includes breeding pigs, piglets and large pigs; estimate the weight of the target pig according to the pig body length, chest circumference cross-section straight line length and the standard coefficient to obtain the pig weight estimation result. By inputting a single target pig's body picture into a pre-trained pig segmentation model and a pig key point detection model, the model outputs the target pig's external contour curve and pig key points, and then determines the target pig's body length, chest circumference section straight length and belly circumference change according to the pig's external contour curve, pig key points and actual physical length. And combined with expert prior knowledge, pig trunk ratio coefficient and belly circumference change, the standard coefficient corresponding to the pig's body shape is adjusted, and finally the target pig is estimated according to the pig's body length, chest circumference section straight length and standard coefficient. Since the pig's body length, chest circumference section straight length, belly circumference change and standard coefficient are all interpretable, stable, and in line with expert knowledge and physical common sense, these features can reflect the change law of pig weight, thereby enabling a more accurate weight estimation of the target pig. Based on this, the embodiment of the present application can be applied to the field of artificial intelligence, and can accurately estimate the weight of pigs of any weight range based on a single pig picture.

[0064] The pig weight estimation method and device, electronic device and storage medium provided in the embodiments of the present application are specifically illustrated through the following embodiments. First, the pig weight estimation method in the embodiments of the present application is described.

[0065] The embodiments of the present application can acquire and process relevant data based on artificial intelligence technology. Among them, artificial intelligence (AI) is the theory, method, technology and application system that uses digital computers or machines controlled by digital computers to simulate, extend and expand human intelligence, perceive the environment, acquire knowledge and use knowledge to obtain the best results.

[0066] AI basic technologies generally include sensors, dedicated AI chips, cloud computing, distributed storage, big data processing technology, operation / interaction systems, mechatronics, etc. AI software technologies mainly include computer vision technology, robotics technology, biometrics technology, speech processing technology, natural language processing technology, and machine learning / deep learning.

[0067] The pig weight estimation method provided in the embodiment of the present application relates to the field of artificial intelligence technology. The pig weight estimation method provided in the embodiment of the present application can be applied to a terminal, can be applied to a server side, or can be software running in a terminal or a server side. In some embodiments, the terminal can be a smart phone, a tablet computer, a laptop computer, a desktop computer, etc.; the server side can be configured as an independent physical server, or can be configured as a server cluster or a distributed system composed of multiple physical servers, and can also be configured as a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN, and big data and artificial intelligence platforms; the software can be an application that implements the pig weight estimation method, etc., but is not limited to the above forms.

[0068] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld or portable devices, tablet devices, multiprocessor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in distributed computing environments, in which tasks are performed by remote processing devices connected through a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media including storage devices.

[0069] It should be noted that in each specific implementation of the present application, when it comes to the need to perform relevant processing based on data related to user identity or characteristics such as user information, user behavior data, user historical data, and user location information, the user's permission or consent will be obtained first, and the collection, use, and processing of these data will comply with relevant laws, regulations, and standards. In addition, when the embodiment of the present application needs to obtain the user's sensitive personal information, the user's separate permission or consent will be obtained through a pop-up window or by jumping to a confirmation page. After clearly obtaining the user's separate permission or consent, the necessary user-related data for the normal operation of the embodiment of the present application will be obtained.

[0070] Figure 1 is an optional flow chart of the pig weight estimation method provided in the embodiment of the present application. Figure 1 The method may include but is not limited to steps S101 to S107.

[0071] Step S101, obtaining a body image of a target pig;

[0072] Step S102, inputting the pig body image into a pre-trained pig body segmentation model to obtain a pig body contour curve of the target pig;

[0073] Step S103, inputting the pig body picture into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig;

[0074] Step S104, determining the actual physical length of each pixel on the pig body image in both the x-axis and y-axis directions;

[0075] Step S105, determining the pig body length, chest circumference cross-section straight line length and belly circumference change of the target pig according to the pig body contour curve, pig body key points and actual physical length;

[0076] Step S106, adjusting the standard coefficient of the target pig's corresponding body type based on prior knowledge, the pig's trunk ratio coefficient and the belly circumference change, where the pig's body type includes sows, piglets and large pigs;

[0077] Step S107, estimating the weight of the target pig according to the pig body length, the straight length of the chest circumference section and the standard coefficient to obtain the pig body weight estimation result.

[0078] In step S101 of some embodiments, a body image of a target pig is obtained. The body image of the target pig can be obtained by photographing the target pig. The target pig can be a live pig or a dead pig. The body types of the target pig can include sows, piglets, and large pigs.

[0079] In step S102 of some embodiments, the pig body image is input into a pre-trained pig body segmentation model to obtain the external contour curve of the target pig. The pig body segmentation model can be a deep learning model trained by UNet for pig body segmentation. For example, during model training, 500 pig body images with pig body contours already marked can be used to train the pig body segmentation model to obtain a trained pig body segmentation model. The pig body image is then input into the pre-trained pig body segmentation model to obtain the external contour curve of the target pig.

[0080] In step S103 of some embodiments, the pig body picture is input into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig. The pig body key point detection model can be a Yolov5 key point detection model. For example, during model training, 500 pig body pictures with pig body key points marked can be used to train the pig body key point detection model to obtain a trained pig body key point detection model. The pig body picture is then input into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig, wherein the pig body key points include but are not limited to the pig's ear point, tail point, the intersection of the two front feet and the abdomen, four points on the abdomen, and the intersection of the hind legs and the abdomen.

[0081] In step S104 of some embodiments, the actual physical length corresponding to each pixel on the pig body image in the x-axis and y-axis directions is determined. Specifically, the corner point coordinates of the pig body image can be detected based on the Harris checkerboard corner point detection algorithm, and the coordinates of the four main corner points of the checkerboard up, down, left, and right can be detected to obtain the corner point detection result; and the actual physical length corresponding to each pixel on the pig body image in the x-axis and y-axis directions can be calculated based on the corner point detection result.

[0082] In step S105 of some embodiments, the pig body length, chest circumference cross-section straight length, and belly circumference change of the target pig are determined based on the pig body contour curve, the pig body key points, and the actual physical length. For the pig body key points, the pig's ear point and tail point can be used to calculate the pig body length curve; the intersection of the pig's two front legs and the abdomen can be used to calculate the pig's chest circumference; the four points of the pig's abdomen and the intersection of the hind legs and the abdomen can be used to calculate the pig's belly circumference change. Based on this, different pig body key points combined with the pig's external contour curve and the actual physical length can be used to calculate the pig body length, chest circumference cross-section straight length, and belly circumference change of the target pig.

[0083] In step S106 of some embodiments, the standard coefficient of the target pig corresponding to the pig body type is adjusted based on prior knowledge, the pig body trunk ratio coefficient and the belly circumference change. The pig body types include sows, piglets and large pigs. Generally speaking, according to expert prior knowledge, the weight of an adult pig is approximately equal to the straight length of the chest circumference section * pig body length / standard coefficient, and the standard coefficient is generally 142. However, the standard coefficient varies greatly among sows, piglets and large pigs, and can vary from 302 to 142, that is, the smaller the pig, the larger its standard coefficient. However, when the belly circumference change of some pigs is large, the above standard coefficient will have a large error, that is, when the belly circumference is large, it means that the pig itself is stronger and has a better nutritional status, and should also be heavier, and the standard coefficient should also be smaller. In addition, for some pigs with very long body trunk ratios, even if their belly circumference does not become very large, they will be heavier, and the corresponding standard coefficient should also be smaller. Therefore, it is necessary to adjust the standard coefficient of the target pig's body shape according to prior knowledge, the pig's trunk proportion coefficient and the belly circumference change to more accurately reflect the target pig's body weight.

[0084] In step S107 of some embodiments, the weight of the target pig is estimated according to the pig body length, the straight length of the chest circumference section and the standard coefficient to obtain the pig body weight estimation result. Since the standard coefficient of the embodiment of the present invention is adjusted according to the prior knowledge, the pig body trunk ratio coefficient and the belly circumference change, the weight of the target pig is estimated according to the pig body length, the straight length of the chest circumference section and the standard coefficient, and an accurate pig body weight estimation result can be obtained. The pig body weight estimation method of the present application is applied to the field of artificial intelligence, and can accurately estimate the weight of pigs of any weight range based on a single pig body picture.

[0085] Steps S101 to S107 shown in the embodiment of the present application are to obtain a body image of a target pig; input the body image into a pre-trained body segmentation model to obtain a body contour curve of the target pig; input the body image into a pre-trained body key point detection model to obtain the body key points of the target pig; determine the actual physical length of each pixel on the body image in both the x-axis and y-axis directions; determine the body length, chest circumference section straight line length and belly circumference variation of the target pig according to the pig's body contour curve, the body key points and the actual physical length; adjust the standard coefficient of the target pig's body shape corresponding to the pig's body shape based on prior knowledge, the pig's body trunk proportion coefficient and the belly circumference variation, the pig's body shape includes breeding pigs, piglets and large pigs; estimate the weight of the target pig according to the pig's body length, the chest circumference section straight line length and the standard coefficient to obtain a pig weight estimation result. By inputting a single target pig's body picture into a pre-trained pig segmentation model and a pig key point detection model, the model outputs the target pig's external contour curve and pig key points, and then determines the target pig's body length, chest circumference section straight length and belly circumference change according to the pig's external contour curve, pig key points and actual physical length. And combined with expert prior knowledge, pig trunk ratio coefficient and belly circumference change, the standard coefficient corresponding to the pig's body shape is adjusted, and finally the target pig is estimated according to the pig's body length, chest circumference section straight length and standard coefficient. Since the pig's body length, chest circumference section straight length, belly circumference change and standard coefficient are all interpretable, stable, and in line with expert knowledge and physical common sense, these features can reflect the change law of pig weight, thereby enabling a more accurate weight estimation of the target pig. Based on this, the embodiment of the present application can be applied to the field of artificial intelligence, and can accurately estimate the weight of pigs of any weight range based on a single pig picture.

[0086] See also Figure 2 In some embodiments, step S104 may include but is not limited to steps S201 to S202:

[0087] Step S201, performing corner point coordinate detection on the pig body image based on Harris checkerboard corner point detection algorithm to obtain a corner point detection result;

[0088] Step S202, calculating the actual physical length of each pixel on the pig body image in the x-axis and y-axis directions according to the corner point detection result.

[0089] In some embodiments, the corner coordinates of the pig body image can be detected based on Harris's checkerboard corner detection algorithm, and the coordinates of the four main corner points of the checkerboard up, down, left and right can be detected to obtain the corner detection results; based on the corner detection results, the actual physical length of each pixel on the pig body image in the x-axis and y-axis directions can be calculated.

[0090] See also Figure 3 In some embodiments, step S105 may include but is not limited to steps S301 to S303:

[0091] Step S301, determining the pig body length according to the ear point, the tail point, the pig body contour curve and the actual physical length;

[0092] Step S302, determining the straight length of the chest section according to the intersection of the two front feet and the abdomen, the external contour curve of the pig and the actual physical length;

[0093] Step S303, determining the change in belly circumference according to four points on the abdomen, the intersection of the hind legs and the abdomen, the external contour curve of the pig and the actual physical length.

[0094] In some embodiments, the key points of the pig body include but are not limited to the pig's ear point, tail point, intersection of the two front legs and abdomen, four points of the abdomen, and intersection of the hind legs and abdomen. Among them, the pig's ear point and tail point can be used to calculate the pig's body length curve; the intersection of the two front legs and abdomen of the pig can be used to calculate the pig's chest circumference; the four points of the pig's abdomen and the intersection of the hind legs and abdomen can be used to calculate the pig's belly circumference change. Based on this, different key points of the pig body can be used in combination with the pig's external contour curve and actual physical length to calculate the pig's body length, chest circumference cross-section straight line length, and belly circumference change of the target pig.

[0095] See also Figure 4 In some embodiments, step S301 may include but is not limited to steps S401 to S403:

[0096] Step S401, determining a first target point and a second target point of the pig's external contour curve that are closest to the ear point and the tail point respectively;

[0097] Step S402, fitting a curve between the first target point and the second target point using a polynomial curve to obtain a curve segment;

[0098] Step S403, calculating the curve length of the curve segment by integration according to the actual physical length to obtain the pig body length.

[0099] In some embodiments, the actual physical length (ds) of each pixel in the pig body image in the x-axis and y-axis directions is calculated based on the corner point detection result. x ,ds y ). Using the ear and tail points output by the pig key point detection model, find out which points on the pig body contour curve output by the pig body segmentation model are closest to the ear and tail key points, find the first target point and the second target point, and let the first target point and the second target point be P earand P tail , the line segment between the two corresponding points is the body length curve. In the embodiment of the present application, the polynomial curve is first used. Fit this section of the curve, and then use the integral to calculate the length of this section of the curve, and then get the pig body length

[0100] See also Figure 5 In some embodiments, step S302 may include but is not limited to steps S501 to S504:

[0101] Step S501, determining a first intersection point between the first front leg and the abdomen, and a second intersection point between the second front leg and the abdomen;

[0102] Step S502, calculating the distance between the first intersection point and the second intersection point;

[0103] Step S503, when the distance value is less than a preset threshold, determine the midpoint between the first intersection and the second intersection as the first chest circumference section point, and determine the point closest to the pig's external contour curve from the first chest circumference section point as the second chest circumference section point; or, when the distance value is greater than or equal to the preset threshold, determine the point between the first intersection and the second intersection that is closest to the hind leg as the first chest circumference section point, and determine the point closest to the pig's external contour curve from the first chest circumference section point as the second chest circumference section point;

[0104] Step S504, calculating the section length between the first chest circumference section point and the second chest circumference section point by integration according to the actual physical length, and obtaining the chest circumference section straight line length.

[0105] In some embodiments, the intersection points of the two front legs and the abdomen of the pig output by the pig body key point detection model include the first intersection point P of the first front leg and the abdomen. leg1 , and the second intersection point P of the second front leg and the abdomen leg2 . Determine the first intersection point P leg1 and the second intersection point P leg2 The distance between the two points. If the distance is less than the threshold value T1, the midpoint of the two points is used as the point on the chest section. Otherwise, the point closer to the pig's hind leg is used as the point on the chest section. Let the chest section point be P belly1 , find the point P bellyl The point closest to the above curve P9(x,y) is set as P belly2 , based on which the straight length of the chest section is calculated, the formula is as follows:

[0106]

[0107] See also Figure 6In some embodiments, step S303 may include but is not limited to steps S601 to S605:

[0108] Step S601, connecting four points on the abdomen and the intersection of the hind legs and the abdomen to obtain a plurality of parallel lines;

[0109] Step S602, determining the maximum value and the minimum value among a plurality of parallel lines;

[0110] Step S603, calculating the difference between the maximum value and the minimum value;

[0111] Step S604, calculating the standard deviation of the length changes of the plurality of parallel lines;

[0112] Step S605, determining the belly circumference change according to the difference and the standard deviation.

[0113] In some embodiments, the four points of the pig's abdomen and the intersection of the hind legs and the abdomen output by the pig's key point detection model are used to perform P along these key points. belly1 and P belly2 By calculating the difference between the maximum and minimum lengths of these parallel lines and the standard deviation of the length changes of these parallel lines, the change in the belly circumference of the target pig can be measured based on the difference and standard deviation.

[0114] The following is a further explanation of the pig weight estimation method of the present application in conjunction with specific examples.

[0115] The specific steps of the pig weight estimation method in the embodiment of the present application are as follows:

[0116] 1. First, design the main key points of the pig's body, including the ear point and the tail point to calculate the pig's body length curve; including the intersection of the pig's two front legs and the abdomen to calculate the pig's chest circumference; including the four points on the pig's abdomen and the intersection of the hind legs and the abdomen to calculate the pig's abdominal circumference changes.

[0117] 2. Label 500 pig body images, including the above key points and the outer contour of the pig.

[0118] 3. Use UNet to train the deep learning model for pig body segmentation, and use the Yolov5 model to train the pig body key point detection model.

[0119] 4. Use Harris corner detection to detect the coordinates of the four main corner points of the chessboard.

[0120] 5. According to the corner point detection results, calculate the actual physical length (dS) of each pixel in the image in the x-axis and y-axis directions. x ,ds y ).

[0121] 6. Using the ear points and tail points output by the Yolo model, find out which points on the pig's external contour curve output by the UNet model are closest to these key points, let P ear and P tail , the line segment between the two corresponding points is the body length curve. In the embodiment of the present application, the polynomial curve is first used. Fit this section of the curve, and then use the integral to calculate the length of this section of the curve, that is, the body length of the pig

[0122] 7. The intersection point P of the pig’s two front legs and abdomen output by the Yolo model leg1 and P leg2 , judge the distance between the two points. If it is less than the threshold T1, the midpoint of the two points is used as the point on the chest section. Otherwise, the point closer to the pig's hind leg is used as the point on the chest section. Let the chest section point be P belly1 , find the point closest to the curve P9(x,y) above, let it be P belly2 .Use the same method as step 6 to calculate the straight length of the chest section. The formula is as follows:

[0123]

[0124] 8. Since it is difficult to accurately restore the shape of the pig's chest circumference cross section with only a single image, the embodiment of the present application assumes that the chest circumference cross section is a curve based on common sense in physics, and the major axis is D calculated in step 7. At the same time, the embodiment of the present application assumes that the minor axis of the ellipse is in a certain positive relationship with the major axis, that is, the larger the major axis of the pig's chest circumference cross section, the larger the corresponding minor axis should be, but it is not completely proportional. However, the embodiment of the present application can assume that within a relatively small range, the ratio of the major and minor axes is consistent, that is, the ratio of the major and minor axes of the ellipse of the chest circumference of pigs of different body sizes is inconsistent, but the ratio of the major and minor axes of the chest circumference of pigs of similar body sizes is relatively consistent. In addition, the embodiment of the present application uses this assumption to segment the training set samples into five major segments according to the size of D, and the ratio of the major and minor axes of each segment is fixed; when the pig body continues to grow larger and longer, the ratio of the minor axis to the major axis also increases.

[0125] 9. More importantly, the embodiment of the present application utilizes the prior knowledge of human experts. The weight of an adult pig is approximately equal to chest circumference*body length / standard coefficient. The standard coefficient is 142. According to the deterioration of nutritional status, the standard coefficient can be increased by 0 to 20. After using the results of steps 6 to 8, the embodiment of the present application found that the standard coefficient is very different for small, medium and large pigs, and can change from 302 to 142, that is, the smaller the pig, the larger the standard coefficient. Based on this inspiration, the form of the human expert formula can be used, but the standard coefficient needs to be discovered through reasonable fitting. Therefore, the embodiment of the present application uses many features in each segment to mine and fit the standard coefficient. As a result, the embodiment of the present application finds that within the five major segments, it is still necessary to perform finer segmentation according to L, and then the L / D coefficient in each segment will be proportional to the labeling coefficient to a certain extent. Therefore, the embodiment of the present application uses the EM algorithm for the five major segments to continuously adjust the segment division method, and finally it is divided into five major segments and 14 small segments. In each small segment, the standard coefficient follows the segment proportional relationship. That is, the standard coefficient of the smallest pig can reach 302 as L / D increases, while the standard coefficient of the largest pig can increase from 142 to 182 as L / D increases. This finding is very consistent with the rule of human expert experience. Using this rule, the weight estimation performance fitted by the embodiment of the present application can reach 85%.

[0126] 10. You can continue to observe the rules in each segment and find that when the belly circumference changes greatly, the above standard coefficient will have a large error. That is, when the belly circumference is large, it means that the pig itself is stronger and has better nutritional status, so it should be heavier and the standard coefficient should be smaller. Therefore, the embodiment of the present application uses the four points of the pig's abdomen output by the Yolo model and the intersection of the hind legs and the abdomen to perform P along these key points. belly1 and P belly2 By calculating the difference between the maximum and minimum lengths of these parallel lines and the standard deviation of the length changes of these parallel lines, and using these features to measure the change in belly circumference, the performance of the embodiment of the present application can be improved to 88%.

[0127] 11. Among the remaining samples with larger errors, the embodiment of the present application found that some pigs have completely different body shapes and very long trunk proportions. Even if their belly circumference does not become very large, they will be heavier, and the corresponding standard coefficient should also be smaller. Therefore, the embodiment of the present application has added features, using the four points on the pig's abdomen and the intersection of the hind legs and the abdomen output by the Yolo model to calculate the length of these line segments, recorded as bellyL. The embodiment of the present application found that when the bellyL / L coefficient exceeds 0.6, the standard coefficient should become much smaller; and between 0.4 and 0.6, the standard coefficient should decrease linearly and slowly; when the coefficient is less than 0.32, the pig's body is often in a bent state. At this time, the pig's belly circumference will appear large due to the bending. In fact, this does not mean that the pig is very strong, so the standard coefficient should be appropriately increased at this time.

[0128] 12. Through data set fitting, the embodiment of the present application can optimize the combination of the above features, sort the priorities, and adjust the combination coefficients.

[0129] Based on this, the embodiment of the present application uses the inspiration of human experts' prior knowledge to study the changing patterns of pig weight on a small sample set with only 500 data in the training set. In actual business tests with samples that are 20 times larger than the training set, the average absolute accuracy rate reached 90%, surpassing all competing products by at least 10 percentage points.

[0130] The weight estimation method based on a small sample in the embodiment of the present application draws on the knowledge and experience of human experts, adopts many assumptions that are consistent with physics and common sense, designs interpretable features, and iteratively divides the data set, and finally solves the pig weight estimation problem more perfectly under a single pig picture. It can give an average absolute accuracy of 90% for pigs in all weight ranges of breeding pigs, piglets, and large pigs, and the estimation results of multiple shots of the same pig are also very stable, because the embodiment of the present application adopts interpretable, stable, and expert knowledge and common sense features.

[0131] See also Figure 7 The embodiment of the present application also provides a pig weight estimation device, which can implement the above pig weight estimation method, and the device includes:

[0132] The first module 710 is used to obtain a body image of a target pig;

[0133] The second module 720 is used to input the pig body image into a pre-trained pig body segmentation model to obtain the pig body contour curve of the target pig;

[0134] The third module 730 is used to input the pig body picture into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig;

[0135] The fourth module 740 is used to determine the actual physical length of each pixel on the pig body image in both the x-axis and y-axis directions;

[0136] The fifth module 750 is used to determine the pig body length, chest girth cross-section straight line length and belly girth change of the target pig according to the pig body contour curve, pig body key points and actual physical length;

[0137] The sixth module 760 is used to adjust the standard coefficient of the target pig corresponding to the pig body type based on the prior knowledge, the pig body trunk ratio coefficient and the belly circumference change, and the pig body type includes breeding pigs, piglets and large pigs;

[0138] The seventh module 770 is used to estimate the weight of the target pig based on the pig's body length, the straight-line length of the chest circumference section and the standard coefficient to obtain the pig's body weight estimation result.

[0139] In some embodiments of the present application, the first module 710 obtains a body image of a target pig; the second module 720 inputs the body image into a pre-trained body segmentation model to obtain a body contour curve of the target pig; the third module 730 inputs the body image into a pre-trained body key point detection model to obtain the body key points of the target pig; the fourth module 740 determines the actual physical length corresponding to each pixel in the body image in both the x-axis and y-axis directions; the fifth module 750 determines the body length, chest circumference section straight line length and belly circumference variation of the target pig based on the pig's body contour curve, the body key points and the actual physical length; the sixth module 760 adjusts the standard coefficient of the target pig corresponding to the body shape based on prior knowledge, the pig's trunk proportion coefficient and the belly circumference variation, and the pig body shapes include breeding pigs, piglets and large pigs; the seventh module 770 estimates the weight of the target pig based on the body length, chest circumference section straight line length and the standard coefficient to obtain the pig weight estimation result.

[0140] In some embodiments of the present application, a pig body picture of a target pig is obtained. The pig body picture of the target pig can be obtained by photographing the target pig. The target pig can be a live pig or a dead pig. The body shape of the target pig can include a sow, a piglet, and a large pig.

[0141] In some embodiments of the present application, a pig body image is input into a pre-trained pig body segmentation model to obtain a pig body external contour curve of a target pig. The pig body segmentation model can be a deep learning model for training pig body segmentation using UNet. For example, during model training, 500 pig body images with pig body external contours already labeled can be used to train the pig body segmentation model to obtain a trained pig body segmentation model. The pig body image is then input into the pre-trained pig body segmentation model to obtain a pig body external contour curve of a target pig.

[0142] In some embodiments of the present application, a pig body picture is input into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig. The pig body key point detection model can be a Yolov5 key point detection model. For example, during model training, 500 pig body pictures with pig body key points marked can be used to train the pig body key point detection model to obtain a trained pig body key point detection model. The pig body picture is then input into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig, wherein the pig body key points include but are not limited to the pig's ear point, tail point, the intersection of the two front feet and the abdomen, four points on the abdomen, and the intersection of the hind legs and the abdomen.

[0143] In some embodiments of the present application, the actual physical length of each pixel on the pig body image in the x-axis and y-axis directions is determined. Specifically, the corner point coordinates of the pig body image can be detected based on the Harris checkerboard corner point detection algorithm, and the coordinates of the four main corner points of the checkerboard up, down, left, and right can be detected to obtain the corner point detection result; the actual physical length of each pixel on the pig body image in the x-axis and y-axis directions is calculated based on the corner point detection result.

[0144] In some embodiments of the present application, the pig body length, chest circumference cross-section straight length, and belly circumference change of the target pig are determined based on the pig body contour curve, the pig body key points, and the actual physical length. For the pig body key points, the pig's ear point and tail point can be used to calculate the pig body length curve; the intersection of the pig's two front legs and the abdomen can be used to calculate the pig's chest circumference; the four points of the pig's abdomen and the intersection of the hind legs and the abdomen can be used to calculate the pig's belly circumference change. Based on this, different pig body key points combined with the pig's external contour curve and the actual physical length can be used to calculate the pig's body length, chest circumference cross-section straight length, and belly circumference change of the target pig.

[0145] In some embodiments of the present application, the standard coefficient of the target pig corresponding to the pig body type is adjusted based on prior knowledge, the pig body trunk ratio coefficient and the belly circumference change, and the pig body type includes sows, piglets and large pigs. Generally speaking, according to expert prior knowledge, the weight of an adult pig is approximately equal to the straight length of the chest circumference section * pig body length / standard coefficient, and the standard coefficient is generally 142. However, the standard coefficient varies greatly among sows, piglets and large pigs, and can vary from 302 to 142, that is, the smaller the pig, the larger its standard coefficient. However, when the belly circumference change of some pigs is large, the above standard coefficient will have a large error, that is, when the belly circumference is large, it means that the pig itself is stronger and has a better nutritional status, and should also be heavier, and the standard coefficient should also be smaller. In addition, for some pigs with very long body trunk ratios, even if their belly circumference does not become very large, they will be heavier, and the corresponding standard coefficient should also be smaller. Therefore, it is necessary to adjust the standard coefficient of the target pig's body shape according to prior knowledge, the pig's trunk proportion coefficient and the belly circumference change to more accurately reflect the target pig's body weight.

[0146] In some embodiments of the present application, the weight of the target pig is estimated according to the pig's body length, the straight length of the chest circumference section and the standard coefficient to obtain the pig's weight estimation result. Since the standard coefficient of the embodiment of the present invention is adjusted according to the prior knowledge, the pig's body trunk ratio coefficient and the belly circumference change, the weight of the target pig is estimated according to the pig's body length, the straight length of the chest circumference section and the standard coefficient, and an accurate pig's weight estimation result can be obtained. The pig weight estimation method of the present application is applied to the field of artificial intelligence, and can accurately estimate the weight of pigs of any weight range based on a single pig picture.

[0147] Based on this, in the pig weight estimation device of the embodiment of the present application, the first module 710 obtains a pig body image of the target pig; the second module 720 inputs the pig body image into a pre-trained pig body segmentation model to obtain the pig body external contour curve of the target pig; the third module 730 inputs the pig body image into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig; the fourth module 740 determines the actual physical length corresponding to each pixel on the pig body image in the x-axis and y-axis directions; the fifth module 750 determines the pig body length, chest circumference section straight line length and belly circumference variation of the target pig according to the pig body external contour curve, the pig body key points and the actual physical length; the sixth module 760 adjusts the standard coefficient of the target pig corresponding to the pig body shape based on prior knowledge, the pig body trunk proportion coefficient and the belly circumference variation, and the pig body shape includes breeding pigs, piglets and large pigs; the seventh module 770 estimates the weight of the target pig according to the pig body length, the chest circumference section straight line length and the standard coefficient to obtain the pig weight estimation result. The present application obtains a body image of a target pig; inputs the body image into a pre-trained body segmentation model to obtain an external contour curve of the target pig; inputs the body image into a pre-trained body key point detection model to obtain the body key points of the target pig; determines the actual physical length corresponding to each pixel on the body image in both the x-axis and y-axis directions; determines the body length, chest circumference section straight line length and belly circumference variation of the target pig according to the external contour curve, the body key points and the actual physical length; adjusts the standard coefficient of the target pig corresponding to the body shape based on prior knowledge, the pig trunk proportion coefficient and the belly circumference variation, the pig body shape including breeding pigs, piglets and large pigs; estimates the weight of the target pig according to the body length, chest circumference section straight line length and the standard coefficient to obtain the pig weight estimation result. By inputting a single target pig's body picture into a pre-trained pig segmentation model and a pig key point detection model, the model outputs the target pig's external contour curve and pig key points, and then determines the target pig's body length, chest circumference section straight length and belly circumference change according to the pig's external contour curve, pig key points and actual physical length. And combined with expert prior knowledge, pig trunk ratio coefficient and belly circumference change, the standard coefficient corresponding to the pig's body shape is adjusted, and finally the target pig is estimated according to the pig's body length, chest circumference section straight length and standard coefficient. Since the pig's body length, chest circumference section straight length, belly circumference change and standard coefficient are all interpretable, stable, and in line with expert knowledge and physical common sense, these features can reflect the change law of pig weight, thereby enabling a more accurate weight estimation of the target pig. Based on this, the embodiment of the present application can be applied to the field of artificial intelligence, and can accurately estimate the weight of pigs of any weight range based on a single pig picture.

[0148] The specific implementation of the pig weight estimation device is basically the same as the specific implementation of the above-mentioned pig weight estimation method, and will not be repeated here.

[0149] The embodiment of the present application also provides an electronic device, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the above-mentioned pig weight estimation method when executing the computer program. The electronic device can be any intelligent terminal including a tablet computer, a car computer, etc.

[0150] See also Figure 8 , Figure 8 The hardware structure of an electronic device of another embodiment is illustrated, and the electronic device includes:

[0151] The processor 801 can be implemented by a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (Application Specific Integrated Circuit, ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solution provided in the embodiment of the present application.

[0152] The memory 802 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 802 can store an operating system and other application programs. When the technical solution provided in the embodiment of the present specification is implemented by software or firmware, the relevant program code is stored in the memory 802, and the processor 801 is called to execute the pig weight estimation method of the embodiment of the present application, that is, by obtaining a pig body image of the target pig; inputting the pig body image into a pre-trained pig body segmentation model to obtain the pig body contour curve of the target pig; inputting the pig body image into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig; determining the actual physical length corresponding to each pixel on the pig body image in the x-axis and y-axis directions; determining the pig body length, chest circumference section straight line length and belly circumference change of the target pig according to the pig body contour curve, the pig body key points and the actual physical length; adjusting the standard coefficient of the target pig corresponding to the pig body shape based on prior knowledge, the pig body trunk ratio coefficient and the belly circumference change, the pig body shape includes breeding pigs, piglets and large pigs; estimating the weight of the target pig according to the pig body length, the chest circumference section straight line length and the standard coefficient to obtain the pig weight estimation result. By inputting a single target pig's body picture into a pre-trained pig segmentation model and a pig key point detection model, the model outputs the target pig's external contour curve and pig key points, and then determines the target pig's body length, chest circumference section straight length and belly circumference change according to the pig's external contour curve, pig key points and actual physical length. And combined with expert prior knowledge, pig trunk ratio coefficient and belly circumference change, the standard coefficient corresponding to the pig's body shape is adjusted, and finally the target pig is estimated according to the pig's body length, chest circumference section straight length and standard coefficient. Since the pig's body length, chest circumference section straight length, belly circumference change and standard coefficient are all interpretable, stable, and in line with expert knowledge and physical common sense, these features can reflect the change law of pig weight, thereby enabling a more accurate weight estimation of the target pig. Based on this, the embodiment of the present application can be applied to the field of artificial intelligence, and can accurately estimate the weight of pigs of any weight range based on a single pig picture.

[0153] The input / output interface 803 is used to implement information input and output.

[0154] The communication interface 804 is used to realize the communication interaction between this device and other devices. Communication can be realized through wired methods (such as USB, network cable, etc.) or wireless methods (such as mobile network, WI FI, Bluetooth, etc.).

[0155] The bus transmits information between various components of the device (eg, the processor 801 , the memory 802 , the input / output interface 803 , and the communication interface 804 ).

[0156] The processor 801 , the memory 802 , the input / output interface 803 and the communication interface 804 are connected to each other in communication within the device via a bus.

[0157] An embodiment of the present application also provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, the above-mentioned pig weight estimation method is implemented.

[0158] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory, and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely disposed relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0159] The pig weight estimation method, pig weight estimation device, electronic device and storage medium provided in the embodiments of the present application are as follows: obtaining a pig body image of a target pig; inputting the pig body image into a pre-trained pig body segmentation model to obtain a pig body external contour curve of the target pig; inputting the pig body image into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig; determining the actual physical length corresponding to each pixel on the pig body image in both the x-axis and y-axis directions; determining the pig body length, chest circumference section straight line length and belly circumference variation of the target pig according to the pig body external contour curve, the pig body key points and the actual physical length; adjusting the standard coefficient of the target pig corresponding to the pig body shape based on prior knowledge, the pig body trunk proportion coefficient and the belly circumference variation, the pig body shape including breeding pigs, piglets and large pigs; estimating the weight of the target pig according to the pig body length, the chest circumference section straight line length and the standard coefficient to obtain the pig body weight estimation result. By inputting a single target pig's body picture into a pre-trained pig segmentation model and a pig key point detection model, the model outputs the target pig's external contour curve and pig key points, and then determines the target pig's body length, chest circumference section straight length and belly circumference change according to the pig's external contour curve, pig key points and actual physical length. And combined with expert prior knowledge, pig trunk ratio coefficient and belly circumference change, the standard coefficient corresponding to the pig's body shape is adjusted, and finally the target pig is estimated according to the pig's body length, chest circumference section straight length and standard coefficient. Since the pig's body length, chest circumference section straight length, belly circumference change and standard coefficient are all interpretable, stable, and in line with expert knowledge and physical common sense, these features can reflect the change law of pig weight, thereby enabling a more accurate weight estimation of the target pig. Based on this, the embodiment of the present application can be applied to the field of artificial intelligence, and can accurately estimate the weight of pigs of any weight range based on a single pig picture.

[0160] It will be appreciated by those skilled in the art that all or some of the steps and systems in the disclosed method above may be implemented as software, firmware, hardware and appropriate combinations thereof. Some physical components or all physical components may be implemented as software executed by a processor, such as a central processing unit, a digital signal processor or a microprocessor, or may be implemented as hardware, or may be implemented as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on a computer-readable medium, which may include a computer storage medium (or a non-transitory medium) and a communication medium (or a temporary medium). As known to those skilled in the art, the term computer storage medium includes volatile and non-volatile, removable and non-removable media implemented in any method or technology for storing information (such as a computer-readable program, a data structure, a program module or other data). Computer storage media include, but are not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, digital versatile disk (DVD) or other optical disk storage, magnetic cassette, magnetic tape, disk storage or other magnetic storage device, or any other medium that may be used to store desired information and may be accessed by a computer. Furthermore, it is well known to those skilled in the art that communication media generally contain computer-readable programs, data structures, program modules, or other data in a modulated data signal such as a carrier wave or other transport mechanism, and may include any information delivery media.

[0161] The embodiments described in the embodiments of the present application are intended to more clearly illustrate the technical solutions of the embodiments of the present application and do not constitute a limitation on the technical solutions provided in the embodiments of the present application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems.

[0162] Those skilled in the art will appreciate that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.

[0163] The device embodiments described above are merely illustrative, and the units described as separate components may or may not be physically separated, that is, they may be located in one place or distributed on multiple network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0164] Those skilled in the art will appreciate that all or some of the steps in the methods disclosed above, and the functional modules / units in the systems and devices may be implemented as software, firmware, hardware, or a suitable combination thereof.

[0165] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.

[0166] It should be understood that in the present application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the objects associated before and after are in an "or" relationship. "At least one of the following" or similar expressions refers to any combination of these items, including any combination of single or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.

[0167] In the several embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the above units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0168] The units described above as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0169] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.

[0170] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including multiple instructions to enable a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (Read-Only Memory, referred to as ROM), random access memory (Random Access Memory, referred to as RAM), disk or optical disk and other media that can store programs.

[0171] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but the scope of the rights of the present invention is not limited thereto. Any modification, equivalent substitution and improvement made by a person skilled in the art without departing from the scope and essence of the present invention should be within the scope of the rights of the present invention.

Claims

1. A method for estimating pig weight, characterized in that: The method comprises: Obtain a body image of the target pig; Inputting the pig body image into a pre-trained pig body segmentation model to obtain a pig body contour curve of the target pig; Inputting the pig body picture into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig; Determine the actual physical length of each pixel on the pig body image in both the x-axis and y-axis directions; Determine the pig body length, chest girth cross-section straight line length and belly girth change of the target pig according to the pig body contour curve, the pig body key points and the actual physical length; Based on prior knowledge, the pig trunk ratio coefficient and the belly circumference change, the standard coefficient of the target pig corresponding to the pig body type is adjusted, and the pig body type includes breeding pigs, piglets and large pigs; The weight of the target pig is estimated according to the pig body length, the straight-line length of the chest girth section and the standard coefficient to obtain a pig body weight estimation result.

2. The method according to claim 1, characterized in that: The key points of the pig body include the pig's ear point, tail point, intersection point of two front legs and abdomen, four points of abdomen and intersection point of hind legs and abdomen.

3. The method according to claim 2, characterized in that The determining of the actual physical length of each pixel on the pig body image in the x-axis and y-axis directions includes: Performing corner point coordinate detection on the pig body image based on Harris checkerboard corner point detection algorithm to obtain a corner point detection result; The actual physical length of each pixel on the pig body image in the x-axis and y-axis directions is calculated according to the corner point detection result.

4. The method according to claim 2, characterized in that: The method of determining the pig body length, chest girth cross-section straight line length and belly girth variation of the target pig according to the pig body contour curve, the pig body key points and the actual physical length includes: Determine the pig body length according to the ear point, the tail point, the pig body contour curve and the actual physical length; Determine the straight length of the chest girth section according to the intersection of the two front feet and the abdomen, the pig's external contour curve and the actual physical length; The belly circumference change is determined based on the four points on the abdomen, the intersection of the hind legs and the abdomen, the pig's external contour curve and the actual physical length.

5. The method according to claim 4, characterized in that The step of determining the pig body length according to the ear point, the tail point, the pig body contour curve and the actual physical length comprises: Determine a first target point and a second target point of the pig's external contour curve that are closest to the ear point and the tail point respectively; Fitting a curve between the first target point and the second target point using a polynomial curve to obtain a curve segment; The curve length of the curve segment is calculated by integration according to the actual physical length to obtain the pig body length.

6. The method according to claim 4, characterized in that The method of determining the straight length of the chest section according to the intersection of the two front feet and the abdomen, the pig's external contour curve and the actual physical length includes: determining a first intersection point between the first front leg and the abdomen, and a second intersection point between the second front leg and the abdomen; Calculating a distance value between the first intersection point and the second intersection point; When the distance value is less than a preset threshold, the midpoint between the first intersection point and the second intersection point is determined as the first chest circumference section point, and the point from the first chest circumference section point to the pig's external contour curve is determined as the second chest circumference section point; or, when the distance value is greater than or equal to the preset threshold, the point from the first intersection point to the second intersection point that is closest to the hind leg is determined as the first chest circumference section point, and the point from the first chest circumference section point to the pig's external contour curve is determined as the second chest circumference section point; The cross-sectional length between the first chest circumference cross-sectional point and the second chest circumference cross-sectional point is calculated by integration according to the actual physical length to obtain the chest circumference cross-sectional straight-line length.

7. The method according to claim 4, characterized in that The step of determining the belly circumference change according to the four points on the abdomen, the intersection of the hind legs and the abdomen, the pig's external contour curve and the actual physical length includes: Draw lines based on the four points on the abdomen and the intersection of the hind legs and the abdomen to obtain multiple parallel lines; determining a maximum value and a minimum value among a plurality of said parallel lines; calculating the difference between the maximum value and the minimum value; Calculate the standard deviation of the length variation of multiple parallel lines; The belly circumference change is determined according to the difference and the standard deviation.

8. A pig weight estimation device, characterized in that: The device comprises: The first module is used to obtain the body image of the target pig; The second module is used to input the pig body image into a pre-trained pig body segmentation model to obtain the pig body contour curve of the target pig; The third module is used to input the pig body picture into a pre-trained pig body key point detection model to obtain the pig body key points of the target pig; The fourth module is used to determine the actual physical length of each pixel on the pig body image in the x-axis and y-axis directions; A fifth module is used to determine the pig body length, chest girth cross-section straight line length and belly girth change of the target pig according to the pig body contour curve, the pig body key points and the actual physical length; The sixth module is used to adjust the standard coefficient of the target pig corresponding to the pig body type based on prior knowledge, the pig body trunk ratio coefficient and the belly circumference change, and the pig body type includes breeding pigs, piglets and large pigs; The seventh module is used to estimate the weight of the target pig according to the pig body length, the straight length of the chest circumference section and the standard coefficient to obtain the pig body weight estimation result.

9. An electronic device, characterized in that: The electronic device comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the pig weight estimation method according to any one of claims 1 to 7 when executing the computer program.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for estimating pig body weight according to any one of claims 1 to 7 is implemented.