A multi-modal decision layer fusion-based cattle identity recognition method
By collecting multiple biological features in the farm and using a multimodal decision-level fusion method, the accuracy and environmental adaptability problems of traditional single-feature identification were solved, achieving efficient and reliable cattle identification.
Patent Information
- Application Number
- CN202410817759.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-24
- Publication Date
- 2026-11-27
- Estimated Expiration
- 2044-06-24
AI Technical Summary
Traditional single biological characteristics have problems such as high false recognition rate, limited information and poor environmental adaptability in cattle identification, especially insufficient identification accuracy in the complex environment of farms.
A multimodal decision-level fusion method is adopted. Multiple biometric features (cattle face, nose mirror pattern and ear tag) are collected in the scenarios of cattle drinking water and eating in the farm. The features are extracted using FaceNet, MobileNetv1 and PP-OCRv4 neural networks, and then combined with decision tree, logistic regression and other algorithms for decision-level fusion to output a unique cattle ID.
It improves the accuracy and robustness of cattle identification, reduces the false recognition rate, enhances the amount of information and the reliability of identification, and adapts to complex farm environments.
Smart Images

Figure CN118823847B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the fields of artificial intelligence technology and livestock information technology, specifically relating to a method for cattle identification based on multimodal decision-level fusion. Background Technology
[0002] In recent years, with the continuous development of science and technology, traditional manual monitoring and breeding has gradually shifted to automatic machine identification and detection. This has led to higher efficiency, lower costs, and more intelligent and sustainable development in animal husbandry, ensuring the quality and safety of livestock products. People are gradually applying artificial intelligence to the animal husbandry industry, which is showing a trend of intelligent and standardized development. People are conducting real-time monitoring of the breeding and health of dairy cows in farms, as this is a prerequisite for ensuring the food safety of meat and dairy products, and a necessary guarantee for management work such as disease prevention and traceability, breeding, breeding, and insurance claims. The main research direction is based on the development model of individual dairy cows that is precise, automated, and intensive.
[0003] Currently, there are still many problems in identifying cattle on farms, specifically in the following aspects:
[0004] (1) Traditional single biological characteristics have a certain misidentification rate. For example, ear tags may fall off, and the cow's face is greatly affected by the shooting angle.
[0005] (2) A single feature contains a limited amount of information and cannot construct a more comprehensive and accurate feature representation. In addition, there are significant individual differences among cattle, and a single feature is unlikely to cover all the differences.
[0006] (3) In the environment of a farm, there are a large number of cattle, the space is narrow, the collection of cattle biological characteristics is limited, and the environment is complex, resulting in a low accuracy rate of cattle identification.
[0007] (4) Existing methods for identifying cattle by photographing local biological features of the cattle’s face are difficult to obtain representative information on the cattle’s biological features, which may lead to a decrease in the identification rate of cattle. Summary of the Invention
[0008] To address the shortcomings of existing technologies, this invention provides a cattle identification method based on multimodal decision-level fusion. This method integrates multiple biological features of cattle collected in scenarios such as drinking water and feeding in a livestock farm. This compensates for the limitations of single biological features (single modality), reduces the false recognition rate, and improves the accuracy and universality of identification. It can effectively solve the aforementioned problems in existing technologies.
[0009] To achieve the above objectives, the present invention is implemented through the following technical solutions.
[0010] This invention provides a method for cattle identification based on multimodal decision-level fusion, comprising the following steps:
[0011] S1. Data acquisition equipment collects facial biometric information of cattle;
[0012] S2. Preprocess the facial biometric information of the cattle to determine the standard photos of the cattle and establish a dataset of cattle facial information.
[0013] S3. Use the cattle face dataset to train the single-modal recognition model in parallel and extract feature vectors;
[0014] S4. Perform special encoding on the feature vectors and use them as input to the decision layer;
[0015] S5. The decision-level fusion algorithm uses a combination of base learners and ensemble learning methods for experimental comparison. The optimal method is selected as the cattle identification model, and the algorithm outputs a unique cattle ID generated by the decision-level fusion algorithm, denoted as ID. final ;
[0016] S6. Deploy a cattle identification model to monitor the cattle herd and identify cattle IDs.
[0017] Preferably, step S1 includes the following steps:
[0018] S10, determine the target cattle and the collection scenario, wherein the collection scenario is the scene of cattle drinking water and / or eating in the farm, and more preferably, collect information from all cattle in the farm;
[0019] S11, located at the front end of the water trough and / or feed trough, the data acquisition device is fixedly installed to collect the facial biometric information of the cattle; more preferably, the data acquisition device is a high-definition camera with a rotation function to collect the facial biometric information of the cattle in a panoramic manner.
[0020] Preferably, in step S11, the high-definition camera is a Hikvision 3T26WDV3-L 4MM camera.
[0021] Preferably, step S2 includes the following steps:
[0022] S21. The video of the cattle's facial biometric information collected by the data acquisition device is transmitted to the background system. It is preprocessed first. The video is decomposed into a series of continuous image frames. Each frame represents a point in time in the video, usually measured in frames per second (FPS). More preferably, the cattle's facial biometric information includes three features: cattle face, cattle nose mirror pattern and cattle ear tag.
[0023] S22. The image frame is segmented into three parts using the SOLO algorithm to form a cow face (background removed), a cow nose mirror pattern, and a cow ear mark.
[0024] S23. Determine the standard photos of cattle from the image frames in S21, and based on the instance segmentation results in S22, establish cattle facial information datasets according to the cattle face, cattle nose mirror pattern and cattle ear mark respectively.
[0025] Preferably, step S3 includes the following steps:
[0026] S31. The FaceNet neural network model is adopted. Cow face images are selected from the cow face information dataset as model input, and the InceptionResNetv1 deep convolutional network model is used as the backbone network for model training to extract the feature vectors of the cow faces. During the single-modal training process, a triplet loss is used to optimize the model's discriminative ability by minimizing the distance between feature vectors of the same cow face and maximizing the distance between feature vectors of different cow faces.
[0027] S32. Using the FaceNet neural network model, images of bovine nose mirror patterns are selected from the bovine facial information dataset as model input. MobileNetv1 is used as the backbone network for model training to extract feature vectors of bovine nose mirror patterns. During single-modal training, a triplet loss is used to optimize the model's discriminative ability by minimizing the distance between feature vectors of the same bovine face and maximizing the distance between feature vectors of different bovine faces.
[0028] The ternary loss is calculated using formula (1).
[0029]
[0030] Where N represents the number of samples, [·] + This represents a function that takes positive values. If the value inside the parentheses is negative, it takes 0; otherwise, it takes the value itself. f(·) represents the Euclidean distance, and f(·) represents the network feature extraction function. Let represent the anchor sample, positive sample, and negative sample of the i-th sample, respectively. α represents a hyperparameter used to adjust the distance between the positive and negative samples. By decreasing the distance between the anchor sample and the positive sample and increasing the distance between the anchor sample and the negative sample, a single-modal model of cow face and cow nose mirror pattern is trained, making the learned feature vectors more discriminative and more accurately identifying different targets. The triplet loss function can effectively optimize the representation of the feature vectors, improving the accuracy and stability of cow face and cow nose mirror pattern recognition.
[0031] S33. Using the PP-OCRv4 model, select cattle ear tag images from the cattle facial information dataset as model input, use PP-LCNetV3 as the backbone network for model training, and extract the feature vector of the cattle ear tag.
[0032] Preferably, step S4 includes the following steps:
[0033] S41, the data in the cattle facial information dataset, excluding the standard photos of cattle, is divided into a training set (Training) and a test set (Testing). Preferably, the ratio of the training set (Training) to the test set (Testing) is 8.5 / 1.5.
[0034] S42, compare the training set Training with standard photos of cattle, and solve for the Euclidean distance between the cattle face and / or the nose mirror pattern;
[0035] S43, compare the training set Training with standard photos of cattle to solve for the similarity of the cattle ear tag text;
[0036] S44. The feature vectors extracted in step S3 are combined with the Euclidean distance and text similarity data by performing One-Hot encoding and used as input to the decision layer.
[0037] Preferably, in step S5, the base learners include decision trees, logistic regression, and Gaussian Naive Bayes; the ensemble learning methods include Bagging (primarily based on bootstrapping and the bias-variance decomposition theorem; bootstrapping is a method of drawing samples with replacement from the original sample set to form a new dataset), Boosting (a machine learning algorithm used to reduce bias in supervised learning; it trains multiple weak classifiers and then weights them together to form a strong classifier), Stacking (an ensemble learning technique that aggregates multiple classification or regression models through a meta-classifier or meta-regression), and VotingClassifier (a voting method).
[0038] Preferably, in step S6, the cattle identification model is deployed to the farm, and the video footage of the cattle monitored by the farm's cameras in real time is transmitted to the backend system and processed according to the above steps S2, S3, S4, and S5 to identify the monitored cattle ID.
[0039] The beneficial effects of this invention are:
[0040] This invention provides a cattle identification method based on multi-feature decision-level fusion, solving the problems of insufficient accuracy, limited information, and poor adaptability to complex environments associated with traditional single-feature identification methods in livestock farms. Compared with existing technologies, this invention has significant advantages in the field of cattle identification, especially in significantly improving identification accuracy, as multi-feature fusion eliminates the risk of high false recognition rates. Simultaneously, the amount of information is effectively increased by utilizing information from multiple biometric features, making identification more reliable. Finally, this study employs an ensemble learning system, making the identification algorithm more robust and maintaining high-efficiency identification performance in complex livestock farm environments.
[0041] Other beneficial effects of the present invention will be further explained in the specific embodiments. Attached Figure Description
[0042] Figure 1 This is a flowchart of a method for improving recognition accuracy by fusing multiple features according to the present invention;
[0043] Figure 2 This is a flowchart of the feature preprocessing before input to the decision layer in this invention. Detailed Implementation
[0044] To elaborate on the objectives, research methods, and advantages of this invention, the following detailed description, in conjunction with the accompanying drawings and embodiments, further illustrates the invention. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention. All other embodiments obtained by those skilled in the art based on the embodiments of this invention without inventive effort are within the scope of protection of this invention.
[0045] This invention provides a method for cattle identification based on multi-feature decision-level fusion, comprising the following steps:
[0046] S1. Data acquisition equipment collects facial biometric information of cattle;
[0047] S2. Preprocess the facial biometric information of the cattle to determine the standard photos of the cattle and establish a dataset of cattle facial information.
[0048] S3. Use the cattle face dataset to train the single-modal recognition model in parallel and extract feature vectors;
[0049] S4. Perform special encoding on the feature vectors and use them as input to the decision layer;
[0050] S5. The decision-level fusion algorithm uses a combination of base learners and ensemble learning methods for experimental comparison. The optimal method is selected as the cattle identification model, and the algorithm outputs a unique cattle ID generated by the decision-level fusion algorithm, denoted as ID. final ;
[0051] S6. Deploy a cattle identification model to monitor the cattle herd and identify cattle IDs.
[0052] Preferably, step S1 includes the following steps:
[0053] S10, determine the target cattle and the collection scenario, wherein the collection scenario is the scene of cattle drinking water and / or eating in the farm, and more preferably, information is collected from all cattle in the farm;
[0054] S11, located at the front end of the water trough and / or feed trough, the data acquisition device is fixedly installed to collect the facial biometric information of the cattle; more preferably, the data acquisition device is a high-definition camera with a rotation function to collect the facial biometric information of the cattle in a panoramic manner.
[0055] Preferably, in step S11, the high-definition camera is a Hikvision 3T26WDV3-L 4MM camera.
[0056] Preferably, the high-definition camera is mounted at a horizontal distance of 2 to 3 meters from the front of the water trough and / or feed trough, and the height of the high-definition camera from the ground is maintained at 1.0 to 1.8 meters. More preferably, the height is maintained at 1.5 meters. The high-definition camera is installed at a slight angle to the cow's face to collect information. The slight angle to the cow's face means that the high-definition camera is installed at a downward angle to cover the entire face of the cow. More preferably, the axis plane of the high-definition camera is installed at a downward angle of 30 to 45 degrees to the horizontal plane.
[0057] Preferably, the image covering the entire face of the cow is captured by the high-definition camera at an angle that includes three features: the cow's face, the nose markings, and the ear tag. More preferably, the maximum range of the side-view shooting angle of the high-definition camera does not exceed the range where the above three features disappear, and the shooting angle is kept within 60 degrees to the left and right of the cow's front face as the center.
[0058] Preferably, in step S1, the data acquisition device collects facial biometric information of cattle by video recording.
[0059] Preferably, step S2 includes the following steps:
[0060] S21. The video of the cattle's facial biometric information collected by the data acquisition device is transmitted to the background system. It is preprocessed first. The video is decomposed into a series of continuous image frames. Each frame represents a point in time in the video, usually measured in frames per second (FPS). More preferably, the cattle's facial biometric information includes three features: cattle face, cattle nose mirror pattern and cattle ear tag.
[0061] S22. The image frame is segmented into three parts using the SOLO algorithm to form a cow face (background removed), a cow nose mirror pattern, and a cow ear mark.
[0062] S23. Determine the standard photos of cattle from the image frames in S21, and based on the instance segmentation results in S22, establish cattle facial information datasets according to the cattle face, cattle nose mirror pattern and cattle ear mark respectively.
[0063] Preferably, the image with the most obvious facial biometric features, the clearest representation, and the best image quality is selected from the image frames in S21 as the standard photo of the cattle, and it is included in the constructed cattle facial information dataset.
[0064] Preferably, the preprocessing further includes employing diverse data augmentation techniques on the image frames to increase data diversity, including rotation, scaling, and brightness adjustment.
[0065] Preferably, the SOLO algorithm segments the image frame into three parts based on the facial biometric features of the cow: the cow face (with background removed), the cow nose mirror pattern, and the cow ear tag.
[0066] Preferably, the SOLO is SOLOv2, which is a method that combines object detection and semantic segmentation.
[0067] Preferably, step S3 includes the following steps:
[0068] S31. The FaceNet neural network model is adopted. Cow face images are selected from the cow face information dataset as model input, and the InceptionResNetv1 deep convolutional network model is used as the backbone network for model training to extract the feature vectors of the cow faces. During the single-modal training process, a triplet loss is used to optimize the model's discriminative ability by minimizing the distance between feature vectors of the same cow face and maximizing the distance between feature vectors of different cow faces.
[0069] S32. Using the FaceNet neural network model, images of bovine nose mirror patterns are selected from the bovine facial information dataset as model input. MobileNetv1 is used as the backbone network for model training to extract feature vectors of bovine nose mirror patterns. During single-modal training, a triplet loss is used to optimize the model's discriminative ability by minimizing the distance between feature vectors of the same bovine face and maximizing the distance between feature vectors of different bovine faces.
[0070] The ternary loss is calculated using formula (1).
[0071]
[0072] Where N represents the number of samples, [·] + This represents a function that takes positive values. If the value inside the parentheses is negative, it takes 0; otherwise, it takes the value itself. f(·) represents the Euclidean distance, and f(·) represents the network feature extraction function. Let represent the anchor sample, positive sample, and negative sample of the i-th sample, respectively. α represents a hyperparameter used to adjust the distance between the positive and negative samples. By decreasing the distance between the anchor sample and the positive sample and increasing the distance between the anchor sample and the negative sample, a single-modal model of cow face and cow nose mirror patterns is trained. This makes the learned feature vectors more discriminative and more accurately identifies different targets. The triplet loss function can effectively optimize the representation of the feature vectors, improving the accuracy and stability of cow face and cow nose mirror pattern recognition.
[0073] S33. Using the PP-OCRv4 model, select cattle ear tag images from the cattle facial information dataset as model input, use PP-LCNetV3 as the backbone network for model training, and extract the feature vector of the cattle ear tag.
[0074] Preferably, in step S31, the input size of the cow face image is set to 160×160×3. The input size is transformed into a preliminary feature of 3×3×1792 using the deep convolutional network model InceptionResNetv1. At the end of the model, average pooling is added to reduce the size of the input feature map, and a fully connected layer with 128 neurons is connected to extract the feature vector of the cow face.
[0075] Preferably, in step S32, the input size of the bovine nose mirror pattern image is set to 358×358×3. MobileNetv1 is a network structure composed of two parts: sequential convolution and 1x1 convolution. The sequential convolution consists of 13 depthwise separable convolutional layers, each including a 3×3 convolution and a batch normalization layer. After convolution, the ReLU6 activation function is applied to accelerate the training of the neural network. The 1x1 convolution serves to output the feature vector. Then, global average pooling is used to reduce the size of the feature map. After the last convolutional layer, a fully connected layer is used to extract the feature vector of the bovine nose mirror pattern.
[0076] Preferably, in step S33, the image of the cow ear logo is input into the PP-OCRv4 model. The model first performs text detection to retrieve text information from the image. It uses PP-LCNetV3 as the backbone network, extracts the PFhead structure of parallel branch fusion, dynamically adjusts the shrink ratio during training, and optimizes the distillation loss of CML to improve the text detection effect. Secondly, if text information is detected and there is any tilt, text correction will be performed. Finally, through text recognition, the obtained text information is encoded and converted into a feature vector.
[0077] Preferably, step S4 includes the following steps:
[0078] S41, the data in the cattle facial information dataset, excluding the standard photos of cattle, is divided into a training set (Training) and a test set (Testing). Preferably, the ratio of the training set (Training) to the test set (Testing) is 8.5 / 1.5.
[0079] S42, compare the training set Training with standard photos of cattle, and solve for the Euclidean distance between the cattle face and / or the nose mirror pattern;
[0080] S43, compare the training set Training with standard photos of cattle to solve for the similarity of the cattle ear tag text;
[0081] S44. The feature vectors extracted in step S3 are combined with the Euclidean distance and text similarity data by performing One-Hot encoding and used as input to the decision layer.
[0082] Preferably, in step S42, the Euclidean distance between the cow face and / or the nose mirror marks is calculated as shown in formula (2).
[0083]
[0084] Where x i and y i Let x and y represent the coordinates of x and y in the i-th dimension, respectively, n represent the number of dimensions, and d represent the distance.
[0085] Preferably, in step S43, text similarity is used, as shown in formula (3).
[0086]
[0087] Where, distance D(i,j) represents the minimum number of edit operations required between the first i characters of string M and the first j characters of string N; l(a i ≠b i) is an Indicator Function used to determine whether two characters are different, denoted as 1 if they are different and 0 otherwise.
[0088] Preferably, in step S44, the One-Hot encoding process is used as the input to the decision layer, and the input is defined as the prediction results given by three independent recognition models: cow face, cow nose mirror pattern, and cow ear mark.
[0089] Preferably, in step S44, the input is defined as the Top 3 predicted cow IDs and their corresponding confidence scores given by the following three independent recognition models:
[0090] cow face recognition model input: F = {(ID f1 C f1 ),(ID f1 C f2 ),(ID f1 C f3 )}(4)
[0091] Input to the bovine nose mirror pattern recognition model: N = {(ID} n1 C n1 ),(ID n1 C n2 ),(ID n1 C n3 )}(5)
[0092] Input to the cow ear tag recognition model: E = {(ID)} e1 C e1 ),(ID e1 C e2 ),(ID e1 C e3 )}(6)
[0093] Among them, ID xi Let C represent the i-th most likely cow ID predicted by the identification model. xi Let x ∈ {f, n, e} represent the corresponding confidence level, where x ∈ {f, n, e} represents the cow face (f), the cow nose mirror pattern (n), and the cow ear mark (e), respectively.
[0094] Preferably, in step S5, the base learners include decision trees, logistic regression, and Gaussian Naive Bayes; the ensemble learning methods include Bagging (primarily based on bootstrapping and the bias-variance decomposition theorem; bootstrapping is a method of drawing samples with replacement from the original sample set to form a new dataset), Boosting (a machine learning algorithm used to reduce bias in supervised learning; it trains multiple weak classifiers and then weights them together to form a strong classifier), Stacking (an ensemble learning technique that aggregates multiple classification or regression models through a meta-classifier or meta-regression), and VotingClassifier (a voting method).
[0095] Preferably, in step S5, by comparing accuracy, validation rate, and F1 score (the F1 score is the harmonic mean of precision and recall) through experiments, the combination of logistic regression and random forest in the voting method is optimal, which can better improve classification performance and is suitable as the final method for decision fusion.
[0096] Preferably, step S5 involves evaluating, using a test set, which ensemble learning method is more suitable as the final method for decision fusion in the decision layer.
[0097] Preferably, in step S6, the cattle identification model is deployed to the farm, and the video footage of the cattle monitored by the farm's cameras in real time is transmitted to the backend system. The system is then processed according to the steps S2, S3, S4, and S5 above to identify the ID of the monitored cattle. During the identification process, the facial biometric information of the monitored cattle is preprocessed and compared with the standard photos of cattle established in the dataset.
[0098] Reference Figure 1 This invention provides a cattle identification method based on multi-feature decision-level fusion. To enhance cattle identification, this paper integrates three single-modal features: cattle face, nose mirror pattern, and ear tag. The method utilizes multi-angle videos of cattle faces captured during watering and feeding scenes at a livestock farm.
[0099] First, videos of cattle faces are input into the backend system. After preprocessing, the video is broken down into a series of consecutive image frames. SOLOv2 (Segmenting Objects by Locations v2) is used to segment out the three parts: the cow's face, the nose mirror pattern, and the ear tag, creating a dataset of the cow's facial biometric information. This dataset is then input into different corresponding models for single-modal parallel recognition. Feature vectors are extracted from the cow's face and nose mirror pattern, while OCR text recognition is performed on the ear tag.
[0100] Secondly, the features are compared with the dataset separately, and the extracted features are processed using One-Hot encoding as input features for the decision layer. Finally, for the decision layer fusion, this invention constructs it as a typical machine learning classification problem. Its core objective is to determine the final unique cow ID by comprehensively considering the prediction results given by three independent recognition models. Different classifiers are used, and the final recognition model is determined through ensemble learning methods.
[0101] Specifically, the steps include the following:
[0102] S1. Data acquisition equipment collects facial biometric information of cattle;
[0103] S2. Preprocess the facial biometric information of the cattle to determine the standard photos of the cattle and establish a dataset of cattle facial information.
[0104] S3. Use the cattle face dataset to train the single-modal recognition model in parallel and extract feature vectors;
[0105] S4. Perform special encoding on the feature vectors and use them as input to the decision layer;
[0106] S5. The decision-level fusion algorithm uses a combination of base learners and ensemble learning methods for experimental comparison. The optimal method is selected as the cattle identification model, and the algorithm outputs a unique cattle ID generated by the decision-level fusion algorithm, denoted as ID. final ;
[0107] S6. Deploy a cattle identification model to monitor the cattle herd and identify cattle IDs.
[0108] Step S1 includes the following steps:
[0109] S10, determine the target cattle and the collection scenario, wherein the collection scenario is the scene of cattle drinking water and / or eating in the farm, and more preferably, information is collected from all cattle in the farm;
[0110] S11, located at the front end of the water trough and / or feed trough, the data acquisition device is fixedly installed to collect the facial biometric information of the cattle; more preferably, the data acquisition device is a high-definition camera with a rotation function to collect the facial biometric information of the cattle in a panoramic manner.
[0111] Step S1 specifically includes the following steps:
[0112] S10, Determine the target cattle and the collection scenario. The collection scenario is the cattle drinking water and / or eating in the farm. In order to ensure that all cattle in the farm are fully collected and identified, comprehensive statistics and collection work is required. Therefore, information is collected from all cattle in the farm.
[0113] S11, located at the front end of the water trough and / or feed trough, is a fixed-point data acquisition device to collect facial biometric information of cattle; the data acquisition device is a high-definition camera with a rotating function, which collects facial biometric information of cattle in a panoramic manner by video recording.
[0114] In this invention, the data acquisition device selected is a Hikvision 3T26WDV3-L 4MM high-definition camera. The high-definition camera is positioned at a horizontal distance of 2-3 meters from the cattle in front of the water trough and / or feed trough in the cattle farm. The high-definition camera is 1.5 meters above the ground. The high-definition camera is installed at a slightly profile angle to acquire information. This slightly profile angle means that the high-definition camera is installed at a downward tilt to cover the entire face of the cattle. Specifically, the axis plane of the high-definition camera is tilted downward at an angle of 30 to 45 degrees to the horizontal plane. Covering the entire face of the cattle means that the high-definition camera's shooting angle covers three features: the face, the nose speculum, and the ear tag (any unclear parts do not affect the overall recognition result). The maximum range of the high-definition camera's side shooting angle does not exceed the range where the above three features disappear, and the shooting angle is kept within 60 degrees to the left and right of the front face as the center.
[0115] This improvement extends the traditional frontal face photography method to include micro-profile photos, introducing more facial angles and pose variations and enriching the representation of facial features. By incorporating micro-profile photos, the aim is to enhance the robustness and accuracy of the recognition system, enabling it to better adapt to cattle identification tasks under different shooting angles and conditions in real-world farms.
[0116] The camera used is a Hikvision 3T26WDV3-L 4mm camera, which captures relatively clear images and subtle features. Compared to traditional cameras, it offers several advantages. First, the camera provides real-time video streaming, enabling continuous monitoring and data acquisition, ensuring no crucial facial feature changes are missed. Second, the camera captures richer data, providing a large number of continuous image samples, improving the accuracy and robustness of the recognition model. Furthermore, the camera can flexibly adjust its angle and position to capture multi-angle images of the cow's face, comprehensively building a facial feature model. The camera also exhibits good environmental adaptability, equipped with autofocus and auto-exposure functions, capable of handling different lighting and environmental changes, ensuring data quality. Finally, the camera is suitable for long-term, uninterrupted monitoring, facilitating continuous recording and long-term analysis. Therefore, the camera's advantages in real-time performance, data richness, multi-angle acquisition, environmental adaptability, and long-term monitoring make it an ideal choice for cow facial recognition data acquisition.
[0117] Step S2 includes the following steps:
[0118] S21. Video footage of cattle facial biometrics captured by a high-definition camera is transmitted to the backend system. Preprocessing is performed, breaking the video down into a series of consecutive image frames, each representing a point in time, typically measured in frames per second (FPS). Cattle facial biometrics include three features: the face, nose speculum, and ear tags. From the image frames in S21, the image with the most prominent, clearest, and highest-quality facial biometrics is selected as the standard image and included in the constructed cattle facial information dataset. Preprocessing also involves employing various data augmentation techniques to increase data diversity, including rotation, scaling, and brightness adjustment. Each cattle facial information dataset is uniquely identified for subsequent comparison with different input datasets.
[0119] S22, SOLO refers to SOLOv2. The SOLO algorithm segments an image frame into three parts based on the cow's facial biometric features: the cow's face (background removed), the nose mirror pattern, and the ear tag. Compared to traditional segmentation methods, the SOLO algorithm is actually a method that combines object detection and semantic segmentation. It reduces multiple processing stages, improves the overall efficiency of the system, greatly accelerates the recognition speed of each single-modal model, and improves accuracy. Furthermore, the SOLO algorithm has significant advantages in handling small objects and is well-suited for processing cow facial feature information. It is a method that combines object detection and semantic segmentation.
[0120] S23. Determine the standard photos of cattle from the image frames in S21, and based on the instance segmentation results in S22, establish cattle facial information datasets according to the cattle face, cattle nose mirror pattern and cattle ear mark respectively.
[0121] Step S3 includes the following steps:
[0122] S31. The FaceNet neural network model is adopted, which has powerful feature extraction capabilities and good generalization performance compared to other networks. These networks are trained on large-scale datasets and can effectively capture biological feature information. Cow face images are selected from a cow face information dataset as model input, with the image size set to 160×160×3, a size that maintains image clarity while reducing computational cost. These images are input into the FaceNet neural network model, where the InceptionResNetv1 deep convolutional network model is used as the backbone to transform the input size into a preliminary feature map of 3×3×1792. Average pooling is added at the end of the model to reduce the size of the input feature map, and a fully connected layer with 128 neurons is added to extract the cow face feature vectors. During single-modal training, a triplet loss is used to optimize the model's discriminative ability by minimizing the distance between feature vectors of the same cow face and maximizing the distance between feature vectors of different cow faces.
[0123] S32. Using the FaceNet neural network model, images of bovine nose mirror patterns are selected from a dataset of bovine facial information as model input. The image size of the bovine nose mirror patterns is set to 358×358×3, which can capture detailed features while avoiding overfitting, thus improving recognition accuracy and efficiency. Next, the images are input into the FaceNet neural network model, using MobileNetv1 as the backbone for model training. MobileNetv1 is chosen as the backbone due to its lightweight nature. MobileNetv1 consists of a network structure composed of sequential convolutions and 1x1 convolutions. The sequential convolutions consist of 13 depthwise separable convolutional layers, each including a 3×3 convolution and a batch normalization layer. A ReLU6 activation function is applied after the convolutions to accelerate neural network training. The 1x1 convolutions output feature vectors, and global average pooling is used to reduce the size of the feature maps. After the last convolutional layer, a fully connected layer is used to extract the feature vector of the bovine nose mirror patterns. In the training process of the single-modality model, a triplet loss was used to optimize the model's discriminative ability by minimizing the distance between the facial feature vectors of the same cow and maximizing the distance between the facial feature vectors of different cows.
[0124] The ternary loss is calculated using formula (1).
[0125]
[0126] Where N represents the number of samples, [·] +This represents a function that takes positive values. If the value inside the parentheses is negative, it takes 0; otherwise, it takes the value itself. f(·) represents the Euclidean distance, and f(·) represents the network feature extraction function. Let represent the anchor sample, positive sample, and negative sample of the i-th sample, respectively. α represents a hyperparameter used to adjust the distance between the positive and negative samples. By decreasing the distance between the anchor sample and the positive sample and increasing the distance between the anchor sample and the negative sample, a single-modal model for cow face and cow nose mirror patterns is trained. This makes the learned feature vectors more discriminative and more accurately identifies different targets. The triplet loss function can effectively optimize the representation of the feature vectors, improving the accuracy and stability of cow face and cow nose mirror pattern recognition.
[0127] S33. The image of the bull's ear logo is input into the PP-OCRv4 model. The model first performs text detection, retrieving text information from the image. It uses PP-LCNetV3 as the backbone network and proposes a parallel branch fusion PFhead structure. During training, the shrink ratio is dynamically adjusted, and the distillation loss of CML is optimized, significantly improving text detection performance. Secondly, if text information is detected and there is any tilting, text correction is performed. Finally, text recognition is performed. The obtained text information is encoded and converted into a feature vector of the bull's ear logo.
[0128] Reference Figure 2 Step S4: The feature vectors are specially encoded and used as input to the decision layer. In step S4, the feature vectors of the model recognition results, the calculated Euclidean distance, and the text similarity data are uniformly processed using One-Hot encoding and used as input to the subsequent decision layer. For decision layer fusion, this invention constructs it as a typical machine learning classification problem, the core objective of which is to determine the final unique cow ID by comprehensively considering the prediction results given by three independent recognition models.
[0129] Step S4 includes the following steps:
[0130] S41. The data in the cattle facial information dataset, excluding standard cattle photos, is divided into a training set (Training) and a testing set (Testing), with a ratio of 8.5 / 1.5. It is crucial to exclude standard cattle photos from the dataset to avoid comparison errors when encountering the same image later. The 8.5 / 1.5 ratio was chosen through experimental comparison to simultaneously address the issue of large discrepancies between multiple and small datasets. The testing set is used to evaluate which ensemble learning method is more suitable as the final fusion method in the decision layer.
[0131] S42, the training set Training is compared with standard photos of cattle to calculate the Euclidean distance between the cow's face and nose mirror marks. This distance is used to evaluate the distance between points in multidimensional space, providing a quantitative basis for feature vector similarity, as shown in formula (2).
[0132]
[0133] Where x i and y i Let x and y represent the coordinates of x and y in the i-th dimension, respectively, n represent the number of dimensions, and d represent the distance.
[0134] S43, compare the training set Training with the standard photos of cattle to calculate the similarity of the cattle ear tag text; the formula is as shown in (3).
[0135]
[0136] Where, distance D(i,j) represents the minimum number of edit operations required between the first i characters of string M and the first j characters of string N; l(a i ≠b i ) is an Indicator Function used to determine whether two characters are different, denoted as 1 if they are different and 0 otherwise.
[0137] S44, the feature vector extracted in step S3, along with the calculated Euclidean distance and text similarity data, are uniformly processed using One-Hot encoding and used as input to the decision layer. The input to the decision layer is defined as the Top 3 predicted cow IDs and their corresponding confidence scores given by the following three independent recognition models:
[0138] cow face recognition model input: F = {(ID f1 C f1 ),(ID f1 C f2 ),(ID f1 C f3 )}(4)
[0139] Input to the bovine nose mirror pattern recognition model: N = {(ID} n1 C n1 ),(ID n1 C n2 ),(ID n1 C n3 )}(5)
[0140] Input to the cow ear tag recognition model: E = {(ID)} e1 C e1 ),(ID e1 Ce2 ),(ID e1 C e3 )}(6)
[0141] Among them, ID xi Let C represent the i-th most likely cow ID predicted by the identification model. xi The corresponding confidence levels are represented by x∈{f,n,e}, which represent the cow face (f), the cow nose mirror pattern (n), and the cow ear mark (e), respectively.
[0142] Three bovine facial biometric features—face, nose mirror markings, and ear tags—were collected to ensure greater accuracy and prevent omissions that could affect the results. Therefore, the feature retrieval scope was expanded, selecting the top three features closest to the sample data for each of the three features. These multiple features were then used as input to the final decision layer. The top three features were chosen because they maintain high accuracy while controlling computational complexity and improving system efficiency. Too many features could lead to overfitting, while the top three features typically contain most of the important information. Considering accuracy, computational efficiency, and system performance, the top three features were ultimately selected.
[0143] Step S5: The decision-level fusion algorithm uses a combination of base learners and ensemble learning methods for experimental comparison. The optimal method is selected as the cattle identification model, and the unique cattle ID generated by the decision-level fusion algorithm is output, denoted as ID. final .
[0144] Through comparative experiments, different base learners such as decision trees, logistic regression, and Gaussian Naive Bayes, as well as various ensemble learning methods, including Bagging (primarily based on bootstrapping and the bias-variance decomposition theorem; bootstrapping is a method of drawing samples with replacement from the original sample set to form a new dataset), Boosting (a machine learning algorithm used to reduce bias in supervised learning; it trains multiple weak classifiers and then weights them together to form a strong classifier), Stacking (an ensemble learning technique that aggregates multiple classification or regression models through meta-classifiers or meta-regressors), and VotingClassifier, were used to evaluate their performance on the cattle identification task. By comparing their performance on the same dataset and under the same evaluation metrics, the best-performing method was selected as the final decision-making method for cattle identification. Through experimental comparison of accuracy, validation rate, and the F1 score (the harmonic mean of precision and recall), comprehensive analysis showed that only in the voting method, the combination of logistic regression and random forest was optimal, better improving classification performance and making it suitable as the final method for decision fusion.
[0145] Step S6: Deploy the cattle identification model to the farm to monitor the cattle herd. Transmit the video footage of the cattle monitored in real time from the farm's cameras to the backend system, and process it according to steps S2, S3, S4, and S5 above to identify the monitored cattle IDs. During the identification process, the facial biometric information of the monitored cattle is preprocessed and compared with the standard cattle photos established in the dataset.
[0146] By establishing a final cattle identification model and deploying it in a real-world cattle farm setting, the system continuously monitors cattle behavior, such as feeding and drinking, by transmitting real-time footage from farm cameras to a backend system. This method automatically identifies cattle IDs and can be combined with other monitoring methods to promptly detect abnormalities, such as sudden weight loss. The proposed multimodal decision-making layer fusion method allows for timely, rapid, and accurate identification of the affected cattle. This automated monitoring system improves farm management efficiency, facilitates the timely detection and resolution of cattle health issues, and ultimately enhances farming profitability.
[0147] Through decision fusion experiments, the accuracy of multimodal recognition was significantly improved compared to single-modal methods that rely solely on one of the cow's facial features, nose markings, or ear tags. Multimodal recognition outperforms single-modal methods, largely due to the data collection process. With the booming development of animal husbandry, the actual environment of farms is extremely complex, and facial occlusion is a common problem, including hair or dirt obscuring the face. If single-modal recognition is used, occlusion of key facial features can lead to blurring or distortion, significantly impacting accuracy. However, multimodal recognition, even with partial feature occlusion, does not affect overall performance. By transmitting multimodal information, richer and more comprehensive feature representations are provided. Furthermore, during the fusion process, missing features are simply ignored, and alternative features are used for discrimination. Therefore, multimodal recognition is significantly superior to single-modal methods.
[0148] In summary, this invention provides a cattle identification method based on multi-feature decision-level fusion. By fusing multiple features such as cattle face, nose mirror pattern, and ear tag, it solves the problems of misidentification rate, limited information, and complex environment in traditional single biological features in farms. It develops a brand-new integrated learning system for accurate classification and identification.
[0149] The above are preferred embodiments of the present invention, but are not limited thereto, and the present invention is not limited to those described herein. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art can still modify the technical solutions described in the above embodiments, or make equivalent substitutions for some of the technical features. As long as they conform to the core ideas and principles of the present invention, any modifications, equivalent substitutions, improvements, etc., made to the present invention should be included within the protection scope of the present invention.
Claims
1. A method for cattle identification based on multimodal decision-level fusion, characterized in that, Includes the following steps: S1. Data acquisition equipment collects facial biometric information of cattle; S2. Preprocess the facial biometric information of the cattle to determine the standard photos of the cattle and establish a dataset of cattle facial information. S3. Use the cattle face dataset to train the single-modal recognition model in parallel and extract feature vectors; S4. Perform special encoding on the feature vectors and use them as input to the decision layer; S5. The decision-level fusion algorithm uses a combination of base learners and ensemble learning methods for experimental comparison. The optimal method is selected as the cattle identification model, and the output is the unique cattle identification model generated by the decision-level fusion algorithm. , recorded as ; S6. Deploy a cattle identification model to monitor the cattle herd and identify cattle IDs; Step S3 includes the following steps: S31. The FaceNet neural network model is adopted. Cow face images are selected from the cow face information dataset as model input. The InceptionResNetv1 deep convolutional network model is used as the backbone network for model training to extract the feature vectors of cow faces. Among them, in the single-modal training process, Triplet Loss is used to optimize the model's discrimination ability by minimizing the distance between the feature vectors of the same cow face and maximizing the distance between the feature vectors of different cow faces. S32. The FaceNet neural network model is adopted. Images of bovine nose mirror patterns are selected from the bovine facial information dataset as model input. MobileNetv1 is used as the backbone network for model training to extract the feature vectors of bovine nose mirror patterns. In the single-modal training process, Triplet Loss is used to optimize the model's discrimination ability by minimizing the distance between feature vectors of the same bovine face and maximizing the distance between feature vectors of different bovine faces. The ternary loss is calculated using the formula (1). (1) in, Represents the number of samples. This represents a function that takes positive values. If the value inside the parentheses is negative, it takes 0; otherwise, it takes the value itself. Represents Euclidean distance. Represents the network feature extraction function. , , They represent the first Anchor samples, positive samples, and negative samples for each sample. This represents a hyperparameter used to adjust the distance between positive and negative samples; S33. Using the PP-OCRv4 model, select cattle ear tag images from the cattle facial information dataset as model input, use PP-LCNetV3 as the backbone network for model training, and extract the feature vector of the cattle ear tag. Step S4 includes the following steps: S41, the data in the cattle facial information dataset, excluding the standard photos of cattle, is divided into a training set (Training) and a testing set (Testing), with a ratio of 8.5 / 1.
5. S42, compare the training set Training with standard photos of cattle, and solve for the Euclidean distance between the cattle face and / or the nose mirror pattern; S43, compare the training set Training with standard photos of cattle to solve for the similarity of the cattle ear tag text; S44. The feature vectors extracted in step S3 are combined with the Euclidean distance and text similarity data by performing One-Hot encoding and used as input to the decision layer.
2. The cattle identification method according to claim 1, characterized in that, Step S1 includes the following steps: S10, Determine the target cattle and the data collection scenario, wherein the data collection scenario is a scene of cattle drinking water and / or eating in a livestock farm. S11, located at the front end of the water trough and / or feed trough, the data acquisition device is fixedly installed to collect the facial biometric information of the cattle; the data acquisition device is a high-definition camera with rotation function to collect panoramic facial biometric information of the cattle.
3. The cattle identification method according to claim 2, characterized in that, The high-definition camera is positioned at a horizontal distance of 2 to 3 meters from the cattle at the front of the water trough and / or feed trough. The high-definition camera is 1.0 to 1.8 meters above the ground. The high-definition camera is installed at a slight angle to capture information from the side of the cattle's face. The slight angle means that the high-definition camera is installed at a downward angle to cover the entire face of the cattle.
4. The cattle identification method according to claim 1, characterized in that, Step S2 includes the following steps: S21. The video of the cattle's facial biometric information collected by the data acquisition device is transmitted to the background system. It is preprocessed first. The video is decomposed into a series of continuous image frames. Each frame represents a point in time in the video and is measured in frames per second (FPS). The cattle's facial biometric information includes three features: cattle face, cattle nose mirror pattern and cattle ear tag. S22. The image frame is segmented into three parts using the SOLO algorithm to form a cow face, a cow nose mirror pattern, and a cow ear mark. S23. Determine the standard photos of cattle from the image frames in S21, and based on the instance segmentation results in S22, establish cattle facial information datasets according to the cattle face, cattle nose mirror pattern and cattle ear mark respectively.
5. The cattle identification method according to claim 1, characterized in that, In step S42, the Euclidean distance between the cow face and / or the cow nose mirror pattern is calculated using formula (2). (2) in and They represent and In the Coordinate values in each dimension Indicates the number of dimensions. Indicates distance; In step S43, text similarity is used, using formula (3). (3) Among them, distance , represents a string The former characters and strings The former Minimum number of edit operations between characters; It is an Indicator Function used to determine whether two characters are different, denoted as 1 if they are different and 0 otherwise.
6. The cattle identification method according to claim 1, characterized in that, In step S44, the One-Hot encoding process is used as input to the decision layer. The input is defined as the Top 3 predicted cow IDs and their corresponding confidence scores given by three independent recognition models: cow face, cow nose mirror pattern, and cow ear tag. Input to the cow face recognition model: (4) Input to the bovine nose mirror pattern recognition model: (5) Input to the cow ear tag recognition model: (6) in, The first prediction made by the recognition model represents the... The most likely cow , This indicates the corresponding confidence level. Representing cow faces , ox-nose mirror pattern , bull's ear mark .
7. The cattle identification method according to any one of claims 1 to 6, characterized in that, In step S5, the base learners include decision trees, logistic regression, and Gaussian Naive Bayes, and the ensemble learning methods include Bagging, Boosting, Stacking, and VotingClassifier.
8. The method for identifying cattle according to any one of claims 1 to 6, characterized in that, In step S6, the cattle identification model is deployed to the farm, and the video footage of the cattle monitored by the farm's cameras in real time is transmitted to the backend system. The system is then processed according to steps S2, S3, S4, and S5 to identify the monitored cattle IDs.
