Method for monitoring and identifying abnormal behavior posture of cattle

Through target detection and skeletal key point detection, combined with a lightweight neural network structure, the cattle posture recognition model solves the high cognitive and computing load problems of abnormal behavior posture recognition in large-scale cattle monitoring, achieving fast and accurate monitoring and identification effects.

CN118736486APending Publication Date: 2024-10-01HANGZHOU DONGXI TECH CO LTD
View PDF 0 Cites 2 Cited by

Patent Information

Application Number
CN202410810607.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-06-21
Publication Date
2024-10-01

AI Technical Summary

Technical Problem

Existing technology In large-scale cattle herd monitoring, the recognition of abnormal behavior and posture of cattle involves high cognitive load and computing power load, making it difficult to achieve low-cost monitoring and identification.

Method used

Using target detection and bone key point detection technology, through the preset cow posture recognition model, monitoring images are obtained for target detection and bone key point detection, combined with a lightweight neural network structure, to achieve end-to-end posture recognition and abnormal behavior monitoring .

Benefits of technology

It reduces the cognitive load of users and the computing load of the livestock management system, enables rapid identification and monitoring of abnormal cattle behavior, and improves monitoring efficiency and accuracy.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118736486A_ABST
    Figure CN118736486A_ABST
Patent Text Reader

Abstract

The invention provides a cattle abnormal behavior posture monitoring and recognition method, which comprises the following steps: acquiring a monitoring image which comprises a cattle; target detection is carried out on the monitoring image, a plurality of target frames are determined, and each target frame contains a cattle image; performing skeleton key point detection on the cattle image in each target frame, and determining skeleton key point coordinate data corresponding to the cattle image in each target frame; inputting the skeleton key point coordinate data into a preset cattle posture recognition model, and determining a cattle posture corresponding to the cattle image in the target frame; and based on the cattle attitude, determining whether the target cattle corresponding to the target frame has an abnormal behavior. Through an end-to-end mode, a user can obtain a corresponding posture enumeration value only by inputting an image without bearing redundant cognitive load. And the monitoring and identification of the abnormal behavior and posture of the cattle are realized through relatively low labor cost and computing power load of a livestock management system.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of breeding monitoring, and in particular to a method for monitoring and identifying abnormal behavior postures of cattle. Background Art

[0002] In actual animal husbandry production, the daily routine of cattle in cattle farms is planned, including sleeping, eating, drinking, ruminating, walking, and resting in the pen. These are the fixed behaviors every day, and the length and distribution of the time periods are guided by economic benefits and subject to the guidance of animal husbandry science and technology. Similarly, the breeding operation is the same. Guided by the optimal economic benefits, during the appropriate estrus period of cattle, the best breeding time period is selected for group mating in the pen to obtain the best conception effect. It can be seen that as an animal husbandry manager, there are actually normative or planned expectations for the daily behavior and estrus behavior of cattle. If the continuous behavior of cattle in a certain period of time is inconsistent with the expected behavior in the current period of time, under this comparison, the behavior that does not meet the expectations of the production plan is regarded as abnormal behavior, and the posture that can clearly represent the current abnormal behavior is called abnormal behavior posture. Abnormal behavior postures that persist for a long time can serve as abnormal prompt information to inform livestock workers that production conditions are abnormal and that they need to promptly check the specific causes and resolve them. This is also in line with the emphasis of modern animal husbandry on improving pasture management efficiency and accuracy. At the same time, the collection and analysis of posture data can also help farm managers better understand the health status and behavioral habits of cattle, predict problems in advance and adjust animal husbandry plans, thereby reducing manpower input and resource waste.

[0003] Here are some practical application scenarios: for example, during the feeding period, all cattle should be eating, but if a certain cattle is monitored not eating for a long time, then the animal husbandry technician should be prompted to check whether the cattle has food accumulation, insufficient gastric motility or other gastrointestinal diseases that cause its loss of appetite. For another example, if a certain cattle does not eat but drinks a lot of water during the feeding period, then the animal husbandry technician should be prompted to confirm whether the feed type fed to the cattle for a long time is too single, resulting in a lack of vitamins in the cattle's daily diet, so they only want to drink water but not eat food. At this time, you should consider adjusting the feed structure, or supplementing the cattle with vitamins such as multivitamin supplements. Otherwise, the cattle will continue to drink a lot of water, which will cause electrolyte imbalance in their bodies, leading to diarrhea, and in severe cases, water poisoning and death. Also, during the rest and rumination period, most cattle lie on the fence, but if a certain cattle is monitored lying on its side or wandering for a long time, then the animal husbandry technician should be prompted to check whether the cattle has mechanical trauma, and if so, medical treatment should be carried out in time. During the non-estrus period, if the cows are frequently mounted (that is, the corresponding bulls are mounted), then the animal husbandry technicians should be prompted to check whether the cows have follicular cysts or male ecstasy and provide timely treatment. On the contrary, if the bulls and cows are always wandering around without mounting during the estrus period, the animal husbandry technicians should be prompted to check the bulls for hoof diseases and cows for ovarian and uterine diseases. In short, when the cows are detected to have behaviors that violate the expectations of the production plan for a long time, the animal husbandry technicians can be prompted to conduct targeted inspections and treatments for the problems.

[0004] At present, in actual ranch production, it is still very common to rely on animal husbandry technicians to conduct manual inspections. At the level of a few hundred heads, it can still cover problem detection and processing relatively well. However, once the number of cattle reaches or even exceeds the level of a few thousand heads, the workload of manual inspections becomes very large, not to mention large ranches with tens of thousands of heads. Routine manual inspections involve a lot of manpower input and waste of inspection resources. Therefore, there is a need for exogenous regular inspections of cattle in stock to prompt animal husbandry technicians to conduct targeted inspections and handle possible problems. At the same time, a matching animal husbandry health management Internet of Things platform is also really needed.

[0005] Based on the above needs, IoT companies and university research institutions are actively promoting the development and popularization of various livestock management platforms. Among them, the recognition and classification of abnormal behavior of cattle based on video images and the provision of directional prompts to livestock technicians have always been an important function that has received attention.

[0006] For the problem of cow posture recognition, there are actually many existing recognition algorithm frameworks that can first detect a single cow target from the picture, then cut out the area where it is located and then identify the skeleton key points of the whole body of a single cow, and finally affine the coordinate positions of all the skeleton key points back to the global coordinate points in the original picture for output, such as Figure 1 shown.

[0007] Comparing with the above requirements, it is not difficult to find that this technology has the following disadvantages: Disadvantage 1. As a user, what you actually want is an enumerated posture classification similar to [0: walking 1: lying down 2: lying on the side 3: climbing 4: eating 5: drinking water]. From the perspective of semantic communication, this is more conducive to people's rapid understanding, and from the perspective of business logic links, it is more suitable for the low-load transmission requirements of the livestock management platform from posture detection and recognition → data upload to the back end → front-end screen summary and display. If the posture output is presented according to the existing 20 skeleton key points, then the computing model side must first output a set of 20-point coordinate data lists for each frame, then bind the frame ID and upload it to the back end, and then transmit it to the front end. So far, the front end cannot display this data in a direct list form, because no one can directly understand the posture of the cow from a bunch of coordinate point values. Therefore, the front end also needs a coordinate connection drawing tool to draw 20 skeleton key points first, and then connect the logically related skeleton points to outline the posture of the cow as a whole. Finally, people observe and understand its specific posture. In this way, only one posture can be seen at a time, rather than a set of continuous posture values ​​within a time period.

[0008] Faced with the dilemma of the first disadvantage, it is easy to think that since the coordinates of the 20 key bone points of the cow in the current picture have been obtained, then it is enough to parse out which enumeration posture the cow's current posture is closer to based on these coordinates. This is indeed a reasonable idea, that is, to classify the posture by analyzing the geometric relationship between the coordinates of the bone points. There are indeed some open source projects that practice this method. There are many schools of thought here. Some directly calculate the Euclidean distance with the standard posture coordinate point template to evaluate the similarity, some use linear interpolation algorithms for feature extraction, and some first connect the limbs and the skeleton outline through the bone points and then use trigonometric functions to calculate the bending angles of each joint before classification. However, without exception, they all introduce the second disadvantage, that is, a large number of complex geometric relationship operations must be performed, and the geometric analysis parameters required also require a lot of time and effort to debug and summarize.

[0009] Therefore, how to provide an abnormal behavior posture monitoring solution suitable for large-scale cattle herds at a lower cost and reduce the cognitive load on users is a problem that needs to be solved in this field. Summary of the invention

[0010] The purpose of the embodiments of the present application is to provide a method for monitoring and identifying abnormal behavior postures of cattle, so as to reduce the cognitive load on users and realize the monitoring and identification of abnormal behavior postures of cattle through lower labor costs and computing power load of livestock management systems.

[0011] In order to achieve the above purpose, the embodiments of the present application are implemented in the following manner:

[0012] In a first aspect, an embodiment of the present application provides a method for monitoring and identifying abnormal behavior and posture of cattle, comprising: acquiring a monitoring image, wherein the monitoring image contains cattle; performing target detection on the monitoring image to determine a plurality of target frames, wherein each target frame contains a cow image; performing skeletal key point detection on the cow image in each target frame to determine skeletal key point coordinate data corresponding to the cow image in each target frame; inputting the skeletal key point coordinate data into a preset cattle posture recognition model to determine the cattle posture corresponding to the cattle image in the target frame; based on the cattle posture, determining whether the target cattle corresponding to the target frame exhibits abnormal behavior.

[0013] In combination with the first aspect, in a first possible implementation of the first aspect, target detection is performed on the monitoring image to determine a number of target frames, including: using a target detector model to perform target detection on the monitoring image to determine a number of target frames, each target frame containing a cow image, wherein the target detector model is constructed using the MMDetection target detection framework.

[0014] In combination with the first aspect, in a second possible implementation method of the first aspect, skeletal key point detection is performed on the cattle image in each target frame, and the skeletal key point coordinate data corresponding to the cattle image in each target frame is determined, including: for each cattle image in the target frame: a skeletal key point detector model is used to perform skeletal key point detection on the cattle image in the target frame, and the skeletal key point coordinate data corresponding to the cattle image in the target frame is determined, wherein the skeletal key point detector model is constructed using the MMPose skeletal key point detection framework.

[0015] In combination with the first aspect, in a third possible implementation of the first aspect, the cattle posture recognition model includes an input layer, a first hidden layer, a second hidden layer, and an output layer connected in sequence, wherein the input layer is used to receive input skeleton key point coordinate data and output the skeleton key point coordinate data to the first hidden layer; the first hidden layer is used to perform full connection processing on the skeleton key point coordinate data, determine the first intermediate data, and output the first intermediate data to the second hidden layer after performing a nonlinear transformation; the second hidden layer is used to perform full connection processing on the first intermediate data after the nonlinear transformation, determine the second intermediate data, and output the second intermediate data to the output layer after performing a nonlinear transformation; the output layer is used to perform full connection processing on the second intermediate data after the nonlinear transformation, determine the third intermediate data, perform loss calculation on the third intermediate data, determine the cattle posture and output it.

[0016] In combination with the third possible implementation of the first aspect, in a fourth possible implementation of the first aspect, the skeleton key point coordinate data includes 20 coordinate data, each coordinate data includes an X coordinate and a Y coordinate, and the input layer is used to receive the skeleton key point coordinate data with a width of 40 and output it to the first hidden layer; the first hidden layer, the forward propagation activation function of the tail connection uses the Sigmoid function, the first hidden layer is used to receive the skeleton key point coordinate data with a width of 40, output the first intermediate data with a width of 20, and use the Sigmoid function to perform a nonlinear transformation on the first intermediate data; the second hidden layer, the forward propagation activation function of the tail connection The activation function uses the Sigmoid function, the second hidden layer is used to receive the first intermediate data with a width of 20 after nonlinear transformation, output the second intermediate data with a width of 10, and use the Sigmoid function to perform nonlinear transformation on the second intermediate data; the output layer, the loss function of the tail connection uses the MSE_Loss function, the output layer is used to receive the second intermediate data with a width of 10 after nonlinear transformation, output the third intermediate data with a width of 5, and calculate the mean square error between the third intermediate data and the 5-bit unique hot encoding converted from each cow posture label through the MSE_Loss function, and determine the cow posture based on the mean square error and output it.

[0017] In combination with the fourth possible implementation method of the first aspect, in a fifth possible implementation method of the first aspect, the cattle posture labels include walking, lying prone, lying sideways, climbing, and eating, and the corresponding 5-bit one-hot codes are [1,0,0,0,0], [0,1,0,0,0], [0,0,1,0,0], [0,0,0,1,0], and [0,0,0,0,1], respectively. The mean square error between the third intermediate data and the 5-bit one-hot code converted from each cattle posture label is calculated by the MSE_Loss function, and the cattle posture is determined based on the mean square error and output, including: for each cattle posture label corresponding to the one-hot code: calculating the mean square error between the third intermediate data with a width of 5 and the one-hot code corresponding to the current cattle posture label by the MSE_Loss function; determining the value closest to 1 from the mean square errors corresponding to the 5 cattle posture labels, and determining the cattle posture label corresponding to this value as the cattle posture corresponding to the cattle image in the target box and outputting it.

[0018] In combination with the fifth possible implementation manner of the first aspect, in the sixth possible implementation manner of the first aspect, the diet in the cattle posture label includes two subdivided posture labels: drinking and eating. If the determined cattle posture label is diet, the method also includes: determining at least one of a water source area and a food area from the monitoring image; determining the nose coordinates of the cattle image in the target frame; and determining whether the cattle posture corresponding to the cattle image in the target frame is drinking or eating based on the nose coordinates, the water source area and / or the food area.

[0019] In combination with the sixth possible implementation manner of the first aspect, in the seventh possible implementation manner of the first aspect, based on the nose coordinates, the water source area and / or the food area, it is determined whether the posture of the cow corresponding to the cow image in the target frame is drinking water or eating food, including: when there is a water source area but no food area in the monitoring image, the cow's posture is determined to be drinking water; when there is no water source area and there is a food area in the monitoring image, the cow's posture is determined to be eating food; when there are both a water source area and a food area in the monitoring image, based on the nose coordinates, the water source area and the food area, it is determined whether the cow's posture is drinking water or eating food.

[0020] In combination with the seventh possible implementation method of the first aspect, in the eighth possible implementation method of the first aspect, based on the nose coordinates, the water source area and the food area, determining whether the cow's posture is drinking or eating includes: calculating the distance between the nose coordinates and the water source area to determine a first distance value; calculating the distance between the nose coordinates and the food area to determine a second distance value; if the first distance value is less than the second distance value, determining that the cow's posture is drinking; if the first distance value is not less than the second distance value, determining that the cow's posture is eating.

[0021] In combination with the eighth possible implementation method of the first aspect, in a ninth possible implementation method of the first aspect, based on the posture of the cow, determining whether the target cow corresponding to the target box has abnormal behavior includes: obtaining the normal posture of the cow at the current stage; if the posture of the cow corresponding to the cow image in the target box does not match the normal posture and meets the frequency setting conditions, determining that the target cow corresponding to the target box has abnormal behavior.

[0022] Beneficial effects:

[0023] 1. This application obtains monitoring images (including cattle); performs target detection to determine several target frames (containing a cattle image); performs skeletal key point detection on the cattle image in each target frame to obtain the corresponding skeletal key point coordinate data; inputs the skeletal key point coordinate data into a preset cattle posture recognition model to determine the cattle posture corresponding to the cattle image in the target frame; thereby, based on the cattle posture, determines whether the target cattle corresponding to the target frame has abnormal behavior. Such a scheme is an end-to-end mode (input monitoring images, output cattle posture types for users to judge, or output monitoring results of whether cattle have abnormal behavior), following the following new path, namely [target detection] → [skeletal key point detection] → [fully connected classification]. Its end-to-end design concept allows users to obtain corresponding posture enumeration values ​​by simply inputting images without having to bear extra cognitive load. Similarly, if a video is input, a continuous list of posture enumeration values ​​is output along the frame slices, which is equivalent to the continuous reuse of a single image. This greatly reduces the user's cognitive load, which is not only conducive to the user's quick understanding, but also convenient for direct access to the livestock management system for table registration and subsequent table operations. For the judgment of abnormal behavior, it can be designed with automatic rules for identifying abnormal behavior, or it can be judged manually, which is very convenient.

[0024] 2. The cattle posture recognition model designed in this scheme adopts a lightweight neural network structure design. There is no need to debug and summarize a large number of complex geometric analysis parameters in advance, and there is no need to perform a large number of complex geometric relationship calculations for each picture during operation, thereby reducing the computing power load of the entire livestock management system.

[0025] 3. The cattle posture recognition model of this scheme includes an input layer, a first hidden layer, a second hidden layer and an output layer. The skeleton key point detection is performed on the cattle image in the target frame obtained by target detection. The obtained skeleton key point coordinate data (width is 40 bits) is used as the model input. Through the full connection processing and nonlinear transformation of the first hidden layer, the first intermediate data (width is 20 bits) after nonlinear processing is obtained. Through the full connection processing and nonlinear transformation of the second hidden layer, the second intermediate data (width is 10 bits) after nonlinear processing is obtained. After the full connection processing of the output layer, the third intermediate data (width is 5 bits) is obtained. The 5-bit third intermediate data corresponds to the label category of the cattle posture. The MSE_Loss function is designed to calculate the mean square error between the third intermediate data and the 5-bit unique hot encoding converted from each cattle posture label, thereby cleverly realizing the classification of cattle posture. As for the posture of eating, the judgment conditions are also cleverly designed to further subdivide the posture of eating and drinking water, ensuring the accuracy of cattle posture recognition, thereby realizing reliable monitoring of abnormal behavior of cattle.

[0026] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0027] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments of the present application will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0028] Figure 1 This is a schematic diagram of the key points of the skeleton of a single cow in the prior art.

[0029] Figure 2 A flowchart of a method for monitoring and identifying abnormal behavior posture of cattle provided in an embodiment of the present application.

[0030] Figure 3 Schematic diagram of obtaining a target frame for target detection of cattle in a monitoring image.

[0031] Figure 4 Schematic diagram of detecting skeleton key points of a cow image within a target frame.

[0032] Figure 5 This is a structural diagram of the cattle posture recognition model.

[0033] Figure 6This is a data diagram of the MSE_Loss loss function value and the iterative training process in model training.

[0034] Icon: 10-cow posture recognition model; 11-input layer; 12-first hidden layer; 13-second hidden layer; 14-output layer. DETAILED DESCRIPTION

[0035] The technical solutions in the embodiments of the present application will be described below in conjunction with the drawings in the embodiments of the present application.

[0036] See also Figure 2 , Figure 2 A flowchart of a method for monitoring and identifying abnormal behavior of cattle provided in an embodiment of the present application. In this embodiment, the method for monitoring and identifying abnormal behavior of cattle can be run by an electronic device (such as a smart terminal, a server, etc.), and can include steps S10, S20, S30, S40, and S50.

[0037] In order to monitor and identify abnormal behavior of cattle, the electronic device may first execute step S10.

[0038] Step S10: Acquire a monitoring image, wherein the monitoring image contains cattle.

[0039] In this embodiment, the electronic device can obtain a monitoring image, and the monitoring image includes cattle. For example, it can be a video or image taken by a monitoring device installed in a ranch. If it is a video, the monitoring image can be obtained by extracting frames and sent to the electronic device; if it is an image, it can be sent to the electronic device as a monitoring image.

[0040] After obtaining the monitoring image, the electronic device may execute step S20.

[0041] Step S20: performing target detection on the monitoring image to determine a number of target frames, wherein each target frame contains a cow image.

[0042] In this embodiment, the electronic device can use the target detector model to perform target detection on the monitoring image, determine a number of target frames, each target frame contains a cow image, and the target detector model is constructed using the MMDetection target detection framework.

[0043] Since the target detection algorithm based on CNN convolutional neural network is now a fairly mature technology, developers do not need to reinvent the wheel. They can achieve very good cattle target detection effects by using the existing algorithm framework and weight model.

[0044] Therefore, this embodiment uses the MMDetection target detection framework. MMDetection is an open source target detection toolbox framework with MMCV as the core component, PyTorch as the implementation basis, belonging to the OpenMMLab open source algorithm system, and jointly maintained by the Multimedia Laboratory of the Chinese University of Hong Kong and SenseTime. This embodiment can use the method of using its framework components and follow its technical specifications to build a target detector model of [image input preprocessing] → [backbone network] → [neck component] → [prediction detection head] → [loss function] → [target frame output], and then load the pre-trained weights that have been trained to identify the location of the cattle target in the monitoring image and frame it in the form of a rectangular frame area (such as Figure 3 As shown), we get a dictionary output similar to the following, where the attributes are used in subsequent calculations.

[0045]

[0046]

[0047] After determining the target frame, the electronic device may execute step S30.

[0048] Step S30: Detect skeleton key points of the cow image in each target frame to determine the skeleton key point coordinate data corresponding to the cow image in each target frame.

[0049] In this embodiment, for each cow image in the target frame: the electronic device can use a skeleton key point detector model to perform skeleton key point detection on the cow image in the target frame, and determine the skeleton key point coordinate data corresponding to the cow image in the target frame. The skeleton key point detector model is constructed using the MMPose skeleton key point detection framework.

[0050] Since the skeleton key point detection algorithm based on CNN convolutional neural network is currently a fairly mature technology, the existing algorithm framework and weight model can achieve very good cattle target detection effect. This embodiment uses the MMPose skeleton key point detection framework. MMPose is a skeleton key point detection open source toolbox framework with MMCV as the core component, PyTorch as the implementation basis, belonging to the OpenMMLab open source algorithm system, and jointly maintained by the Multimedia Laboratory of the Chinese University of Hong Kong and SenseTime Technology. This embodiment can use the method of using its framework components and follow its technical specifications to build a skeleton key point detector model of [target frame input preprocessing] → [backbone network] → [neck component] → [prediction detection head] → [loss function] → [skeletal coordinate point list output], and then load the pre-trained weights that have been trained, and you can identify the coordinate positions of 20 skeleton key points of cattle (such as Figure 4 ), and output as an ordered list of coordinate points similar to the following.

[0051] Cow_1_skeleton_keypoints__20=[

[0052] / / Serial number: coordinates [x, y]

[0053] 0: [55.4, 108.6], / / left_eye left eye point

[0054] 1: [35.7, 108.7], / / right_eye right eye point

[0055] 2: [61.3, 104.6], / / left_ear left ear point

[0056] 3: [29.8, 102.7], / / right_ear right ear point

[0057] 4: [43.6, 128.2], / / nose point

[0058] 5: [63.2, 140.1], / / throat point

[0059] 6: [205.1, 100.7], / / root__of_tail root point

[0060] 7: [86.9, 92.8], / / hump point

[0061] 8: [94.7, 149.9], / / left_shoulder left shoulder point

[0062] 9: [96.7, 153.8], / / right_shoulder right shoulder point

[0063] 10: [189.2, 138.1], / / left_hip left hip point

[0064] 11: [173.5, 145.9], / / right_hip right hip point

[0065] 12: [94.7, 177.5], / / left_elbow left elbow point

[0066] 13: [92.8, 173.5], / / right_elbow right elbow point

[0067] 14: [203.0, 171.5], / / left_knee left knee point

[0068] 15: [189.2, 173.6], / / right_knee right knee point

[0069] 16: [92.8, 201.1], / / left_front_paw left front paw position

[0070] 17: [92.9, 197.2], / / right__front_paw right front paw point

[0071] 18: [206.9, 199.2, / / left__back_paw left hind paw position

[0072] 19: [181.3, 199.1], / / right_back__paw right hind paw position ]

[0074] Based on this, the electronic device can determine the coordinate data of the skeleton key points corresponding to the cow image in each target frame. Afterwards, the electronic device can execute step S40.

[0075] Step S40: inputting the coordinate data of the skeleton key points into a preset cow posture recognition model to determine the cow posture corresponding to the cow image in the target frame.

[0076] In order to facilitate the understanding of this solution, the cattle posture recognition model 10 is first introduced here.

[0077] In this embodiment, the cattle posture recognition model 10 is designed to include an input layer 11, a first hidden layer 12, a second hidden layer 13, and an output layer 14 connected in sequence. Figure 5 shown.

[0078] The input layer 11 is used to receive the input skeleton key point coordinate data and output the skeleton key point coordinate data to the first hidden layer 12. Since the skeleton key point coordinate data includes 20 coordinate data, each coordinate data includes an X coordinate and a Y coordinate, the input layer 11 is designed to receive the skeleton key point coordinate data with a width of 40 (the skeleton key point coordinate data in the form of an ordered list of coordinate points determined in the previous step needs to be preprocessed to form a one-dimensional preprocessed coordinate value array with a width of 40 bits) and output it to the first hidden layer 12.

[0079] For example, the input layer 11 receives the pre-processed skeleton key point coordinate data with a width of 40, which is recorded as

[40] .

[0080] The first hidden layer 12 is used to perform full connection processing on the coordinate data of the skeleton key points, determine the first intermediate data, and perform nonlinear transformation on the first intermediate data before outputting it to the second hidden layer 13. Specifically, the forward propagation activation function connected to the tail of the first hidden layer 12 uses the Sigmoid function. The first hidden layer 12 is used to receive the coordinate data of the skeleton key points with a width of 40 (a one-dimensional preprocessed coordinate value array with a width of 40 bits), output the first intermediate data with a width of 20, and use the Sigmoid function to perform nonlinear transformation on the first intermediate data.

[0081] For example, the first hidden layer 12 is recorded as hidden layer 1, that is, the first fully connected layer, which accepts an input of width 40 and an output width of 20, recorded as Linear(40,20). The forward propagation activation function of the tail connection uses the Sigmoid function, that is, the fully connected output needs to be calculated and processed by the Sigmoid function before being input to the next layer (that is, the second hidden layer 13).

[0082] The second hidden layer 13 is used to perform full connection processing on the first intermediate data after nonlinear transformation, determine the second intermediate data, and output the second intermediate data to the output layer 14 after nonlinear transformation. Specifically, the forward propagation activation function connected to the tail of the second hidden layer 13 also uses the Sigmoid function. The second hidden layer 13 is used to receive the first intermediate data with a width of 20 after nonlinear transformation, output the second intermediate data with a width of 10, and use the Sigmoid function to perform nonlinear transformation on the second intermediate data.

[0083] For example, the second hidden layer 13 is recorded as hidden layer 2, that is, the second fully connected layer, which accepts input of width 20 and outputs width 10, recorded as Linear(20,10), and the forward propagation activation function of the tail connection uses the Sigmoid function, that is, the fully connected output needs to be calculated and processed by the Sigmoid function before being input to the next layer (that is, the output layer 14).

[0084] The output layer 14 is used to perform full connection processing on the second intermediate data after nonlinear transformation, determine the third intermediate data, calculate the loss of the third intermediate data, determine the posture of the cow and output it. Specifically, the loss function connected at the end of the output layer 14 uses the MSE_Loss function, then the output layer 14 is used to receive the second intermediate data after nonlinear transformation with a width of 10, output the third intermediate data with a width of 5, and calculate the mean square error between the third intermediate data and the 5-bit unique hot encoding converted from each cow posture label through the MSE_Loss function, and determine the cow posture based on the mean square error and output it.

[0085] For example, the cattle posture labels may include walking, lying prone, lying sideways, climbing, and eating, and the corresponding 5-bit one-hot encodings are [1,0,0,0,0], [0,1,0,0,0], [0,0,1,0,0], [0,0,0,1,0], and [0,0,0,0,1]. Then, the one-hot encoding corresponding to each cattle posture label is:

[0086] The output layer 14 can calculate the mean square error between the third intermediate data with a width of 5 and the unique hot encoding corresponding to the current cow posture label through the MSE_Loss function, determine the value closest to 1 from the mean square errors corresponding to the five cow posture labels, and determine the cow posture label corresponding to this value as the cow posture corresponding to the cow image in the target box and output it.

[0087] For example, the output layer 14, that is, the third fully connected layer, accepts an input of width 10 and an output width of 5 (corresponding to the closeness values ​​of the five posture classifications), which is recorded as Linear(10,5). It should be noted here that the tail is no longer connected to the forward propagation activation function, but requires a loss function to evaluate the accuracy of the output result. The smaller the loss function value, the closer the output result is to the actual posture classification enumeration value, which means that the prediction result is closer to the actual situation. In this embodiment, the MSE_Loss function is selected.

[0088] Here, the prepared real posture enumeration value corresponding to the input of width 40 in the form of a one-dimensional preprocessed coordinate value array (i.e., the preprocessed skeletal key point coordinate data) can be first converted into a one-hot encoding with a width of 5 (for example, 0: walking = [1,0,0,0,0], 1: lying down = [0,1,0,0,0], 2: lying on the side = [0,0,1,0,0], 3: climbing = [0,0,0,1,0], 4: eating = [0,0,0,0,1]), and then the MSE mean square error between the fully connected output with a width of 5 and the one-hot encoding with a width of 5 is calculated, that is, MSE_Loss is used as the loss function to evaluate the accuracy.

[0089] After building the architecture of the cattle posture recognition model 10, the 1000 pre-prepared samples can be split and used. For example, 700 samples are extracted from the 800 samples from the AP-10K dataset, and 100 samples are extracted from the 200 self-shot samples to form a training set for neural network training. The remaining (800-700)+(200-100)=200 samples together form a validation set, which is used to verify the classification effect of the cattle posture recognition model 10. During the training process, the SGD stochastic gradient descent method is selected as the parameter update optimizer of the fully connected neural network. With multiple iterative training, it can be seen that the MSE_Loss loss function value continues to decrease, such as Figure 6 As shown in the figure, the recognition accuracy can reach about 95.7%, which is enough to meet the application requirements of the livestock management platform.

[0090] The above is a detailed introduction to the cattle posture recognition model 10 . The following will introduce the process of performing cattle posture recognition using the preset cattle posture recognition model 10 .

[0091] After obtaining the skeletal key point coordinate data of a cow image in a target frame in step S30, the electronic device can run step S40 to input the skeletal key point coordinate data (formed into a fixed one-dimensional preprocessed coordinate value array with a width of 40 bits after preprocessing) into the cow posture recognition model 10, and identify the cow posture corresponding to the cow image in the target frame through the cow posture recognition model 10.

[0092] For example, taking the monitoring image in the previous example as an example, the bone key point coordinate data of the cow image in the target frame is preprocessed into a 40-bit width one-dimensional preprocessed coordinate value array form and then input into the cow posture recognition model 10. The cow posture recognition model 10 can receive the 20 bone key point coordinate sequences of the cow output by the second step of bone key point detection as input, and then infer the cow posture classification enumeration value. Figure 3 and Figure 4) is taken as an example, and Cow_1_skeleton_keypoints_20 is pushed into the cow posture recognition model 10 to get the output [1.0128, 0.0075, -0.0168, 0.0489, 0.0971]. Then find out that the value closest to 1 is 1.0128, and its corresponding subscript is 0. Query the subscript definition [0: Wandering 1: Lying 2: Lying on the side 3: Climbing 4: Eating] to know that the cow posture is wandering. Similarly, the Cow_2_skeleton_keypoints_20 of another cow is pushed into the cow posture recognition model 10 to get the output [-0.1075, 0.9852, 0.2243, 0.0962, 0.1141]. Then find out that the value closest to 1 is 0.9852, and its corresponding subscript is 1. Query the subscript definition [0: Wandering 1: Lying 2: Lying on the side 3: Climbing 4: Eating] to know that the cow's posture is lying down.

[0093] Thus, the electronic device can recognize the posture of the cow corresponding to the cow image in the target frame.

[0094] Since the posture of the cattle is eating, it can be further subdivided into drinking and eating postures. This subdivision is indeed very meaningful for animal husbandry management. However, from the perspective of cattle posture recognition, the two postures of eating and drinking are too close, almost identical, so it is difficult to effectively distinguish them only by the cattle posture recognition model 10. Therefore, a set of eating posture subdivision judgment strategies can be added to efficiently and reliably realize the subdivision of the two cattle postures of drinking and eating.

[0095] For example, based on the cattle posture recognition model 10, a layer of target detector can be cascaded conditionally. That is, if the cattle posture recognized by the cattle posture recognition model 10 is [4: eating], then the electronic device also needs to detect the area frames of the food area and the water source area in the picture, and then calculate the Euclidean distance between the cattle's nose point (that is, a set of coordinate points in the skeletal key point coordinate data in the previous text) and the food area and the water source area respectively. If the Euclidean distance to the food area is closer, then it is judged as [4: eating], and if the Euclidean distance to the water source area is closer, then it is judged as [5: drinking water].

[0096] Therefore, the diet in the cattle posture label can include two sub-posture labels of drinking and eating. If the determined cattle posture label is eating, the electronic device can also determine at least one of the water source area and the food area from the monitoring image. Then, the electronic device can determine the nose coordinates of the cattle image in the target frame, and then determine whether the cattle posture corresponding to the cattle image in the target frame is drinking or eating based on the nose coordinates, the water source area and / or the food area.

[0097] Exemplarily, when there is a water source area and no food area in the monitoring image, the electronic device can determine that the cow's posture is drinking water. When there is no water source area and a food area in the monitoring image, the electronic device can determine that the cow's posture is eating food. When there are both a water source area and a food area in the monitoring image, the electronic device needs to determine whether the cow's posture is drinking water or eating food based on the nose coordinates, the water source area, and the food area.

[0098] Specifically, the electronic device can calculate the distance between the nose coordinates and the water source area to determine a first distance value, and then calculate the distance between the nose coordinates and the food area to determine a second distance value. If the first distance value is less than the second distance value, the electronic device can determine that the cow is drinking water; if the first distance value is not less than the second distance value, the electronic device can determine that the cow is eating.

[0099] After determining the posture of the cow corresponding to the cow image in the target frame, the electronic device may further execute step S50.

[0100] Step S50: Based on the posture of the cow, determine whether the target cow corresponding to the target frame has abnormal behavior.

[0101] In this embodiment, based on the posture of the cattle, whether the target cattle corresponding to the target frame has abnormal behavior can be determined manually by the user. Of course, it can also be determined by electronic equipment according to rules to determine whether the target cattle has abnormal behavior.

[0102] Exemplarily, the electronic device can obtain the normal posture of the cow in the current stage (for example, during sleep and rest, the normal posture of the cow is lying prone); if the posture of the cow corresponding to the cow image in the target frame is inconsistent with the normal posture (for example, the cow's posture is wandering), and meets the frequency setting conditions (for example, 5 consecutive times in 10 frames of monitoring images acquired within 10 minutes are inconsistent with the normal posture), the electronic device can determine that the target cow corresponding to the target frame has abnormal behavior, and prompt the management personnel to pay attention to the target cow.

[0103] In summary, the embodiment of the present application provides a monitoring and identification method for abnormal behavior postures of cattle, by acquiring a monitoring image (including cattle); performing target detection to determine a number of target frames (containing a cattle image); performing skeletal key point detection on the cattle image in each target frame to obtain corresponding skeletal key point coordinate data; inputting the skeletal key point coordinate data into a preset cattle posture recognition model 10 to determine the cattle posture corresponding to the cattle image in the target frame; thereby determining whether the target cattle corresponding to the target frame has abnormal behavior based on the cattle posture. Such a scheme is an end-to-end mode (inputting a monitoring image, outputting the type of cattle posture for the user to judge, or outputting the monitoring result of whether the cattle has abnormal behavior), which greatly reduces the cognitive load of the user, is conducive to the user's quick understanding, and is also convenient for direct access to the livestock management system for table registration and subsequent table operations.

[0104] The cattle posture recognition model 10 designed in this scheme adopts a lightweight neural network structure design. There is no need to debug and summarize a large number of complex geometric analysis parameters in advance, and there is no need to perform a large number of complex geometric relationship calculations for each picture during operation, thereby reducing the computing power load of the entire livestock management system.

[0105] The cattle posture recognition model 10 of the present scheme comprises an input layer 11, a first hidden layer 12, a second hidden layer 13 and an output layer 14. Skeletal key point detection is performed on the cattle image in the target frame obtained by target detection, and the obtained skeletal key point coordinate data (width of 40 bits) is used as the model input. The first intermediate data (width of 20 bits) after nonlinear processing is obtained through the full connection processing and nonlinear transformation of the first hidden layer 12. The second intermediate data (width of 10 bits) after nonlinear processing is obtained through the full connection processing and nonlinear transformation of the second hidden layer 13. The third intermediate data (width of 5 bits) is obtained through the full connection processing of the output layer 14. The 5-bit third intermediate data is corresponded to the label category of the cattle posture. The MSE_Loss function is designed to calculate the mean square error between the third intermediate data and the 5-bit unique hot encoding converted from each cattle posture label, thereby cleverly realizing the classification of cattle posture. As for the eating posture, the judgment conditions are cleverly designed to further subdivide the eating and drinking postures, ensuring the accuracy of cattle posture recognition, thereby achieving reliable monitoring of abnormal cattle behavior.

[0106] In this document, relational terms such as first and second, etc. are used merely to distinguish one entity or operation from another entity or operation, but do not necessarily require or imply any such actual relationship or order between these entities or operations.

[0107] The above description is only an embodiment of the present application and is not intended to limit the protection scope of the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.

Claims

1. A method for monitoring and identifying abnormal behavior of cattle, characterized in that: include: Acquire a monitoring image, wherein the monitoring image contains cattle; Perform target detection on the monitoring image and determine a number of target frames, each of which contains a cow image; Performing skeleton key point detection on the cattle image in each target frame, and determining the skeleton key point coordinate data corresponding to the cattle image in each target frame; Input the coordinate data of the key points of the skeleton into a preset cow posture recognition model to determine the cow posture corresponding to the cow image in the target frame; Based on the posture of the cattle, determine whether the target cattle corresponding to the target frame has abnormal behavior.

2. The method for monitoring and identifying abnormal behavior of cattle according to claim 1, characterized in that: Perform target detection on the monitoring image and determine several target frames, including: The target detector model is used to perform target detection on the monitoring image to determine several target frames, each of which contains a cow image. The target detector model is constructed using the MMDetection target detection framework.

3. The method for monitoring and identifying abnormal behavior of cattle according to claim 1, characterized in that: Perform skeleton key point detection on the cow image in each target frame to determine the skeleton key point coordinate data corresponding to the cow image in each target frame, including: For each cow image in the target box: A skeleton key point detector model is used to detect skeleton key points of the cattle image in the target frame to determine the skeleton key point coordinate data corresponding to the cattle image in the target frame. The skeleton key point detector model is constructed using the MMPose skeleton key point detection framework.

4. The method for monitoring and identifying abnormal behavior of cattle according to claim 1, characterized in that: The cattle posture recognition model includes an input layer, a first hidden layer, a second hidden layer, and an output layer connected in sequence. The input layer is used to receive input skeleton key point coordinate data and output the skeleton key point coordinate data to the first hidden layer; The first hidden layer is used to perform full connection processing on the coordinate data of the skeleton key points, determine the first intermediate data, and perform nonlinear transformation on the first intermediate data and then output it to the second hidden layer; The second hidden layer is used to perform full connection processing on the first intermediate data after nonlinear transformation, determine the second intermediate data, and perform nonlinear transformation on the second intermediate data and then output it to the output layer; The output layer is used to perform full connection processing on the second intermediate data after nonlinear transformation, determine the third intermediate data, perform loss calculation on the third intermediate data, determine the posture of the cow and output it.

5. The method for monitoring and identifying abnormal behavior of cattle according to claim 4, characterized in that: The coordinate data of the skeleton key points contains 20 coordinate data, each of which contains X coordinates and Y coordinates. The input layer is used to receive the coordinate data of the skeleton key points with a width of 40 and output it to the first hidden layer; The first hidden layer, the tail connection forward propagation activation function uses the Sigmoid function, the first hidden layer is used to receive the skeleton key point coordinate data with a width of 40, output the first intermediate data with a width of 20, and use the Sigmoid function to perform nonlinear transformation on the first intermediate data; The second hidden layer, the tail connection forward propagation activation function uses the Sigmoid function, the second hidden layer is used to receive the first intermediate data with a width of 20 after nonlinear transformation, output the second intermediate data with a width of 10, and use the Sigmoid function to perform nonlinear transformation on the second intermediate data; The output layer uses the MSE_Loss function as the loss function for the tail connection. The output layer is used to receive the second intermediate data with a width of 10 after nonlinear transformation, output the third intermediate data with a width of 5, and calculate the mean square error between the third intermediate data and the 5-bit unique hot encoding converted from each cow posture label through the MSE_Loss function, and determine the cow posture based on the mean square error and output it.

6. The method for monitoring and identifying abnormal behavior of cattle according to claim 5, characterized in that: The cattle posture labels include walking, lying down, lying sideways, climbing, and eating, and the corresponding 5-bit unique hot codes are [1,0,0,0,0], [0,1,0,0,0], [0,0,1,0,0], [0,0,0,1,0], and [0,0,0,0,1]. The mean square error between the third intermediate data and the 5-bit unique hot code converted from each cattle posture label is calculated by the MSE_Loss function, and the cattle posture is determined based on the mean square error and output, including: For the one-hot encoding corresponding to each cow posture label: the mean square error between the third intermediate data with a width of 5 and the one-hot encoding corresponding to the current cow posture label is calculated by the MSE_Loss function; The value closest to 1 is determined from the mean square errors corresponding to the five cow posture labels, and the cow posture label corresponding to this value is determined as the cow posture corresponding to the cow image in the target frame and output.

7. The method for monitoring and identifying abnormal behavior of cattle according to claim 6, characterized in that: The diet in the cattle posture label includes two subdivided posture labels: drinking water and eating food. If the determined cattle posture label is diet, the method further includes: Determining at least one of a water source area and a food area from the monitoring image; Determine the nose coordinates of the cow image within the target frame; Based on the nose coordinates, the water source area and / or the food area, it is determined whether the posture of the cow corresponding to the cow image in the target frame is drinking water or eating food.

8. The method for monitoring and identifying abnormal behavior of cattle according to claim 7, characterized in that: Based on the nose coordinates, the water source area and / or the food area, determine whether the cow posture corresponding to the cow image in the target frame is drinking water or eating food, including: When there is a water source area and no food area in the monitoring image, determining that the posture of the cattle is drinking water; When there is no water source area and a food area in the monitoring image, determining that the posture of the cattle is feeding; When the monitoring image contains both a water source area and a food area, the posture of the cattle is determined to be drinking water or eating food based on the nose coordinates, the water source area and the food area.

9. The method for monitoring and identifying abnormal behavior of cattle according to claim 8, characterized in that: Based on the nose coordinates, water source area and food area, determine whether the cow is drinking or eating, including: Calculate the distance between the nose coordinates and the water source area to determine a first distance value; Calculating the distance between the nose coordinates and the food area to determine a second distance value; If the first distance value is less than the second distance value, it is determined that the cow is drinking water; if the first distance value is not less than the second distance value, it is determined that the cow is eating food.

10. The method for monitoring and identifying abnormal behavior of cattle according to claim 9, characterized in that: Based on the cow's posture, determine whether the target cow corresponding to the target frame has abnormal behavior, including: Get the normal posture of the cattle at the current stage; If the posture of the cow corresponding to the cow image in the target frame does not match the normal posture and meets the frequency setting condition, it is determined that the target cow corresponding to the target frame has abnormal behavior.

Citation Information

Cited By

  • Transform lightweight model-based cattle health assessment method

    CN120998498A

  • A cow health evaluation method based on a Transformer light-weight model

    CN120998498B