Non-contact cattle weight measuring method based on image segmentation

Through image segmentation technology and YOLOv8 model, contactless automated measurement of cattle weight is achieved, and the problem of relying on manual intervention and operation difficulties in the existing technology is solved, and measurement efficiency and accuracy are improved.

CN119068043APending Publication Date: 2024-12-03ZHONGNONG SUNSHINE (JILIN PROVINCE) BIG DATA GROUP CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202411570317.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-06
Publication Date
2024-12-03

AI Technical Summary

Technical Problem

In the prior art, the cattle weight measurement method relies on manual intervention and is difficult to operate on large dead cattle, and lacks automated identification methods, resulting in high operating risks and low efficiency.

Method used

Using a contactless method based on image segmentation, we can use cattle images, perspective correction, establish a YOLOv8 cattle body recognition model, extract body ruler parameters, establish a regression model, predict the bust circumference and calculate the body weight, and achieve contactless weight measurement.

Benefits of technology

It realizes rapid and accurate automated measurement of cattle weight, reduces manual labor, improves measurement efficiency and stability, and is suitable for computer vision and deep learning fields.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119068043A_ABST
    Figure CN119068043A_ABST
Patent Text Reader

Abstract

The invention discloses a non-contact cattle weight measuring method based on image segmentation, relates to the field of cattle weight image segmentation, and solves the problem that a brand new automatic identification method capable of accurately identifying the cattle weight and reducing manual labor to the greatest extent is lacked in the prior art. The method comprises the following steps: acquiring a cattle image, judging a cattle visual angle, and performing visual angle correction on the cattle image with visual angle deviation; marking a cattle body and a disc on the cattle body, and establishing a cattle body identification model based on YOLOv8; body size parameters of the cattle are extracted according to digital image processing algorithms such as a minimum enclosing rectangle; collecting information of multiple groups of cattle body sizes to establish a regression model of the body lengths, the heights and the chest circumference of the cattle, and predicting the chest circumference of the cattle by adopting the model; calculating the weight of the cattle according to the chest circumference; the method is also suitable for the fields of computer vision and deep learning.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to the technical field of cattle weight image segmentation, and in particular to a non-contact cattle weight measurement method based on image segmentation. Background Art

[0002] The existing method for measuring the weight of dead cattle is to directly measure the weight of the cattle by using a scale. However, when facing large cattle, especially dead cattle, their muscles are stiff, so it becomes extremely difficult to move and place them, which not only increases the risk of operation, but also greatly consumes manpower and material resources.

[0003] At present, existing technical research has shown that certain morphological characteristics of cattle, such as height, body length, chest circumference, etc., are closely related to weight. Based on this finding, researchers have developed various regression models to try to predict cattle weight through these morphological characteristics. Although these models have been successful to a certain extent, they still rely on human intervention, such as manual measurement of cattle morphological characteristics, input of data, etc., and have not yet achieved full automation.

[0004] Therefore, it is necessary to develop a new automated identification method that can accurately identify cattle weight and minimize manual labor. Summary of the invention

[0005] The present invention aims to solve the problem in the prior art that there is a lack of a new automated identification method that can both accurately identify the weight of cattle and minimize manual labor.

[0006] To solve the above technical problems, the present invention is achieved through the following technical solutions: Solution 1: The present invention proposes a non-contact cattle weight measurement method based on image segmentation, the method comprising the following steps: S1, collecting cattle images, determining the cattle perspective, and performing perspective correction on cattle images with perspective deviation; S2, marking the discs on the cows, and establishing a cow body recognition model based on YOLOv8 based on the discs; S3, determining the position of the disk, and extracting the body size parameters of the cattle according to the digital image processing algorithm of the minimum circumscribed rectangle; S4, collecting multiple groups of cattle body size parameter information, and establishing a regression model of cattle body length, height and chest circumference, and using the regression model to predict the cattle chest circumference; S5. Calculate the weight of the cow based on the chest circumference of the cow, and complete the non-contact cow weight measurement based on image segmentation.

[0007] Further, a preferred implementation is provided, where S1 specifically includes: S11, placing a disc at the center of the cow's side, using a camera to take a picture of the cow's side, and collecting an image of the cow's side; S12, preliminarily screening the cow side images collected in S11, and converting all the cow side images into a color space; S13, clustering the cow side image obtained in S12 through k-means to obtain the diameter of the blue disk; S14, obtaining the ratio of the horizontal diameter to the vertical diameter based on the diameter size of the blue disk, and determining the viewing angle of the cattle; S15, performing perspective transformation on the cattle body measurement image with perspective deviation to obtain a corrected cattle image.

[0008] Further, a preferred implementation is provided, in which the method for establishing a cow body recognition model based on YOLOv8 in S2 is: S21, based on the side image of the cow collected in step S11, annotate the side part and the disc part of the cow, and convert the annotation into a txt storage label format after completion; S22, randomly dividing the annotated cow side images into a training set and a test set according to the proportion; S23, performing data augmentation on the training set and test set of the annotated cow side images; S24, inputting the training set enhanced by S23 into the YOLOv8 network model to perform cow body and disc segmentation training, and obtaining a trained cow body and disc segmentation model; S25. Input the training set obtained in step S24 into the trained cow body and disc segmentation model, verify the segmentation model, and output the verification result to obtain the final cow body and disc segmentation model.

[0009] Further, a preferred embodiment is provided, in which the method for determining the position of the disk in S3 is: S31, determining the cow's viewing angle on the collected cow image, and when the cow's viewing angle is determined to be a positive viewing angle, inputting the cow image into a cow body disc segmentation model for segmentation; outputting the image to determine whether the cow body and the disc exist at the same time; Define the cow body detection category as , the disk detection category is , if there are categories With category , then it meets the judgment criteria, otherwise the output is wrong; S32, under the condition of S31, determining the position of the disk; Define the cow body detection area as , define the disk detection area as , the intersection area of ​​the cow's body and the disk is ; Cow body ,disc Intersection Area There is an equation relationship = , the disk is contained in the middle of the cow's body, which meets the judgment criteria; otherwise, an error is output.

[0010] Further, a preferred embodiment is provided, in which the method for collecting multiple groups of cattle body size parameter information in S4 is: S41, based on S32, extract the cow body and the disc respectively; S42, extracting mask1 from the collected disk, and segmenting the extracted mask1 disk image; S43, extracting mask2 from the collected cow body image, where the extracted mask2 is a merged image of the cow body segmentation image and the disk segmentation image; S44, searching the target boundary for the mask1 image obtained in S42 and calculating the minimum circumscribed rectangle, and extracting the long side of the minimum circumscribed rectangle as the diameter of the disk on the pixel; S45, performing hole filling processing on the mask2 image obtained in S43 to obtain a complete mask2 image without internal gaps; S46, searching the target boundary for the mask2 image obtained in S45 and calculating the body length of the cattle; Define the leftmost point of the cow body extraction image as the key point The rightmost point is defined as the key point , The coordinates of , The coordinates of , for key points , Draw straight lines in the vertical direction , ,get , Distance ,distance Defined as the body length of cattle; S47, find the target boundary and calculate the height of the cow for the mask2 image obtained in S45, and define the distance For body height.

[0011] Further, a preferred embodiment is provided, in which the method for extracting the body size parameters of cattle according to the digital image processing algorithm of the minimum circumscribed rectangle in S3 is: S51, obtain the diameter size data of the blue disk in S13, and obtain the diameter size data based on S14 ; is the horizontal diameter of the blue disk With longitudinal diameter The maximum value of S52, using the following formula to calculate the scaling ratio k between the pixel image size and the true value size: ; S53. Calculate the actual value of the cow's body length based on the scaling ratio between the pixel image size and the actual value size. Length of cattle .

[0012] Further, a preferred embodiment is provided, in which the method for calculating the cattle weight based on the chest circumference of the cattle in S5 is: S71, the body length of the cattle calculated by S53 Length of cattle Input the cattle body size parameters and the cattle chest circumference prediction regression model to obtain the predicted chest circumference ; S72, based on Calculate the weight of the cattle.

[0013] Furthermore, a preferred implementation is provided, in which the data ratio of the training set and the test set in S22 is 8:2.

[0014] Solution 2: A computer device includes a processor and a storage medium, wherein the memory stores a computer program. When the processor runs the computer program stored in the memory, the processor executes any one of the methods described in Solution 1.

[0015] Solution 3: A computer storage medium for storing a computer program. When the computer program is read by a computer, the computer executes any one of the methods described in Solution 1.

[0016] The present invention is beneficial in that: The non-contact cattle weight measurement method based on image segmentation described in the present invention directly measures the weight of cattle in a non-contact manner. Especially in the case of accidental death of cattle, breeders can quickly estimate the weight of the dead cattle, thereby improving the efficiency of estimation.

[0017] The method described in the present invention will integrate the most cutting-edge computer vision, deep learning and multi-sensor technology to achieve full automated processing from image or video input to weight prediction output, and has the advantages of good stability and strong anti-interference.

[0018] The present invention corrects the images of cattle that are not taken at a completely level view by preferentially identifying the distortion information of the shooting angle, which is beneficial to improving the accuracy of weight estimation; The present invention is also applicable to the fields of computer vision and deep learning. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 This is a flow chart of a non-contact cattle weight measurement method based on image segmentation described in Implementation Method 1.

[0020] Figure 2 This is a schematic diagram of the lateral body size parameters of a cattle in a non-contact cattle weight measurement method based on image segmentation described in Implementation Example 1.

[0021] Figure 3 This is a schematic diagram of segmentation and extraction of the cow body and the disc in a non-contact cow weight measurement method based on image segmentation described in Implementation Example 1.

[0022] Figure 4 This is a schematic diagram of the conversion between cow pixels and true values ​​in a non-contact cow weight measurement method based on image segmentation described in Implementation Example 1.

[0023] Figure 5 This is a schematic diagram of solving the height and length of a cow in a non-contact cattle weight measurement method based on image segmentation described in Implementation Mode 5. DETAILED DESCRIPTION

[0024] In order to make the purpose, technical solutions and advantages of the implementation methods of the present application clearer, the technical solutions in the implementation methods of the present application will be clearly and completely described below in conjunction with the drawings in the implementation methods of the present application. Obviously, the described implementation methods are only part of the implementation methods of the present application, not all of the implementation methods.

[0025] Embodiment 1: This embodiment provides a non-contact cattle weight measurement method based on image segmentation, the method comprising the following steps: S1, collecting cattle images, determining the cattle perspective, and performing perspective correction on cattle images with perspective deviation; S2, marking the discs on the cows, and establishing a cow body recognition model based on YOLOv8 based on the discs; S3, determining the position of the disk, and extracting the body size parameters of the cattle according to the digital image processing algorithm of the minimum circumscribed rectangle; S4, collecting multiple groups of cattle body size parameter information, and establishing a regression model of cattle body length, height and chest circumference, and using the regression model to predict the cattle chest circumference; S5. Calculate the weight of the cow based on the chest circumference of the cow, and complete the non-contact cow weight measurement based on image segmentation.

[0026] Embodiment 2: This embodiment further limits the non-contact cattle weight measurement method based on image segmentation described in Embodiment 1. S1 specifically includes: S11, placing a disc at the center of the cow's side, using a camera to take a picture of the cow's side, and collecting an image of the cow's side; S12, preliminarily screening the cow side images collected in S11, and converting all the cow side images into a color space; S13, clustering the cow side image obtained in S12 through k-means to obtain the diameter of the blue disk; S14, obtaining the ratio of the horizontal diameter to the vertical diameter based on the diameter size of the blue disk, and determining the viewing angle of the cattle; S15, performing perspective transformation on the cattle body measurement image with perspective deviation to obtain a corrected cattle image.

[0027] Implementation method 3: This implementation method further limits the non-contact cattle weight measurement method based on image segmentation described in implementation method 2. The method for establishing a cattle body recognition model based on YOLOv8 in S2 is: S21, based on the side image of the cow collected by S11, annotate the side part and the disc part of the cow, and convert the annotation into a txt storage label format after completion; S22, randomly dividing the annotated cow side images into a training set and a test set according to the proportion; S23, performing data augmentation on the training set and test set of the annotated cow side images; S24, inputting the training set enhanced by S23 into the YOLOv8 network model to perform cow body and disc segmentation training, and obtaining a trained cow body and disc segmentation model; S25, inputting the training set obtained in S24 into the trained cow body and disc segmentation model, verifying the segmentation model, and outputting the verification result to obtain the final cow body and disc segmentation model.

[0028] Embodiment 4: This embodiment further limits the non-contact cattle weight measurement method based on image segmentation described in Embodiment 1. The method for determining the position of the disk in S3 is: S31, determining the cow's viewing angle on the collected cow image, and when the cow's viewing angle is determined to be a positive viewing angle, inputting the cow image into a cow body disc segmentation model for segmentation; outputting the image to determine whether the cow body and the disc exist at the same time; Define the cow body detection category as , the disk detection category is , if there are categories With category , then it meets the judgment criteria, otherwise the output is wrong; Step S32: Under the condition of S31, determine the position of the disk; Define the cow body detection area as , define the disk detection area as , the intersection area of ​​the cow's body and the disk is ; Cow body ,disc Intersection Area There is an equation relationship = , the disk is contained in the middle of the cow's body, which meets the judgment criteria; otherwise, an error is output.

[0029] Embodiment 5: This embodiment further limits the non-contact cattle weight measurement method based on image segmentation described in Embodiment 4. The method for collecting multiple groups of cattle body size parameter information in S4 is: S41: Based on S32, extract the cow body and the disc separately; S42: extracting mask1 from the collected disk, and segmenting the extracted mask1 disk image; S43: extracting mask2 from the collected cow body image, where the extracted mask2 is a merged image of the cow body segmentation image and the disk segmentation image; S44, searching the target boundary for the mask1 image obtained in S42 and calculating the minimum circumscribed rectangle, and extracting the long side of the minimum circumscribed rectangle as the diameter of the disk on the pixel; S45, performing hole filling processing on the mask2 image obtained in S43 to obtain a complete mask2 image without internal gaps; S46, searching the target boundary for the mask2 image obtained in S45 and calculating the body length of the cattle; Define the leftmost point of the cow body extraction image as the key point The rightmost point is defined as the key point , The coordinates of , The coordinates of , for key points , Draw straight lines in the vertical direction , ,get , Distance ,distance Defined as the body length of cattle; S47, find the target boundary and calculate the height of the cow for the mask2 image obtained in S45, define the proximity of the cow body extraction image, and define the distance For body height.

[0030] Embodiment 6: This embodiment further limits the non-contact cattle weight measurement method based on image segmentation described in Embodiment 2. The method for extracting the body size parameters of cattle according to the digital image processing algorithm of the minimum circumscribed rectangle in S3 is: S51, obtain the diameter size data of the blue disk in S13, and obtain the diameter size data based on S14 ; is the horizontal diameter of the blue disk With longitudinal diameter The maximum value of S52, using the following formula to calculate the scaling ratio k between the pixel image size and the true value size: ; S53. Calculate the actual value of the cow's body length based on the scaling ratio between the pixel image size and the actual value size. Length of cattle .

[0031] Embodiment 7: This embodiment further limits the non-contact cattle weight measurement method based on image segmentation described in Embodiment 1. The method for calculating the cattle weight based on the chest circumference of the cattle in S5 is: S71, the body length of the cattle calculated by S53 Length of cattle , input the cattle body size parameters and cattle chest circumference prediction regression model, and get the predicted chest circumference ; S72, based on Calculate the weight of the cattle.

[0032] Embodiment 8: This embodiment further limits the non-contact cattle weight measurement method based on image segmentation described in Embodiment 1. The data ratio of the training set and the test set in S22 is 8:2.

[0033] Embodiment 9. This embodiment proposes a computer device, including a processor and a storage medium, wherein a computer program is stored in the memory. When the processor runs the computer program stored in the memory, the processor executes the method described in any one of embodiments 1 to 8.

[0034] Embodiment 10: This embodiment proposes a computer storage medium for storing a computer program. When the computer program is read by a computer, the computer executes the method described in any one of Embodiments 1 to 8.

[0035] Implementation 11. This implementation includes an example, which is used to explain the above implementation. Figures 1 to 5 To explain this embodiment, Embodiment 1, as Figure 1 FIG. 1 is a flow chart of non-contact measurement of cattle weight according to an embodiment of the present invention; a method for determining and correcting the cattle viewing angle comprises the following steps: S1. Use a blue disc with a diameter of 30 cm and hang it in the middle of the side of the cow. The disc is close to the cow's body. Professionals stand on the side of the cow to collect single cows in the cattle farm, with the viewing angle level with the cow's body, and collect a large number of images.

[0036] S2. Preliminary screening is performed on the collected sideways images of cattle, and they are divided into head-on images and non-head-on images.

[0037] The method for determining the perspective of cattle is as follows: transform the color space of all side images, convert RGB to Lab color space, extract the ab color channel alone, and obtain the blue disk image through k-means clustering.

[0038] The formula for converting RGB to Lab space is as follows:

[0039] , Among them, X, Y, Z are the representation of colors in the XYZ color space, and , , is the XYZ value of the reference white point. The k-means clustering steps and formula are as follows: Data preprocessing, labeling and outlier filtering of data, random selection Center, denoted as , ,…, ; Define the loss function: , let t = 0, 1, 2, ... be the number of iterations, and repeat the process until J converges. For each sample , assign it to the nearest center

[0040] For each type of center , recalculate the center of the class

[0041] in, For the first Sample points, is the total number of samples, For the At the iteration, The coordinates of the cluster centers, For the At the iteration, The coordinates of the cluster centers, For the At the iteration, the sample The index of the cluster center to which it belongs.

[0042] S3. Obtain the ratio of the horizontal diameter to the vertical diameter of the blue disk image. If the maximum absolute value of the ratio of the vertical diameter to the horizontal diameter of the disk does not exceed 1.2, it is determined that no large distortion has occurred; otherwise, it is determined that large distortion has occurred.

[0043] S4. Perform perspective correction on the entire image that is judged to be distorted The perspective correction formula is as follows: The original image is projected, and the general formula for transforming from the original image plane to the new image plane is:

[0044] in( ) is the plane coordinate point of the original image, and the corresponding transformed image is ( , Set in 2D image , the image is converted from two dimensions to three dimensions:

[0045] make , get a point:

[0046] in, , , and To define linear transformations in a two-dimensional plane, such as rotation, scaling, and skewing. , To implement translation transformation, , Introducing perspective transformation effects in the conversion from 2D to 3D, Typically set to 1.

[0047] Embodiment 2: The method for training the cow body disc model comprises the following steps: S1. Use a blue disc with a diameter of 30 cm to hang in the middle of the side of the cow. The disc is close to the cow's body. Professionals stand on the side of the cow to collect data of a single cow in the cattle farm. The perspective is level with the cow's body. Collect data and perform judgment correction. The corrected image is used as the cow body disc data set, where: Figure 4 Where x is the length of the disc in pixels in the individual information picture of the cow with the full disc, and y is the length of the cow in pixels in the individual information picture of the cow with the full disc. Since the real disc length is known, the real cow body length is calculated according to the geometric conversion formula.

[0048] S2. Use labelme image annotation tool to identify the individual cattle with discs obtained in S2 After processing, the cow's body information and the disc information on the cow's body are manually identified. After all images are labeled, the json storage label is changed to the txt storage label format. The data information of the storage label is the category and the location point of each labeled outline box from left to right.

[0049] S3. Randomly divide the labeled cattle individual identity images into training set and test set in a ratio of 8:2, and there is no duplication or overlap between the training set and the test set images.

[0050] S4. Build the environment required for YOLOv8; S5. Input the training set into YOLOv8 to train the cow body disc segmentation model; S6. Input the test set into the trained model, verify the model, and output the verification result. The final cow body disc segmentation model is obtained.

[0051] Embodiment 3: First, the collected cow images are corrected for cow perspective judgment, and the cow images with distorted perspective are corrected. The correct ones directly proceed to the next step, and all cow images are input into the cow body disc segmentation model for segmentation; the output image is used to determine whether the cow body and the disc exist at the same time, including the following steps.

[0052] (1) Determination of the simultaneous existence of the cow body and the disc Define the cow body detection category as , the disk detection category is , if there are categories With category , then it meets the judgment criteria, otherwise it outputs an error.

[0053] (2) Disk position determination Define the cow body detection area as , define the disk detection area as , the intersection area of ​​the cow's body and the disk is Like a cow's body ,disc Intersection Area There is an equation relationship = , the disk is contained in the middle of the cow's body, which meets the judgment criteria; otherwise, the output is an error.

[0054] Embodiment 4: like Figure 3 As shown: extract the cow body and the disc separately, extract mask1 from the collected disc, and extract The obtained mask1 disk segmentation image; extract mask2 from the collected cow body image, and the extracted mask2 is the merged image of the cow body segmentation image and the disk segmentation image; the obtained mask1 image finds the target boundary and calculates the minimum enclosing rectangle, and extracts the long side of the minimum enclosing rectangle as the diameter of the disk on the pixel. The obtained mask2 image is processed with hole filling to obtain a complete mask2 image without internal gaps; define the leftmost point of the cow body extraction image as the key point The rightmost point is defined as the key point , The coordinates of , The coordinates of , for key points , Draw straight lines in the vertical direction , ,get , Distance ,distance Defined as the body length of the cattle.

[0055] Define the height of the cow body as the maximum in the image and the position that is 1 / 2 of the cow's height away from the boundary. Define the distance For body height.

[0056] Embodiment 5: Get the blue disk data and go to , is the horizontal diameter of the blue disk With longitudinal diameter Calculate the scaling ratio k between the pixel image size and the true value size ; Solve the actual value of the cow's body length based on the scaling ratio of the pixel image size to the actual value size Length of cattle ; Example 6: The collected body length, body height and chest circumference of cattle are divided into a training set and a control set, and a local weighted linear regression neural network is constructed. Sample training data set , for the training samples, the weights in the LWLR model are based on the samples to be predicted. The distance between the training samples is used for calculation.

[0057] Prediction results It can be expressed by the following formula:

[0058] in, is the regression coefficient, In LWLR, for training samples, we need to minimize all training samples and the actual output value The weighted square error between .

[0059] Calculate the sample points to be predicted With training sample points The distance between (Euclidean distance squared) can be expressed as:

[0060] in, is the feature vector of the sample to be tested, is the feature vector of the jth sample in the training set.

[0061] Assume The weight of a training sample is , then the overall goal It can be expressed as:

[0062] The Gaussian kernel function selected in the LWLR model can be expressed as:

[0063] in, For the The weights for training samples.

[0064] Cost Function for:

[0065]

[0066] in, The linear regression model is The predicted value of is the true output vector of the training set,

[0067] is a weighted cost function. It measures the weighted square error between the predicted value and the true value. It is necessary to select a suitable regression coefficient Value Reaching the minimum value, the formula is derived:

[0068] Obtain regression coefficient parameters It can be calculated as:

[0069] in, is the regression coefficient vector, and the fitted value is measured It can be expressed as:

[0070] Embodiment 7: Calculated cattle length Length of cattle Input the cattle body size parameters and the cattle chest circumference prediction regression model to obtain the predicted chest circumference , calculate the weight of the cattle: .

[0071] In summary, the present embodiment discloses a non-contact cattle weight measurement method based on the image segmentation network model YOLOv8. First, a cattle image is collected, and a disc with a diameter of 30 cm is placed on the cattle. The proportion information of the disc is calculated by digital image processing, and the cattle image with a deviation in perspective is corrected to obtain a cattle perspective correction model; individual information pictures of the cattle with a full disc are collected, and the cattle body and the disc are segmented and trained to establish a cattle body disc segmentation model based on YOLOv8; the position of the disc on the cattle body is determined by using the area intersection, and the cattle body size parameters are determined by the minimum circumscribed rectangle and the maximum inscribed circle.

[0072] Those skilled in the art will appreciate that the above are only preferred embodiments of the present invention, and the various embodiments of the present disclosure and / or the features described in the claims may be combined or combined in various ways, even if such combinations or combinations are not explicitly described in the present disclosure. It is not intended to limit the present invention. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art may still modify the technical solutions described in the aforementioned embodiments, or perform equivalent substitutions on some of the technical features therein. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention shall be included in the protection scope of the present invention.

[0073] Although preferred embodiments of the present invention have been described, additional changes and modifications may be made to these embodiments by those skilled in the art once the basic inventive concepts are known. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention. Obviously, those skilled in the art may make various changes and modifications to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention is also intended to include these modifications and variations.

Claims

1. A non-contact cattle weight measurement method based on image segmentation, characterized in that: The method comprises the following steps: S1, collecting cattle images, determining the cattle perspective, and performing perspective correction on cattle images with perspective deviation; S2, marking the discs on the cows, and establishing a cow body recognition model based on YOLOv8 based on the discs; S3, determining the position of the disk, and extracting the body size parameters of the cattle according to the digital image processing algorithm of the minimum circumscribed rectangle; S4, collecting multiple groups of cattle body size parameter information, and establishing a regression model of cattle body length, height and chest circumference, and using the regression model to predict the cattle chest circumference; S5. Calculate the weight of the cow based on the chest circumference of the cow, and complete the non-contact cow weight measurement based on image segmentation.

2. The non-contact cattle weight measurement method based on image segmentation according to claim 1, characterized in that: S1 specifically includes: S11, placing a disc at the center of the cow's side, using a camera to take a picture of the cow's side, and collecting an image of the cow's side; S12, preliminarily screening the cow side images collected in S11, and converting all the cow side images into a color space; S13, clustering the cow side image obtained in S12 through k-means to obtain the diameter of the blue disk; S14, obtaining the ratio of the horizontal diameter to the vertical diameter based on the diameter size of the blue disk, and determining the viewing angle of the cattle; S15, performing perspective transformation on the cattle body measurement image with perspective deviation to obtain a corrected cattle image.

3. The non-contact cattle weight measurement method based on image segmentation according to claim 2, characterized in that: The method for establishing a cow body recognition model based on YOLOv8 in S2 is: S21, based on the side image of the cow collected by S11, annotate the side part and the disc part of the cow, and convert the annotation into a txt storage label format after completion; S22, randomly dividing the annotated cow side images into a training set and a test set according to the proportion; S23, performing data augmentation on the training set and test set of the annotated cow side images; S24, inputting the training set enhanced by S23 into the YOLOv8 network model to perform cow body and disc segmentation training, and obtaining a trained cow body and disc segmentation model; S25, inputting the training set obtained in S24 into the trained cow body and disc segmentation model, verifying the segmentation model, and outputting the verification result to obtain the final cow body and disc segmentation model.

4. The non-contact cattle weight measurement method based on image segmentation according to claim 1, characterized in that: The method for determining the position of the disk in S3 is: S31, determining the cow's viewing angle on the collected cow image, and when the cow's viewing angle is determined to be a positive viewing angle, inputting the cow image into a cow body disc segmentation model for segmentation; outputting the image to determine whether the cow body and the disc exist at the same time; Define the cow body detection category as , the disk detection category is , if there are categories With category , then it meets the judgment criteria, otherwise the output is wrong; S32, under the condition of S31, determining the position of the disk; Define the cow body detection area as , define the disk detection area as , the intersection area of ​​the cow's body and the disk is ; Cow body ,disc Intersection Area There is an equation relationship = , the disk is contained in the middle of the cow's body, which meets the judgment criteria; otherwise, an error is output.

5. The non-contact cattle weight measurement method based on image segmentation according to claim 4, characterized in that: The method for collecting multiple groups of cattle body size parameter information in S4 is: S41, based on S32, extract the cow body and the disc respectively; S42, extracting mask1 from the collected disk, and segmenting the extracted mask1 disk image; S43, extracting mask2 from the collected cow body image, where the extracted mask2 is a merged image of the cow body segmentation image and the disk segmentation image; S44, searching the target boundary for the mask1 image obtained in S42 and calculating the minimum circumscribed rectangle, and extracting the long side of the minimum circumscribed rectangle as the diameter of the disk on the pixel; S45, performing hole filling processing on the mask2 image obtained in S43 to obtain a complete mask2 image without internal gaps; S46, searching the target boundary for the mask2 image obtained in S45 and calculating the body length of the cattle; Define the leftmost point of the cow body extraction image as the key point , the rightmost point is defined as the key point , The coordinates of , The coordinates of , for key points , Draw straight lines in the vertical direction , ,get , Distance ,distance Defined as the body length of cattle; S47, find the target boundary and calculate the height of the cow for the mask2 image obtained in S45, and define the distance For body height.

6. The non-contact cattle weight measurement method based on image segmentation according to claim 2, characterized in that: The method for extracting the body size parameters of cattle in S3 based on the digital image processing algorithm of the minimum circumscribed rectangle is: S51, obtain the diameter size data of the blue disk in S13, and obtain the diameter size data based on S14 ; is the horizontal diameter of the blue disk With longitudinal diameter The maximum value of S52, using the following formula to calculate the scaling ratio k between the pixel image size and the true value size: ; S53. Calculate the actual value of the cow's body length based on the scaling ratio between the pixel image size and the actual value size. Length of cattle .

7. The non-contact cattle weight measurement method based on image segmentation according to claim 1, characterized in that: The method for calculating the weight of the cattle based on the chest circumference of the cattle in S5 is: S71, the body length of the cattle calculated by S53 Length of cattle Input the cattle body size parameters and the cattle chest circumference prediction regression model to obtain the predicted chest circumference ; S72, based on Calculate the weight of the cattle.

8. The non-contact cattle weight measurement method based on image segmentation according to claim 1, characterized in that: The data ratio of the training set and the test set in S22 is 8:

2.

9. A computer device comprising a memory and a processor, characterized in that: A computer program is stored in the memory. When the processor runs the computer program stored in the memory, the processor executes the method according to any one of claims 1 to 8.

10. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 8 are implemented.

Citation Information

Patent Citations

  • Method and device for identifying weight of animal

    CN108830293A

  • Livestock weight identification method and device, storage medium and terminal equipment

    CN114863478A

  • Non-contact cattle weight measurement method based on target detection network model YOLOv8

    CN117765329A

  • Pig body size and weight estimation method based on deep learning

    WO2023060777A1