Automatic inspection method and system for animal husbandry and pasturing area
Through edge detection and cluster segmentation technology, the problem of difficulty in segmenting livestock and background in animal husbandry and pastoral images is solved, and the precise positioning of livestock in animal husbandry and pastoral areas is improved.
Patent Information
- Application Number
- CN202510480806.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2045-04-17
AI Technical Summary
In image processing in animal husbandry and pastoral areas, it is difficult to accurately segment the livestock part and background part, resulting in lower accuracy of health testing.
By performing edge detection of target images in animal husbandry and pastoral areas, target clusters are determined as livestock connectivity domains, and the degree of abnormality is evaluated based on the shriveling rate and segmentation, and abnormal livestock are located and inspected.
The segmentation accuracy of livestock parts in animal husbandry and pastoral images has been improved, and the accuracy of health detection has been accurately positioned.
Smart Images

Figure CN119992350A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to an automatic inspection method and system for livestock and animal husbandry areas. Background Art
[0002] Livestock pastoral areas refer to areas specifically used for grazing livestock. These areas are usually located in places with suitable natural conditions, such as grasslands, mountain meadows, etc. Livestock pastoral areas are mainly used to raise and manage livestock. Grasslands and mountain meadows usually have vast land and suitable environmental conditions to support the growth and reproduction of livestock. In livestock pastoral areas, livestock health monitoring is crucial to ensure the sustainable development of animal husbandry. Traditional health monitoring methods usually rely on the experience and regular visual inspections of veterinarians or herders. This method is not only time-consuming and labor-intensive, but also difficult to achieve comprehensive coverage of a large number of livestock, especially in vast grasslands and mountain meadow environments with complex terrain.
[0003] In some scenarios, in order to detect the health problems of livestock in animal husbandry areas, it is usually necessary to collect images of animal husbandry areas and segment the livestock in the images for health analysis. Since the livestock part and the background part in the images of animal husbandry areas are similar, it is difficult to accurately segment the livestock part in the images of animal husbandry areas, and thus it is difficult to accurately locate the livestock in the animal husbandry areas, resulting in low accuracy of livestock health detection. Summary of the invention
[0004] In order to solve the technical problem that the accuracy of livestock health detection is low due to the low segmentation accuracy of livestock parts in images, the purpose of the present invention is to provide an automatic inspection method and system for livestock pastoral areas. The technical solutions adopted are as follows: In a first aspect, an embodiment of the present invention provides an automatic inspection method for livestock and pastoral areas, comprising: performing edge detection on a target image of the livestock and pastoral area to obtain edges in the target image; determining a target cluster by the grayscale value of each pixel in the target image, the grayscale value of the pixel in the neighborhood corresponding to each pixel, and the edge pixel on the edge, and recording the target cluster as a livestock connected domain; determining a shrivelling rate of the livestock connected domain according to the edge pixel on the edge in the livestock connected domain and the edge pixel adjacent to the edge pixel; determining a segmentation condition of the livestock connected domain according to the comparison pixel of the edge pixel in the livestock connected domain, the edge pixel adjacent to the edge pixel, and a first number of edge pixels in the livestock connected domain; determining a degree of abnormality of the livestock connected domain based on the shrivelling rate and segmentation condition of the livestock connected domain, and recording a livestock connected domain with a degree of abnormality 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.
[0005] Optionally, determining the target cluster through the grayscale value of each pixel in the target image, the grayscale value of the pixels in the neighborhood corresponding to each pixel, and the edge pixels on the edge includes: determining the difference coefficient of each pixel through the grayscale value of each pixel in the target image and the grayscale value of the pixels in the neighborhood corresponding to each pixel; determining the change factor of the pixel according to the difference coefficient of the pixel and the second number of edge pixels included in the pixel block where the pixel is located; clustering each pixel based on the grayscale value and the change factor of each pixel to obtain multiple clusters; and selecting, from each cluster, a target cluster whose average change factor of each pixel in the cluster is greater than a second threshold.
[0006] Optionally, determining the change factor of a pixel point based on the difference coefficient of the pixel point and a second number of edge pixels in a pixel block where the pixel point is located includes: calculating an average value of the difference coefficient between the pixel point and each pixel point in a corresponding neighborhood, and a first product between the average value and the second number; and normalizing the first product using a hyperbolic function to obtain the change factor of the pixel point.
[0007] Optionally, determining the shriveling rate of the livestock connected domain based on edge pixel points on the edge of the livestock connected domain and edge pixel points adjacent to the edge pixel points includes: determining the angle of the edge pixel points based on the edge pixel points in the livestock connected domain and the pixel points adjacent to the edge pixel points on both sides; determining the degree of concavity of the edge pixel points based on the angle and a predetermined angle, and selecting edge pixel points with a concavity greater than a third threshold as concaved pixel points; dividing the edge into two sections based on the concaved pixel points on the edge of the livestock connected domain, and recording the longer edge as the trunk edge; determining the concavity rate of the trunk edge based on the first concavity degree, the second concavity degree, the average of the concavity degrees, the third quantity, and the fourth quantity, the first concavity degree being The concave degree of any concave pixel point on the edge of the trunk, the second concave degree is the concave degree of the concave pixel point closest to any concave pixel point on the edge of the trunk, the average concave degree is the average of the concave degrees of all pixels between any concave pixel point on the edge of the trunk and the nearest concave pixel point, the third number is the number of all pixels between any concave pixel point on the edge of the trunk and the nearest concave pixel point, and the fourth number is the number of concave pixels on the edge of the trunk; the trunk edge is ellipse-fitted using the least squares method to obtain the loss value of the trunk edge in the livestock connected domain; the shriveling rate of the livestock connected domain is determined based on the loss value of the trunk edge in the livestock connected domain and the concave rate of the trunk edge.
[0008] Optionally, determining the degree of depression of the edge pixel point according to the included angle and the predetermined included angle includes: calculating a first difference between the included angle and the predetermined angle; and normalizing the first difference using a hyperbolic function to obtain the degree of depression of the edge pixel point.
[0009] Optionally, determining the concavity rate of the trunk edge according to the first concavity degree, the second concavity degree, the mean concavity degree, the third quantity and the fourth quantity includes: calculating a first sum between the first concavity degree and the second concavity degree, and a first ratio between the first sum and twice the mean concavity degree; calculating a second product between the first ratio and the reciprocal of the third quantity; adding the second products of each concave 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 concavity rate of the trunk edge.
[0010] Optionally, determining the shrinkage rate of the livestock connected domain based on the loss value of the trunk edge and the depression rate of the trunk edge in the livestock connected domain includes: calculating the third product between the loss value of the trunk edge and the depression rate of the trunk edge; and normalizing the third product using a hyperbolic function to obtain the shrinkage rate of the livestock connected domain.
[0011] Optionally, determining the segmentation of the livestock connected domain based on comparison pixels of edge pixels in the livestock connected domain, edge pixels adjacent to the edge pixels, and a first number of edge pixels in the livestock connected domain includes: obtaining a line connecting the edge pixels in the livestock connected domain and the centroid of the livestock connected domain, and recording pixels in the line located outside the livestock connected domain as comparison pixels of the edge pixels; determining an angle of the edge pixels based on the edge pixels in the livestock connected domain and pixels adjacent to both sides of the edge pixels; determining a degree of depression of the edge pixels based on the angle and a predetermined angle; and determining the segmentation of the livestock connected domain based on a fifth number of comparison pixels of the edge pixels, the degree of depression of the edge pixels, and the first number of edge pixels in the livestock connected domain.
[0012] Optionally, determining the segmentation of the livestock connected domain based on the fifth number of comparison pixels of the edge pixels, the degree of depression of the edge pixels, and the first number of edge pixels in the livestock connected domain includes: calculating a fourth product between the degree of depression of each edge pixel and the fifth number of comparison pixels of each edge pixel; adding each fourth product to obtain a second added value, and calculating a third ratio between the second added value and the first number; and normalizing the third ratio using an exponential function to obtain the segmentation of the livestock connected domain.
[0013] In a second aspect, an embodiment of the present invention provides an automatic inspection system for livestock and pastoral areas, comprising: a processor and a memory; wherein the memory is used to store computer programs that can be run on the processor; the processor is used to execute the program stored in the memory to implement the steps of the automatic inspection method for livestock and pastoral areas as mentioned in the first aspect.
[0014] The present invention has the following beneficial effects: firstly, edge detection is performed on a target image of a livestock and animal husbandry area to obtain edges in the target image; then, a target cluster is determined by the grayscale value of each pixel in the target image, the grayscale value of the pixel in the neighborhood corresponding to each pixel, and the edge pixel on the edge, and the target cluster is recorded as a livestock connected domain; secondly, the shrivelling rate of the livestock connected domain is determined according to the edge pixel on the edge in the livestock connected domain and the edge pixel adjacent to the edge pixel; then, the segmentation of the livestock connected domain is determined according to the comparison pixel of the edge pixel in the livestock connected domain, the edge pixel adjacent to the edge pixel, and the first number of edge pixels in the livestock connected domain; and based on the shrivelling rate and segmentation of the livestock connected domain, the abnormality of the livestock connected domain is determined, and the livestock connected domain with an abnormality greater than a first threshold is recorded as an abnormal livestock connected domain; finally, abnormal livestock is determined according to the position of the abnormal livestock connected domain in the target image, and the abnormal livestock is inspected.
[0015] Thus, the embodiment of the present invention obtains the target image of the livestock area, and analyzes the gray value of the pixel points in the target image to segment the livestock connected domain of the livestock part in the target image. The shrinkage rate of the livestock connected domain is obtained by analyzing the edge pixel points of the livestock connected domain, and the segmentation of the livestock connected domain is obtained according to the characteristics of the comparison pixel points outside the livestock connected domain, thereby obtaining the abnormal degree of the livestock connected domain and obtaining the abnormal livestock connected domain. Finally, the abnormal livestock is determined based on the position of the abnormal livestock connected domain in the target image and inspected. Therefore, the embodiment of the present invention calculates the segmentation of the livestock part and the background part in the image of the livestock area, thereby determining the abnormal degree of the livestock connected domain in combination with the segmentation situation, and evaluating the degree of segmentation of the livestock part in the image of the livestock area through the calculated segmentation situation, thereby improving the accuracy of segmentation of the livestock part in the image of the livestock area, thereby accurately locating the abnormal livestock in the livestock area, and improving the accuracy of livestock health detection. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0017] Figure 1 A flow chart of an automatic inspection method for livestock pastures provided by one embodiment of the present invention.
[0018] Figure 2 A schematic diagram of the morphology of a livestock connectivity domain provided by an embodiment of the present invention.
[0019] Figure 3 A schematic structural diagram of an automatic inspection system for livestock and animal husbandry areas provided in another embodiment of the present invention. DETAILED DESCRIPTION
[0020] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the automatic inspection method and system for livestock and animal husbandry areas proposed by the present invention, its specific implementation method, structure, features and effects, in conjunction with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0021] 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.
[0022] The following is a detailed description of a specific scheme of an automatic inspection method for livestock and animal husbandry areas provided by the present invention in conjunction with the accompanying drawings.
[0023] Embodiment 1: See also Figure 1 , which shows a flow chart of an automatic inspection method for livestock and pastoral areas provided by an embodiment of the present invention, including: S101, performing edge detection on a target image of a livestock breeding area to obtain edges in the target image.
[0024] Specifically, the embodiment of the present invention uses a drone to take aerial photos of the livestock breeding area. First, a camera with a suitable resolution is selected according to the size of the livestock breeding area, and the camera is installed under the drone. The drone is started, and a suitable height and path are set for it to collect images of the livestock breeding area. The images of the livestock breeding area include livestock and backgrounds such as land and trees. Since the analysis of the health status of livestock only needs to be analyzed from its morphological characteristics and does not require a color space, the image obtained in the livestock breeding area is grayed to obtain a grayscale image in the livestock breeding area, that is, the target image in the embodiment of the present invention is a grayscale image of the livestock breeding area.
[0025] Furthermore, since the grayscale image of the livestock area obtained in the above embodiment of the present invention contains many livestock and includes pasture grassland in the livestock area, in order to identify the health status of the livestock, it is necessary to first obtain the livestock part. Therefore, canny edge detection is first performed on the obtained grayscale image to obtain the edge in the target image.
[0026] S102, determining a target cluster by the grayscale value of each pixel in the target image, the grayscale value of each pixel in the neighborhood corresponding to the pixel, and the edge pixel on the edge, and recording the target cluster as a livestock connected domain.
[0027] Specifically, for the several edges in the target image, which include the texture edges in the animal husbandry area and the edges of the livestock, it is necessary to analyze the edges in the target image to obtain the livestock connected domain. 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 since the fur on the surface of the livestock is relatively dense, the grayscale value inside the livestock does not change much. Therefore, the embodiment of the present invention analyzes the change of the grayscale value of the pixel points in the target image and combines superpixel segmentation to segment the livestock part in the target image.
[0028] Further, as an optional embodiment of the present invention, determining the target cluster through the grayscale value of each pixel in the target image, the grayscale value of the pixel in the neighborhood corresponding to each pixel, and the edge pixel on the edge includes: determining the difference coefficient of each pixel through the grayscale value of each pixel in the target image and the grayscale value of the pixel in the neighborhood corresponding to each pixel; determining the change factor of the pixel according to the difference coefficient of the pixel and the second number of edge pixels included in the pixel block where the pixel is located; clustering each pixel based on the grayscale value and the change factor of each pixel to obtain multiple clusters; and selecting, from each cluster, a target cluster whose average change factor of each pixel in the cluster is greater than a second threshold.
[0029] Specifically, the embodiment of the present invention constructs an 8-neighborhood for each pixel point, and obtains the difference coefficient of the pixel point by the grayscale value difference between the pixel point and the pixels in its 8-neighborhood. Specifically, the difference between the grayscale value of the pixel point and the grayscale value of each pixel point in its 8-neighborhood is calculated, and the difference is used as the difference coefficient between the pixel point and each pixel point in its 8-neighborhood.
[0030] Further, as an optional embodiment of the present invention, determining the change factor of a pixel point based on the difference coefficient of the pixel point and a second number of edge pixels in a pixel block where the pixel point is located includes: calculating the average value of the difference coefficient between the pixel point and each pixel point in the corresponding neighborhood range, and a first product between the average value and the second number; normalizing the first product using a hyperbolic function to obtain the change factor of the pixel point.
[0031] Specifically, the embodiment of the present invention specifically uses the following formula to calculate the change factor of the pixel: In the above formula, It is The change factor of each pixel. It is A pixel and its 8 neighbors The coefficient of difference between pixels. So The second number of edge pixels included in the interior of the 5×5 pixel block is constructed with the pixel points as the center. is a hyperbolic function, which is used to Perform normalization.
[0032] Among them, the mean difference coefficient of the pixel points in the 8 neighborhoods of the pixel point is , the larger the value, the greater the difference in grayscale values of the pixels around the pixel point, and the number of edge pixels in the 5×5 pixel block of the pixel point The larger the value, the greater the gradient in the surrounding area of the pixel point, so the larger the change factor of the pixel point. There is a positive correlation.
[0033] Furthermore, according to the variation factor of the pixel points in the acquired target image, superpixel segmentation is performed in combination with the gray value of the pixel points, and clusters of several pixel points clustered according to the gray value and the variation factor can be obtained. For the clusters selected from the clusters whose variation factor is greater than the second threshold, the selected clusters are recorded as target clusters. The second threshold can be determined according to actual conditions, and in the embodiment of the present invention, the value is 0.8.
[0034] S103, determining the desiccation rate of the livestock connected domain according to edge pixels on the edge of the livestock connected domain and edge pixels adjacent to the edge pixels.
[0035] Specifically, for the several livestock connected domains obtained in the above embodiment of the present invention, the health status of the livestock is obtained according to the characteristics of the livestock connected domains. Since the body shape of 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, so that the body shape of the livestock will appear shriveled. Therefore, the health status of the livestock can be evaluated by evaluating the shape of the several livestock connected domains obtained. However, since the above embodiment may not achieve a good segmentation effect on the livestock due to the small difference between the livestock and the pasture background when segmenting the livestock connected domain, it is necessary to evaluate the segmentation of the livestock.
[0036] Furthermore, for the livestock connected domains obtained by the above embodiments of the present invention, since the bodies of normally growing and healthy livestock are uniform and full, the livestock under normal circumstances appear in the target image as a combination of two nearly elliptical shapes, a head and a body, which are one large and one small; but when livestock have diseases or other conditions, they will become thin, and the limbs and bones of the livestock will be more obvious, which will cause the body of the livestock to appear concave inward in the target image. Since the several targets in the target image obtained by the above embodiments are clustered into connected domains, their shriveling rate can be obtained by analyzing the morphology of the livestock connected domains. For example, Figure 2 As shown, Figure 2 A schematic diagram of a livestock connectivity domain provided by an embodiment of the present invention is shown in FIG. Figure 2 In the embodiment, the livestock connected domain has two forms, and both are inwardly concave. It is worth noting that, according to actual conditions, the livestock connected domain can also be in other shapes, which is not limited in the embodiment of the present invention.
[0037] Further, as an optional embodiment of the present invention, determining the shriveling rate of the livestock connected domain based on edge pixel points on the edge of the livestock connected domain and edge pixel points adjacent to the edge pixel points includes: determining the angle of the edge pixel points based on the edge pixel points in the livestock connected domain and the pixel points adjacent to the edge pixel points on both sides; determining the degree of concavity of the edge pixel points based on the angle and the predetermined angle, and selecting the edge pixel points with a concavity greater than a third threshold as the concavity pixel points; dividing the edge into two sections through the concavity pixel points on the edge of the livestock connected domain, and recording the longer edge as the trunk edge; determining the concavity rate of the trunk edge based on the first concavity degree, the second concavity degree, the average of the concavity degrees, the third number, and the fourth number , the first concave degree is the concave degree of any concave pixel point on the edge of the trunk, the second concave degree is the concave degree of the concave pixel point closest to any concave pixel point on the edge of the trunk, the average concave degree is the average of the concave degrees of all pixels between any concave pixel point on the edge of the trunk and the nearest concave pixel point, the third number is the number of all pixels between any concave pixel point on the edge of the trunk and the nearest concave pixel point, and the fourth number is the number of concave pixels on the edge of the trunk; the trunk edge is ellipse-fitted using the least squares method to obtain the loss value of the trunk edge in the livestock connected domain; the shriveling rate of the livestock connected domain is determined according to the loss value of the trunk edge in the livestock connected domain and the concave rate of the trunk edge.
[0038] Specifically, in order to quantify the shrunken rate of livestock according to the concave condition of the edge of the livestock connected domain, the embodiment of the present invention needs to first obtain the inward concave condition of the edge pixel points of the livestock connected domain. Therefore, the embodiment of the present invention obtains three edge pixel points on both sides of the edge pixel points of each livestock connected domain, and the angle between the edge pixel points on both sides and the two fitting straight lines between the edge pixel points and the edge pixel points located inside the livestock connected domain is recorded as the angle of the edge pixel point. Among them, the predetermined angle can be determined according to the actual situation, and the value in the embodiment of the present invention is 180 degrees.
[0039] Further, as an optional embodiment of the present invention, determining the degree of depression of the edge pixel point based on the angle and the predetermined angle includes: calculating a first difference between the angle and the predetermined angle; normalizing the first difference using a hyperbolic function to obtain the degree of depression of the edge pixel point.
[0040] Specifically, the embodiment of the present invention specifically uses the following formula to calculate the concavity of edge pixels: In the above formula, For the Livestock Connectivity Domain The concavity of the edge pixel. It is The edge of the livestock connected domain The angle between the edge pixels. is a hyperbolic function, which is used to Normalization is performed and the degree of concavity of edge pixels is obtained by analyzing the degree to which the angle of edge pixels exceeds 180°.
[0041] Furthermore, the present invention obtains the degree of concavity of each edge pixel point of the connected domain of the livestock through the above embodiment, and selects the concavity pixel points whose degree of concavity is greater than the third threshold value among the edge pixel points. The third threshold value can be determined according to the actual situation, and the embodiment of the present invention does not limit it here. Since the concavity in the target image is not entirely caused by emaciation, and there is also concavity caused by the connection between the body and the head of the livestock, two concavity pixel points in the edge are arbitrarily selected, and the edge of the connected domain of the livestock is divided into two segments. The two segments of the edge are ellipse-fitted using the least squares method, and the two concavity pixel points with the smallest loss value are obtained and recorded as the neck pixel points. The longer edge segment is selected and recorded as the trunk edge. The livestock's shrunken rate is obtained by analyzing the concavity condition of the trunk edge.
[0042] Further, as an optional embodiment of the present invention, determining the concavity rate of the trunk edge according to the first concavity degree, the second concavity degree, the concavity degree average, the third quantity and the fourth quantity includes: calculating a first sum between the first concavity degree and the second concavity degree, and a first ratio between the first sum and twice the average of the concavity degrees; calculating a second product between the first ratio and the reciprocal of the third quantity; adding the second products of each concave 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 concavity rate of the trunk edge.
[0043] Specifically, the embodiment of the present invention specifically uses the following formula to calculate the concavity rate of the trunk edge: In the above formula, It is The concavity rate of the trunk edge of the connected domain of livestock. is any concave pixel on the edge of the torso, It is the distance between any concave pixel on the edge of the torso and its nearest concave pixel. Is the fourth number of concave pixels on the edge of the torso. It is The first The degree of depression of a concave pixel. It is The first The degree of depression of a concave pixel. It is The first The average of the concavity degrees of all pixels between a concave pixel and its nearest concave pixel. It is The first The third number of all pixels between a concave pixel and the nearest concave pixel. is a hyperbolic function, which is used to Perform normalization.
[0044] Among them, the ratio of the concave pixel point on the trunk edge of the livestock connected area to the concave pixel point closest to it and the pixel point between them is The larger the value, the greater the gap between the concave pixels, so the greater the concave rate, and the smaller the distance between the concave pixel and the nearest concave pixel, the smaller the distance, so the faster the concave change, so the greater the concave rate.
[0045] Furthermore, as an optional embodiment of the present invention, determining the shrinkage rate of the livestock connected domain based on the loss value of the trunk edge and the depression rate of the trunk edge in the livestock connected domain includes: calculating the third product between the loss value of the trunk edge and the depression rate of the trunk edge; normalizing the third product using a hyperbolic function to obtain the shrinkage rate of the livestock connected domain.
[0046] Specifically, the embodiment of the present invention specifically uses the following formula to calculate the dryness rate of the livestock connected domain: In the above formula, It is The dryness rate of livestock connected areas. It is The loss value of the least squares fitting ellipse of the trunk edge in the connected domain of livestock. is a hyperbolic function, which is used to Perform normalization. It is The concavity rate of the trunk edge of the connected domain of livestock. The larger the concavity rate and loss value of the trunk edge in the connected domain of livestock, the more concavities there are in the trunk of the livestock, and the lower the fullness of the trunk according to the loss value, so it can indicate the shriveling rate of the connected domain of livestock.
[0047] S104, determining the segmentation status 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 number of the edge pixel points in the livestock connected domain.
[0048] Specifically, for the desiccation rate of the livestock connected domain obtained by the above embodiment of the present invention, since the livestock connected domain is obtained based on superpixel segmentation, there may be some livestock and their backgrounds with similar textures, resulting in poor effect of connected domain segmentation, which leads to more depressions in the livestock connected domain, resulting in deviation in the desiccation rate analysis. Therefore, the embodiment of the present invention obtains its segmentation loss by analyzing the peripheral area of the livestock connected domain. For any edge pixel point on the edge of the obtained livestock connected domain, the line between it and the centroid of the connected domain is obtained, and the pixel point located outside the livestock connected domain in the line is recorded as the comparison pixel point of the edge pixel point. By analyzing the gray value difference between the adjacent pixel points of the edge pixel point and the gray value difference between the comparison pixel point and its adjacent pixel points, when the difference between the gray value difference between the comparison pixel point and the edge pixel point is greater than 5, stop looking for comparison pixels for each edge pixel point, and obtain a number of comparison pixels for each edge pixel point.
[0049] Further, as an optional embodiment of the present invention, determining the segmentation 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 number of edge pixels in the livestock connected domain includes: obtaining a line connecting the edge pixels in the livestock connected domain and the centroid of the livestock connected domain, and recording the pixels in the line located outside the livestock connected domain as comparison pixels of the edge pixels; determining the angle of the edge pixels according to the edge pixels in the livestock connected domain and the pixels adjacent to the edge pixels on both sides; determining the degree of depression of the edge pixels according to the angle and the predetermined angle; determining the segmentation of the livestock connected domain according to the fifth number of comparison pixels of the edge pixels, the degree of depression of the edge pixels, and the first number of edge pixels in the livestock connected domain.
[0050] Further, as an optional embodiment of the present invention, determining the segmentation of the livestock connected domain based on the fifth number of comparison pixels of the edge pixels, the degree of depression of the edge pixels, and the first number of edge pixels in the livestock connected domain includes: calculating the fourth product between the degree of depression of each edge pixel and the fifth number of comparison pixels of each edge pixel; adding each fourth product to obtain a second added value, and calculating a third ratio between the second added value and the first number; and normalizing the third ratio using an exponential function to obtain the segmentation of the livestock connected domain.
[0051] Specifically, the embodiment of the present invention specifically uses the following formula to calculate the segmentation of the livestock connected domain: In the above formula, Represents the segmentation of the jth livestock connected domain. It is the first number of edge pixels of the livestock connected domain. It is The edge of the livestock connected domain The fifth number of comparison pixels of edge pixels, is an exponential function with the natural constant e as its base, which is used to Perform inverse proportional normalization. For the Livestock Connectivity Domain The concavity of the edge pixel.
[0052] Among them, by analyzing the number of comparison pixels of the edge pixels of the livestock connected domain, since the comparison pixels reflect the same changes on both sides of the edge pixels, the more edge pixels there are, the more pixels are not segmented into the livestock connected domain, and the weighting is performed according to the degree of concavity of the edge pixels. The higher the degree of concavity, the more sensitive it is to the number of missing segmentation pixels, thereby obtaining the segmentation of the livestock connected domain.
[0053] S105, determining the abnormality of the livestock connected domain based on the shrivelling rate and segmentation status of the livestock connected domain, and recording the livestock connected domain with an abnormality greater than a first threshold as an abnormal livestock connected domain.
[0054] Specifically, the embodiment of the present invention specifically uses the following formula to calculate the abnormality degree of the livestock connectivity domain: In the above formula, Indicates the abnormality degree of the jth livestock connected domain. It is The dryness rate of livestock connected areas. Represents the segmentation of the jth livestock connected domain.
[0055] Among them, the shrinkage rate and segmentation condition of the livestock connected domain, where the higher the shrinkage rate indicates the worse the growth of the livestock, but the segmentation condition will affect the judgment of its abnormality, the corresponding abnormality weight of the livestock connected domain with poor segmentation is lower, thereby obtaining the abnormality degree of the livestock connected domain.
[0056] Furthermore, the first threshold can be determined according to actual conditions, and in the embodiment of the present invention, the value is 0.8. In the embodiment of the present invention, the livestock connected domain with an abnormality greater than 0.8 is recorded as an abnormal livestock connected domain.
[0057] S106, determining abnormal livestock according to the position of the abnormal livestock connected domain in the target image, and inspecting the abnormal livestock.
[0058] Specifically, the embodiment of the present invention locates the livestock connected domain in the target image according to its position to obtain abnormal livestock therein, inspects the abnormal livestock, determines whether it has diseases, etc., and ensures its health.
[0059] The embodiment of the present invention obtains a target image of a livestock breeding area, and analyzes the grayscale values of pixels in the target image to segment the livestock connected domain of the livestock part in the target image. The shrivelling rate of the livestock connected domain is obtained by analyzing the edge pixels of the livestock connected domain, and the segmentation of the livestock connected domain is obtained according to the characteristics of the comparison pixels outside the livestock connected domain, thereby obtaining the abnormal degree of the livestock connected domain and obtaining the abnormal livestock connected domain. Finally, based on the position of the abnormal livestock connected domain in the target image, the abnormal livestock is determined and inspected. Therefore, the embodiment of the present invention calculates the segmentation of the livestock part and the background part in the image of the livestock breeding area, thereby determining the abnormal degree of the livestock connected domain in combination with the segmentation, and evaluating the degree of segmentation of the livestock part in the image of the livestock breeding area through the calculated segmentation, thereby improving the accuracy of segmentation of the livestock part in the image of the livestock breeding area, thereby accurately locating the abnormal livestock in the livestock breeding area, and improving the accuracy of livestock health detection.
[0060] Embodiment 2: Corresponding to the automatic inspection method for animal husbandry 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 animal husbandry areas, the automatic inspection system for animal husbandry areas is used to execute the automatic inspection method for animal husbandry areas, Figure 3 A schematic diagram of the structure of an automatic inspection system for livestock and animal husbandry areas provided by another embodiment of the present invention is shown in FIG. Figure 3 The automatic inspection system for livestock and animal husbandry areas may have relatively large differences due to different configurations or performances, and may include one or more processors 301 and memory 302, the memory 302 is used to store computer programs that can be run on the processor 301, and the processor 301 is used to execute the program stored in the memory 302 to achieve the above Figure 1 The memory 302 may be a temporary storage or a permanent storage. The application stored in the memory 302 may include one or more modules (not shown in the figure), each of which may include a series of computer executable instructions for the automatic inspection system for livestock and pastoral areas.
[0061] Furthermore, the processor 301 can be configured to communicate with the memory 302 to execute a series of computer executable instructions in the memory 302 on the automatic inspection system for livestock and pasture areas. The automatic inspection system for livestock and pasture areas can also include one or more power supplies 303, one or more wired or wireless network interfaces 304, one or more input and output interfaces 305, and one or more keyboards 306.
[0062] Specifically in this embodiment, the automatic inspection system for animal husbandry areas includes a processor, a communication interface, a memory and a communication bus; wherein the processor, the communication interface and the memory communicate with each other through the bus; the memory is used to store computer programs; the processor is used to execute the programs stored in the memory to achieve the above Figure 1 The various steps in the method embodiment are similar to those in the method embodiment, and have the beneficial effects of the above method embodiments. To avoid repetition, the embodiments of the present invention will not be described in detail here.
[0063] It should be noted that the automatic inspection system for livestock and animal husbandry areas provided by the embodiment of the present invention and the automatic inspection method for livestock and animal husbandry areas provided by the embodiment 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 livestock and animal husbandry areas, and has the same or similar beneficial effects, and the repeated parts will not be repeated.
[0064] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying 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.
[0065] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
Claims
1. An automatic inspection method for livestock and animal husbandry areas, characterized in that: The automatic inspection method for animal husbandry areas comprises: Performing edge detection on a target image of a livestock and animal husbandry area to obtain edges in the target image; Determine a target cluster by using the grayscale value of each pixel in the target image, the grayscale value of each pixel in the neighborhood corresponding to the pixel, and the edge pixel on the edge, and record the target cluster as a livestock connected domain; Determine the desiccation rate of the livestock connected domain according to edge pixel points on the edge of the livestock connected domain and edge pixel points adjacent to the edge pixel points; Determine the segmentation 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 number of the edge pixel points in the livestock connected domain, wherein the first number is the number of the edge pixel points in the livestock connected domain; Determine the abnormality of the livestock connected domain based on the shrivelling rate and segmentation condition of the livestock connected domain, and record the livestock connected domain with the abnormality greater than a first threshold as an abnormal livestock connected domain; The abnormal livestock is determined according to the position of the abnormal livestock connected domain in the target image, and the abnormal livestock is inspected.
2. The automatic inspection method for livestock and animal husbandry areas according to claim 1, characterized in that: Determining the target cluster by the grayscale value of each pixel in the target image, the grayscale value of the pixel in the neighborhood corresponding to each pixel, and the edge pixel on the edge includes: Determine the difference coefficient of each pixel point by using the grayscale value of each pixel point in the target image and the grayscale value of each pixel point in the neighborhood range corresponding to each pixel point; Determine a variation factor of the pixel point according to a difference coefficient of the pixel point and a second number of edge pixels in a pixel block where the pixel point is located, wherein the second number is the number of edge pixels in the pixel block where the corresponding pixel point is located; Clustering each of the pixel points based on the grayscale value and the variation factor of each of the pixel points to obtain a plurality of clusters; A target cluster is selected from each of the clusters, wherein the average change factor of each pixel point in the cluster is greater than a second threshold.
3. The automatic inspection method for livestock and animal husbandry areas according to claim 2 is characterized in that: The step of determining the variation factor of the pixel point according to the difference coefficient of the pixel point and the second number of edge pixels in the pixel block where the pixel point is located comprises: Calculate an average value of difference coefficients between the pixel point and each pixel point in a corresponding neighborhood range, and a first product between the average value and the second number; The first product is normalized using a hyperbolic function to obtain a change factor of the pixel.
4. The automatic inspection method for livestock and animal husbandry areas according to claim 1, characterized in that: The step of determining the desiccation rate of the livestock connected domain according to edge pixels on the edge of the livestock connected domain and edge pixels adjacent to the edge pixels comprises: Determine the angle of the edge pixel point according to the edge pixel point in the livestock connected domain and the pixel points adjacent to both sides of the edge pixel point; Determine the degree of depression of the edge pixel point according to the included angle and the predetermined included angle, and select the edge pixel point whose depression degree is greater than a third threshold as a depressed pixel point; Dividing the edge into two segments according to the concave pixel points of the edge in the livestock connected domain, and recording the longer edge as the trunk edge; The concavity rate of the trunk edge is determined according to a first concavity degree, a second concavity degree, an average of the concavity degrees, a third number and a fourth number, wherein the first concavity degree is the concavity degree of any concavity pixel point on the trunk edge, the second concavity degree is the concavity degree of the concavity pixel point closest to any concavity pixel point on the trunk edge, the average of the concavity degree is the average of the concavity degrees of all pixel points between any concavity pixel point on the trunk edge and the nearest concavity pixel point, the third number is the number of all pixel points between any concavity pixel point on the trunk edge and the nearest concavity pixel point, and the fourth number is the number of concavity pixel points on the trunk edge; Using the least square method to perform ellipse fitting on the trunk edge, and obtain the loss value of the trunk edge in the livestock connected domain; The shrinkage rate of the livestock connected domain is determined according to the loss value of the trunk edge and the concavity rate of the trunk edge in the livestock connected domain.
5. The automatic inspection method for animal husbandry areas according to claim 4 is characterized in that: Determining the degree of depression of the edge pixel point according to the angle and the predetermined angle includes: Calculating an angle difference between the included angle and the predetermined included angle as a first difference; The first difference is normalized using a hyperbolic function to obtain the degree of depression of the edge pixel.
6. The automatic inspection method for animal husbandry areas according to claim 4 is characterized in that: The step of determining the concavity rate of the trunk edge according to the first concavity degree, the second concavity degree, the average of the concavity degrees, the third quantity and the fourth quantity comprises: Calculating a sum of the first concavity degree and the second concavity degree as a first sum, and calculating a ratio of the first sum to twice the average of the concavity degrees as a first ratio; Calculate the product value between the first ratio and the reciprocal of the third quantity as a second product; Adding the second products of the concave pixel points to obtain a first added value, and calculating a second ratio between the first added value and the fourth number; The second ratio is normalized by using a hyperbolic function to obtain the concavity rate of the trunk edge.
7. The automatic inspection method for animal husbandry areas according to claim 4, characterized in that: The step of determining the shrinkage rate of the livestock connected domain according to the loss value of the trunk edge and the concavity rate of the trunk edge in the livestock connected domain comprises: Calculate the product value between the loss value of the trunk edge and the concavity rate of the trunk edge as a third product; The third product is normalized using a hyperbolic function to obtain the desiccation rate of the livestock connected domain.
8. The automatic inspection method for animal husbandry areas according to claim 1, characterized in that: The determining of the segmentation 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 number of the edge pixel points in the livestock connected domain comprises: Obtaining a line connecting an edge pixel point in the livestock connected domain and the centroid of the livestock connected domain, and recording pixel points in the line located outside the livestock connected domain as comparison pixel points of the edge pixel points; Determine the angle of the edge pixel point according to the edge pixel point 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 angle and a predetermined angle; The segmentation of the livestock connected domain is determined according to the fifth number of comparison pixels of the edge pixel points, the depression degree of the edge pixel points and the first number of edge pixels in the livestock connected domain, wherein the fifth number is the number of comparison pixels corresponding to the edge pixel points.
9. The automatic inspection method for animal husbandry areas according to claim 8, characterized in that: The determining of the segmentation of the livestock connected domain according to the fifth number of comparison pixels of the edge pixels, the depression degree of the edge pixels, and the first number of edge pixels in the livestock connected domain comprises: Calculating a fourth product between the degree of concavity of each edge pixel point and the fifth number of comparison pixels of each edge pixel point; adding the fourth products to obtain a second added value, and calculating a third ratio between the second added value and the first number; The third ratio is normalized using an exponential function to obtain the segmentation of the livestock connected domain.
10. An automatic inspection system for livestock and animal husbandry areas, characterized in that: include: A processor and a memory; wherein the memory is used to store a computer program that can be run on the processor; A processor is used to execute the program stored in the memory to implement the steps of the automatic inspection method for livestock and pastoral areas as described in any one of claims 1 to 9.
Citation Information
Patent Citations
Animal husbandry health monitoring method and system based on artificial intelligence
CN114638536A
Method for detecting defects of filter screen of filter based on machine vision
CN115830022A
Broiler chicken breeding health state detection method based on artificial intelligence
CN116912260A
Cow abnormal behavior detection method based on remote monitoring
CN117831136A
Livestock posture measuring method and device for livestock detection
CN118864908A