A method, device and storage medium for estimating the average daily weight of pigs in the same pen
Through image processing and weight estimation models, the average daily weight of pigs in the same pen is directly calculated, which solves the problem of poor measurement convenience in the prior art, and realizes efficient and accurate monitoring of pig growth status.
Patent Information
- Application Number
- CN202310602053.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-05-25
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2043-05-25
AI Technical Summary
The prior art is not convenient to measure the average daily weight of pigs in pigs on a large-scale breeding of pigs, including the need to wait for the pigs to grow and weigh them, the high cost of installing a weight measurement station in each pig pen, and Pigs need to be driven to a shared scale for measurement, which affects growth and time-consuming.
By obtaining pig pen images, using recognition algorithm model processing to obtain pig identification information and feature groups, combining the weight estimation model to calculate the pig weight, and then calculating the average daily weight of pigs in the same pen, avoiding artificial weighing and weight measurement stations Install.
It realizes a timely understanding of the growth status during the pig growth process, reduces the detection cost and time, and improves the detection convenience and accuracy.
Smart Images

Figure CN117789243B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of growth status monitoring of penned livestock, and in particular to a method, device and storage medium for estimating the average daily weight of pigs in the same pen. Background Art
[0002] In the large-scale pig farming process, real-time knowledge of the average daily weight of pigs in the same pen can provide an important basis for evaluating the growth status of pigs.
[0003] At present, a method of measuring the average daily weight of pigs in the same pen is: after the pigs in the pen are determined to be grown up, the pigs in the pen are weighed one by one using a scale to obtain the weight of each pig, and then the average daily weight of the pigs in the same pen is calculated.
[0004] Another current method of measuring the average daily weight of pigs in the same pen is to install a weight measuring station at each pig pen. When weight testing is required, the weight of the pigs in the herd is tested through the weight measuring station to calculate the average daily weight of the pigs in the same pen.
[0005] Another current method of measuring the average daily weight of pigs in the same pen is that multiple pig pens share a scale. When the pigs in a certain pen need to be weighed, all the pigs in the pen need to be driven to the shared scale for weighing, so as to detect the weight of the pigs in the pen and then calculate the average daily weight of the pigs in the same pen.
[0006] In the process of implementing the present application, it was found that the above-mentioned technology has at least the following problems: For the above-mentioned first method of measuring the daily average weight of the pig herd, the disadvantage is that the daily average weight of the pigs in the same pen can only be known after the pigs grow up, and it is difficult to timely understand the growth status of the pigs during their growth; For the above-mentioned second method of measuring the daily average weight of the pig herd, the disadvantage is that a weight measuring station is installed in each pig pen, which not only makes the installation process cumbersome but also the installation cost too high; For the above-mentioned third method of measuring the daily average weight of the pig herd, the disadvantage is that when measuring, the pigs need to be driven to the shared scale for measurement, which is time-consuming and labor-intensive, and is likely to have an adverse effect on the growth of the pigs; In summary, it can be seen that the convenience of detecting the daily average weight of pigs in the same pen using the existing technology is not good. Summary of the invention
[0007] In order to improve the convenience of detecting the daily average weight of pigs in the same pen, the present application provides a method, device and storage medium for estimating the daily average weight of pigs in the same pen.
[0008] In the first aspect, the present application provides a method for estimating the average daily weight of pigs in the same pen, using the following technical solution:
[0009] A method for estimating the average daily weight of pigs in the same pen, comprising:
[0010] Obtain at least one pig pen image in a single day;
[0011] The pig pen image is processed by a recognition algorithm model to obtain pig identification information; the pig identification information includes the pig outline and pig posture of each pig in the pig pen image;
[0012] Processing the pig identification information and the pig pen image to determine a feature group corresponding to each pig in the pig pen image; the feature group includes at least one of contour area, body length and width, pig part width group, distance between the pig and the image center, pig identification angle goodness, pig posture, contour shape description, and contour fit degree;
[0013] Processing all of the feature groups through a weight estimation model to obtain weight estimation data;
[0014] The weight estimation data is filtered according to the pig identification information to obtain first filtered weight estimation data, and mathematical statistics are performed on the filtered weight estimation data to obtain the average daily weight of the pigs in the same pen.
[0015] By adopting the above technical solution, the pig pen image is collected at least once a day, and then the collected image is processed to obtain pig identification information; then the feature group of each pig in the pig pen image is determined according to the pig identification information and the pig pen image, and then the feature group is input into the weight estimation model for processing, so as to obtain the weight estimation of the pig corresponding to the feature group; all feature groups are processed by the weight estimation model to obtain weight estimation data composed of weight estimation; finally, the weight estimation data is filtered and mathematically counted, so as to obtain the daily average weight of all the pigs in the pen; Compared with the existing technology, there is no need to weigh the pigs after they grow up and then calculate the corresponding average daily weight of the pigs in the same pen; there is no need to install a weight measuring station at each pig pen, weigh the pigs through the weight measuring station, and then calculate the corresponding average daily weight of the pigs in the same pen; there is no need to drive the pigs in the same pen to a shared scale for weighing, and then calculate the corresponding average daily weight of the pigs in the same pen; instead, the average daily weight of the pigs in the same pen can be directly estimated by performing image processing and mathematical calculations on the collected pig pen images. Compared with the existing technology, the convenience of detecting the average daily weight of the pigs in the same pen is improved.
[0016] In a specific implementation scheme, the step of processing the pig identification information and the pig pen image to determine a feature group corresponding to each pig in the pig pen image includes:
[0017] Obtaining the pig outline;
[0018] Processing the pig outline to obtain a pig identification box;
[0019] The pig identification information and the pig identification box are processed to obtain the feature group.
[0020] By adopting the above technical solution, the corresponding pig identification box is calculated based on the pig outline, which makes it easy to process the pig identification information and pig identification box that have been obtained to obtain the feature group corresponding to each pig, so as to subsequently estimate the corresponding pig's weight estimate based on the feature group, and calculate the pig's weight estimate by combining multiple features of the pig, thereby improving the credibility and accuracy of the calculated pig weight estimate data.
[0021] In a specific implementation manner, the step of determining the body length and width in the feature group includes:
[0022] Obtain a corner pixel coordinate group of the pig pen image, recorded as a first corner pixel coordinate group, and also obtain the actual length and width of the pig pen; obtain the pig identification box, determine the corner pixel coordinate group of the pig identification box, recorded as a second corner pixel coordinate group;
[0023] The actual length and width of the pig pen, the first corner point pixel coordinate group and the second corner point pixel coordinate group are processed through a coordinate transformation model to obtain the body length and width, which include the actual length and actual width of the pig identification box.
[0024] By adopting the above technical solution, the first corner point pixel coordinate group corresponding to the pigpen image and the actual length and width of the pigpen are obtained, and then the first corner point pixel coordinate group and the actual length and width of the pigpen are input into the coordinate conversion model, and then the second corner point pixel coordinate group corresponding to the pig identification box is obtained, and the second corner point pixel coordinate group is also input into the coordinate conversion model. Then, the coordinate conversion model can calculate the actual length and actual width of the corresponding pig identification box based on the first corner point pixel coordinate group, the actual length and width of the pigpen and the second corner point pixel coordinate group, so as to obtain the body length and width feature in the required feature group, so as to facilitate the subsequent calculation of pig weight estimation.
[0025] In a specific implementation manner, the step of determining the pig part width group in the feature group includes:
[0026] Obtaining the pig outline and the corresponding pig identification box;
[0027] determining the orientation of the pig's head according to the pig's outline;
[0028] The pig identification box is divided into equal parts by drawing lines to obtain a plurality of intersection point groups, and the intersection point groups are sorted according to the orientation of the pig heads to obtain a set of intersection point groups;
[0029] Each intersection point group in the intersection point group set is processed in turn by the coordinate transformation model to obtain the pig part width group.
[0030] By adopting the above technical solution, each pig identification frame is divided into equal parts, and the corresponding intersection point group set is determined according to the orientation of the pig head. Finally, the intersection point group set is processed through the coordinate transformation model to obtain the feature of the pig part width group, so as to facilitate the subsequent calculation of the pig weight estimation.
[0031] In a specific possible implementation method, the pig identification box is divided into equal parts by drawing lines to obtain a plurality of intersection point groups, and the intersection point groups are sorted according to the orientation of the pig heads to obtain a set of intersection point groups, including:
[0032] Determine a plurality of equally divided points on the long side of the pig identification box;
[0033] Draw an intersection line perpendicular to the long side of the pig identification box through the equal division point;
[0034] Combining the intersection points of each intersection line and the pig outline into a corresponding intersection point group;
[0035] The plurality of intersection point groups are sorted according to the orientation of the pig head to obtain an intersection point group set.
[0036] By adopting the above technical solution, the pig identification box is first divided into equal parts using intersection lines along the long side of the pig identification box. Each intersection line will generate two intersection points with the pig outline, and the two intersection points are combined into a corresponding intersection point group. In this way, a number of intersection point groups corresponding to a number of intersection lines will be obtained. Then, the number of intersection point groups are sorted according to the direction of the pig head to obtain an intersection point group set, so that the corresponding pig part width group feature can be calculated based on the intersection point group set.
[0037] In a specific implementation manner, the step of determining the goodness of the pig identification angle in the feature group includes:
[0038] Determine the center point of the pig pen image, recorded as the first center point; determine the center point of the pig outline, recorded as the second center point;
[0039] Draw a connecting line through the first center point and the second center point;
[0040] Calculating the angle between the connecting line and the corresponding long side of the pig identification box;
[0041] The degree of deviation between the included angle and the straight angle is calculated, and the degree of deviation is recorded as the degree of goodness of the pig recognition angle.
[0042] By adopting the above technical solution, the connecting line passing through the center of the pig pen image and the center of the corresponding pig outline is first calculated, and then the angle between the connecting line and the long side of the corresponding pig identification box is calculated. Finally, the degree of deviation between the angle and the straight angle is calculated, and the degree of deviation is recorded as the degree of good pig identification angle, which facilitates the use of the degree of good pig identification angle as a feature in the feature group for the subsequent calculation of pig weight estimation.
[0043] In a specific implementation scheme, the step of filtering the weight estimation data according to the pig identification information to obtain the first filtered weight estimation data includes:
[0044] Determine the pig outline that is blocked in the pig pen image and record it as an abnormal outline;
[0045] Determine the pig outline at the edge of the pig pen image and record it as the edge outline;
[0046] The pig weight estimates corresponding to the abnormal contour and the edge contour are filtered out from the weight estimate data to obtain the first filtered weight estimate data.
[0047] By adopting the above technical solution, since both the abnormal contour and the edge contour are significantly different from the ideal pig contour, if the pig weight estimate calculated based on the abnormal contour and the edge contour is added to the calculation of the final average daily weight of the pigs in the same pen, the accuracy of the average daily weight of the pigs in the same pen will be reduced. Therefore, the weight estimate corresponding to the abnormal contour and the edge contour is filtered out, which helps to improve the accuracy of the final calculated average daily weight of the pigs in the same pen.
[0048] In a specific implementation scheme, the step of performing mathematical statistics on the filtered weight estimation data to obtain the average daily weight of pigs in the same pen includes:
[0049] Calculating a corresponding statistical threshold range based on the first filtered weight estimation data;
[0050] Filtering out the estimated weights of pigs that are not within the statistical threshold range from the first filtered estimated weight data to obtain second filtered estimated weight data;
[0051] The mean of the second filtered weight estimation data is calculated to obtain the average daily weight of the pigs in the same pen.
[0052] By adopting the above technical solution, the weight estimates of pigs that are too large or too small in the weight estimate data after the first filter can be filtered out through the statistical threshold range, so as to further improve the accuracy of the subsequent final calculated average daily weight of pigs in the same pen.
[0053] In a second aspect, the present application provides a computer device, which adopts the following technical solution: it includes a memory and a processor, and the memory stores a computer program that can be loaded by the processor and execute any of the above-mentioned methods for estimating the daily average weight of pigs in the same pen.
[0054] In a third aspect, the present application provides a computer-readable storage medium, which adopts the following technical solution: a computer program that can be loaded by a processor and execute any of the above-mentioned methods for estimating the average daily weight of pigs in the same pen is stored.
[0055] In summary, the present application includes at least one of the following beneficial technical effects:
[0056] 1. It is convenient to improve the convenience of detecting the average daily weight of pigs in the same pen;
[0057] 2. It is convenient to calculate the estimated weight of pigs by integrating multiple characteristics of pigs, thereby improving the credibility and accuracy of the calculated estimated weight data of pigs;
[0058] 3. It is convenient to improve the accuracy of the calculated average daily weight of pigs in the same pen. BRIEF DESCRIPTION OF THE DRAWINGS
[0059] Figure 1 It is a flow chart of a method for estimating the average daily weight of pigs in the same pen in an embodiment of the present application. DETAILED DESCRIPTION
[0060] The following is combined with Figure 1 This application is described in further detail.
[0061] The present application embodiment discloses a method for estimating the average daily weight of pigs in the same pen. Figure 1 , the methods for estimating the average daily weight of pigs in the same pen include:
[0062] S100. Acquire at least one pig pen image within a single day.
[0063] The implementation of step S100 of a method for estimating the average daily weight of pigs in the same pen in this embodiment requires capturing images of the square pig pen. For this purpose, a corresponding camera is pre-set directly above the center of each square pig pen, and all cameras are electrically connected to a preset processing system. In this embodiment, in order to facilitate the camera to be as close to the pig pen as possible to improve the clarity of the shooting, and to take into account the need to fully capture the entire square pig pen, in this embodiment, the lens used by the camera is a fisheye lens.
[0064] During implementation, the processing system is used to manually control the camera to collect images of the corresponding pig pen, and at least one pig pen image is collected in a single day. In this embodiment, in order to increase the accuracy of the final calculated average daily weight of pigs in the same pen, the method of collecting multiple pig pen images in a single day is adopted.
[0065] Taking one of the pig pens as an example, multiple pig pen images are collected for the pig pen in a single day. When collecting images, the pig pen images can be collected at a certain frequency to obtain multiple pig pen images in a single day. The timing of collecting pig pen images can also be determined manually to obtain multiple pig pen images in a single day. After each image collection is completed, the camera sends the collected pig pen images to the processing system.
[0066] S200, processing the pig pen image through a recognition algorithm model to obtain pig identification information; the pig identification information includes the pig outline and pig posture of each pig in the pig pen image.
[0067] It should be noted that a recognition algorithm model is preset in the processing system, and the recognition algorithm model is used to perform image processing on the collected images. In this embodiment, the recognition algorithm model is preferably Detectron2.
[0068] The following still takes a pigpen as an example. Each time the corresponding camera captures the pigpen image of the pigpen, it sends the pigpen image to the processing system. The processing system performs image processing on the received pigpen image through Detectron2, thereby generating the pig outline and pig posture corresponding to each pig in the pigpen image. Here, the pig outline and pig posture of each pig in the pigpen image are collectively referred to as pig identification information.
[0069] It should be noted that pig postures include standing and lying. In the present embodiment, if Detectron2 determines that a pig's posture is standing, the corresponding pig outline is marked in green; if Detectron2 determines that a pig's posture is lying, the corresponding pig outline is marked in purple. The above green and purple are used as specific marking colors to artificially distinguish pig postures in the present embodiment. In other embodiments, other marking colors may also be used, and the specific colors are not limited.
[0070] S300, processing the pig identification information and the pig pen image to determine the feature group corresponding to each pig in the pig pen image; the feature group includes at least one of contour area, body length and width, pig part width group, distance between the pig and the image center, degree of pig identification angle, pig posture, contour shape description, and contour fit.
[0071] It should be noted that, subsequently, it is necessary to first calculate the estimated weight of each pig, and then calculate the average daily weight of the pigs in the same pen based on the estimated weight of each pig; in this example, it is necessary to calculate the estimated weight of the pigs through the weight estimation model preset in the processing system, and the input of the weight estimation model is the feature group of the corresponding pig, and the feature group is at least one of the following: contour area, body length and width, pig part width group, distance between the pig and the center of the image, degree of goodness of the pig recognition angle, pig posture, contour shape description, and degree of contour fit; in this embodiment, the feature group is preferably a combination of eight features including contour area, body length and width, pig part width group, distance between the pig and the center of the image, degree of goodness of the pig recognition angle, pig posture, contour shape description, and degree of contour fit.
[0072] It should be noted that in order to calculate each feature in the feature group, the processing system needs to be preset; the preset process is as follows:
[0073] After acquiring the pigpen image, the processing system identifies the four corner points of the pigpen image and obtains the corner point pixel coordinates of the four corner points, which are recorded as the first corner point pixel coordinate group; in addition, the actual length and width of the pigpen are manually input into the processing system.
[0074] Each feature in the feature group needs to be calculated based on the above pig identification information and the pig pen image. The following is an introduction to the acquisition process of each feature:
[0075] 1. The process of obtaining the contour area:
[0076] Taking a pig in a pigpen image as an example, after the pig outline is identified by Detectron2, the pig outline, the first corner point pixel coordinate group and the actual length and width of the pigpen are input into the coordinate conversion model preset in the processing system; it should be noted that the coordinate conversion model can convert the pixel coordinates into world two-dimensional coordinates. In this embodiment, the coordinate conversion model is preferably an optical perspective coordinate conversion model; the optical perspective coordinate conversion model and the processing system process the pig outline, the first corner point pixel coordinate group and the actual length and width of the pigpen to obtain the actual area of the pig outline, which is recorded as the outline area.
[0077] 2. The process of obtaining body length and width:
[0078] After obtaining the pig outline, the processing system continues to perform image processing on the pig outline to obtain a pig identification box surrounding the corresponding pig outline; the body length and width are the actual length and actual width of the pig identification box; after the processor obtains the pig identification box, it further determines the corner point pixel coordinates of the four corner points of the pig identification box in the corresponding pig pen image, and the corner point pixel coordinates of the four corner points of the pig box are collectively referred to as the second corner point pixel coordinate group.
[0079] Taking one of the corner point pixel coordinates as the starting point and following the clockwise direction, the four corner point pixel coordinates are recorded in sequence as: the first corner point pixel coordinate, the second corner point pixel coordinate, the third corner point pixel coordinate, and the fourth corner point pixel coordinate. Then, the first corner point pixel coordinate, the second corner point pixel coordinate, the third corner point pixel coordinate, and the fourth corner point pixel coordinate are all input into the optical perspective coordinate conversion model, and the optical perspective coordinate conversion model converts the first corner point pixel coordinate, the second corner point pixel coordinate, the third corner point pixel coordinate, and the fourth corner point pixel coordinate into: the first corner point world 2D coordinate, the second corner point world 2D coordinate, the third corner point world 2D coordinate, and the fourth corner point world 2D coordinate.
[0080] In one embodiment, the processing system calculates the distance between the world two-dimensional coordinates of the first corner point and the world two-dimensional coordinates of the second corner point as the actual length of the pig identification box; the processing system calculates the distance between the world two-dimensional coordinates of the second corner point and the world two-dimensional coordinates of the third corner point as the actual width of the pig identification box.
[0081] 3. The process of obtaining the width group of pig parts:
[0082] S1: Obtain the pig outline and the corresponding pig identification box.
[0083] After the processing system obtains a pig pen image, it first processes the pig pen image through the built-in Detectron2 to obtain the pig outline of each pig in the pig pen image; further, the processing system continues to process the pig outline to obtain a pig identification box corresponding to each pig outline.
[0084] S2: Determine the direction of the pig head based on the pig's outline.
[0085] After obtaining the outlines of all the pigs in the pig pen image, the processing system further identifies the position of the pig's head in each pig outline to determine the corresponding pig head orientation.
[0086] S3: The pig identification box is divided into equal parts by drawing lines to obtain a number of intersection point groups, and the intersection point groups are sorted according to the directions of the pig heads to obtain a set of intersection point groups.
[0087] Specifically, S3 includes the following sub-steps:
[0088] S3a: Determine a number of equally divided points on the long side of the pig identification box.
[0089] After the processing system obtains each pigpen identification box in the pigpen image through step S1, a plurality of equal division points are determined on one of the long sides of the pig identification box, and the plurality of equal division points divide the long side of the pig identification box into equal parts.
[0090] It should be noted that the pig part width group includes a number of part width values corresponding one-to-one to a number of different parts of the pig; the number of equally divided points set on the long side of a pig identification box is consistent with the number of types of part width values in the pig part width group.
[0091] In this embodiment, the pig part width group specifically includes five part width values: shoulder width, chest width, belly width, waist width, and hip width. Therefore, in this example, each pig identification box is provided with five equal division points on the long side, thereby dividing the pig identification box into six equal parts along the long side of the pig identification box.
[0092] S3b: Draw an intersection line perpendicular to the long side of the pig identification box through the equally divided point.
[0093] In this embodiment, after five equally divided points are determined on a certain long side of the pig identification box through step S3a, an intersection line perpendicular to the long side of the pig identification box is drawn through each equally divided point.
[0094] S3c: Combine the intersection points of each intersection line and the pig outline into corresponding intersection point groups.
[0095] Each intersection line will intersect with the pig outline in the pig identification box at two intersection points, and the two intersection points corresponding to each intersection line are collectively referred to as an intersection point group; 5 equally divided points correspond to 5 intersection lines, and 5 intersection lines correspond to 5 intersection point groups.
[0096] S3d: Sort several intersection point groups according to the directions of the pig heads to obtain a set of intersection point groups.
[0097] After obtaining 5 intersection point groups through step S3c, the 5 intersection point groups are sorted in the direction opposite to the direction of the pig's head, that is, the 5 intersection point groups are recorded in the direction opposite to the direction of the pig's head as: the first intersection point group, the second intersection point group, the third intersection point group, the fourth intersection point group and the fifth intersection point group; and the first intersection point group, the second intersection point group, the third intersection point group, the fourth intersection point group and the fifth intersection point group are collectively referred to as the intersection point group set. Among them, the first intersection point group corresponds to the shoulder width in the pig's part width group; the second intersection point group corresponds to the chest width in the pig's part width group; the third intersection point group corresponds to the belly width in the pig's part width group; the fourth intersection point group corresponds to the waist width in the pig's part width group; and the fifth intersection point group corresponds to the hip width in the pig's part width group.
[0098] S4: Process each intersection point group in the intersection point group set in turn through the coordinate transformation model to obtain the pig part width group.
[0099] After obtaining the first intersection point group, the second intersection point group, the third intersection point group, the fourth intersection point group and the fifth intersection point group through the S3d step, the world two-dimensional coordinates corresponding to the two intersection points in each intersection point group are calculated respectively through the coordinate transformation model, and then the distance between the two world two-dimensional coordinates corresponding to each intersection point group is calculated.
[0100] If the distance corresponds to the first intersection point group, the distance represents the shoulder width in the pig part width group; if the distance corresponds to the second intersection point group, the distance represents the chest width in the pig part width group; if the distance corresponds to the third intersection point group, the distance represents the belly width in the pig part width group; if the distance corresponds to the fourth intersection point group, the distance represents the waist width in the pig part width group; if the distance corresponds to the fifth intersection point group, the distance represents the hip width in the pig part width group. In this way, the pig part width group corresponding to each pig identification box is calculated.
[0101] 4. The process of obtaining the distance between the pig and the center of the image:
[0102] After acquiring a pigpen image, the processing system first determines the image center point of the pigpen image, which is the intersection point of the two diagonals of the pigpen image; after acquiring a pigpen image, the processing system also determines the contour center point of each pig in the pigpen image.
[0103] After obtaining the image center point of the pigpen image and all the contour center points in the pigpen image, in this example, the processing system converts both the image center point and the contour center point into corresponding world two-dimensional coordinates through an optical perspective coordinate transformation model; then the distance between the world two-dimensional coordinate corresponding to the image center point and the world two-dimensional coordinate corresponding to the contour center point is calculated, thereby obtaining the actual distance between the image center point and the contour center point, that is, the distance between the pig and the image center.
[0104] 5. The process of obtaining the best degree of pig identification angle:
[0105] S10. Determine the center point of the pig pen image, which is recorded as the first center point; determine the center point of the pig outline, which is recorded as the second center point.
[0106] After acquiring the pigpen image, the processing system first determines the center point of the pigpen image and records it as the first center point; after acquiring the pigpen image, the processing system also determines the center point of the outline of each pig in the pigpen image, where the center point of the pig outline is recorded as the second center point.
[0107] S20, drawing a connecting line through the first center point and the second center point.
[0108] The processing system draws corresponding connecting lines between the first center point of the pig pen image and the second center point of the outline of each pig in the pig pen image.
[0109] S30, calculating the angle between the connecting line and the long side of the corresponding pig identification box.
[0110] After completing the implementation of step S20, each connecting line will intersect with the long side of the corresponding pig identification box, and the processing system further calculates the angle between the connecting line and the long side of the pig identification box at the intersection point.
[0111] S40, calculating the degree of deviation between the included angle and the straight angle, and recording the degree of deviation as the degree of good pig recognition angle.
[0112] It should be explained that in the pigpen pictures taken with a fisheye lens, the closer the above angle is to a straight angle, the more realistic the corresponding pig outline will be.
[0113] When the angle corresponding to each pig identification box is obtained through step S30, the angle difference between the angle and the straight angle is calculated, and then the angle difference is processed according to a preset function to obtain the degree of deviation between the angle and the straight angle; the closer the angle difference is to a right angle, the greater the corresponding degree of deviation.
[0114] 6. The process of obtaining pig posture:
[0115] Looking back at step S200, after acquiring the pig pen image, the processing system processes the pig pen image through Detectron2, thereby obtaining the posture of each pig in the pig pen image.
[0116] 7. The process of obtaining the contour shape description:
[0117] The contour shape description is obtained by the processing system after further analyzing the pig contour after obtaining the pig contour.
[0118] It should be explained that, on the one hand, the contour shape description is used to describe the current body posture of the pig, such as whether the current body posture of the pig is in a state of raising its head or lowering its head; the current body posture of the pig will affect the final estimated weight of the pig; for example, if the current body posture of the pig is in a state of raising its head, the corresponding pig contour area is larger when it is in a state of raising its head than when it is in a state of lowering its head, so the final calculated weight of the pig will also be larger. On the other hand, the contour shape description is used to describe the current physical condition of the pig, such as whether the pig's buttocks are round; the current physical condition of the pig will also affect the final estimated weight of the pig, for example, if the processing system determines that the pig's buttocks are in a rounded state, the final calculated weight of the pig will also be larger when it is in a rounded state than when it is not rounded.
[0119] It should be noted that the contour shape description includes but is not limited to the contents introduced in the above two aspects.
[0120] 8. The process of obtaining the degree of contour fit:
[0121] After acquiring the pigpen image, the processing system further processes the pigpen image through the Detectron2 recognition algorithm model, thereby calculating the degree of fit between the pig contour in the pig identification information and the actual contour of the corresponding pig, that is, the contour fit degree.
[0122] S400: Process all feature groups through a weight estimation model to obtain weight estimation data.
[0123] After obtaining the corresponding feature group of each pig in each pig pen image through step S300, the eight features in each feature group are further synchronously input into the weight estimation model preset in the processing system for calculation. The weight estimation model processes the feature group input therein to calculate the estimated weight of the pig corresponding to each feature group.
[0124] It should be noted that, in this example, the above-mentioned weight estimation model is specifically a pre-trained LightGBM regression prediction model, which is used to process the feature group input therein, so as to calculate the estimated weight of the corresponding pig.
[0125] In this embodiment, the processing system controls the camera to collect images of the corresponding pig pen multiple times in a single day, thereby obtaining a number of pig pen images. For each pig pen image, the feature group of each pig in each pig pen image can be obtained through the implementation of step S300, and then the weight estimation of the pig corresponding to each feature group is calculated through the LightGBM regression prediction model, thereby obtaining weight estimation data composed of all calculated pig weight estimations.
[0126] S500, filtering the weight estimation data according to the pig identification information to obtain the first filtered weight estimation data, performing mathematical statistics on the filtered weight estimation data to obtain the average daily weight of the pigs in the same pen.
[0127] Specifically, S500 includes the following sub-steps:
[0128] S501. Determine the pig outline that is blocked in the pig pen image and record it as an abnormal outline.
[0129] After obtaining the pig outline in each pig identification information, the processing system also determines whether the pig outline is the pig outline obscured in the pigpen image. If so, the pig outline is recorded as an abnormal outline, which is an incomplete pig outline that is identified due to being obscured by other pigs.
[0130] It should be noted that, since the abnormal contour is greatly distorted compared to the actual pig contour, the pig weight estimation calculated based on the abnormal contour will also be greatly distorted.
[0131] S502: Determine the outline of the pigs at the edge of the pig pen image and record it as the edge outline.
[0132] After obtaining the pig outline in each pig identification information, the processing system also determines whether the pig outline is at the edge of the pig pen. If so, the corresponding pig outline is recorded as the edge outline.
[0133] It should be noted that, since the camera uses a fisheye lens, the edge contour is more distorted than the normal pig contour, and the pig weight estimation calculated based on the edge contour will also be more distorted.
[0134] S503, filtering out the pig weight estimates corresponding to the abnormal contours and edge contours from the weight estimate data to obtain first filtered weight estimate data.
[0135] Since the pig weight estimates calculated based on abnormal contours and edge contours are highly distorted, in implementation, after obtaining the weight estimate data, the pig weight estimates corresponding to the abnormal contours and edge contours in the weight estimate data are further filtered out to obtain the first filtered weight estimate data.
[0136] S504: Calculate a corresponding statistical threshold range based on the first filtered weight estimation data.
[0137] After the first filtered weight estimation data is obtained through step S503, the pig weight estimation data in the first filtered weight estimation data is further sorted in ascending order of value, thereby obtaining sorted weight estimation data.
[0138] It should be noted that in the actual pig breeding process, pigs of similar weight will be kept in the same pig pen; therefore, each pig pen will have a corresponding weight threshold range for pigs in the same pen, and the weight values of all pigs in the corresponding pig pen are within the weight threshold range for pigs in the same pen.
[0139] Based on the sorted weight estimation data, a statistical threshold range corresponding to the weight threshold range of pigs in the same pen can be calculated. The weight estimation of pigs that is more in line with reality in the sorted weight estimation data will be within the statistical threshold range.
[0140] The steps to calculate the statistical threshold range are as follows:
[0141] A: Calculate the estimated weight of pigs in the first quartile of the sorted weight estimation data, as well as the estimated weight of pigs in the third quartile.
[0142] For example, suppose there are 20 weight estimation data after sorting: T1, T2, T3, T4, T5, T6, T7, T8, T9, T 10 , T 11 , T 12 , T 13 , T 14 , T 15 , T 16 , T 17 , T 18 , T 19 , T 20 ;
[0143] The weight estimate of the pigs in the first quartile of the sorted weight estimate data is: T 20×1 / 4 =T5;
[0144] The estimated weight of the pigs in the third quartile of the sorted weight estimation data is: T 20×3 / 4 =T 15 ;
[0145] B: Interquartile range (IQR) calculated based on the estimated weight of pigs in the first quartile and the third quartile of the sorted estimated weight data.
[0146] IQR = estimated weight of pigs in the third quartile of the sorted estimated weight data - estimated weight of pigs in the first quartile of the sorted estimated weight data = T 15 -T5.
[0147] C: Calculate the abnormal threshold Q based on the interquartile range IQR.
[0148] Q = 1.5·IQR;
[0149] D: Calculate the maximum extreme value of the threshold range and the minimum extreme value of the threshold range based on the abnormal threshold Q.
[0150] The maximum extreme value of the threshold range = the estimated weight of the pig in the third quartile of the sorted weight estimation data + Q = T 15 +Q; the minimum extreme value of the threshold range = the estimated weight of the pigs in the first quartile of the sorted estimated weight data -Q = T5-Q;
[0151] D: Based on the maximum extreme value of the threshold range and the minimum extreme value of the threshold range, the statistical threshold range is obtained, and the statistical threshold range is: [the weight estimate of the pig in the first quartile of the weight estimate data after sorting - Q, the weight estimate of the pig in the third quartile of the weight estimate data after sorting + Q]. In this embodiment, the statistical threshold range is [T5-Q, T 15 +Q].
[0152] S505. Filter out the pig weight estimates that are not within the statistical threshold range from the first filtered weight estimate data to obtain second filtered weight estimate data.
[0153] After obtaining the statistical threshold range through step S504, the weight estimates of all pigs in the sorted first filtered weight estimate data are judged based on the statistical threshold range, that is, the weight estimates of all pigs in the sorted weight estimate data are judged based on the statistical threshold range, and the weight estimates of pigs in the sorted weight estimate data that are not within the statistical threshold range are filtered out, thereby obtaining the second filtered weight estimate data.
[0154] S506. Calculate the mean of the estimated weight data after the second filtration to obtain the average daily weight of the pigs in the same pen.
[0155] After obtaining the second filtered body weight estimation data through step S505, the average of the second filtered body weight estimation data is calculated, that is, the average daily weight of the pigs in the same pen.
[0156] Figure 1 FIG. 1 is a flow chart of a method for estimating the average daily weight of pigs in the same pen in one embodiment. It should be understood that although Figure 1 The steps in the flowchart are shown in sequence as indicated by the arrows, but the steps are not necessarily executed in the order indicated by the arrows; unless otherwise specified in this document, there is no strict order restriction for the execution of the steps, and the steps may be executed in other orders; and Figure 1 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.
[0157] In this embodiment, a computer device is disclosed, including a memory and a processor. The memory stores a computer program. When the computer program is executed by the processor, the processor executes the steps of the above-mentioned method for estimating the average daily weight of pigs in the same pen.
[0158] In this embodiment, a computer-readable storage medium is also disclosed, which stores a computer program that can be loaded by a processor and execute a method for estimating the average daily weight of pigs in the same pen as described above. The computer-readable storage medium includes, for example: a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and other media that can store program codes.
[0159] This specific embodiment is merely an explanation of the present invention and is not a limitation of the present invention. After reading this specification, those skilled in the art may make non-creative modifications to the present embodiment as needed. However, as long as they are within the scope of the claims of the present invention, they are protected by the patent law.
Claims
1. A method for estimating the average daily weight of pigs in the same pen, characterized by: include: Obtain at least one pig pen image in a single day; Processing the pig pen image through a recognition algorithm model to obtain pig identification information; The pig identification information includes the pig outline and pig posture of each pig in the pig pen image; Processing the pig identification information and the pig pen image to determine a feature group corresponding to each pig in the pig pen image; the feature group includes at least one of contour area, body length and width, pig part width group, distance between the pig and the image center, pig identification angle goodness, pig posture, contour shape description, and contour fit degree; Processing all of the feature groups through a weight estimation model to obtain weight estimation data; Filtering the weight estimation data according to the pig identification information to obtain first filtered weight estimation data, and performing mathematical statistics on the first filtered weight estimation data to obtain the average daily weight of pigs in the same pen; The step of determining the pig part width group in the feature group comprises: Obtaining the pig outline and the corresponding pig identification box; determining the orientation of the pig's head according to the pig's outline; The pig identification box is divided into equal parts by drawing lines to obtain a plurality of intersection point groups, and the intersection point groups are sorted according to the orientation of the pig heads to obtain a set of intersection point groups; Processing each of the intersection point groups in the intersection point group set in turn through a coordinate transformation model to obtain the pig part width group; The steps of dividing the pig identification box into equal parts by drawing lines to obtain a plurality of intersection point groups, and sorting the intersection point groups according to the orientation of the pig heads to obtain a set of intersection point groups include: Determine a plurality of equally divided points on the long side of the pig identification box; Draw an intersection line perpendicular to the long side of the pig identification box through the equal division point; Combining the intersection points of each intersection line and the pig outline into a corresponding intersection point group; Sorting the plurality of intersection point groups according to the orientation of the pig head to obtain an intersection point group set; The step of filtering the weight estimation data according to the pig identification information to obtain first filtered weight estimation data comprises: Determine the pig outline that is blocked in the pig pen image and record it as an abnormal outline; Determine the pig outline at the edge of the pig pen image and record it as the edge outline; Filtering out the pig weight estimates corresponding to the abnormal contour and the edge contour from the weight estimate data to obtain the first filtered weight estimate data; The step of performing mathematical statistics on the first filtered weight estimation data to obtain the average daily weight of pigs in the same pen comprises: Calculating a corresponding statistical threshold range based on the first filtered weight estimation data; Filtering out the estimated weights of pigs that are not within the statistical threshold range from the first filtered estimated weight data to obtain second filtered estimated weight data; The mean of the second filtered weight estimation data is calculated to obtain the average daily weight of the pigs in the same pen.
2. The method for estimating the average daily weight of pigs in the same pen according to claim 1, characterized in that: The step of processing the pig identification information and the pig pen image to determine a feature group corresponding to each pig in the pig pen image includes: Obtaining the pig outline; Processing the pig outline to obtain a pig identification box; The pig identification information and the pig identification box are processed to obtain the feature group.
3. The method for estimating the average daily weight of pigs in the same pen according to claim 2, characterized in that: The step of determining the body length and width in the feature group comprises: Obtain a pixel coordinate group of the corner points of the pig pen image, recorded as the first pixel coordinate group of the corner points, and also obtain the actual length and width of the pig pen; Obtain the pig identification box, determine a corner pixel coordinate group of the pig identification box, and record it as a second corner pixel coordinate group; The actual length and width of the pig pen, the first corner point pixel coordinate group and the second corner point pixel coordinate group are processed through a coordinate transformation model to obtain the body length and width, which include the actual length and actual width of the pig identification box.
4. The method for estimating the average daily weight of pigs in the same pen according to claim 3, characterized in that: The step of determining the goodness of the pig identification angle in the feature group includes: Determine the center point of the pig pen image, recorded as the first center point; determine the center point of the pig outline, recorded as the second center point; Draw a connecting line through the first center point and the second center point; Calculating the angle between the connecting line and the corresponding long side of the pig identification box; The degree of deviation between the included angle and the straight angle is calculated, and the degree of deviation is recorded as the degree of goodness of the pig recognition angle.
5. A computer device, characterized in that: The computer device includes a memory and a processor, the memory stores a computer program, and when the computer program is executed by the processor, the processor executes any one of the methods for estimating the average daily weight of pigs in the same pen as described in claims 1-4.
6. A computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor executes any one of the methods for estimating the average daily weight of pigs in the same pen as described in claims 1-4.
