CN113505795A - Method and system for detecting diarrhea of herd of pigs - Google Patents

Method and system for detecting diarrhea of herd of pigs Download PDF

Info

Publication number
CN113505795A
CN113505795A CN202110806680.6A CN202110806680A CN113505795A CN 113505795 A CN113505795 A CN 113505795A CN 202110806680 A CN202110806680 A CN 202110806680A CN 113505795 A CN113505795 A CN 113505795A
Authority
CN
China
Prior art keywords
image
diarrhea
inspection image
floor
pig farm
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110806680.6A
Other languages
Chinese (zh)
Inventor
张玉良
黄魏
黄煜
尤园
李攀鹏
彭佳勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Henan Muyuan Intelligent Technology Co Ltd
Original Assignee
Henan Muyuan Intelligent Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Henan Muyuan Intelligent Technology Co Ltd filed Critical Henan Muyuan Intelligent Technology Co Ltd
Priority to CN202110806680.6A priority Critical patent/CN113505795A/en
Publication of CN113505795A publication Critical patent/CN113505795A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/21Design or setup of recognition systems or techniques; Extraction of features in feature space; Blind source separation
    • G06F18/214Generating training patterns; Bootstrap methods, e.g. bagging or boosting
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/24Classification techniques
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06NCOMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
    • G06N3/00Computing arrangements based on biological models
    • G06N3/02Neural networks
    • G06N3/04Architecture, e.g. interconnection topology
    • G06N3/045Combinations of networks

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Physics & Mathematics (AREA)
  • Evolutionary Computation (AREA)
  • Artificial Intelligence (AREA)
  • General Engineering & Computer Science (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • General Physics & Mathematics (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Biology (AREA)
  • General Health & Medical Sciences (AREA)
  • Computing Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • Molecular Biology (AREA)
  • Computational Linguistics (AREA)
  • Biophysics (AREA)
  • Biomedical Technology (AREA)
  • Health & Medical Sciences (AREA)
  • Image Analysis (AREA)

Abstract

The invention discloses a method and a system for detecting diarrhea in a swinery, wherein the method comprises the steps of S1, acquiring a pig farm inspection image, and removing abnormal, fuzzy, foggy and angle-abnormal images in the pig farm inspection image to obtain a normal inspection image; s2, extracting a floor foreground image from the normal inspection image according to an example segmentation model; s3, inputting the floor foreground image into an image classification model, and judging whether diarrhea exists in the floor foreground image; if so, S4, a diarrhea warning message is sent to the breeder or veterinarian. After the images which do not meet the standard are removed, the floor foreground images are extracted through the example segmentation model, and then diarrhea early warning information is sent after the diarrhea is judged through the image classification model, so that automatic detection is realized, the detection efficiency is improved, the labor intensity is reduced, and the safety and the reliability of cultivation are improved.

Description

Method and system for detecting diarrhea of herd of pigs
Technical Field
The invention relates to the technical field of breeding, in particular to a method and a system for detecting diarrhea of a swinery.
Background
China is the first major country for pork production and consumption in the world, the pork yield accounts for more than half of the world, the pork consumption is several times of that of other countries in the world, and the development of the pig raising industry directly influences the improvement of national economy and the living standard of people.
At present, the pig raising mode in China gradually develops from a small scattered family scattered raising mode to a centralized, intensive, specialized and industrialized modern breeding mode. With the increasing degree of pig raising centralization, people must pay more attention to the health condition of a swinery, and the disease condition can be rapidly spread in the swinery due to slight negligence.
The most common animal diseases in a pig farm are generally accompanied by symptoms of animal bunching, cough, diarrhea and the like, and currently, the diarrhea of a swinery is determined mainly by manual inspection of a breeder or inspection of pig farm images through an inspection platform. The manual inspection mode is greatly influenced by mental states and experience levels of feeders, on one hand, the risk of virus propagation is increased when the workers enter and exit the pig farm, and epidemic situations can be caused, on the other hand, the disease degrees of all sick pigs are not completely the same, and are certainly light and heavy, so that the disease is heavier and is easy to find, the disease is lighter and is not easy to find, and the disease acquisition difficulty is higher; the pig farm images are checked through the inspection platform, the platform watch personnel are required to concentrate on the attention for a long time, and the missed and wrong watching can be frequently caused.
Therefore, a method for efficiently obtaining diarrhea of a swinery is needed, so that the working intensity is reduced, and the breeding safety is improved.
Disclosure of Invention
The invention aims to provide a method and a system for detecting diarrhea of a swinery, which can automatically detect whether the swinery in a column is diarrhea, can immediately find the diarrhea of the swinery, realize early discovery, early treatment and early treatment, reduce loss, improve production value, solve the problems of potential safety hazard caused by manual inspection or overlooking and wrong watching caused by remote watching at present, improve detection efficiency, reduce labor intensity and improve the safety and reliability of breeding.
In order to solve the technical problem, the embodiment of the invention provides a method for detecting diarrhea in a herd of pigs, which comprises the following steps:
s1, acquiring a pig farm inspection image, and removing abnormal illumination, blur, fog and angle images in the pig farm inspection image to obtain a normal inspection image;
s2, extracting a floor foreground image from the normal inspection image according to an example segmentation model;
s3, inputting the floor foreground image into an image classification model, and judging whether diarrhea exists in the floor foreground image;
if so, S4, a diarrhea warning message is sent to the breeder or veterinarian.
Wherein the S1 includes:
reading the pig farm inspection image by using opencv, converting the pig farm inspection image from the read BGR format into an HSV format image, and removing an illumination abnormal image with H less than 20;
converting the pig farm inspection image into a gray scale image, equally dividing the gray scale image into a plurality of regions, calculating the variance of a Laplacian operator of each region, judging that the pig farm inspection image is fuzzy after the variance of any one region in the gray scale image is smaller than a threshold variance, and rejecting the pig farm inspection image;
and carrying out minimum filtering processing on the pig farm inspection image, wherein a minimum filtering formula is as follows:
Figure BDA0003166623640000021
where x and y are the coordinates of the pixel, vx,yMin represents the minimum pixel for calculating the specified pixel region for the value of the pixelThe value of the one or more of the one,
judging the pig farm inspection image and rejecting the pig farm inspection image after detecting whether the number of the statistical pixel values larger than 35 exceeds the threshold number;
calculating the gradient of the pig farm inspection image, then counting the straight lines and angle distribution reaching the specified length in the pig farm inspection image, indicating that the angle of the column is abnormal when the angle with the maximum frequency is not in the specified angle range, and rejecting the pig farm inspection image.
Wherein said calculating the variance of the laplacian for each of the regions comprises:
calculating the Laplace operator, and the formula is as follows:
Figure BDA0003166623640000031
wherein x and y are coordinates of the pixel, and f (x, y) is a value of the pixel;
calculating the variance of the Laplacian of each block of the region, wherein the formula is as follows:
Figure BDA0003166623640000032
wherein x is1,x2,x3...xnIs the value of the Laplace operator, M is the average value thereof, n is the number of pixels in the region, s2Is the variance of the laplacian for each block region.
Wherein the S1 includes:
based on a FastLineDetector linear detector, calculating the gradient of the inspection image of the pig farm, wherein the formula is as follows:
gx=f(x+1,y)-f(x,y)+f(x+1,y+1)-f(x,y+1)
gy=f(x,y+1)-f(x,y)+f(x+1,y+1)-f(x+1,y)
Figure BDA0003166623640000033
wherein x and y are coordinates of the pixel, and f (x, y) is a value of the pixel;
the included angle between each pixel and the row and column lines in the image forms a row and column line field, and the angle of the row and column line field is calculated by the following formula:
Figure BDA0003166623640000034
sorting, namely starting region growth from the pixel with the maximum gradient, and judging whether the difference of degree between the current pixel and 8 surrounding pixels is smaller than a threshold value or not;
if so, taking the pixel which is finally compared and added as a reference pixel for the next comparison, and taking the area which contains the pixels with the number less than the threshold value in the obtained area;
traversing all the pixels, and acquiring the pixels on the most boundary in four directions as boundary pixels;
calculating to obtain a circumscribed rectangle of the boundary pixel and midpoint coordinates (x1, y1) and (x2, y2) of two short sides of the circumscribed rectangle, side length width of the short sides, barycentric coordinates (centerX, centerY), a main direction angle radian, an angle arc cosine value degreeX, an angle arc sine value degreeY, probability that a pixel point and an angle arc coincide, and a threshold prec of a difference between a pixel point field direction and the main direction angle radian, wherein the probability is a proportion that a usage threshold occupies 180 degrees, and the prec is a radian threshold corresponding to the usage 22.5 degrees;
counting straight lines reaching the specified length in the pig farm inspection image, and counting the angle distribution of the straight lines;
and if the angle with the maximum frequency is not in the designated angle range, indicating that the column angle is abnormal, and rejecting the pig farm inspection image.
Wherein the S2 includes:
collecting a visible light image in the normal inspection image, and labeling the outlines of the objects such as a pig, an old trough, a new trough, a trough, an iron rail, an acrylic plate and the like in the main fence position in the visible light image to train a MaskRCNN instance segmentation model to obtain an instance segmentation neural network model;
reasoning the input normal patrol inspection image by using the example segmentation neural network model, obtaining the number of examples of the iron handrail and the acrylic plate according to a reasoning result, indicating that the columns are incomplete after the sum of the number of examples of the iron columns and the acrylic plate in the normal patrol inspection image is less than 2, and rejecting the normal patrol inspection image;
after judging that the number of the normal inspection images but the number of the pigs is equal to 0, carrying out no diarrhea detection;
selecting the leftmost and rightmost example position information in the normal inspection image according to the position information of the acrylic plate and the iron handrail;
for the leftmost example, the positions of the lower left and upper right points are taken as the left boundary, for the rightmost example, the positions of the upper left and lower right points are taken as the right boundary, and the area connected by the four points is the floor foreground area;
and setting all areas except the floor foreground area in the normal inspection image as black, and extracting to obtain a floor foreground image.
Wherein the S3 includes:
classifying the floor foreground images, judging the floor foreground images containing diarrhea objects as diarrhea images, and judging the floor foreground images without diarrhea objects as normal images;
training a diarrheal classification model by adopting the two classified images, inputting the images into a convolutional neural network model to extract deep features, and calculating the class of the images by using a full connection layer to obtain a classification neural network model;
reasoning the floor foreground image extracted based on the example segmentation result by using the diarrheal classification model, and judging whether the obtained reasoning result is greater than or equal to 0.5;
and if so, judging that the floor foreground image is the diarrhea image, otherwise, judging that the floor foreground image is the normal image.
Wherein the S1 further includes:
and acquiring the pig farm inspection image at regular time.
In addition, this application embodiment also provides a herd of pigs thing detection system that diarrhoea, includes:
the image acquisition module is used for acquiring a pig farm inspection image, and removing abnormal illumination, fuzzy, foggy and abnormal angle images in the pig farm inspection image to obtain a normal inspection image;
the floor foreground image extraction module is used for extracting a floor foreground image from the normal inspection image according to an example segmentation model;
and the diarrhea detection module is used for inputting the floor foreground image into an image classification model and judging that diarrhea warning information is sent to a breeder or a veterinarian after diarrhea exists in the floor foreground image.
The device also comprises a timing module connected with the image acquisition module and used for setting the image acquisition time interval of the image acquisition module.
The system also comprises an alarm device connected with the diarrheal detection module and used for outputting alarm information after the diarrheal detection module judges that diarrheal exists in the floor foreground image.
Compared with the prior art, the method and the system for detecting the pig herd diarrhea provided by the embodiment of the invention have the following advantages:
according to the detection method and system for the pig group diarrhea provided by the embodiment of the invention, after the image is obtained, the image which does not meet the standard is removed, the floor foreground image is extracted through the example segmentation model, the diarrhea early warning information is sent after the diarrhea is judged by the image classification model, the pig group diarrhea can be found immediately, the early discovery, the early treatment and the loss are realized, the production value is improved, the problems of potential safety hazards caused by manual inspection or overlooking and wrong watching caused by remote watching are solved, the detection efficiency is improved, the labor intensity is reduced, and the safety and the reliability of the breeding are improved.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below, and it is obvious that the drawings in the following description are some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a schematic flow chart illustrating steps of one embodiment of a method for detecting diarrhea in a herd according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a specific embodiment of a pig herd diarrhea detection system according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Referring to fig. 1-2, fig. 1 is a schematic flow chart illustrating steps of a method for detecting diarrhea in a herd according to an embodiment of the present invention; fig. 2 is a schematic structural diagram of a specific embodiment of a pig herd diarrhea detection system according to an embodiment of the present invention.
In one embodiment, the method for detecting swine herd diarrhea comprises:
s1, acquiring a pig farm inspection image, and removing abnormal illumination, blur, fog and angle images in the pig farm inspection image to obtain a normal inspection image;
s2, extracting a floor foreground image from the normal inspection image according to an example segmentation model;
s3, inputting the floor foreground image into an image classification model, and judging whether diarrhea exists in the floor foreground image;
if so, S4, a diarrhea warning message is sent to the breeder or veterinarian.
After the image which is not in accordance with the standard is removed after the image is obtained, the floor foreground image is extracted through the example segmentation model, the diarrhea early warning information is sent after the diarrhea is judged through the image classification model, the diarrhea of the swinery can be found immediately, the early finding, the early treatment and the loss reduction are achieved, the production value is improved, the problems of missing and wrong watching caused by the potential safety hazard caused by manual inspection or remote watching at present are solved, the detection efficiency is improved, the labor intensity is reduced, and the safety and the reliability of breeding are improved.
The mode that filters is patrolled and examined the image to the pig farm in this application does not do the restriction, can adopt the manual work to get rid of, also can adopt the machine to adopt certain mode to filter, can also adopt manual work and machine cooperation to filter.
In one embodiment, the automatic machine screening is adopted, and the S1 includes:
reading the pig farm inspection image by using opencv, converting the pig farm inspection image from the read BGR format into an HSV format image, and removing an illumination abnormal image with H less than 20;
converting the pig farm inspection image into a gray scale image, equally dividing the gray scale image into a plurality of regions, calculating the variance of a Laplacian operator of each region, judging that the pig farm inspection image is fuzzy after the variance of any one region in the gray scale image is smaller than a threshold variance, and rejecting the pig farm inspection image;
and carrying out minimum filtering processing on the pig farm inspection image, wherein a minimum filtering formula is as follows:
Figure BDA0003166623640000081
where x and y are the coordinates of the pixel, vx,yMin represents the calculation of the minimum pixel value for a given pixel region, being the value of the pixel,
judging the pig farm inspection image and rejecting the pig farm inspection image after detecting whether the number of the statistical pixel values larger than 35 exceeds the threshold number;
calculating the gradient of the pig farm inspection image, then counting the straight lines and angle distribution reaching the specified length in the pig farm inspection image, indicating that the angle of the column is abnormal when the angle with the maximum frequency is not in the specified angle range, and rejecting the pig farm inspection image.
It should be noted that, in the present application, the factors for screening the pig farm inspection images are not limited, and the screening order is not limited, different orders may be adopted in multiple screening, an optimal algorithm may appear, so that the calculation amount can be reduced or the calculation accuracy can be improved, and the like, which is not limited in the present application.
In an embodiment of the present application, the fuzzy determination is performed by using a variance, a specific algorithm of the fuzzy determination is not limited in the present application, and in an embodiment, the calculating the variance of the laplacian of each of the regions includes:
calculating the Laplace operator, and the formula is as follows:
Figure BDA0003166623640000082
wherein x and y are coordinates of the pixel, and f (x, y) is a value of the pixel;
calculating the variance of the Laplacian of each block of the region, wherein the formula is as follows:
Figure BDA0003166623640000083
wherein x is1,x2,x3...xnIs the value of the Laplace operator, M is the average value thereof, n is the number of pixels in the region, s2Is the variance of the laplacian for each block region.
The method calculation is not limited to the algorithm, and the fuzzy decision is not limited to the variance.
In the application, the abnormal column angle is needed, so that the specified column can be judged, the one-to-one correspondence between the detection object and the actual pig can be ensured, and the dislocation can not occur.
In one embodiment, the S1 includes:
based on a FastLineDetector linear detector, calculating the gradient of the inspection image of the pig farm, wherein the formula is as follows:
gx=f(x+1,y)-f(x,y)+f(x+1,y+1)-f(x,y+1)
gy=f(x,y+1)-f(x,y)+f(x+1,y+1)-f(x+1,y)
Figure BDA0003166623640000091
wherein x and y are coordinates of the pixel, and f (x, y) is a value of the pixel;
the included angle between each pixel and the row and column lines in the image forms a row and column line field, and the angle of the row and column line field is calculated by the following formula:
Figure BDA0003166623640000092
sorting, namely starting region growth from the pixel with the maximum gradient, and judging whether the difference of degree between the current pixel and 8 surrounding pixels is smaller than a threshold value or not;
if so, taking the pixel which is finally compared and added as a reference pixel for the next comparison, and taking the area which contains the pixels with the number less than the threshold value in the obtained area;
traversing all the pixels, and acquiring the pixels on the most boundary in four directions as boundary pixels;
calculating to obtain a circumscribed rectangle of the boundary pixel and midpoint coordinates (x1, y1) and (x2, y2) of two short sides of the circumscribed rectangle, side length width of the short sides, barycentric coordinates (centerX, centerY), a main direction angle radian, an angle arc cosine value degreeX, an angle arc sine value degreeY, probability that a pixel point and an angle arc coincide, and a threshold prec of a difference between a pixel point field direction and the main direction angle radian, wherein the probability is a proportion that a usage threshold occupies 180 degrees, and the prec is a radian threshold corresponding to the usage 22.5 degrees;
counting straight lines reaching the specified length in the pig farm inspection image, and counting the angle distribution of the straight lines;
and if the angle with the maximum frequency is not in the designated angle range, indicating that the column angle is abnormal, and rejecting the pig farm inspection image.
The method includes but is not limited to gradient calculation by adopting a FastLineDetector linear detector, and is not limited to the algorithm and the threshold, the corresponding algorithm can be replaced, and the threshold can be manually set according to certain requirements.
In this application, after the picture screening is completed, a floor foreground image needs to be obtained, and the example segmentation model and the training mode are not limited, and in one embodiment, the S2 includes:
collecting a visible light image in the normal inspection image, and labeling the outlines of the objects such as a pig, an old trough, a new trough, a trough, an iron rail, an acrylic plate and the like in the main fence position in the visible light image to train a MaskRCNN instance segmentation model to obtain an instance segmentation neural network model; the method comprises the steps of collecting a visible light image, marking the outlines of objects such as pigs, old troughs, new troughs, water troughs, iron railings, acrylic plates and the like in a main stall in the image, training a MaskRCNN example segmentation model based on the visible light image, namely, inputting the image into a convolutional neural network model to extract a feature map, generating an advice window by using an area advice neural network, mapping the advice window to the last layer of feature map of the convolutional neural network, generating a feature map with a fixed size through an interested area alignment layer, and performing regression by using full-connection classification, a frame and a mask to obtain an example segmentation neural network model.
Reasoning the input normal patrol inspection image by using the example segmentation neural network model, obtaining the number of examples of the iron handrail and the acrylic plate according to a reasoning result, indicating that the columns are incomplete after the sum of the number of examples of the iron columns and the acrylic plate in the normal patrol inspection image is less than 2, and rejecting the normal patrol inspection image;
after judging that the number of the normal inspection images but the number of the pigs is equal to 0, carrying out no diarrhea detection;
selecting the leftmost and rightmost example position information in the normal inspection image according to the position information of the acrylic plate and the iron handrail;
for the leftmost example, the positions of the lower left and upper right points are taken as the left boundary, for the rightmost example, the positions of the upper left and lower right points are taken as the right boundary, and the area connected by the four points is the floor foreground area;
and setting all areas except the floor foreground area in the normal inspection image as black, and extracting to obtain a floor foreground image.
The present application includes, but is not limited to, obtaining a floor foreground image in the manner described above.
In the present application, the image classification model is used for diarrhea, the determination criteria and the determination process are not limited, and in one embodiment, the S3 includes:
classifying the floor foreground images, judging the floor foreground images containing diarrhea objects as diarrhea images, and judging the floor foreground images without diarrhea objects as normal images;
training a diarrheal classification model by adopting the two classified images, inputting the images into a convolutional neural network model to extract deep features, and calculating the class of the images by using a full connection layer to obtain a classification neural network model; if the binomietv 2 diarrheal classification model is trained by using the images after the binary classification, namely, the images are input into a convolutional neural network model to extract deep features, and then the categories of the images are calculated by using a full connection layer to obtain a classification neural network model;
reasoning the floor foreground image extracted based on the example segmentation result by using the diarrheal classification model, and judging whether the obtained reasoning result is greater than or equal to 0.5;
and if so, judging that the floor foreground image is the diarrhea image, otherwise, judging that the floor foreground image is the normal image.
The present application includes, but is not limited to, the above-mentioned diarrhea classification model training mode and the classification mode.
In the present application, the frequency of image acquisition of the diarrhea material is not limited, and may be according to a predetermined time, or may change with time, such as increasing the detection average rate during the day activity and decreasing the detection average rate at night, and therefore, the S1 generally further includes:
and acquiring the pig farm inspection image at regular time.
In addition, this application embodiment also provides a herd of pigs thing detection system that diarrhoea, includes:
the image acquisition module 10 is used for acquiring a pig farm inspection image, and removing the abnormal illumination, blur, fog and angle images in the pig farm inspection image to obtain a normal inspection image;
the floor foreground image extracting module 20 is used for extracting a floor foreground image from the normal inspection image according to an example segmentation model;
and the diarrhea detection module 30 is used for inputting the floor foreground image into an image classification model, and sending diarrhea early warning information to a breeder or a veterinarian after judging that the floor foreground image has diarrhea.
The swinery diarrhea detection system is the system of the swinery diarrhea detection method, has the same beneficial effects, and is not limited in the application.
In order to flexibly adapt to the detection of the swinery with different breeding ages in different time periods, in one embodiment, the swinery diarrhea detection system further comprises a timing module connected with the image acquisition module and used for setting the image acquisition time interval of the image acquisition module.
The timing module can be set on a platform, can be automatically set according to a certain rule, or can be remotely set by using a mobile phone APP, and the method is not limited in the application.
In order to further improve the early warning effect, in an embodiment, the pig group diarrhea detection system further includes an alarm device connected to the diarrhea detection module, and configured to output alarm information after the diarrhea detection module determines that there is diarrhea in the floor foreground image.
Be in through alarm device diarrhea thing detection module judges there is diarrhea thing back output alarm information in the floor prospect image, personnel such as raiser can obtain alarm information like this, can close the warning after obtaining alarm information to improve and maintain reliability, floor prospect image: the image only contains a floor part, all areas except the floor are set to be black, namely the pixel values of the areas where the floor part is located in the image are kept unchanged, and the pixel values of the rest parts are all set to be 0.
Opencv: an open source cross-platform computer vision and machine learning software library. HSV: HSV (Hue, Saturation, Value) is a color space created according to the intuitive characteristics of color, and the parameters of color in this model are: hue (H), saturation (S), lightness (V).
Gray scale map: the logarithmic relationship between white and black is divided into several levels called gray scale, the gray scale is divided into 256 steps, and the image represented by gray scale is called gray scale map.
Laplace operator: when the method is used for calculating the second derivative, the area with the pixel value changing rapidly in the image is found, the boundary of the normal image is clearer, so the variance is larger, and the boundary information contained in the blurred image is less, so the variance is smaller.
Minimum value filtering: and filling the target pixel after the target pixel and the peripheral pixels take the minimum value.
LineSegmentDetector: a method for detecting a straight line.
A neural network: an arithmetic mathematical model simulating animal neural network behavior characteristics and performing distributed parallel information processing. The network achieves the aim of processing information by adjusting the mutual connection relationship among a large number of nodes in the network depending on the complexity of the system.
A feed-forward neural network: in the simplest neural network, neurons are arranged in layers. Each neuron is connected to only the neuron in the previous layer. The output of the previous layer is received and output to the next layer with no feedback between layers.
Convolution: a mathematical operator of a third function is generated by two functions f and g, characterizing the integral of the overlap length of the product of the function values of the overlap of the function f and g, which have been inverted and translated. A convolutional neural network: one class includes convolution computations and feed-forward neural networks with depth structures. Full connection layer: each node of the fully connected layer is connected to all nodes of the previous layer for integrating the extracted features.
Masking: for example, if there is a circular object in the image, we cut a circle with the same size as the object from a piece of paper, and cover the piece of paper on the image, we can only see the circular object at this time, and the piece of paper is the mask.
Image classification: there is a fixed set of classification labels, then for an input image, a classification label is found from the set of classification labels, and finally the classification label is assigned to the input image.
Example segmentation: on the basis of semantic segmentation, different labels are provided for the individual instances belonging to the same class of objects.
mask rcnn: an example partitioning method.
mobilenetv 2: an image classification method is also a skeleton network.
In summary, according to the method and system for detecting pig farm diarrhea provided by the embodiments of the present invention, after the image is obtained, the image that does not meet the standard is removed, the floor foreground image is extracted through the example segmentation model, and then the diarrhea warning information is sent after the diarrhea is determined by the image classification model, so that the pig farm diarrhea can be immediately discovered, the early discovery, the early treatment and the loss reduction are achieved, the production value is improved, the problems of potential safety hazard caused by manual inspection or overlooking and wrong watching caused by remote watching are solved, the detection efficiency is improved, the labor intensity is reduced, and the safety and the reliability of the breeding are improved.
The method and system for detecting diarrhea in a swinery provided by the invention are described in detail above. The principles and embodiments of the present invention are explained herein using specific examples, which are presented only to assist in understanding the method and its core concepts. It should be noted that, for those skilled in the art, it is possible to make various improvements and modifications to the present invention without departing from the principle of the present invention, and those improvements and modifications also fall within the scope of the claims of the present invention.

Claims (10)

1. A method for detecting diarrhea in a herd of pigs is characterized by comprising the following steps:
s1, acquiring a pig farm inspection image, and removing abnormal illumination, blur, fog and angle images in the pig farm inspection image to obtain a normal inspection image;
s2, extracting a floor foreground image from the normal inspection image according to an example segmentation model;
s3, inputting the floor foreground image into an image classification model, and judging whether diarrhea exists in the floor foreground image;
if so, S4, a diarrhea warning message is sent to the breeder or veterinarian.
2. The method of detecting porcine diarrhea according to claim 1, wherein S1 comprises:
reading the pig farm inspection image by using opencv, converting the pig farm inspection image from the read BGR format into an HSV format image, and removing an illumination abnormal image with H less than 20;
converting the pig farm inspection image into a gray scale image, equally dividing the gray scale image into a plurality of regions, calculating the variance of a Laplacian operator of each region, judging that the pig farm inspection image is fuzzy after the variance of any one region in the gray scale image is smaller than a threshold variance, and rejecting the pig farm inspection image;
and carrying out minimum filtering processing on the pig farm inspection image, wherein a minimum filtering formula is as follows:
Figure FDA0003166623630000011
where x and y are the coordinates of the pixel, vx,yMin represents the calculation of the minimum pixel value for a given pixel region, being the value of the pixel,
judging the pig farm inspection image and rejecting the pig farm inspection image after detecting whether the number of the statistical pixel values larger than 35 exceeds the threshold number;
calculating the gradient of the pig farm inspection image, then counting the straight lines and angle distribution reaching the specified length in the pig farm inspection image, indicating that the angle of the column is abnormal when the angle with the maximum frequency is not in the specified angle range, and rejecting the pig farm inspection image.
3. The method of detecting porcine diarrhea material of claim 2 wherein said calculating the variance of the laplacian for each of said regions comprises:
calculating the Laplace operator, and the formula is as follows:
Figure FDA0003166623630000021
wherein x and y are coordinates of the pixel, and f (x, y) is a value of the pixel;
calculating the variance of the Laplacian of each block of the region, wherein the formula is as follows:
Figure FDA0003166623630000022
wherein x is1,x2,x3...xnIs the value of the Laplace operator, M is the average value thereof, n is the number of pixels in the region, s2Is the variance of the laplacian for each block region.
4. The method of detecting porcine diarrhea of claim 3 wherein S1 comprises:
based on a FastLineDetector linear detector, calculating the gradient of the inspection image of the pig farm, wherein the formula is as follows:
gx=f(x+1,y)-f(x,y)+f(x+1,y+1)-f(x,y+1)
gy=f(x,y+1)-f(x,y)+f(x+1,y+1)-f(x+1,y)
Figure FDA0003166623630000023
wherein x and y are coordinates of the pixel, and f (x, y) is a value of the pixel;
the included angle between each pixel and the row and column lines in the image forms a row and column line field, and the angle of the row and column line field is calculated by the following formula:
Figure FDA0003166623630000024
sorting, namely starting region growth from the pixel with the maximum gradient, and judging whether the difference of degree between the current pixel and 8 surrounding pixels is smaller than a threshold value or not;
if so, the pixel which is compared and added at the last time is taken as the reference pixel of the next comparison,
taking regions in which the number of pixels included in the obtained region is less than a threshold value;
traversing all the pixels, and acquiring the pixels on the most boundary in four directions as boundary pixels;
calculating to obtain a circumscribed rectangle of the boundary pixel and midpoint coordinates (x1, y1) and (x2, y2) of two short sides of the circumscribed rectangle, side length width of the short sides, barycentric coordinates (centerX, centerY), a main direction angle radian, an angle arc cosine value degreeX, an angle arc sine value degreeY, probability that a pixel point and an angle arc coincide, and a threshold prec of a difference between a pixel point field direction and the main direction angle radian, wherein the probability is a proportion that a usage threshold occupies 180 degrees, and the prec is a radian threshold corresponding to the usage 22.5 degrees;
counting straight lines reaching the specified length in the pig farm inspection image, and counting the angle distribution of the straight lines;
and if the angle with the maximum frequency is not in the designated angle range, indicating that the column angle is abnormal, and rejecting the pig farm inspection image.
5. The method of detecting porcine diarrhea of claim 4 wherein S2 comprises:
collecting a visible light image in the normal inspection image, and labeling the outlines of the objects such as a pig, an old trough, a new trough, a trough, an iron rail, an acrylic plate and the like in the main fence position in the visible light image to train a MaskRCNN instance segmentation model to obtain an instance segmentation neural network model;
reasoning the input normal patrol inspection image by using the example segmentation neural network model, obtaining the number of examples of the iron handrail and the acrylic plate according to a reasoning result, indicating that the columns are incomplete after the sum of the number of examples of the iron columns and the acrylic plate in the normal patrol inspection image is less than 2, and rejecting the normal patrol inspection image;
after judging that the number of the normal inspection images but the number of the pigs is equal to 0, carrying out no diarrhea detection;
selecting the leftmost and rightmost example position information in the normal inspection image according to the position information of the acrylic plate and the iron handrail;
for the leftmost example, the positions of the lower left and upper right points are taken as the left boundary, for the rightmost example, the positions of the upper left and lower right points are taken as the right boundary, and the area connected by the four points is the floor foreground area;
and setting all areas except the floor foreground area in the normal inspection image as black, and extracting to obtain a floor foreground image.
6. The method and system for swine herd diarrhea detection of claim 5 wherein said S3 comprises:
classifying the floor foreground images, judging the floor foreground images containing diarrhea objects as diarrhea images, and judging the floor foreground images without diarrhea objects as normal images;
training a diarrheal classification model by adopting the two classified images, inputting the images into a convolutional neural network model to extract deep features, and calculating the class of the images by using a full connection layer to obtain a classification neural network model;
reasoning the floor foreground image extracted based on the example segmentation result by using the diarrheal classification model, and judging whether the obtained reasoning result is greater than or equal to 0.5;
and if so, judging that the floor foreground image is the diarrhea image, otherwise, judging that the floor foreground image is the normal image.
7. The method and system for swine herd diarrhea detection of claim 6 wherein said S1 further comprises:
and acquiring the pig farm inspection image at regular time.
8. A herd of pigs diarrhea detection system, comprising:
the image acquisition module is used for acquiring a pig farm inspection image, and removing abnormal illumination, fuzzy, foggy and abnormal angle images in the pig farm inspection image to obtain a normal inspection image;
the floor foreground image extraction module is used for extracting a floor foreground image from the normal inspection image according to an example segmentation model;
and the diarrhea detection module is used for inputting the floor foreground image into an image classification model and judging that diarrhea warning information is sent to a breeder or a veterinarian after diarrhea exists in the floor foreground image.
9. The swine herd diarrhea detection system of claim 8 further comprising a timing module coupled to the image acquisition module for setting an image acquisition time interval of the image acquisition module.
10. The swine herd diarrhea detection system of claim 9 further comprising an alarm device connected to the diarrhea detection module for outputting an alarm message after the diarrhea detection module determines that there is diarrhea in the floor foreground image.
CN202110806680.6A 2021-07-16 2021-07-16 Method and system for detecting diarrhea of herd of pigs Pending CN113505795A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110806680.6A CN113505795A (en) 2021-07-16 2021-07-16 Method and system for detecting diarrhea of herd of pigs

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110806680.6A CN113505795A (en) 2021-07-16 2021-07-16 Method and system for detecting diarrhea of herd of pigs

Publications (1)

Publication Number Publication Date
CN113505795A true CN113505795A (en) 2021-10-15

Family

ID=78013590

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110806680.6A Pending CN113505795A (en) 2021-07-16 2021-07-16 Method and system for detecting diarrhea of herd of pigs

Country Status (1)

Country Link
CN (1) CN113505795A (en)

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200019752A1 (en) * 2018-07-12 2020-01-16 TerraClear Inc. Object identification and sensing system and method
CN110706219A (en) * 2019-09-27 2020-01-17 北京海益同展信息科技有限公司 Animal waste monitoring method, monitoring device, inspection equipment and inspection system
CN111183917A (en) * 2019-11-14 2020-05-22 北京海益同展信息科技有限公司 Animal abnormity monitoring and image processing method and device
CN111310596A (en) * 2020-01-20 2020-06-19 北京海益同展信息科技有限公司 Animal diseased state monitoring system and method
CN113095441A (en) * 2021-04-30 2021-07-09 河南牧原智能科技有限公司 Pig herd bundling detection method, device, equipment and readable storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20200019752A1 (en) * 2018-07-12 2020-01-16 TerraClear Inc. Object identification and sensing system and method
CN110706219A (en) * 2019-09-27 2020-01-17 北京海益同展信息科技有限公司 Animal waste monitoring method, monitoring device, inspection equipment and inspection system
CN111183917A (en) * 2019-11-14 2020-05-22 北京海益同展信息科技有限公司 Animal abnormity monitoring and image processing method and device
CN111310596A (en) * 2020-01-20 2020-06-19 北京海益同展信息科技有限公司 Animal diseased state monitoring system and method
CN113095441A (en) * 2021-04-30 2021-07-09 河南牧原智能科技有限公司 Pig herd bundling detection method, device, equipment and readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
张善文 等: "《图像模式识别》", 西安电子科技大学出版社, pages: 124 - 125 *

Similar Documents

Publication Publication Date Title
CN108921105B (en) Method and device for identifying target number and computer readable storage medium
CN111709333B (en) Tracing early warning system based on abnormal excrement of cage-raised chickens and health monitoring method
CN102024146B (en) Method for extracting foreground in piggery monitoring video
WO2020125057A1 (en) Livestock quantity identification method and apparatus
CN112364740B (en) Unmanned aerial vehicle room monitoring method and system based on computer vision
CN109087363B (en) HSV color space-based sewage discharge detection method
CN113324864B (en) Pantograph carbon slide plate abrasion detection method based on deep learning target detection
CN112200011B (en) Aeration tank state detection method, system, electronic equipment and storage medium
CN113095441A (en) Pig herd bundling detection method, device, equipment and readable storage medium
CN113820326B (en) Defect detection system of long-code zipper
CN115861721B (en) Livestock and poultry breeding spraying equipment state identification method based on image data
Ji et al. In-field automatic detection of maize tassels using computer vision
CN109086696B (en) Abnormal behavior detection method and device, electronic equipment and storage medium
CN113723300A (en) Artificial intelligence-based fire monitoring method and device and storage medium
CN106570440A (en) People counting method and people counting device based on image analysis
CN115661650A (en) Farm management system based on data monitoring of Internet of things
CN114092378A (en) Animal health detection method, device, equipment and storage medium
CN114627505A (en) Automatic milk cow cleanliness scoring method and system, storage medium and equipment
JPH05263411A (en) Object observation method and device
CN113505795A (en) Method and system for detecting diarrhea of herd of pigs
CN113327263A (en) Fish shoal liveness monitoring method based on image vision
CN115006901B (en) Automatic control method and system for intelligent backwashing filter
CN116646082A (en) Disease early warning traceability system based on abnormal chicken manure under laminated cage raising mode
CN115331166B (en) Intelligent monitoring and early warning method and system for grid trash remover
CN114943929B (en) Real-time detection method for abnormal behaviors of fish based on image fusion technology

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20211015

RJ01 Rejection of invention patent application after publication