Cattle abnormal behavior detection method and system based on neural network and centroid tracking
By employing cascaded classifiers and centroid tracking, the problem of low accuracy in bovine detection algorithms was solved, achieving efficient detection of abnormal bovine behavior and improving detection accuracy and efficiency.
Patent Information
- Application Number
- CN202211640707.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-20
- Publication Date
- 2026-02-03
- Estimated Expiration
- 2042-12-20
AI Technical Summary
In existing intelligent livestock systems, the accuracy of cattle detection algorithms is not high, making it difficult to accurately identify abnormal cattle behavior. Furthermore, existing methods have large errors and low detection precision.
A cascaded classifier combined with neural networks and centroid tracking was used to construct a bovine sample dataset, extract scale-invariant features, and perform detection using a support vector machine and an optimized InceptionV3 network. Abnormal behavior was judged by combining changes in centroid coordinates.
It improves the accuracy and efficiency of cattle detection, simplifies the judgment of abnormal behavior, reduces false positives, and achieves high-precision detection of abnormal behavior in cattle.
Smart Images

Figure CN115984959B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of intelligent livestock monitoring technology, and in particular to a method and system for detecting abnormal bovine behavior based on neural networks and centroid tracking. Background Technology
[0002] The statements in this section merely refer to the background art relevant to this application and do not necessarily constitute prior art.
[0003] In recent years, with the continuous development of large-scale and intensive livestock farming and the increase in the number of farms, large-scale farming has brought new challenges and requirements to livestock management methods. In particular, real-time monitoring of animal behavior and timely analysis can effectively improve efficiency, prevent disease outbreaks, and greatly promote the development of the livestock industry.
[0004] Current technologies for detecting target animals require manual labeling of seed pixels. Detection via video images followed by computer processing cannot accurately distinguish difficult-to-distinguish targets, reducing detection precision and significantly increasing errors. For tracking target animals, manual labeling with paint is commonly used, which is labor-intensive and the paint is not durable. Alternatively, inter-frame difference detection can be used, but this is easily affected by sudden changes in lighting, leading to inaccurate detection. All of these methods have significant implementation errors and low detection accuracy.
[0005] With the increasing demand for intelligent livestock farming, existing intelligent cattle-herding systems suffer from insufficient accuracy in cattle detection algorithms, making the implementation of cattle tracking algorithms difficult. The root cause lies in the limited availability of datasets specifically for cattle detection, the challenge of controlling cattle, their tendency to change position and angle in camera footage, and the resulting alteration of their features. These difficulties make it hard to extract features that indicate abnormal cattle behavior, leading to low accuracy in cattle detection algorithms. Currently, existing intelligent livestock farming systems lack a precise algorithm for detecting common abnormal behaviors in cattle. Summary of the Invention
[0006] To address the shortcomings of existing technologies, this application provides a method and system for detecting abnormal bovine behavior based on neural networks and centroid tracking. A cascaded classifier is used to detect bovine targets. In addition to improving the detection performance, the method tracks bovine targets by extracting their centroid coordinates and detects abnormal bovine behavior based on changes in the centroid coordinates, thus improving the accuracy and efficiency of abnormal bovine behavior detection.
[0007] Firstly, this application provides a method for detecting abnormal bovine behavior based on neural networks and centroid tracking;
[0008] Methods for detecting abnormal bovine behavior based on neural networks and centroid tracking include:
[0009] Acquire images of cattle and construct a sample dataset of cattle in various shapes and angles;
[0010] Scale-invariant features extracted from the sample dataset are input into a support vector machine for learning to obtain the first detection model; the InceptionV3 network optimized by the support vector machine is trained using the same sample dataset to obtain the second detection model.
[0011] The image to be identified is input into the first detection model. If the detection result is true, it is then input into the second detection model. If both detection results are true, the image is classified as a cow, thus completing the cow target detection.
[0012] Extract the centroid coordinates of the bovine target and determine whether abnormal behavior has occurred based on changes in the centroid coordinates.
[0013] Furthermore, the learning process involves automatically finding the best function among the functions, then optimizing the parameters within the function, and finally obtaining an optimal function.
[0014] Furthermore, the second detection model optimizes the neural network model by connecting an SVM classifier after the InncepitonV3 network.
[0015] Furthermore, the InncepitonV3 network first extracts features from the training samples, then inputs the features into the SVM classifier to train a model that can compare the features of the image to be identified with those of the training samples, i.e., the second detection model.
[0016] Furthermore, the bovine target detection process first involves inputting the image to be identified into a first detection model to extract scale-invariant features. These features are then substituted into the optimal function, and if the results are similar, the target is judged as true. When the detection result is true, the target sample is then input into the SVM-optimized InceptionV3 network for comparison. If the features are similar, the target is judged as true. If both detection results are true, the target is judged as bovine, and the detection is completed. If one of the detection results is false, the target is judged as non-bovine.
[0017] Furthermore, the extraction of the centroid coordinates of the bovine target specifically involves: extracting the contour of the bovine target, finding the independent centroids in the X and Y directions of the two-dimensional image respectively, and obtaining the centroid coordinates.
[0018] Furthermore, the abnormal behavior includes two types: running in fright and remaining still. When the movement speed exceeds a set threshold speed, it is determined that the abnormal behavior of running in fright has occurred. The centroid coordinates of all cattle in the picture are stored within a unit of time. When the same coordinate or similar coordinates exceed the threshold time, it is determined that the abnormal behavior of cattle remaining still in the picture has occurred.
[0019] Secondly, this application provides a bovine abnormal behavior detection system based on neural networks and centroid tracking;
[0020] A bovine abnormal behavior detection system based on neural networks and centroid tracking includes:
[0021] The sample construction module acquires images of cattle and constructs a sample dataset of cattle in various shapes and angles.
[0022] The model building module extracts scale-invariant features from the sample dataset and inputs them into a support vector machine for learning, resulting in the first object detection model; the InceptionV3 network optimized by the support vector machine is trained using the same sample dataset to obtain the second detection model;
[0023] The target detection module inputs the image to be identified into the first detection model. If the detection result is true, it then inputs it into the second detection model. If both detection results are true, the image is classified as a cow, thus completing the cow target detection.
[0024] The behavior judgment module extracts the centroid coordinates of the bovine target and determines whether abnormal behavior has occurred based on changes in the centroid coordinates.
[0025] Thirdly, this application also provides an electronic device, including: one or more processors, one or more memories, and one or more computer programs; wherein the processor is connected to the memory, the one or more computer programs are stored in the memory, and when the electronic device is running, the processor executes the one or more computer programs stored in the memory to cause the electronic device to perform the method described in the first aspect.
[0026] Fourthly, this application also provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, perform the method described in the first aspect.
[0027] Compared with the prior art, the beneficial effects of this application are:
[0028] This invention improves the detection performance of cattle by extracting their centroid coordinates to track cattle targets, and then detects abnormal behavior based on changes in these centroid coordinates. First, a cascaded classifier is used to detect the cattle targets, improving accuracy and enabling precise target detection. Second, using the centroid instead of the cattle target simplifies the abnormal behavior judgment process, reducing algorithm time and improving efficiency. Attached Figure Description
[0029] The accompanying drawings, which form part of this application, are used to provide a further understanding of this application. The illustrative embodiments of this application and their descriptions are used to explain this application and do not constitute an undue limitation of this application.
[0030] Figure 1 This is a flowchart illustrating the method of an embodiment of this application;
[0031] Figure 2 This is a schematic diagram illustrating the detection results of bovine targets in an embodiment of this application;
[0032] Figure 3 This is a schematic diagram showing the result of extracting the centroid of a bovine target according to an embodiment of this application; Detailed Implementation
[0033] Example 1
[0034] This embodiment provides a method for detecting abnormal bovine behavior based on neural networks and centroid tracking.
[0035] A method for detecting abnormal bovine behavior based on neural networks and centroid tracking includes the following steps:
[0036] S1: Obtain images of cattle and construct a sample dataset of cattle in various shapes and angles;
[0037] S2: Extract scale-invariant features from the sample dataset and input them into a support vector machine for learning to obtain the first detection model; use the same sample dataset to train the InceptionV3 network optimized by the support vector machine to obtain the second detection model;
[0038] S3: Input the image to be identified into the first detection model. If the detection result is true, then input it into the second detection model. If both detection results are true, then classify it as a cow and complete the cow target detection.
[0039] S4: Extract the centroid coordinates of the bovine target and determine whether abnormal behavior has occurred based on changes in the centroid coordinates.
[0040] In this embodiment, before detection, a camera with an angle that can cover the area to be detected is first set up manually, and then the detection is carried out using the method described above.
[0041] In step S1, a dataset of 1836 images of different cattle species under various shapes and angles was first constructed. This dataset was then augmented by randomly cropping parts of the data, scaling, and adding noise, resulting in 29376 sample images of each cattle species under various angles and shapes.
[0042] In step S2, scale-invariant features (SIFTs) are extracted from the sample data and then fed into a support vector machine (SVM) for learning, resulting in a model for detecting bovine SIFT features, i.e., the first detection model. Then, the same sample images are input into the SVM-optimized InceptionV3 network for training, resulting in a neural network feature model, i.e., the second detection model.
[0043] The learning process involves automatically finding the best function among the available functions, then optimizing the parameters within that function, and finally obtaining an optimal function.
[0044] The InncepitonV3 mentioned above is a neural network, belonging to the category of deep learning. It is generally followed by a Softmax classifier. In this embodiment, an SVM classifier is connected after the InncepitonV3 network to optimize the neural network model. InncepitonV3 first extracts the features from the samples, and then inputs the features into the classifier to train a model that can compare the features of the object to be detected with those of the samples. Then, the model trained by the classifier is compared with the object to be detected to determine whether it is a cow-like target.
[0045] The first and second detection models are weighted files. Based on the bovine features extracted from all samples, the features are compared with the bovine samples. If they are similar, the sample is identified as a bovine sample.
[0046] In step S3, when detecting cattle, the first detection model is first used to detect their SIFT features.
[0047] The sample to be detected is input into the model and substituted into the optimal function. If the result is similar, it is judged as true. When the detection result is true, it is then input into the SVM-optimized InceptionV3 network for further detection. If both detection results are true, it is classified as a cow, and the detection is completed. If one detection result is false, it is judged not to be a cow. The purpose of this second detection is to construct a cascaded classifier to improve the detection accuracy and avoid misidentifying targets as cows. The target to be detected is input into the neural network, and the neural network automatically extracts features from the sample.
[0048] In step S4, after identifying the organism as a bovine, the contour of the bovine target is extracted. Since the image is two-dimensional, independent centroids are found in the X and Y directions respectively. In the x direction, the pixel sums on both sides of the centroid are the same, and in the Y direction, the pixel sums on both sides of the centroid are the same. Then, the bovine is tracked by using the centroid coordinates.
[0049] The formula for the independent centroid in the X direction is:
[0050]
[0051] Similarly, the independent centroid coordinates in the Y direction can be obtained.
[0052] The formula for centroid coordinates is:
[0053]
[0054] Where, x i Let p be the coordinate of each pixel in the X direction, and the corresponding pixel value be p. i x is the coordinate of the centroid in the X direction, r is a coordinate axis, and m is the coordinate of the centroid. i Let r be the mass of a particle in a material system. i Let be the coordinates of a point in the material system. In this embodiment, it is assumed that each particle of the bovine target has the same mass.
[0055] This embodiment identifies two abnormal behaviors: running in fright and remaining motionless.
[0056] When the abnormal behavior of running in fright occurs, its characteristic at the image level is that the pixel movement speed is too fast compared to the normal state. Therefore, the optical flow method is used to determine the centroid movement speed of the cattle. If the movement speed exceeds the set threshold (the movement speed threshold needs to be calibrated based on factors such as the camera installation position, angle, and height, and is generally set to 10-15 m / s), then the abnormal behavior of running in fright is judged to have occurred.
[0057] The optical flow method is as follows:
[0058] All centroids of the current frame were detected;
[0059] By comparing the grayscale values of the current frame with those of the next frame, the positions of all centroids in the current frame in the next frame can be estimated.
[0060] By filtering out the stationary center of mass, the remaining center of mass is the moving target, and the speed of the moving target is determined.
[0061] The centroid coordinates of all cattle in the image are stored once per minute. If the same or similar coordinates are present for more than a threshold time, in order to eliminate false judgments caused by cattle resting, the time threshold is generally set to 300 minutes. Centroids with small changes within a range of more than 300 minutes will be judged as cattle exhibiting abnormal behavior of remaining still in the image.
[0062] If any abnormal behavior occurs, the device will sound an alarm; if no abnormal behavior occurs, the monitoring of the screen will continue.
[0063] Example 2
[0064] This embodiment provides a bovine abnormal behavior detection system based on neural networks and centroid tracking;
[0065] A bovine abnormal behavior detection system based on neural networks and centroid tracking includes:
[0066] The sample construction module acquires images of cattle and constructs a sample dataset of cattle in various shapes and angles.
[0067] The model building module extracts scale-invariant features from the sample dataset and inputs them into a support vector machine for learning, resulting in the first object detection model; the InceptionV3 network optimized by the support vector machine is trained using the same sample dataset to obtain the second detection model;
[0068] The target detection module inputs the image to be identified into the first detection model. If the detection result is true, it then inputs it into the second detection model. If both detection results are true, the image is classified as a cow, thus completing the cow target detection.
[0069] The behavior judgment module extracts the centroid coordinates of the bovine target and determines whether abnormal behavior has occurred based on changes in the centroid coordinates.
[0070] Example 3
[0071] This embodiment also provides an electronic device, including: one or more processors, one or more memories, and one or more computer programs; wherein, the processor is connected to the memory, and the one or more computer programs are stored in the memory. When the electronic device is running, the processor executes the one or more computer programs stored in the memory to cause the electronic device to perform the method described in Embodiment 1.
[0072] Example 4
[0073] This embodiment also provides a computer-readable storage medium for storing computer instructions, which, when executed by a processor, complete the method described in Embodiment 1.
[0074] The above description is merely a preferred embodiment of this application and is not intended to limit this application. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the protection scope of this application.
Claims
1. A method for detecting abnormal bovine behavior based on neural networks and centroid tracking, characterized in that, include: Acquire images of cattle and construct a sample dataset of cattle in various shapes and angles; Scale-invariant features extracted from the sample dataset are input into a support vector machine for learning to obtain the first detection model; the InceptionV3 network optimized by the support vector machine is trained using the same sample dataset to obtain the second detection model. The image to be identified is input into the first detection model. If the detection result is true, it is then input into the second detection model. If both detection results are true, the image is classified as a cow, thus completing the cow target detection. Extract the centroid coordinates of the bovine target and determine whether abnormal behavior has occurred based on changes in the centroid coordinates.
2. The method for detecting abnormal bovine behavior based on neural networks and centroid tracking as described in claim 1, characterized in that, The process of inputting scale-invariant features into a support vector machine for learning involves automatically finding the best function among the functions, then fine-tuning the parameters within the function, and finally obtaining an optimal function.
3. The method for detecting abnormal bovine behavior based on neural networks and centroid tracking as described in claim 1, characterized in that, The second detection model uses an SVM classifier following the InncepitonV3 network to optimize the neural network model.
4. The method for detecting abnormal bovine behavior based on neural networks and centroid tracking as described in claim 3, characterized in that, The InncepitonV3 network first extracts features from the training samples, then inputs the features into an SVM classifier to train a model that can compare the features of the image to be identified with those of the training samples, i.e., the second detection model.
5. The method for detecting abnormal bovine behavior based on neural networks and centroid tracking as described in claim 1, characterized in that, The bovine target detection process first involves inputting the image to be identified into a first detection model to extract scale-invariant features. These features are then substituted into an optimal function, and if the results are similar, the target is considered true. If the detection result is true, the target sample is then input into an SVM-optimized InceptionV3 network for comparison. If the features are similar, the target is considered true. If both detection results are true, the target is identified as bovine, and the detection is complete. If one of the detection results is false, the target is identified as non-bovine.
6. The method for detecting abnormal bovine behavior based on neural networks and centroid tracking as described in claim 1, characterized in that, The extraction of the centroid coordinates of the bovine target specifically involves: extracting the contour of the bovine target, finding the independent centroids in the X and Y directions of the two-dimensional image, and obtaining the centroid coordinates.
7. The method for detecting abnormal bovine behavior based on neural networks and centroid tracking as described in claim 1, characterized in that, The abnormal behaviors include two types: running in fright and remaining still. When the movement speed exceeds a set threshold speed, it is determined that the abnormal behavior of running in fright has occurred. The centroid coordinates of all cattle in the picture are stored within a unit of time. When the same coordinate or similar coordinates exceed the threshold time, it is determined that the abnormal behavior of cattle remaining still in the picture has occurred.
8. A bovine abnormal behavior detection system based on neural networks and centroid tracking, characterized in that, include: The sample construction module acquires images of cattle and constructs a sample dataset of cattle in various shapes and angles. The model building module extracts scale-invariant features from the sample dataset and inputs them into a support vector machine for learning, resulting in the first object detection model; the first detection model is then trained to obtain the second detection model. The target detection module inputs the image to be identified into the first detection model. If the detection result is true, it then inputs it into the second detection model. If both detection results are true, the image is classified as a cow, thus completing the cow target detection. The behavior judgment module extracts the centroid coordinates of the bovine target and determines whether abnormal behavior has occurred based on changes in the centroid coordinates.
9. An electronic device, characterized in that, include: One or more processors, one or more memories, and one or more computer programs; wherein the processor is connected to the memory, the one or more computer programs are stored in the memory, and when the electronic device is running, the processor executes the one or more computer programs stored in the memory to cause the electronic device to perform the method described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, Used to store computer instructions, which, when executed by a processor, perform the method described in any one of claims 1-7.
Citation Information
Patent Citations
Power transmission line hardware fitting defect detection method and system based on cascade target detection
CN111650204A
Abnormal behavior recognition method and device, electronic equipment and storage medium
CN112200081A