Automatic Inspection Method and System for Pastoral Areas of Animal Husbandry
By performing edge detection and connectivity analysis on animal husbandry and pastoral images, the problem of low accuracy of livestock health detection in traditional methods is solved, and accurate positioning and health detection of abnormal livestock in animal husbandry and pastoral areas is achieved.
Patent Information
- Application Number
- CN202510480806.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-08-01
- Estimated Expiration
- 2045-04-17
AI Technical Summary
Traditional animal husbandry and pastoral health monitoring methods rely on manual inspections, making it difficult to fully cover a large number of livestock, especially in complex terrain, resulting in low accuracy in livestock health testing.
By performing edge detection on animal husbandry and pastoral images, the livestock connectivity domain is determined, the shriveling rate and segmentation situation are calculated, the abnormal livestock connectivity domain is identified, and the inspection is carried out.
The segmentation accuracy of the livestock parts in the animal husbandry and pastoral images is improved, the precise positioning of abnormal livestock is achieved, and the accuracy of health detection is improved.
Smart Images

Figure CN119992350B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and particularly to an automatic inspection method and system for livestock pastures. Background Art
[0002] Livestock pastures refer to areas specifically used for grazing livestock. These areas are usually located in places with suitable natural conditions, such as grasslands and mountain meadows. Livestock pastures are mainly used for raising and managing livestock. Grasslands and mountain meadows usually have vast land and suitable environmental conditions to support the growth and reproduction of livestock. In livestock pastures, the health monitoring of livestock is crucial for ensuring the sustainable development of the livestock industry. Traditional health monitoring methods usually rely on the experience of veterinarians or herdsmen and regular visual inspections. This method is not only time-consuming and laborious, but also difficult to achieve full coverage of a large number of livestock, especially in the vast and complex terrain of grasslands and mountain meadows.
[0003] In some scenarios, in order to detect the health problems of livestock in livestock pastures, images of livestock pastures are usually collected and the livestock in the images are segmented for health analysis. Since the livestock part and the background part in the images of livestock pastures are similar, it is difficult to accurately segment the livestock part in the images of livestock pastures, thus making it difficult to accurately locate the livestock in livestock pastures, resulting in a low accuracy of health detection of livestock. Summary of the Invention
[0004] In order to solve the technical problem of low accuracy in segmenting the livestock part in the image, which leads to low accuracy in the health detection of livestock, the purpose of the present invention is to provide an automatic inspection method and system for livestock pastures. The specific technical solutions adopted are as follows:
[0005] In a first aspect, an embodiment of the present invention provides an automatic inspection method for livestock pastures, including: performing edge detection on a target image of a livestock pasture to obtain the edges in the target image; determining a target cluster through the gray values of each pixel point in the target image, the gray values of the pixel points within the neighborhood range corresponding to each pixel point, and the edge pixel points on the edge, and denoting the target cluster as a livestock connected domain; determining the shrivel rate of the livestock connected domain according to the edge pixel points on the edge in the livestock connected domain and the edge pixel points adjacent to the edge pixel points; determining the segmentation situation of the livestock connected domain according to the comparison pixel points of the edge pixel points in the livestock connected domain, the edge pixel points adjacent to the edge pixel points, and the first quantity of the edge pixel points in the livestock connected domain; determining the abnormal degree of the livestock connected domain based on the shrivel rate and the segmentation situation of the livestock connected domain, and denoting the livestock connected domain with an abnormal degree greater than a first threshold as an abnormal livestock connected domain; determining abnormal livestock according to the position of the abnormal livestock connected domain in the target image, and inspecting the abnormal livestock.
[0006] Optionally, determining the target cluster based on the gray values of each pixel in the target image, the gray values of the pixels within the neighborhood corresponding to each pixel, and the edge pixels on the edge includes: determining the difference coefficient of each pixel based on the gray value of each pixel in the target image and the gray values of the pixels within the neighborhood corresponding to each pixel; determining the change factor of the pixel according to the difference coefficient of the pixel and the second quantity of edge pixels included in the pixel block where the pixel is located; clustering each pixel based on the gray value and the change factor of each pixel to obtain a plurality of clusters; and selecting, from each cluster, the target cluster whose average change factor of the pixels within the cluster is greater than the second threshold.
[0007] Optionally, determining the change factor of the pixel according to the difference coefficient of the pixel and the second quantity of edge pixels included in the pixel block where the pixel is located includes: calculating the average value of the difference coefficients between the pixel and each pixel within the corresponding neighborhood range, and the first product between the average value and the second quantity; and normalizing the first product using a hyperbolic function to obtain the change factor of the pixel.
[0008] Optionally, determining the shriveling rate of the livestock connected region based on the edge pixels on the edge of the livestock connected region and the edge pixels adjacent to the edge pixels includes: determining the included angle of the edge pixels according to the edge pixels in the livestock connected region and the pixels adjacent to both sides of the edge pixels; determining the degree of depression of the edge pixels according to the included angle and a predetermined included angle, and selecting the edge pixels with a degree of depression greater than the third threshold as the depressed pixels; dividing the edge into two segments by the depressed pixels on the edge of the livestock connected region, and denoting the longer edge as the trunk edge; determining the depression rate of the trunk edge according to the first degree of depression, the second degree of depression, the average degree of depression, the third quantity, and the fourth quantity, where the first degree of depression is the degree of depression of any depressed pixel on the trunk edge, the second degree of depression is the degree of depression of the depressed pixel closest to any depressed pixel on the trunk edge, the average degree of depression is the average of the degrees of depression of all pixels between any depressed pixel and the closest depressed pixel on the trunk edge, the third quantity is the number of all pixels between any depressed pixel and the closest depressed pixel on the trunk edge, and the fourth quantity is the number of depressed pixels on the trunk edge; fitting an ellipse to the trunk edge using the least squares method to obtain the loss value of the trunk edge in the livestock connected region; and determining the shriveling rate of the livestock connected region according to the loss value of the trunk edge in the livestock connected region and the depression rate of the trunk edge.
[0009] Optionally, determining the degree of depression of the edge pixels according to the included angle and a predetermined included angle includes: calculating the first difference between the included angle and the predetermined included angle; and normalizing the first difference using a hyperbolic function to obtain the degree of depression of the edge pixels.
[0010] Optionally, determining the depression rate of the torso edge based on the first depression degree, the second depression degree, the average depression degree, the third quantity, and the fourth quantity includes: calculating a first sum value between the first depression degree and the second depression degree, and a first ratio between the first sum value and twice the average depression degree; calculating a second product between the first ratio and the reciprocal of the third quantity; adding up the second products of each depressed pixel point to obtain a first added value, and calculating a second ratio between the first added value and the fourth quantity; and normalizing the second ratio using a hyperbolic function to obtain the depression rate of the torso edge.
[0011] Optionally, determining the shrivel rate of the livestock connected region based on the loss value of the torso edge in the livestock connected region and the depression rate of the torso edge includes: calculating a third product between the loss value of the torso edge and the depression rate of the torso edge; and normalizing the third product using a hyperbolic function to obtain the shrivel rate of the livestock connected region.
[0012] Optionally, determining the segmentation situation of the livestock connected region based on the comparison pixel points of the edge pixel points in the livestock connected region, the edge pixel points adjacent to the edge pixel points, and the first quantity of the edge pixel points in the livestock connected region includes: obtaining the connection line between the edge pixel points in the livestock connected region and the centroid of the livestock connected region, and marking the pixel points located outside the livestock connected region in the connection line as the comparison pixel points of the edge pixel points; determining the included angle of the edge pixel points according to the edge pixel points in the livestock connected region and the pixel points adjacent to both sides of the edge pixel points; determining the depression degree of the edge pixel points according to the included angle and a predetermined included angle; and determining the segmentation situation of the livestock connected region according to the fifth quantity of the comparison pixel points of the edge pixel points, the depression degree of the edge pixel points, and the first quantity of the edge pixel points in the livestock connected region.
[0013] Optionally, determining the segmentation situation of the livestock connected region based on the fifth quantity of the comparison pixel points of the edge pixel points, the depression degree of the edge pixel points, and the first quantity of the edge pixel points in the livestock connected region includes: calculating a fourth product between the depression degree of each edge pixel point and the fifth quantity of the comparison pixel points of each edge pixel point; adding up each fourth product to obtain a second added value, calculating a third ratio between the second added value and the first quantity; and normalizing the third ratio using an exponential function to obtain the segmentation situation of the livestock connected region.
[0014] In a second aspect, an embodiment of the present invention provides an automatic inspection system for a livestock and pastoral area, including: a processor and a memory; wherein, the memory is used to store a computer program that can run on the processor; the processor is used to execute the program stored on the memory to implement the steps of the automatic inspection method for a livestock and pastoral area as mentioned in the first aspect.
[0015] The present invention has the following beneficial effects: First, edge detection is performed on the target image in the livestock pasture area to obtain the edges in the target image; then, the target clusters are determined based on the gray values of the pixel points in the target image, the gray values of the pixel points within the neighborhood range corresponding to each pixel point, and the edge pixel points on the edge, and the target clusters are denoted as livestock connected regions; secondly, the shriveling rate of the livestock connected region is determined according to the edge pixel points on the edge in the livestock connected region and the edge pixel points adjacent to the edge pixel points; further, the segmentation situation of the livestock connected region is determined according to the comparison pixel points of the edge pixel points in the livestock connected region, the edge pixel points adjacent to the edge pixel points, and the first quantity of the edge pixel points in the livestock connected region; and the abnormality degree of the livestock connected region is determined based on the shriveling rate and the segmentation situation of the livestock connected region, and the livestock connected regions with an abnormality degree greater than the first threshold are denoted as abnormal livestock connected regions; finally, the abnormal livestock are determined according to the positions of the abnormal livestock connected regions in the target image, and the abnormal livestock are inspected.
[0016] In this way, the embodiment of the present invention obtains the target image in the livestock pasture area, and segments the livestock connected regions of the livestock part in the target image by analyzing the gray values of the pixel points in the target image. The shriveling rate of the livestock connected region is obtained by analyzing the edge pixel points of the livestock connected region, and the segmentation situation of the livestock connected region is obtained according to the characteristics of the comparison pixel points outside the livestock connected region, so that the abnormality degree of the livestock connected region can be obtained and the abnormal livestock connected regions can be obtained. Finally, the abnormal livestock are determined based on the positions of the abnormal livestock connected regions in the target image and inspected. Therefore, the embodiment of the present invention calculates the segmentation situation of the livestock part and the background part in the image of the livestock pasture area, thereby determining the abnormality degree of the livestock connected region in combination with this segmentation situation, evaluating the degree of segmentation of the livestock part in the image of the livestock pasture area through the calculated segmentation situation, improving the accuracy of segmenting the livestock part in the image of the livestock pasture area, thereby accurately positioning the abnormal livestock in the livestock pasture area and improving the accuracy of health detection of the livestock. Description of the Drawings
[0017] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the following will briefly introduce the drawings required for use in the description of the embodiments or the prior art. Obviously, the following drawings are only some embodiments of the present invention. For those of ordinary skill in the art, without creative efforts, other drawings can also be obtained based on these drawings.
[0018] Figure 1 It is a flowchart of an automatic inspection method for a livestock pasture area provided by an embodiment of the present invention.
[0019] Figure 2 It is a schematic diagram of the morphology of a livestock connected region provided by an embodiment of the present invention.
[0020] Figure 3 A schematic structural diagram of an automatic inspection system for livestock and pastoral areas provided in accordance with another embodiment of the present invention. DETAILED DESCRIPTION
[0021] To further illustrate the technical means and effectiveness of the present invention to achieve its intended purpose, the following, in conjunction with the accompanying drawings and preferred embodiments, describes in detail the specific implementation, structure, features, and effectiveness of an automatic inspection method and system for livestock and pastoral areas proposed by the present invention. In the following description, different references to "one embodiment" or "another embodiment" do not necessarily refer to the same embodiment. Furthermore, specific features, structures, or characteristics of one or more embodiments may be combined in any suitable manner.
[0022] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0023] The following describes in detail a specific solution of an automatic inspection method for livestock and animal husbandry areas provided by the present invention in conjunction with the accompanying drawings.
[0024] Example 1:
[0025] See also Figure 1 , which shows a flow chart of an automatic inspection method for livestock and pastoral areas provided by one embodiment of the present invention, including:
[0026] S101, performing edge detection on a target image of a livestock breeding area to obtain edges in the target image.
[0027] Specifically, an embodiment of the present invention uses a drone to take aerial photos of a livestock area. First, a camera with an appropriate resolution is selected based on the size of the livestock area and mounted below the drone. The drone is then activated, set to an appropriate altitude and path, and images of the livestock area are captured. Images of the livestock area contain livestock as well as background information such as land and trees. Because livestock health analysis requires analysis solely of morphological characteristics and does not require a color space, the captured images of the livestock area are grayscaled to obtain a grayscale image of the area. In other words, the target image in the embodiment of the present invention is a grayscale image of the livestock area.
[0028] Furthermore, since the grayscale image of the livestock breeding area obtained in the above embodiment of the present invention contains many livestock and includes pasture grassland in the livestock breeding area, in order to identify the health status of the livestock, it is necessary to first obtain the livestock part. Therefore, the obtained grayscale image is first subjected to canny edge detection to obtain the edge in the target image.
[0029] S102. Determine a target cluster based on the gray values of each pixel point in the target image, the gray values of the pixel points within the neighborhood range corresponding to each pixel point, and the edge pixel points on the edge, and denote the target cluster as the livestock connected region.
[0030] Specifically, for several edges in the obtained target image, which include the texture edges in the livestock pastoral area and the edges of livestock, it is necessary to analyze the edges in the target image to obtain the livestock connected regions therein. Among them, the livestock part in the target image is the pasture grassland part. Since there is grass and soil in the pasture grassland part, the target image will be relatively rough. And because the fur on the surface of livestock is relatively dense, the gray value change within the livestock is not significant. Therefore, in the embodiment of the present invention, by analyzing the change of the gray values of the pixel points in the target image in combination with superpixel segmentation, the livestock part in the target image is segmented out.
[0031] Further, as an optional embodiment of the present invention, determining the target cluster based on the gray values of each pixel point in the target image, the gray values of the pixel points within the neighborhood range corresponding to each pixel point, and the edge pixel points on the edge includes: determining the difference coefficient of each pixel point based on the gray value of each pixel point in the target image and the gray values of the pixel points within the neighborhood range corresponding to each pixel point; determining the change factor of the pixel point according to the difference coefficient of the pixel point and the second number of edge pixel points included in the pixel block where the pixel point is located; clustering each pixel point based on the gray value and the change factor of each pixel point to obtain multiple clusters; selecting the target cluster from each cluster whose average change factor of the pixel points within the cluster is greater than the second threshold.
[0032] Specifically, in the embodiment of the present invention, an 8-neighborhood is constructed for each pixel point, and the difference coefficient of the pixel point is obtained through the gray value difference between the pixel point and the pixel points within its 8-neighborhood. Specifically, calculate the difference between the gray value of the pixel point and the gray value of each pixel point within its 8-neighborhood, and use this difference as the difference coefficient between the pixel point and each pixel point within its 8-neighborhood.
[0033] Further, as an optional embodiment of the present invention, determining the change factor of the pixel point according to the difference coefficient of the pixel point and the second number of edge pixel points included in the pixel block where the pixel point is located includes: calculating the average value of the difference coefficients of the pixel point and each pixel point within the corresponding neighborhood range, and the first product between the average value and the second number; performing normalization processing on the first product using a hyperbolic function to obtain the change factor of the pixel point.
[0034] Specifically, the embodiment of the present invention specifically uses the following formula to calculate the change factor of the pixel point:
[0035]
[0036] In the above formula, is the variation factor of the th pixel point. is the th pixel point and the difference coefficient between it and the th pixel point within its 8-neighborhood range. is the second quantity of edge pixel points included inside the 5×5 pixel block constructed with the th pixel point as the center. is a hyperbolic function, which is used to perform normalization processing.
[0037] Among them, for the average value of the difference coefficients of the pixel points in the 8-neighborhood of the pixel point, the larger its value indicates that the gray value difference of the pixel points around the pixel point is greater, and for the quantity of the edge pixel points in the 5×5 pixel block of the pixel point, the larger its value indicates that there is a large gradient in the surrounding area of the pixel point. Therefore, it indicates that the variation factor of the pixel point is larger, and it is positively correlated with.
[0038] Furthermore, according to the variation factors of the pixel points in the obtained target image, combined with the gray values of the pixel points, superpixel segmentation is performed, and several clusters of pixel points clustered according to the gray values and variation factors can be obtained. For the clusters in the clusters, select the clusters whose variation factors are greater than the second threshold, and record the selected several clusters as target clusters. Among them, the second threshold can be determined according to the actual situation, and the value in the embodiment of the present invention is 0.8.
[0039] S103. Determine the shriveling rate of the livestock connected domain according to the edge pixel points on the edge of the livestock connected domain and the edge pixel points adjacent to the edge pixel points.
[0040] Specifically, for the several livestock connected domains obtained in the above embodiments of the present invention, the health status of the livestock is obtained according to the characteristics of the livestock connected domain. Since the body shape of a normal and healthy livestock is normal and symmetrical, but if the livestock has an unhealthy condition such as a disease, the livestock will become emaciated, resulting in a shriveled shape of the livestock's body. Therefore, the health status of the livestock can be evaluated by evaluating the shapes of the several livestock connected domains obtained. However, since the difference between the livestock and the pasture background may be small during the segmentation of the livestock connected domain in the above embodiments, resulting in a poor segmentation effect on the livestock, it is necessary to evaluate from the segmentation situation of the livestock.
[0041] Furthermore, for the livestock connected regions obtained in the above embodiments of the present invention, since the body shapes of livestock with normal growth and good health conditions are uniform and plump, the performance of livestock in the target image under normal circumstances is composed of two nearly oval shapes, one large and one small, namely the head and the body. However, when livestock are diseased or in other situations, they will become emaciated, resulting in more obvious limbs and bones, and thus the body part of the livestock in the target image will show an inward depression. Since the several target clusters in the target image obtained in the above embodiments are connected regions, the shrivel rate of the livestock can be obtained by analyzing the shape of the livestock connected region. Exemplarily, as Figure 2 shown Figure 2 in, Figure 2 FIG. 1 is a schematic diagram of the shape of a livestock connected region provided by an embodiment of the present invention. In FIG. 1, there are two shapes of the livestock connected region, and both show an inward depression. It should be noted that, according to the actual situation, the shape of the livestock connected region can also be other shapes, and the embodiments of the present invention do not limit this here.
[0042] Furthermore, as an optional embodiment of the present invention, determining the shrivel rate of the livestock connected region according to the edge pixel points on the edge of the livestock connected region and the edge pixel points adjacent to the edge pixel points includes: determining the angle between the edge pixel points according to the edge pixel points in the livestock connected region and the pixel points adjacent to both sides of the edge pixel points; determining the depression degree of the edge pixel points according to the angle and a predetermined angle, and selecting the edge pixel points with a depression degree greater than a third threshold as the depressed pixel points; dividing the edge into two segments by the depressed pixel points on the edge of the livestock connected region, and denoting the longer edge as the torso edge; determining the depression rate of the torso edge according to a first depression degree, a second depression degree, an average depression degree, a third quantity, and a fourth quantity, where the first depression degree is the depression degree of any depressed pixel point on the torso edge, the second depression degree is the depression degree of the depressed pixel point closest to any depressed pixel point on the torso edge, the average depression degree is the average of the depression degrees of all pixel points between any depressed pixel point on the torso edge and the closest depressed pixel point, the third quantity is the number of all pixel points between any depressed pixel point on the torso edge and the closest depressed pixel point, and the fourth quantity is the number of depressed pixel points on the torso edge; fitting an ellipse to the torso edge by using the least squares method to obtain the loss value of the torso edge in the livestock connected region; and determining the shrivel rate of the livestock connected region according to the loss value of the torso edge in the livestock connected region and the depression rate of the torso edge.
[0043] Specifically, for the obtained livestock connected region in the embodiments of the present invention, in order to quantify the shriveling rate of livestock based on the depression condition of the edge of the livestock connected region, it is necessary to first obtain the inward depression condition of the pixel points on the edge of the livestock connected region. Therefore, in the embodiments of the present invention, for each pixel point on the edge of the livestock connected region, three adjacent edge pixel points on each of the left and right sides are obtained, and the angle located inside the livestock connected region between the two fitting lines between the edge pixel points on both sides and this edge pixel point is denoted as the included angle of this edge pixel point. Among them, the predetermined angle can be determined according to the actual situation, and the value in the embodiments of the present invention is 180 degrees.
[0044] Further, as an optional embodiment of the present invention, determining the depression degree of the edge pixel point according to the included angle and the predetermined included angle includes: calculating the first difference between the included angle and the predetermined included angle; performing normalization processing on the first difference by using a hyperbolic function to obtain the depression degree of the edge pixel point.
[0045] Specifically, the embodiments of the present invention specifically use the following formula to calculate the depression degree of the edge pixel point:
[0046]
[0047] In the above formula, is the depression degree of the th edge pixel point of the th livestock connected region. is the included angle of the th edge pixel point on the edge of the th livestock connected region. is a hyperbolic function, which is used to perform normalization processing on . The depression degree of the edge pixel point is obtained by analyzing the degree to which the included angle of the edge pixel point exceeds 180°.
[0048] Further, for the depression degree of each edge pixel point of the livestock connected region obtained through the above embodiments of the present invention, the depressed pixel points with a depression degree greater than the third threshold are selected from the edge pixel points. The third threshold can be determined according to the actual situation, and the embodiments of the present invention do not limit it here. Since the depressed part in the target image is not entirely caused by emaciation, there is also a depression caused by the connection part between the body and the head of the livestock. Therefore, any two depressed pixel points on the edge are selected, the edge of the livestock connected region is divided into two segments, the two segments of the edge are ellipse-fitted by using the least squares method, the two depressed pixel points with the minimum loss value are denoted as neck pixel points, and the longer segment of the edge is selected and denoted as the trunk edge. The shriveling rate of the livestock is obtained by analyzing the depression condition of the trunk edge.
[0049] Further, as an alternative embodiment of the present invention, determining the depression rate of the torso edge according to the first depression degree, the second depression degree, the average depression degree, the third quantity, and the fourth quantity includes: calculating a first sum value between the first depression degree and the second depression degree, and a first ratio between the first sum value and twice the average depression degree; calculating a second product between the first ratio and the reciprocal of the third quantity; adding the second products of each depressed pixel point to obtain a first added value, and calculating a second ratio between the first added value and the fourth quantity; and normalizing the second ratio using a hyperbolic function to obtain the depression rate of the torso edge.
[0050] Specifically, the embodiments of the present invention specifically use the following formula to calculate the depression rate of the torso edge:
[0051]
[0052] In the above formula, is the depression rate of the torso edge of the th livestock connected region. is an arbitrary depressed pixel point on the torso edge, is an arbitrary depressed pixel point on the torso edge and its nearest depressed pixel point. is the fourth quantity of the depressed pixel points on the torso edge. is the th depressed pixel point on the torso edge of the th livestock connected region, and its depression degree. is the th depressed pixel point on the torso edge of the th livestock connected region, and its depression degree. is the th livestock connected region, the average depression degree of all pixel points between the th depressed pixel point and its nearest depressed pixel point on the torso edge. is the th livestock connected region, the third quantity of all pixel points between the th depressed pixel point and its nearest depressed pixel point on the torso edge. is a hyperbolic function, which is used to normalize .
[0053] Among them, for the ratio of the depression degree between the depressed pixel point on the torso edge of the livestock connected region and its nearest depressed pixel point to the pixel points therebetween , the larger its value indicates the greater the gap between the depressed pixel points, so the greater the depression rate, and for the distance between the depressed pixel point and its nearest depressed pixel point, the smaller its value indicates the smaller the distance, so the faster the concave-convex change, and thus the greater the depression rate.
[0054] Further, as an alternative embodiment of the present invention, determining the shrivel rate of the livestock connected region according to the loss value of the torso edge and the depression rate of the torso edge in the livestock connected region includes: calculating a third product between the loss value of the torso edge and the depression rate of the torso edge; and normalizing the third product using a hyperbolic function to obtain the shrivel rate of the livestock connected region.
[0055] Specifically, the embodiment of the present invention specifically calculates the shrivel rate of the livestock connected region using the following formula:
[0056]
[0057] In the above formula, is the shrivel rate of the th livestock connected region. is the loss value of the least squares fitting ellipse of the torso edge in the th livestock connected region. is a hyperbolic function, which is used to normalize .. is the depression rate of the torso edge of the th livestock connected region. For the depression rate and loss value of the torso edge in the livestock connected region, the larger the value, the more depressions there are in the torso of the livestock, and according to the loss value, the lower the fullness of the torso. Therefore, the shrivel rate of the livestock connected region can be indicated.
[0058] S104. Determine the segmentation situation of the livestock connected region according to the comparison pixels of the edge pixels in the livestock connected region, the edge pixels adjacent to the edge pixels, and the first quantity of the edge pixels in the livestock connected region.
[0059] Specifically, for the shrivel rate of the livestock connected region obtained in the above embodiment of the present invention, since the obtained livestock connected region is obtained by superpixel segmentation, there may be a situation where the texture between some livestock and their background is relatively similar, resulting in a poor segmentation effect of the connected region, thus causing more depressions in the livestock connected region and leading to a deviation in the analysis of its shrivel rate. Therefore, the embodiment of the present invention obtains its segmentation loss by analyzing the peripheral region of the livestock connected region. For any edge pixel on the edge of the obtained livestock connected region, obtain the connection line between it and the centroid of the connected region, and record the pixel points outside the livestock connected region in the connection line as the comparison pixels of the edge pixel. By analyzing the gray value difference between the adjacent pixels of the edge pixel and it, and comparing the gray value difference between its comparison pixel and its adjacent pixel, when the gap between the gray value differences between the comparison pixel and the edge pixel is greater than 5, stop looking for comparison pixels for each edge pixel, and obtain several comparison pixels for each edge pixel.
[0060] Further, as an optional embodiment of the present invention, determining the segmentation situation of the livestock connected domain according to the comparison pixels of the edge pixels in the livestock connected domain, the edge pixels adjacent to the edge pixels, and the first quantity of the edge pixels in the livestock connected domain includes: obtaining the connection line between the edge pixels in the livestock connected domain and the centroid of the livestock connected domain, and marking the pixels located outside the livestock connected domain in the connection line as the comparison pixels of the edge pixels; determining the included angle of the edge pixels according to the edge pixels in the livestock connected domain and the pixels adjacent to both sides of the edge pixels; determining the depression degree of the edge pixels according to the included angle and the predetermined included angle; determining the segmentation situation of the livestock connected domain according to the fifth quantity of the comparison pixels of the edge pixels, the depression degree of the edge pixels, and the first quantity of the edge pixels in the livestock connected domain.
[0061] Further, as an optional embodiment of the present invention, determining the segmentation situation of the livestock connected domain according to the fifth quantity of the comparison pixels of the edge pixels, the depression degree of the edge pixels, and the first quantity of the edge pixels in the livestock connected domain includes: calculating the fourth product between the depression degree of each edge pixel and the fifth quantity of the comparison pixels of each edge pixel; adding up each fourth product to obtain a second addition value, and calculating the third ratio between the second addition value and the first quantity; performing normalization processing on the third ratio using the exponential function to obtain the segmentation situation of the livestock connected domain.
[0062] Specifically, the embodiment of the present invention specifically calculates the segmentation situation of the livestock connected domain using the following formula:
[0063]
[0064] In the above formula, represents the segmentation situation of the j-th livestock connected domain. is the first quantity of the edge pixels in the livestock connected domain. is the th comparison pixel fifth quantity of the th edge pixel on the edge of the j-th livestock connected domain, is the exponential function with the natural constant e as the base, which is used to perform inverse proportional normalization processing on is the th depression degree of the
[0065] Among them, by analyzing the number of comparison pixel points of the edge pixel points of the livestock connected region, since the comparison pixel points reflect the same change situation on both sides of the edge pixel points, the more edge pixel points indicate that there are more pixel points that are not segmented into the livestock connected region, and a weight is applied according to the depression degree of the edge pixel points, where the higher the depression degree, the more sensitive it is to the number of missing segmented pixel points. Thus, the segmentation situation of the livestock connected region can be obtained.
[0066] S105. Determine the abnormality degree of the livestock connected region based on the shrivel rate and segmentation situation of the livestock connected region, and mark the livestock connected region with an abnormality degree greater than the first threshold as an abnormal livestock connected region.
[0067] Specifically, in the embodiment of the present invention, the following formula is specifically used to calculate the abnormality degree of the livestock connected region:
[0068]
[0069] In the above formula, represents the abnormality degree of the j-th livestock connected region. is the shrivel rate of the j-th livestock connected region. represents the segmentation situation of the j-th livestock connected region.
[0070] Among them, for the shrivel rate and segmentation situation of the livestock connected region, since the higher the shrivel rate indicates the worse the growth situation of the livestock, but since the segmentation situation will affect the judgment of its abnormality degree, the weight of the corresponding abnormality degree of the livestock connected region with a poor segmentation situation is lower. Thus, the abnormality degree of the livestock connected region is obtained.
[0071] Furthermore, the first threshold can be determined according to the actual situation, and in the embodiment of the present invention, the value is 0.8. In the embodiment of the present invention, the livestock connected region with an abnormality degree greater than 0.8 is marked as an abnormal livestock connected region.
[0072] S106. Determine the abnormal livestock according to the position of the abnormal livestock connected region in the target image, and inspect the abnormal livestock.
[0073] Specifically, in the embodiment of the present invention, the livestock connected region in the target image is located according to its position to obtain the abnormal livestock, and the abnormal livestock is inspected to determine whether there are diseases or other situations to ensure its health status.
[0074] In an embodiment of the present invention, a target image of a livestock pasture area is obtained, and the livestock connected region of the livestock part in the target image is segmented by analyzing the gray values of the pixel points in the target image. The shrivel rate of the livestock connected region is obtained by analyzing the edge pixel points of the livestock connected region, and the segmentation situation of the livestock connected region is obtained according to the characteristics of the comparison pixel points outside the livestock connected region. Thus, the abnormal degree of the livestock connected region can be obtained and the abnormal livestock connected region can be acquired. Finally, abnormal livestock are determined and inspected based on the positions of the abnormal livestock connected regions in the target image. Therefore, in the embodiment of the present invention, the segmentation situation of the livestock part and the background part in the image of the livestock pasture area is calculated, so as to determine the abnormal degree of the livestock connected region in combination with this segmentation situation, and the degree of segmentation of the livestock part in the image of the livestock pasture area is evaluated through the calculated segmentation situation, improving the accuracy of segmenting the livestock part in the image of the livestock pasture area, thereby accurately positioning the abnormal livestock in the livestock pasture area and improving the accuracy of livestock health detection.
[0075] Embodiment 2:
[0076] Corresponding to the automatic inspection method for livestock pasture areas provided in the above embodiment, based on the same technical concept, an embodiment of the present invention further provides an automatic inspection system for livestock pasture areas. This automatic inspection system for livestock pasture areas is used to execute the above automatic inspection method for livestock pasture areas. Figure 3 As shown in the structural schematic diagram of an automatic inspection system for livestock pasture areas provided in another embodiment of the present invention. Figure 3 As shown. The automatic inspection system for livestock pasture areas may vary greatly due to configuration or performance differences, and may include one or more processors 301 and a memory 302. The memory 302 is used to store computer programs that can run on the processor 301. The processor 301 is used to execute the programs stored in the memory 302 to implement each step in the method embodiment above. Figure 1 Among them, the memory 302 can be short-term storage or persistent storage. The application programs stored in the memory 302 may include one or more modules (not shown in the figure), and each module may include a series of computer-executable instructions for the automatic inspection system for livestock pasture areas.
[0077] Furthermore, the processor 301 can be set to communicate with the memory 302 and execute a series of computer-executable instructions in the memory 302 on the automatic inspection system for livestock pasture areas. The automatic inspection system for livestock pasture areas may further include one or more power supplies 303, one or more wired or wireless network interfaces 304, one or more input / output interfaces 305, and one or more keyboards 306.
[0078] Specifically, in this embodiment, the automatic inspection system for the livestock and pastoral area includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete the communication with each other through the bus. The memory is used to store computer programs. The processor is used to execute the programs stored on the memory to implement the above Figure 1 steps in the method embodiments in the above, and has the beneficial effects of the above method embodiments. To avoid repetition, the embodiments of the present invention will not be elaborated herein.
[0079] It should be noted that the automatic inspection system for the livestock and pastoral area provided by the embodiments of the present invention and the automatic inspection method for the livestock and pastoral area provided by the embodiments of the present invention are based on the same application concept. Therefore, the specific implementation of this embodiment can refer to the implementation of the aforementioned automatic inspection method for the livestock and pastoral area, and has the same or similar beneficial effects. The repeated parts will not be elaborated.
[0080] It should be noted that the above sequence of the embodiments of the present invention is only for description and does not represent the superiority or inferiority of the embodiments. The processes depicted in the drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0081] Each embodiment in this specification is described in a progressive manner. The same or similar parts between the embodiments can be referred to each other. Each embodiment focuses on the differences from other embodiments.
Claims
1. An automatic inspection method for livestock pastures, characterized in that, The automatic inspection method for livestock pastures includes: Performing edge detection on the target image of the livestock pasture to obtain the edges in the target image; Determining a target cluster based on the gray values of each pixel point in the target image, the gray values of the pixel points within the neighborhood range corresponding to each of the pixel points, and the edge pixel points on the edge, and denoting the target cluster as the livestock connected domain; Determining the shriveling rate of the livestock connected domain according to the edge pixel points on the edge in the livestock connected domain and the edge pixel points adjacent to the edge pixel points; Determining the segmentation situation of the livestock connected domain according to the comparison pixel points of the edge pixel points in the livestock connected domain, the edge pixel points adjacent to the edge pixel points, and the first quantity of the edge pixel points in the livestock connected domain, where the first quantity is the number of edge pixel points in the livestock connected domain; Determining the degree of abnormality of the livestock connected domain based on the shriveling rate and the segmentation situation of the livestock connected domain, and denoting the livestock connected domain with the degree of abnormality greater than the first threshold as the abnormal livestock connected domain; Determining abnormal livestock according to the position of the abnormal livestock connected domain in the target image and inspecting the abnormal livestock; The determining the shriveling rate of the livestock connected domain according to the edge pixel points on the edge in the livestock connected domain and the edge pixel points adjacent to the edge pixel points includes: Determining the included angle of the edge pixel point according to the edge pixel points in the livestock connected domain and the pixel points adjacent to both sides of the edge pixel point; Determining the degree of depression of the edge pixel point according to the included angle and a predetermined included angle, and selecting the edge pixel points with the degree of depression greater than the third threshold as the depressed pixel points; Dividing the edge into two segments by the depressed pixel points on the edge in the livestock connected domain, and denoting the longer edge as the torso edge; Determining the depression rate of the torso edge according to the first depression degree, the second depression degree, the average depression degree, the third quantity, and the fourth quantity, where the first depression degree is the depression degree of any depressed pixel point on the torso edge, the second depression degree is the depression degree of the depressed pixel point closest to any depressed pixel point on the torso edge, the average depression degree is the average of the depression degrees of all pixel points between any depressed pixel point on the torso edge and the closest depressed pixel point, the third quantity is the number of all pixel points between any depressed pixel point on the torso edge and the closest depressed pixel point, and the fourth quantity is the number of depressed pixel points on the torso edge; Performing elliptical fitting on the torso edge using the least squares method to obtain the loss value of the torso edge in the livestock connected domain; Determining the shriveling rate of the livestock connected domain according to the loss value of the torso edge in the livestock connected domain and the depression rate of the torso edge.
2. The automatic inspection method for livestock pastures according to claim 1, wherein, The determining the target cluster based on the gray values of each pixel point in the target image, the gray values of the pixel points within the neighborhood range corresponding to each of the pixel points, and the edge pixel points on the edge includes: Determine the difference coefficient of each pixel point in the target image based on the gray value of each pixel point in the target image and the gray values of the pixel points within the neighborhood range corresponding to each pixel point; Determine the change factor of each pixel point according to the difference coefficient of the pixel point and the second quantity of edge pixel points included in the pixel block where the pixel point is located, where the second quantity is the number of edge pixel points included in the pixel block corresponding to the pixel point; Cluster each pixel point based on the gray value and change factor of each pixel point to obtain multiple clusters; Select a target cluster from each cluster where the average change factor of the pixel points within the cluster is greater than a second threshold.
3. The automatic inspection method for livestock pastures according to claim 2, characterized in that, The determining the change factor of the pixel point according to the difference coefficient of the pixel point and the second quantity of edge pixel points included in the pixel block where the pixel point is located includes: Calculate the average value of the difference coefficients of the pixel point and each pixel point within the corresponding neighborhood range, and the first product between the average value and the second quantity; Perform normalization processing on the first product using a hyperbolic function to obtain the change factor of the pixel point.
4. The automatic inspection method for livestock pastures according to claim 1, wherein, The determining the depression degree of the edge pixel point according to the included angle and a predetermined included angle includes: Calculate the angle difference between the included angle and the predetermined included angle as a first difference; Perform normalization processing on the first difference using a hyperbolic function to obtain the depression degree of the edge pixel point.
5. The automatic inspection method for livestock pastures according to claim 1, characterized in that The determining the depression rate of the torso edge according to the first depression degree, the second depression degree, the average depression degree, the third quantity, and the fourth quantity includes: Calculate the sum value between the first depression degree and the second depression degree as a first sum value, and the ratio between the first sum value and twice the average depression degree as a first ratio; Calculate the product value between the first ratio and the reciprocal of the third quantity as a second product; Add the second products of each depression pixel point to obtain a first addition value, and calculate the second ratio between the first addition value and the fourth quantity; Perform normalization processing on the second ratio using a hyperbolic function to obtain the depression rate of the torso edge.
6. The automatic inspection method for livestock pastures according to claim 1, wherein, The determining the shriveling rate of the livestock connected region according to the loss value of the torso edge in the livestock connected region and the depression rate of the torso edge includes: Calculate the product value between the loss value of the torso edge and the depression rate of the torso edge as a third product; Perform normalization processing on the third product using a hyperbolic function to obtain the shriveling rate of the livestock connected region.
7. The automatic inspection method for livestock pastures according to claim 1, characterized in that The determining the segmentation situation of the livestock connected region according to the comparison pixel points of the edge pixel points in the livestock connected region, the edge pixel points adjacent to the edge pixel points, and the first quantity of the edge pixel points in the livestock connected region includes: Obtain the connection line between the edge pixel points in the livestock connected region and the centroid of the livestock connected region, and record the pixel points located outside the livestock connected region in the connection line as the comparison pixel points of the edge pixel points; Determine the included angle of the edge pixel point according to the edge pixel points in the livestock connected region and the pixel points adjacent to both sides of the edge pixel point; Determine the depression degree of the edge pixel point according to the included angle and a predetermined included angle; Determine the segmentation situation of the livestock connected region according to the fifth quantity of the comparison pixels of the edge pixels, the depression degree of the edge pixels, and the first quantity of the edge pixels in the livestock connected region, where the fifth quantity is the quantity of the comparison pixels corresponding to the edge pixels.
8. The automatic inspection method for livestock pastures according to claim 7, characterized in that The determining the segmentation situation of the livestock connected region according to the fifth quantity of the comparison pixels of the edge pixels, the depression degree of the edge pixels, and the first quantity of the edge pixels in the livestock connected region includes: Calculate a fourth product between the depression degree of each of the edge pixels and the fifth quantity of the comparison pixels of each of the edge pixels; Add up each of the fourth products to obtain a second addition value, and calculate a third ratio between the second addition value and the first quantity; Use an exponential function to perform normalization processing on the third ratio to obtain the segmentation situation of the livestock connected region.
9. An automatic inspection system for livestock pastures, characterized in that, Including: A processor and a memory; wherein, the memory is used to store a computer program that can run on the processor; The processor is configured to execute the program stored on the memory to implement the steps of the automatic inspection method for livestock pastures as described in any one of claims 1-8.
Citation Information
Patent Citations
Method for detecting defects of filter screen of filter based on machine vision
CN115830022A
Visual-assisted detection method for health status of chicken large-scale breeding
CN119027984A