A pig posture tracking method based on edge computing and improved Yolo

By improving the YOLOv5s model and combining it with the DeepSort algorithm, real-time and stable tracking of pig postures is achieved, solving the problem of real-time tracking of posture characteristics of group-raised pigs and supporting unmanned and healthy pig farming.

CN115909481BActive Publication Date: 2025-09-16ANHUI AGRICULTURAL UNIVERSITY
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202211355314.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-11-01
Publication Date
2025-09-16
Estimated Expiration
2042-11-01

AI Technical Summary

Technical Problem

Existing technologies have failed to effectively solve the real-time tracking of posture characteristics of group-raised pigs, especially in the deployment and optimization of embedded edge computing nodes, resulting in limitations in unmanned and healthy pig disease warning.

Method used

The improved YOLOv5s model based on edge computing is used for pig posture tracking. Lightweight improvements are made through void convolution, CA coordinated attention mechanism and BN layer pruning. Combined with the DeepSort algorithm for target tracking, a target detection and tracking model is constructed to achieve real-time and stable tracking of pig posture.

Benefits of technology

It achieves real-time and stable tracking of the postures of multiple pigs in group farming, improves the recognition and tracking effect, supports unmanned and healthy pig farming, and provides a basis for early warning of pig diseases.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115909481B_ABST
    Figure CN115909481B_ABST
Patent Text Reader

Abstract

The present invention discloses a pig posture tracking method based on edge computing and improved YOLO, comprising: collecting pig posture behavior images to obtain a behavior monitoring data set; dividing the behavior monitoring data set in proportion to obtain a training set and a test set; constructing a target recognition model, inputting the training set into the target recognition model for recognition, and obtaining a recognition detection result; constructing a target tracking model, inputting the recognition detection result into the target tracking model to further identify and track the pig group, and obtaining a pig behavior tracking result; the present invention meets the requirements of real-time and stable tracking of the postures of multiple pigs in group breeding through edge computing and improved algorithms, and the algorithm has very good recognition and tracking effects on pigs of different numbers and different orientations, which is conducive to promoting unmanned and healthy breeding of group-raised pigs, and laying a solid foundation for early warning of pig diseases and taking countermeasures against them in the later stage.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of pig farming, and in particular relates to a pig posture tracking method based on edge computing and improved YOLO. Background Art

[0002] The health of pigs determines the development and economic benefits of the pig industry. Clinical or subclinical signs of most pig diseases are often preceded by behavioral abnormalities. Therefore, monitoring pigs' movements and other behaviors can help assess their health. However, current daily pig management is largely manual, which is subjective and uncertain. Therefore, the introduction of artificial intelligence and embedded technologies into pig farming management can leverage computer vision and embedded technologies to achieve low-cost, contactless monitoring of individual pigs' postures, including standing, sitting, prone, and side-lying, and real-time tracking. This is crucial for early warning of pig diseases and enabling timely response measures.

[0003] Currently, domestic and international research on tracking and identification in the pig farming sector falls into two main categories: morphological pig identification and deep learning-based pig identification and tracking. Li Dan et al. proposed a pig mounting behavior recognition algorithm based on Mask R-CNN, which can automatically and effectively detect pig mounting behavior. Zhu et al. used machine vision techniques such as threshold segmentation and morphological processing to achieve non-contact identification of pig drinking behavior. He Yutong et al. used a non-invasive method based on an improved YOLOv3 model to study multi-individual pig identification. Alamer et al. used YOLOv2 and Faster R-CNN to monitor pig posture and drinking behavior, without the need for sensors or individual identification. Xie Qiuju et al. achieved individual pig face recognition by integrating DenseNet with CBAM using a fusion attention mechanism. Dong Lizhong et al. proposed a pig behavior recognition method based on posture and temporal features. They combined the YOLOv5s pig detection model with the ST-GCN behavior recognition algorithm to create a pig behavior recognition system that effectively identifies pig posture and behavior characteristics. Zhang Wei et al. designed a weaned piglet target detection model based on CenterNet and combined it with the DeepSORT algorithm to achieve multi-target tracking of weaned piglets, improving tracking performance in situations where pigs are highly similar in appearance and occluded. These studies primarily use deep learning techniques to identify behavioral postures during pig farming or track individual pigs. They do not fully consider the tracking of posture characteristics of multiple pigs raised in groups, nor do they optimize the deployment of embedded edge computing nodes for practical applications. Summary of the Invention

[0004] The purpose of the present invention is to provide a pig posture tracking method based on edge computing and improved YOLO to solve the problems existing in the above-mentioned prior art.

[0005] To achieve the above objectives, the present invention provides a pig posture tracking method based on edge computing and improved YOLO, comprising:

[0006] Collecting pig posture and behavior images to obtain a behavior monitoring data set; dividing the behavior monitoring data set in proportion to obtain a training set and a test set;

[0007] Constructing a target recognition model, inputting the training set into the target recognition model for recognition, and obtaining recognition detection results;

[0008] A target tracking model is constructed, and the identification and detection results are input into the target tracking model to perform further identification and tracking processing on the pig group to obtain pig behavior tracking results.

[0009] Preferably, the process of collecting individual pig posture and behavior images to obtain a behavior monitoring data set includes:

[0010] Collect and mix video images of pig herds with open-source video images in an existing database to obtain a mixed image; obtain initial pig posture and behavior images from the mixed image by time-interval frame extraction, and perform data augmentation processing on the initial pig posture and behavior images to generate the behavior monitoring dataset; wherein the data augmentation processing includes random color channel conversion, random saturation transformation, and random chromaticity transformation.

[0011] Preferably, the target recognition model is obtained by performing lightweight improvement processing on the original YOLOv5s model through void convolution, CA coordinated attention mechanism backbone network, and BN layer pruning;

[0012] The lightweight improvement process includes:

[0013] The 6×6 convolution in the first CBS layer at the input end of the YOLOv5s model is deleted and replaced with a 3×3 normal convolution and a 3×3 dilated convolution with a dilation rate of 2; wherein the CBS layer includes a Conv layer, a BN layer and a SiLU layer; at the same time, the CA coordinated attention mechanism is connected to the backbone network of the YOLOv5s model; a regularization constraint is added to the BN layer through a Loss function, a scaling factor is introduced, and sparsity regularization is applied to the scaling factor to generate a pruned network, which is fine-tuned to generate an improved YOLOv5 model.

[0014] Preferably, the calculation formula of the BN layer is:

[0015]

[0016]

[0017] Among them, Z in and Z out is the input and output of the BN layer, represents the intermediate variable; B represents the current small batch, where μ B and σ B are the mean and variance of the input activations on B, and γ and β are trainable scaling and translation dynamic conversion coefficients.

[0018] Preferably, the expression of the Loss function is:

[0019]

[0020] Where Loss_0 represents the original loss function, the second term is the constraint, g(γ) = |γ| is called the L1 norm, λ is the regularization coefficient, and Γ represents the range of γ.

[0021] Preferably, the target recognition model performs cascade matching based on the recognition detection result to obtain a first matching result; performs IOU matching on the first matching result to obtain a second matching result; further tracks the second matching result to generate a tracking result, performs Kalman filter detection on the tracking result to generate a prediction result, and determines whether the trajectory is successfully matched based on the prediction result. If successful, output the matching result, otherwise return to match again.

[0022] Preferably, the process of performing IOU matching on the first matching result includes:

[0023] When the first matching result is a first unmatched trajectory result or a first unmatched detection result, IOU matching is performed; when the first matching result is a first matching trajectory result, further tracking is performed.

[0024] Preferably, the process of further tracking the second matching result includes: when the second matching result is a second unmatched trajectory result, determining the trajectory; when the second matching result is a second unmatched detection result, performing new tracking; when the second matching result is a second matching trajectory, performing further tracking.

[0025] Preferably, the process of determining the trajectory includes: when the unmatched trajectory is an undetermined trajectory, deleting it; when the unmatched trajectory is a determined trajectory, judging whether the number of cycles reaches a preset threshold; if the determined trajectory is greater than or equal to the preset threshold, deleting it; if the determined trajectory is less than the preset threshold, further tracking judgment is performed.

[0026] Preferably, the process of matching the prediction result again includes: when the prediction result is a confirmed prediction result, performing cascade matching; when the prediction result is an unconfirmed prediction result, performing IOU matching.

[0027] The technical effect of the present invention is: it meets the requirements of real-time and stable tracking of the postures of multiple pigs in group farming, and the algorithm has a very good recognition and tracking effect on pigs of different numbers and different orientations, which helps to promote unmanned and healthy farming of group pigs, and lays a solid foundation for early warning of pig diseases and taking countermeasures against them in the later stage. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] The accompanying drawings, which constitute part of this application, are intended to provide a further understanding of this application. The exemplary embodiments and descriptions of this application are intended to explain this application and do not constitute an improper limitation on this application. In the accompanying drawings:

[0029] Figure 1 Flowchart of a tracking algorithm based on target detection in an embodiment of the present invention;

[0030] Figure 2 This is a point diagram for improving the dilated convolution in an embodiment of the present invention;

[0031] Figure 3 This is a structural diagram of the attention mechanism in an embodiment of the present invention;

[0032] Figure 4 This is a connection position diagram of the CA attention mechanism in YOLOv5s in an embodiment of the present invention;

[0033] Figure 5 This is a flowchart of the BN layer pruning in an embodiment of the present invention;

[0034] Figure 6 is a DeepSort flow chart in an embodiment of the present invention;

[0035] Figure 7 is a flow chart of Tracking By Detecting in an embodiment of the present invention;

[0036] Figure 8 : The border loss value curves of different models in the embodiment of the present invention;

[0037] Figure 9 This is a comparison curve of the accuracy of different models in the embodiment of the present invention; DETAILED DESCRIPTION

[0038] It should be noted that, in the absence of conflict, the embodiments and features of the embodiments in this application can be combined with each other. The present application will be described in detail below with reference to the accompanying drawings and in combination with the embodiments.

[0039] It should be noted that the steps shown in the flowcharts of the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions, and that, although a logical order is shown in the flowcharts, in some cases, the steps shown or described can be executed in an order different from that shown here.

[0040] Example 1

[0041] In this embodiment, the pig sample data were mainly collected from the farm of Jinghuimeng Agricultural Science and Technology Development Co., Ltd. in Mengcheng County, Anhui Province. Several clear videos of group-raising pigs were collected, including different videos from multiple angles and multiple time periods. Some open source data videos from the University of Nebraska-Lincoln were mixed to supplement local videos. Then, 5,751 clear pictures in the video were obtained by time-interval frame extraction. The labelImg tool was used to annotate them with reference to the VOC dataset format, and four different pig postures, namely standing, sitting, lying, and lateral, were annotated. There were 18,316 posture labels in total, including 5,867 standing labels, 3,861 sitting labels, 4,202 lying labels, and 4,386 lying labels.

[0042] In order to improve the generalization ability of the model, this study used data augmentation techniques such as rotating the image 90 degrees left and right and flipping the image left and right to expand the size of the dataset; random color channel conversion, random saturation transformation, and random chromaticity transformation were used to simulate the interference of changes in lighting conditions on the image, eliminating the influence of the light environment to a certain extent. Finally, the image dataset was expanded to 40,257 pictures, and then divided into training set and test set according to the ratio of 80% and 20%.

[0043] like Figure 1 As shown in the figure, the tracking algorithm based on target detection is called Tracking By Detecting. The algorithm is divided into two steps. The output result of the first step target detection algorithm is the input of the second step multi-target tracking algorithm. The detected category data and its coordinate values ​​are input into the tracking algorithm for further tracking processing.

[0044] In order to make the YOLOv5s detection model lightweight and suitable for deployment on embedded edge computing nodes, the dilated convolution and attention mechanism are introduced into the YOLOv5s model and its BN layer is pruned.

[0045] like Figure 2 As shown in the figure, the 6×6 convolution in the first CBS layer at the input of YOLOv5s is replaced by a 3×3 normal convolution and a 3×3 dilated convolution (with an expansion rate of 2), and the subsequent BN layer and SiLU layer of this layer are simplified and removed. This can reduce the calculation parameters in the input stage and thus reduce the amount of network calculation.

[0046] like Figure 3-4 As shown, the present invention uses CA coordination attention mechanism to connect between C3_1 layer and SPPF layer in the backbone network of YOLOv5s. The CA attention mechanism structure is shown in Figure 5 As shown, the added position is as follows Figure 6 The added CA coordinated attention mechanism can reasonably utilize limited visual information processing resources, lock the candidate area of ​​focus, automatically block some background and redundant information, and help the model better locate and identify targets.

[0047] The CBS layer in the backbone network consists of a Conv layer, a Batch Normalization layer, and a SiLU layer. The BN layer, or batch normalization layer, accelerates network training and convergence, controls gradient explosion and vanishing gradients, and prevents model overfitting. The BN layer calculation formulas are shown in Equations (1) and (2).

[0048]

[0049]

[0050] Among them, Z in and Z out is the input and output of the BN layer, B represents the current mini-batch, where μ B and σ B is the mean and variance of the input activation on B, γ and β are trainable scaling and translation dynamic conversion coefficients that can linearly transform the normalized activation to any other scale. From the BN layer formula, we can see that the activation size Z of each channel in the BN layer out It is positively correlated with the scaling factor γ. When γ is close to 0, Z out The activation value is also very small. At this time, cutting out the channels when γ is close to 0 will not have much impact on the model, but can reduce a lot of computing resources.

[0051] By adding an L1 regularization constraint to the loss function, a scaling factor λ is introduced for each channel and multiplied by the output of that channel. The network weights and these scaling factors are jointly trained, and sparsity regularization is applied to the latter. Finally, the small-factor channels in the batch normalization layer are pruned, and the pruned network is fine-tuned. The formula for the loss function is shown in Equation (3).

[0052]

[0053] Here, Loss_0 represents the original loss function. The second term is the constraint, g(γ) = |γ|, known as the L1 norm. γ is the regularization coefficient, which balances the two terms and can be adjusted based on the dataset. This allows for sparse batch normalization (BN) layer parameters, making it easier to identify and prune channels in the BN layer where γ is close to 0.

[0054] like Figure 5 As shown, pruning unimportant channels may sometimes temporarily degrade performance, but this effect can be compensated by subsequently fine-tuning the pruned network. After pruning, the resulting narrow network is more compact in terms of model size, runtime memory, and computational operations compared to the initial wide network.

[0055] like Figure 6 As shown in the figure, the present invention uses DeepSort as the tracking algorithm. Its core is to use Kalman filtering to predict the motion of the next frame of the input of the target detection algorithm, and use the Hungarian algorithm to perform association matching on the data trajectory. In the matching process, a combination of cascade matching and IOU matching is adopted, and new trajectory judgment and confirmation are added to the trajectory update process to improve the speed of multi-target tracking.

[0056] like Figure 7 As shown in the figure, Tracking By Detecting uses the detection results output based on the improved YOLOv5s target detection algorithm as the input of the DeepSort algorithm, and then performs further tracking processing to form a complete tracking algorithm based on target detection.

[0057] This example uses the improved YOLOv5s6.0 version software and uses the supercomputer provided by the Beijing Super Cloud Computing Center for deep training calculations. The supercomputer hardware and software environment is as follows: the supercomputer system is Linux CentOS7.9, the CPU is two AMD EPYC7282, 16-core 32-thread processors, the device runs 256GB of memory, and the graphics card is NVIDIA RTX3090, 24GB of video memory version (8 graphics cards are loaded on demand); the software environment for program operation is as follows: NVIDIA CUDA version 11.3, torch version 0.10.0, and Python version 3.8.

[0058] In this embodiment, the training parameter settings for each ablation experiment are consistent, where the network image input is 640x640 pixels, the batch size is set to 16, the initial learning rate is set to 0.001, the number of iterations is 100, and the model data is saved every iteration cycle. Finally, the optimal model is selected by comparison.

[0059] This example uses a lightweight YOLOv5s model for target detection. This model detects four postures of pigs: standing, sitting, lying on their side, and prone. The detected results are then fed into the DeepSort tracking algorithm for tracking the postures. To further analyze the impact of various improvements on the YOLOv5s algorithm, we conducted a series of comparative experiments to identify a model that delivers fast recognition speed, high model accuracy, and excellent performance, while also being easily deployed on embedded edge computing nodes.

[0060] 1) Add dilated convolution to compare results

[0061] We added dilated convolutions to the YOLOv5s backbone network for training comparison. As shown in Table 1, after adding dilated convolutions, the accuracy was significantly improved while the average precision remained almost unchanged, while the recall rate only slightly decreased. This is because to ensure model accuracy, the prediction results are screened more strictly during training, which results in a small number of low-confidence positive examples being eliminated, resulting in a slight decrease in recall rate, but the value is still greater than 95%, which meets the needs of daily detection.

[0062] Table 1

[0063]

[0064] 2) Add different attention mechanisms to compare results

[0065] In order to verify the impact of different attention mechanisms on model data, the detection comparison results after adding the attention mechanism are shown in Table 2. Adding the attention mechanism generally leads to an increase in model accuracy and a decrease in recall rate. Comparing the CA attention mechanism and the CBAM attention mechanism in the experiment, it is found that compared with CBAM, adding the CA attention mechanism increases the accuracy by 0.7%, and the average accuracy remains almost unchanged. It can be seen that adding the CA attention mechanism is more sensitive to the dataset in this study and can effectively improve the model accuracy.

[0066] Table 2

[0067]

[0068]

[0069] 3) Comprehensive comparison results analysis of models with different improvement points

[0070] like Figure 8-9As shown in the figure, the loss curves of each model are steadily decreasing, and the accuracy is steadily improving and tending to be stable. Compared with the YOLOv5s model, the border loss value of YOLOv5s_Dilated Convolution_CA is significantly better than the original model, and the model accuracy is also slightly better than the original model, both achieving the expected improvement effect.

[0071] 4) Comparative analysis of the impact of different pruning ratios on the model

[0072] Table 3 shows comparative experimental results after fine-tuning models with different pruning ratios. As the BN layer pruning ratio increases, the model's recall and parameter count decrease, while the average precision fluctuates. When the pruning ratio reaches 80%, the critical value for BN layer sparsification pruning is reached, and pruning ends.

[0073] Table 3

[0074]

[0075]

[0076] By comparing the effects of pruning at different ratios, it was found that when YOLOv5_Dilated Convolution_CA was pruned by 60%, the model size was reduced by 65.3% compared to the unpruned algorithm while the accuracy remained basically unchanged. The average accuracy only dropped by 0.7 percentage points, which is better than other pruning ratio algorithms in comprehensive comparison.

[0077] The pig multi-target detection and tracking algorithm trained in this embodiment ultimately needs to be deployed in an embedded edge computing node, so for the trained model, it is necessary to perform model transplantation in the Jetson AGX Xavier embedded environment. Embedded system hardware platform: Jetson AGX Xavier, NVIDIA Carmel ARMv8 64-bit CPU, 16GB of running memory, GPU equipped with 512 NVIDIA CUDA cores and 64 Tensor Cores. The operating system is ARM version Ubuntu 18.04, NVIDIA CUDA version 10.2, torch version 0.10.0, python version 3.8, TensorRT version 7.1.3.

[0078] The real-time detection results of the improved algorithms with different pruning ratios after deployment on the Jetson AGX Xavier edge computing node are shown in Table 4. The experimental results show that as the model pruning ratio increases, the number of parameters decreases rapidly, and the detection speed also increases simultaneously.

[0079] Table 4

[0080]

[0081] The YOLOv5s_Dilated Convolution_CA_Pruning 60% selected in this study maintains a high level of accuracy and average precision while having only 33% of the original version's parameter size, reducing the inference time by 19.3% and increasing the recognition frame rate by 7.8 frames. This allows it to run stably and in real time in embedded edge nodes, laying a good foundation for subsequent multi-target tracking of pigs in embedded edge nodes and providing fast and stable input results.

[0082] Table 5 shows the real-time tracking results of the same video on a Jetson AGX Xavier edge computing node using the improved algorithms with different pruning ratios. As shown in the table, as the model pruning ratio increases, the algorithm time decreases and the frame rate steadily increases. Compared to the original YOLOv5s-based DeepSort algorithm, the proposed YOLOv5s-Dilated Convolution-Convolutional Asynchronous Detection (DCA) algorithm with a 60% pruning ratio significantly reduces tracking and inference time, while also increasing the frame rate by 8.4 FPS to 21.7 FPS. This algorithm achieves fast, stable, and real-time execution on embedded edge nodes, achieving its intended purpose.

[0083] Table 5

[0084]

[0085] Tracking tests were conducted on embedded edge computing nodes using the original YOLOv5s algorithm combined with the DeepSort algorithm and the improved YOLOv5_Dilated Convolution_CA Pruning 60% algorithm combined with the DeepSort algorithm. These tests included 60-second pig videos of three pigs (primarily standing), seven pigs (primarily lying), and 14 pigs of different types. The test results are shown in Table 6 below. The improved YOLOv5s_Dilated Convolution_CA Pruning 60% algorithm, combined with the DeepSort tracking algorithm, performed well in tracking the same videos, significantly outperforming the unmodified algorithm in both tracking frame loss and ID jumps.

[0086] Table 6

[0087]

[0088] When the pig makes complex movements, the original YOLOv5 + DeepSort tracking algorithm may lose the tracking frame. However, the improved YOLOv5_Dilated Convolution_CA Pruning 60% + DeepSort algorithm can still stably track the pig even when it makes fast and complex movements. This shows that the improved algorithm can reduce the loss of tracking frames in complex environments.

[0089] Aiming at the actual situation of pig farms, the present invention selects the YOLOv5s algorithm as the detector in the Tracking By Detecting tracking algorithm based on target detection, and then performs lightweight optimization and pruning on it. The algorithm is actually tested in the embedded edge computing node Jetson AXG Xavier. The improved YOLOv5s_Void Convolution_CA Pruning 60% algorithm has good recognition effect, with an average accuracy of 97% and a model accuracy of 96.6%. The model size is reduced by 65.3% compared with the original version, which is only 4.74MB. The frame rate of the improved recognition algorithm is increased by 7.8 frames compared with the original algorithm, reaching 40 frames / second. After using NVIDIA TensorRT C++ hardware acceleration, it reaches 111 frames / second, which can provide high-precision recognition results quickly, stably and in real time. After combining with the DeepSort tracking algorithm, the Tracking By Detecting algorithm was fully tested in the embedded edge computing node Jetson AXG Xavier. The YOLOv5_Void Convolution_CA pruning 60% combined with the DeepSort tracking algorithm achieved a frame rate of 21.7FPS, an improvement of 8.4FPS compared to the original version.

[0090] The above description is merely a preferred embodiment of the present application, but the scope of protection of the present application is not limited thereto. Any changes or substitutions that can be easily conceived by a person skilled in the art within the technical scope disclosed in the present application should be included in the scope of protection of the present application. Therefore, the scope of protection of the present application should be based on the scope of protection of the claims.

Claims

1. A pig posture tracking method based on edge computing and improved yolo, characterized in that: The following steps are involved: Collecting pig posture and behavior images to obtain a behavior monitoring data set; dividing the behavior monitoring data set to obtain a training set and a test set; Constructing a target recognition model, inputting the training set into the target recognition model for recognition, and obtaining recognition detection results; The target recognition model is obtained by lightweight improvement of the original YOLOv5s model through void convolution, CA coordinated attention mechanism backbone network, and BN layer pruning; The lightweight improvement process includes: The 6×6 convolution in the first Conv-BN-SiLU layer at the input of the YOLOv5s model is deleted and replaced with a 3×3 normal convolution and a 3×3 dilated convolution with a dilation rate of 2. The CBS layer includes a Conv layer, a BN layer, and a SiLU layer. At the same time, the CA coordinated attention mechanism network is connected to the backbone network of the YOLOv5s model. A regularization constraint is added to the BN layer through a loss function, a scaling factor is introduced, and sparsity regularization is applied to the scaling factor to generate a pruned network. The pruned network is fine-tuned to generate an improved YOLOv5 model. Constructing a target tracking model, inputting the recognition detection results into the target tracking model to perform recognition and tracking processing on the pig herd, and obtaining pig behavior tracking results; The target tracking model performs cascade matching based on the recognition detection result to obtain a first matching result; performs IOU matching on the first matching result to obtain a second matching result; further tracks the second matching result to generate a tracking result, performs Kalman filter detection on the tracking result to generate a prediction result, and determines whether the trajectory is successfully matched based on the prediction result. If successful, output the matching result; otherwise, return to match again.

2. The pig posture tracking method based on edge computing and improved yolo according to claim 1 is characterized in that, The process of collecting pig posture and behavior images and obtaining a behavior monitoring dataset includes: Collect and mix video images of pig herds with open-source video images in an existing database to obtain a mixed image; obtain initial pig posture and behavior images from the mixed image by time-interval frame extraction, and perform data augmentation processing on the initial pig posture and behavior images to generate the behavior monitoring dataset; wherein the data augmentation processing includes random color channel conversion, random saturation transformation, and random chromaticity transformation.

3. The pig posture tracking method based on edge computing and improved yolo according to claim 1 is characterized in that, The calculation formula of the BN layer is: Among them, Z in and Z out is the input and output of the BN layer, represents the intermediate variable; B represents the current small batch, where μ B and σ B are the mean and variance of the input activations on B, respectively, and γ and β are trainable scaling and translation dynamic conversion coefficients.

4. The pig posture tracking method based on edge computing and improved yolo according to claim 1 is characterized in that, The expression of the Loss function is: Where Loss_0 represents the original loss function, the second term is the constraint, g(γ) = |γ| is called the L1 norm, λ is the regularization coefficient, and Γ represents the range of γ.

5. The pig posture tracking method based on edge computing and improved yolo according to claim 1 is characterized in that, The process of performing IOU matching on the first matching result includes: When the first matching result is a first unmatched trajectory result or a first unmatched detection result, IOU matching is performed; when the first matching result is a first matching trajectory result, further tracking is performed.

6. The pig posture tracking method based on edge computing and improved yolo according to claim 1 is characterized in that, The process of further tracking the second matching result includes: determining a trajectory when the second matching result is a second unmatched trajectory result, performing new tracking when the second matching result is a second unmatched detection result, and performing further tracking when the second matching result is a second matching trajectory.

7. The pig posture tracking method based on edge computing and improved yolo according to claim 6 is characterized in that, The process of determining the trajectory includes: when the unmatched trajectory is an undetermined trajectory, deleting it; when the unmatched trajectory is a determined trajectory, judging whether the number of cycles reaches a preset threshold; if the determined trajectory is greater than or equal to the preset threshold, deleting it; if the determined trajectory is less than the preset threshold, further tracking judgment is performed.

8. The pig posture tracking method based on edge computing and improved yolo according to claim 1 is characterized in that, The process of matching the prediction result again includes: when the prediction result is a confirmed prediction result, performing cascade matching; when the prediction result is an unconfirmed prediction result, performing IOU matching.