Visual perception and trajectory restoration method, system and device for chicken motion analysis and anomaly detection in large-cage farm and storage medium
By improving target detection and multi-target tracking methods, and combining Kalman filtering and the Hungarian algorithm, the problems of discontinuous target tracking and trajectory interruption in complex breeding environments are solved, and efficient and accurate anomaly detection and health early warning are achieved in large cage breeding farms.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING AGRICULTURAL UNIVERSITY
- Filing Date
- 2026-01-20
- Publication Date
- 2026-05-01
AI Technical Summary
Existing target detection methods lack robustness in complex aquaculture environments, resulting in false positives and false negatives, poor target tracking continuity, frequent trajectory interruptions and ID drift, and difficulty in achieving individualized anomaly identification and early health warning.
An improved target detection method is adopted, combined with multi-target tracking and trajectory repair mechanism. Features are extracted through spatial and channel attention mechanism, and Kalman filtering and Hungarian algorithm are used for tracking. Frequency domain feature analysis and deep learning coding technology are introduced to generate behavioral feature vectors and establish individual and group baseline mechanisms for health early warning.
It achieves efficient target tracking and accurate anomaly detection in complex aquaculture scenarios, solves problems such as changes in light and shading, ensures the stability and adaptability of detection, and realizes individualized anomaly identification and early health warning.
Smart Images

Figure CN121963310A_ABST
Abstract
Description
A visual perception and trajectory repair method, system, equipment, and storage medium for motion analysis and anomaly detection in chickens raised in large cages. Technical Field
[0001] This invention relates to the field of video monitoring and behavior analysis technology, specifically to a visual perception and trajectory repair method, system, equipment, and storage medium for analyzing the movement and detecting anomalies in chickens raised in large cages. Background Technology
[0002] With the development of computer vision and deep learning technologies, video-based poultry behavior analysis systems have been widely used in modern poultry farming management. Traditional manual inspection methods suffer from low efficiency, strong subjectivity, and the inability to continuously monitor. Visual perception systems, on the other hand, can automatically identify and statistically analyze the activity status, health level, and behavioral abnormalities of chickens. Traditional target detection methods typically analyze each frame of image using convolutional neural networks. However, in farms with highly variable environments, this often faces multiple interferences such as changes in lighting, occlusion, and angular deviations, leading to false positives and false negatives. The stability of the detection results is not high, especially when the number of chickens is large or their posture changes drastically, significantly reducing detection accuracy and making subsequent multi-target tracking and behavior analysis difficult. In cage farming, the dense space and widespread occlusion make it even more difficult for existing target detection methods to accurately identify and track each chicken.
[0003] Most multi-target tracking algorithms rely on continuous output of detection results to maintain the consistency of target identity through state prediction and spatial matching. When there are false detections or missed detections, ID drift or trajectory breakage often occurs, especially in farms. Due to the similar appearance and large number of chickens, existing target tracking algorithms lack sufficient constraints on motion patterns and cannot make reasonable predictions based on the physiological characteristics or motion limits of chickens, resulting in interruption or error in target identity tracking. The discontinuous movement trajectory of the target affects the accuracy of subsequent behavior analysis. Existing systems lack a mechanism for automatically repairing trajectory interruptions caused by occlusion, missed detections, or detection errors. The discontinuity of trajectory data seriously affects the accuracy of feature extraction, thereby affecting the performance of the entire system.
[0004] In the areas of abnormal behavior detection and health early warning, most existing technologies rely on simple threshold settings or single machine learning models for anomaly identification. These methods ignore individual differences, group rhythms, and temporal dynamics, and cannot identify complex abnormal patterns. Due to the accumulation of errors in front-end detection and tracking, anomaly detection models often produce false positives or false negatives, reducing the reliability of the system. The lack of effective historical behavior modeling and multimodal information fusion capabilities makes existing systems unable to provide accurate early warnings, especially when facing potential diseases or stressful behaviors, where the system struggles to detect and respond in a timely manner. Summary of the Invention
[0005] In view of the above-mentioned problems, the present invention is proposed.
[0006] Therefore, the technical problem solved by this invention is that existing target detection methods in complex aquaculture environments suffer from insufficient robustness, false detection and false negative detection, poor target tracking continuity, frequent trajectory interruptions and ID drift, and lack of standardization and poor cross-scenario adaptability in behavioral feature quantification, making it difficult to achieve individualized anomaly identification and early health warning. By introducing improved target detection methods, combining multi-target tracking and trajectory repair mechanisms, and standardizing the extraction and analysis of behavioral features, efficient monitoring and accurate anomaly detection in complex aquaculture scenarios can be ensured.
[0007] To address the aforementioned technical problems, this invention provides the following technical solution: a visual perception and trajectory repair method for motion analysis and anomaly detection in chickens raised in cages, comprising: target detection of chickens in video frames, extraction of target features, and fine feature extraction using spatial and channel attention mechanisms; tracking each target using fine features combined with Kalman filtering and the Hungarian algorithm, continuously tracking and adjusting the individual chicken identity through time series prediction and spatial matching, and outputting the target bounding box; adjusting the individual chicken identity based on tracking, smoothing and repairing interrupted and occluded trajectory segments through spline interpolation and Kalman filtering, and using biological kinematic constraints for trajectory repair. Reasonable recovery of traces; based on the target bounding box, a frequency domain feature analysis mechanism and deep learning coding technology are introduced to generate behavioral feature vectors, and health warnings are triggered based on anomaly confidence. The health warning includes statistical detection of behavioral features, establishing a normal distribution baseline for each behavioral feature based on historical data using the Z-score algorithm, standardizing the feature values input in real time, identifying abnormal features that deviate from the normal range, integrating the confidence and anomaly confidence using a weighted fusion algorithm, and triggering a health warning when the anomaly detection reaches the confidence threshold. A two-layer mechanism of individual baseline and group baseline is constructed to comprehensively obtain the degree of deviation of feature values from the baseline.
[0008] As a preferred embodiment of the visual perception and trajectory repair method for motion analysis and anomaly detection of chickens in large cage farms described in this invention, the target detection includes: using a YOLOv7 network backbone combined with an E-ELAN structure, extracting low-level, mid-level and high-level features through multi-branch feature fusion and extended residual connections, and performing adaptive weighted processing on the input feature map by combining the CBAM attention mechanism.
[0009] As a preferred embodiment of the visual perception and trajectory repair method for chicken movement analysis and anomaly detection in caged farms described in this invention, the CBAM attention mechanism includes a channel attention mechanism and a spatial attention mechanism; the channel attention mechanism includes extracting global information of feature channels through global pooling, and generating an importance weight for each channel based on a multi-layer perception mechanism, expressed as: ,
[0010] in, Represents the input feature map The output after processing by the channel attention mechanism , Indicates the number of channels. Indicates the height of the image. Indicates the width of the image. This refers to the Sigmoid function, which maps the output value to the range of 0 to 1. Representing spatial dimension * Average pooling on top, Representing spatial dimension * Max pooling on This represents a multilayer perceptron; the spatial attention mechanism includes weighting the spatial distribution of each location in the feature map through convolution operations, enabling the network to focus on occluded and dense spatial regions of the target, as shown below: ,in, Represents the input feature map The output after attention mechanism processing This represents a 7×77×7 convolutional layer. Representation of feature map The Middle Features of each channel.
[0011] As a preferred embodiment of the visual perception and trajectory repair method for motion analysis and anomaly detection of chickens in caged farms described in this invention, the method for tracking each target includes: constructing a state-space model; generating a continuous trajectory sequence based on the target detection output of each frame; predicting the target's motion state using Kalman filtering; defining a matching cost for the detected target and the predicted target; performing spatial matching using the Hungarian algorithm; and associating the continuity of each target's identity in cases of target occlusion, overlap, and changes in illumination. The matching cost is expressed as: ,in, Indicates the first The first goal and the first The matching cost between prediction targets The intersection-over-union ratio (IoU) measures the degree of overlap between the predicted bounding box and the ground truth bounding box. Indicates the first Each target appearance feature vector Indicates the first Each predicted target appearance feature vector Indicates the displacement of the center point. , , This represents the weighting coefficients, used to balance the different parts of the cost function.
[0012] As a preferred embodiment of the visual perception and trajectory repair method for chicken movement analysis and anomaly detection in caged farms described in this invention, the continuous tracking and adjustment of individual chicken identities includes: constructing a time series prediction model to predict the target state; using spatial matching to associate the target; if the detection result is not matched by any predicted target, a new trajectory is generated; if the predicted trajectory does not match for consecutive frames, the current target is marked as temporarily lost; if the loss continues for more than a set threshold number of frames, the trajectory is deleted; a matching confidence index is introduced, and individual appearance vectors are extracted based on Re-ID features using ResNet18 and MobileNet structures, and cosine similarity is used to re-associate the identities of the disappeared and newly detected targets.
[0013] As a preferred embodiment of the visual perception and trajectory repair method for motion analysis and anomaly detection of chickens in caged farms described in this invention, the smooth repair includes: constructing a kinematic constraint model based on the kinematic characteristics of the chickens; repairing the trajectory using cubic spline interpolation when interruptions or occlusions occur; combining maximum speed and acceleration limits; performing high-precision interpolation on the missing parts based on information from the preceding and following valid trajectory segments; and predicting the trajectory position of the current frame based on the trajectory state of the previous frame using a state transition equation. ,in, Indicates the first The goal is at a certain moment Time to time The predicted location, Represents the state transition matrix. Represents the control matrix. Indicates at time step Time-based control input, Indicates the first The goal is in time step The actual position at any given time; combined with the observation data of the current frame, if some valid observations exist, the predicted position is corrected using the Kalman gain formula: ,in, Kalman gain is used to calculate the weights between the predicted location and the observed data. This represents the prediction error covariance, reflecting the uncertainty of the prediction result at the current moment. Represents the observation matrix. Represents the observation noise covariance. The transpose of the observation matrix is represented; constraints on velocity, acceleration, and rate of change of direction are applied during the repair process; the kinematic constraint model is represented as: velocity and acceleration constraints: , ,in, Indicates the current state Speed of motion at any moment Indicates the current state The acceleration of motion at any moment, Indicates in Always The instantaneous velocity component in the direction, Indicates in Always The instantaneous velocity component in the direction, Indicates the inter-frame time interval. This indicates the preset maximum speed of motion. Indicates the preset maximum acceleration; directional rate of change constraint: ,in, This indicates the maximum permissible turning angle for the chicken's movement direction. Indicates time The change in angle.
[0014] As a preferred embodiment of the visual perception and trajectory repair method for motion analysis and anomaly detection of chickens in caged farms described in this invention, the generation of behavioral feature vectors includes: obtaining basic physical features based on continuous trajectory sequences, extracting main frequency and spectral energy features by combining frequency domain analysis, using a bidirectional long short-term memory network, encoding the temporal features through a Bi-LSTM network, and generating a high-level behavioral representation vector.
[0015] Another objective of this invention is to provide a visual perception and trajectory repair system for motion analysis and anomaly detection in large cage farms of chickens. This system combines improved target detection, Kalman filtering, and the Hungarian algorithm for multi-target tracking, solving the problems of unstable target detection, discontinuous target tracking, and low trajectory repair efficiency in complex environments in current technologies.
[0016] As a preferred embodiment of the visual perception and trajectory repair system for chicken movement analysis and anomaly detection in caged farms described in this invention, the system includes: a target detection and feature extraction module, a multi-target tracking and trajectory repair module, and an anomaly detection and health warning module. The target detection and feature extraction module extracts low-level, mid-level, and high-level features of chickens from video frames using a YOLOv7 network backbone combined with an E-ELAN structure, and adaptively weights the feature maps using CBAM attention, channel attention, and spatial attention mechanisms. The multi-target tracking and trajectory repair module generates a continuous trajectory sequence based on the target detection output of each frame, and then... Kalman filtering predicts the target's motion state, and the Hungarian algorithm is used for spatial matching. For interrupted or occluded trajectory segments, cubic spline interpolation and Kalman filtering are used for trajectory repair, and the trajectory is restored by combining a kinematic constraint model. The anomaly detection and health warning module is used to identify abnormal behaviors of chickens based on high-level behavioral representation vectors. The anomaly confidence is integrated into a final anomaly confidence through a weighted fusion algorithm. When a preset confidence threshold is reached, a health warning is triggered, and the anomaly type and related data are recorded. The Z-score algorithm is used to establish a statistical baseline of normal behavioral characteristics through historical data, and a two-layer mechanism of individual baseline and group baseline is used to comprehensively identify abnormal behaviors.
[0017] Another objective of this invention is to provide a visual perception and trajectory repair device for analyzing and detecting the movement of chickens in cage farms, comprising a memory and a processor. The memory stores a computer program, and the processor executes the computer program to implement the steps of a visual perception and trajectory repair method for analyzing and detecting the movement of chickens in cage farms.
[0018] Another object of the present invention is to provide a visual perception and trajectory repair storage medium for analyzing and detecting the movement of chickens in cage farms, wherein a computer program is stored thereon, and when the computer program is executed by a processor, it implements the steps of the visual perception and trajectory repair method for analyzing and detecting the movement of chickens in cage farms.
[0019] The beneficial effects of this invention are as follows: The visual perception and trajectory repair method for chicken movement analysis and anomaly detection in caged farms provided by this invention solves the problems of ID drift and trajectory interruption in target tracking by combining Kalman filtering and Hungarian algorithm, ensuring continuous and stable tracking of individual chickens in complex farming scenarios. By accurately extracting the behavioral features of chickens through frequency domain analysis and deep learning coding technology, it achieves accurate abnormal behavior identification and comprehensively captures the movement state and behavior patterns of chickens. Combined with YOLOv7 and CBAM attention mechanism, it enhances the accuracy of target detection and solves problems such as changes in lighting, occlusion and complex background. It achieves better results in terms of target detection accuracy, robustness and adaptability, and meets the needs of chicken monitoring in the complex environment of caged farms. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 is an overall flowchart of a visual perception and trajectory repair method for analyzing the movement and detecting anomalies in chickens in a large cage farm, provided in Embodiment 1 of the present invention. Detailed Implementation
[0022] To make the above-mentioned objects, features, and advantages of the present invention more apparent and understandable, specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of the present invention, and not all of them. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort should fall within the protection scope of the present invention.
[0023] Example 1, referring to Figure 1, is an embodiment of the present invention, providing a visual perception and trajectory repair method for movement analysis and anomaly detection of chickens in large cage farms, including:
[0024] S1: Target detection is performed on chickens in video frames, target features are extracted, and spatial and channel attention mechanisms are used for fine feature extraction.
[0025] It should be noted that the native E-ELAN structure of YOLOv7 is used as the backbone network to extract low-level, mid-level and high-level features of chickens in video frames, taking into account both the semantic information and spatial details of the target. The E-ELAN structure uses multi-branch feature fusion and extended residual connections. In the actual cage farming environment, due to the high density of chickens, frequent interactions, large changes in posture and occlusion, CBAM (Convolutional Block Attention Module) modules are introduced at different scales of the backbone network feature output. The feature maps are adaptively weighted through channel attention mechanism and spatial attention mechanism.
[0026] The channel attention mechanism extracts global information from feature channels through global pooling and generates importance weights for each channel using a multilayer perceptron. This enhances the response to key feature channels (such as the chicken head, legs, and feather edges) while suppressing background noise. It is represented as follows: ,in, Represents the input feature map The output after processing by the channel attention mechanism , Indicates the number of channels. Indicates the height of the image. Indicates the width of the image. This refers to the Sigmoid function, which maps the output value to the range of 0 to 1. Representing spatial dimension * Average pooling on top, Representing spatial dimension * Max pooling on This represents a multilayer perceptron.
[0027] Spatial attention mechanisms use convolutional operations to weight the spatial distribution of feature maps, enabling the network to focus on the spatial region of the target. This maintains high localization accuracy even in occluded or densely populated areas. Weighting the feature responses at each location emphasizes the spatial position of the target, as shown below: ,in, Represents the input feature map The output after attention mechanism processing This represents a 7×77×7 convolutional layer. Representation of feature map The Middle Features of each channel.
[0028] The combined channel attention and spatial attention mechanisms output enhancement features are represented as follows: ,in, This represents the output enhanced feature map.
[0029] It should also be noted that, through the enhanced feature maps, the network integrates information from each level in the subsequent feature fusion stage, taking into account both the spatial details and semantic representation of the target. The multi-scale features extracted by the backbone network are fused through the Feature Pyramid Network (FPN). The FPN fuses the high-resolution features of the low layer with the semantically rich features of the high layer layer by layer, enabling the network to perceive small targets while maintaining accurate localization of large targets.
[0030] The fused multi-scale feature maps are fed into the YOLOv7 prediction head for final target prediction. The YOLOv7 prediction head outputs the bounding box, confidence score, and class label for each target: ,in, This represents the result of processing input image data using a neural network or deep learning model. Indicates the first One goal is A bounding box that always contains the center coordinates, width, and height. Indicates the first One goal is Confidence score at time point Indicates the first One goal is time .
[0031] The bounding box localization loss uses CloU or SIoU to improve the localization accuracy of overlapping targets; the classification loss and confidence loss employ an improved Focal Loss to suppress the imbalanced effect of a large number of negative samples on training. ,in, This represents the total loss function, used to optimize the network's output. The loss function represents the bounding box, which calculates the difference between the predicted and the true bounding boxes. Represents the probability of the target category. This represents the classification loss function, which calculates the error in classifying the target. The adjustment coefficient is used to assign greater weight to targets that are difficult to detect, so that the network can maintain a high recognition rate under occlusion and changes in lighting. The training strategy employs multi-scale data augmentation, random cropping, color perturbation and rotation transformation.
[0032] S2: Employs a combination of refined features, Kalman filtering, and Hungarian algorithm to track each target. Continuously tracks and adjusts the individual chicken identities through time-series prediction and spatial matching, and outputs the target bounding box.
[0033] It should be noted that in each frame, multiple candidate targets are detected and output. Through time series prediction and spatial matching, the detection results are associated with the trajectory of the previous frame to maintain the continuity of target identity. In the video sequence, the identity of each chicken is maintained (ID Consistency) and the trajectory is continuously tracked (Trajectory Continuity). Even in complex situations such as occlusion, overlap, and sudden changes in lighting, the detection-driven multi-target tracking framework (Tracking-by-Detection) is used to dynamically track and associate the target with its identity, combining Kalman filter state prediction and Hungarian Algorithm.
[0034] The dynamic state of each individual consists of position and velocity, and is defined as follows: ,in, This represents the current dynamic state of an individual. Represents the planar coordinates of the target.
[0035] It should also be noted that a state-space model is constructed to generate a continuous trajectory sequence based on the target detection output of each frame. The motion state of the target is predicted by Kalman filtering. A matching cost is defined for the detected target and the predicted target. The Hungarian algorithm is used for spatial matching. In the case of target occlusion, overlap and illumination changes, the continuity of each target identity is associated.
[0036] The matching cost is expressed as: ,in, Indicates the first The first goal and the first The matching cost between prediction targets The intersection-over-union ratio (IoU) measures the degree of overlap between the predicted bounding box and the ground truth bounding box. Indicates the first Each target appearance feature vector Indicates the first Each predicted target appearance feature vector Indicates the displacement of the center point. , , This represents the weighting coefficients, used to balance the different parts of the cost function.
[0037] Using a state-space model, it can be represented as: , ,in, This represents the observation vector (the observation position from the detector). Represents the state transition matrix. Indicates process noise. Indicates observation noise. Represents the process noise covariance matrix. Represents the observation noise covariance. This represents the observation matrix.
[0038] Assumption The state transition matrix represents the inter-frame time interval as follows: The observation matrix is represented as: The standard Kalman filter is used for state prediction and updating. The prediction stage is represented as follows: , ,in, Indicates the current prediction status. This represents the predicted covariance matrix.
[0039] The update phase (when the detection result is received) is represented as: , , ,in, This represents the Kalman gain matrix, used to balance the weights of predictions and observations.
[0040] S3: Based on the individual chicken identity, the interrupted and occluded trajectory segments are smoothed and repaired by spline interpolation and Kalman filtering, and the trajectory is reasonably restored by biological kinematic constraints.
[0041] It should also be noted that a state-space model is constructed to generate a continuous trajectory sequence based on the target detection output of each frame. The motion state of the target is predicted by Kalman filtering. A matching cost is defined for the detected target and the predicted target. The Hungarian algorithm is used for spatial matching. In the case of target occlusion, overlap and illumination changes, the continuity of each target identity is associated.
[0042] The matching cost is expressed as: ,in, Indicates the first The first goal and the first The matching cost between prediction targets The intersection-over-union ratio (IoU) measures the degree of overlap between the predicted bounding box and the ground truth bounding box. Indicates the first Each target appearance feature vector Indicates the first Each predicted target appearance feature vector Indicates the displacement of the center point. , , This represents the weighting coefficients, used to balance the different parts of the cost function.
[0043] A time-series prediction model is constructed to predict the target state. Spatial matching is used to associate the target. If the detection result is not matched by any predicted target, a new trajectory is generated. If the predicted trajectory does not match for consecutive frames, the current target is marked as temporarily lost. If the loss continues for more than a set threshold number of frames (e.g., 10 frames), the trajectory is deleted. A matching confidence index is introduced. Based on Re-ID features, individual appearance vectors are extracted through ResNet18 and MobileNet structures. Cosine similarity is used to re-associate the identity of the lost and newly detected targets.
[0044] The matching confidence index is expressed as: ,in, This represents the matching confidence index. The higher the value, the more reliable the target match. If the value is less than the preset index threshold, the current match is rejected. The scaling factor representing the matching reliability. Indicate target and target The distance between them.
[0045] To address the issue of identity recovery when a target reappears after occlusion, the system introduces a lightweight Re-ID model based on convolutional features. The Re-ID features extract individual appearance vectors using ResNet18 or MobileNet architectures. ,in, Indicate target eigenvectors, This is the feature extraction function.
[0046] Cosine similarity is used to re-associate the disappearing and newly detected targets, which is represented as: ,in, : indicates the first The first goal and the first Similarity between targets Indicate target eigenvectors.
[0047] S4: Based on the target bounding box, a frequency domain feature analysis mechanism and deep learning coding technology are introduced to generate behavioral feature vectors and trigger health warnings based on the anomaly confidence level.
[0048] It should be noted that smoothing repair includes constructing a kinematic constraint model based on the kinematic characteristics of chickens, and using cubic spline interpolation to repair trajectory segments with no more than 3 consecutive missing frames when the trajectory is interrupted or occluded, as shown below: ,in, Indicates the first The goal is at a certain moment Predicted location at time Indicates the valid frame time before the missing segment. Indicates the effective frame time after the missing segment. Represents a constant term. The linear coefficients representing time. The coefficient representing the squared term of time. This represents the coefficient of the time cube term.
[0049] Combining maximum speed and acceleration limits, high-precision interpolation is performed on the missing parts based on information from the preceding and following valid trajectory segments. Based on the trajectory state of the previous frame, the trajectory position of the current frame is predicted through a state transition equation. ,in, Indicates the first The goal is at a certain moment moment to moment The predicted location, Represents the state transition matrix. Represents the control matrix. Indicates at time step Time-based control input, Indicates the first The goal is in time step The actual location at any given moment.
[0050] Based on the observation data of the current frame, if some valid observations exist, the predicted position is corrected using the Kalman gain formula: ,in, Kalman gain is used to calculate the weights between the predicted location and the observed data. This represents the prediction error covariance, reflecting the uncertainty of the prediction result at the current moment. Represents the observation matrix. Represents the observation noise covariance. This represents the transpose of the observation matrix.
[0051] During the repair process, constraints are applied to velocity, acceleration, and rate of change of direction.
[0052] The kinematic constraint model is represented as: velocity and acceleration constraints: , ,in, Indicates the current state Speed of motion at any moment Indicates the current state The acceleration of motion at any moment, Indicates in Always The instantaneous velocity component in the direction, Indicates in Always The instantaneous velocity component in the direction, Indicates the inter-frame time interval. This indicates the preset maximum speed of motion. This indicates the preset maximum acceleration.
[0053] Directional change rate constraint: ,in, This indicates the maximum permissible turning angle for the chicken's movement direction. Indicates time The change in angle.
[0054] The target detection and multi-target tracking module obtains a set of bounding boxes for chicken targets in each frame of the image. The bounding box of each target includes its center coordinates, width, height, and target detection confidence. The detected targets are matched with the target IDs output by the multi-target tracking module, and the positions of the same chicken in different frames are associated to generate a continuous trajectory sequence. Basic behavioral features such as position, velocity, acceleration, range of motion, and rate of change of direction are calculated. Combined with frequency domain analysis and deep learning coding techniques, a behavioral feature vector containing temporal information is generated, including key indicators such as average velocity, velocity variance, acceleration, acceleration variance, area of activity region, motion curvature, dominant frequency, and frequency domain energy, to comprehensively describe the chicken's motion state and behavioral patterns.
[0055] In terms of motion state quantification, instantaneous velocity is first calculated by the displacement of two adjacent frames. The average velocity is used to distinguish different activity intensities of chickens (such as standing still, walking, running, etc.), and the velocity variance reflects the stability of the motion. Acceleration is obtained by the ratio of the difference between the instantaneous velocity sequences to the time interval, which is used to identify the chickens' abrupt behavior. The rate of change of direction is calculated by the position difference between two adjacent frames to determine the motion direction angle. The difference between the two is compared with the maximum direction change threshold to determine the sudden change of direction. Frequency domain analysis uses Fast Fourier Transform (FFT) to extract the frequency domain features of the velocity sequence, calculate the main frequency and spectral energy, and analyze the periodic behavior of chickens, such as pecking or pacing behavior.
[0056] Frequency domain characteristics include first selecting an instantaneous velocity sequence within a time window, performing a Fast Fourier Transform to obtain the frequency domain signal: ,in, Represents frequency The frequency domain signal below, It represents the imaginary unit.
[0057] The dominant frequency is the frequency corresponding to the maximum amplitude in the amplitude spectrum. ,in, It represents the dominant frequency, reflecting the main rhythm of chicken behavior.
[0058] The dominant frequency of pecking behavior is usually high, corresponding to short-period repetitive actions, while the dominant frequency of pacing behavior is low, corresponding to long-period back-and-forth actions. The spectral energy is the sum of the squares of the amplitudes of all frequency components of the frequency domain signal. ,in, The spectrum energy represents the activity intensity of the chickens within the time window. The higher the spectrum energy, the more significant the change in activity intensity within the time window, corresponding to abnormal excitement or restlessness.
[0059] Using a bidirectional long short-term memory network as the encoding model, a lightweight deep learning network (such as Bi-LSTM) is employed to encode temporal features, generating high-dimensional feature vectors that comprehensively reflect behavioral patterns. During the training phase, the Bi-LSTM network is trained in a supervised manner using labeled datasets with labels such as "stationary," "walking," "clustering," and "escape." In unlabeled data scenarios, unsupervised clustering algorithms such as K-means are used to cluster high-level features, automatically identifying and classifying chicken behavioral patterns. The temporal behavioral feature vectors and high-level behavioral representation vectors extracted from the behavioral features are stored in the system database and associated with metadata such as the individual chicken ID, timestamp, and storage path of the corresponding frame image to form a complete behavioral feature dataset.
[0060] It should also be noted that the generation of behavioral feature vectors includes obtaining basic physical features based on continuous trajectory sequences, extracting main frequency and spectral energy features by combining frequency domain analysis, using a bidirectional long short-term memory network, encoding the temporal features through a Bi-LSTM network, and generating high-level behavioral representation vectors.
[0061] In the anomaly detection and health early warning mechanism based on time-series behavioral feature vector input, in the first stage, the input feature vector is fed into the statistical detection model, the time-series prediction model, the unsupervised anomaly detection model, and the group anomaly and density analysis model, respectively, and independently outputs the corresponding anomaly confidence scores, namely the statistical detection confidence score, the time-series prediction confidence score, the unsupervised detection confidence score, and the group anomaly confidence score.
[0062] In the second stage, the four confidence levels are integrated into the final anomaly confidence level using a weighted fusion algorithm.
[0063] In the third stage, the final anomaly confidence level is compared with the preset confidence level threshold. If it is greater than the confidence level threshold and the number of frames the state lasts exceeds the minimum duration threshold, a health warning is triggered, and the corresponding anomaly type and related data are recorded.
[0064] Among them, the statistical detection model is the basic step of anomaly detection. By analyzing the statistical distribution of behavioral characteristics, it identifies abnormal characteristics that deviate from the normal distribution range. The core algorithm is based on standardized scores (Z-score), which means: First, the system uses historical data, such as normal behavioral characteristic data in the past 24 hours, to statistically analyze each behavioral characteristic, such as average speed, acceleration variance, mean and standard deviation, to establish a statistical distribution baseline of normal characteristics and construct a two-layer baseline mechanism of individual baseline + group baseline.
[0065] Subsequently, for the real-time input feature values, the Z-score is calculated using the formula: ,in, Represents the Z-score standardized value. Represents the input feature values. Representation of features The mean, Representation of features The standard deviation.
[0066] The larger the absolute value of the Z-score, the further the current input feature value is from the mean, indicating a greater deviation from the normal value. A Z-score threshold of 2.5 is usually set, meaning that when the Z-score exceeds the current threshold, the data point is considered abnormal.
[0067] If the absolute value of the Z-score is greater than the preset Z-score threshold, it indicates that the data point deviates from the normal range and may require further processing or be marked as abnormal. The system will output an abnormal alarm and detect whether the feature value exceeds the set Z-score threshold, and mark or adjust the abnormal behavior.
[0068] Example 2, an embodiment of the present invention, provides a visual perception and trajectory repair system for movement analysis and anomaly detection in chickens raised in large cages, including a target detection and feature extraction module, a multi-target tracking and trajectory repair module, and an anomaly detection and health warning module.
[0069] The target detection and feature extraction module is used to extract low-level, mid-level and high-level features of chickens from video frames by combining the YOLOv7 network backbone with the E-ELAN structure. It also performs adaptive weighting processing on the feature maps by combining the CBAM attention mechanism, channel attention mechanism and spatial attention mechanism.
[0070] The multi-target tracking and trajectory repair module generates a continuous trajectory sequence based on the target detection output of each frame. It predicts the target's motion state through Kalman filtering, performs spatial matching using the Hungarian algorithm, and repairs interrupted or occluded trajectory segments through cubic spline interpolation and Kalman filtering. Finally, it restores the trajectory by combining the kinematic constraint model.
[0071] The anomaly detection and health early warning module is used to identify abnormal behaviors of chickens based on high-level behavioral representation vectors. It integrates the anomaly confidence into a final anomaly confidence through a weighted fusion algorithm. When the confidence threshold is reached, a health early warning is triggered. The module records the anomaly type and related data. It uses the Z-score algorithm to establish a statistical baseline of normal behavioral characteristics through historical data. It adopts a two-layer mechanism of individual baseline and group baseline to comprehensively identify abnormal behaviors.
[0072] This embodiment also provides a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements a visual perception and trajectory repair system for analyzing the movement and detecting anomalies of chickens in a cage farm, as proposed in the above embodiment.
[0073] This embodiment also provides a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements a visual perception and trajectory repair system for analyzing the movement and detecting anomalies of chickens in a cage farm, as proposed in the above embodiment.
[0074] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0075] The logic and / or steps represented in the flowchart or otherwise described herein, for example, can be considered as a sequenced list of executable instructions for implementing logical functions, and can be embodied in any computer-readable medium for use by, or in conjunction with, an instruction execution system, apparatus, or device (such as a computer-based system, a processor-including system, or other system that can fetch and execute instructions from, an instruction execution system, apparatus, or device). For the purposes of this specification, "computer-readable medium" can be any means that can contain, store, communicate, propagate, or transmit programs for use by, or in conjunction with, an instruction execution system, apparatus, or device.
[0076] More specific examples of computer-readable media (a non-exhaustive list) include: electrical connections (electronic devices) having one or more wires, portable computer disk drives (magnetic devices), random access memory (RAM), read-only memory (ROM), erasable and editable read-only memory (EPROM or flash memory), fiber optic devices, and portable optical disc read-only memory (CDROM). Furthermore, computer-readable media can even be paper or other suitable media on which the program can be printed, because the program can be obtained electronically, for example, by optically scanning the paper or other medium, followed by editing, interpreting, or otherwise processing as necessary, and then stored in computer memory.
[0077] It should be understood that various parts of the present invention can be implemented in hardware, software, firmware, or a combination thereof. In the above embodiments, multiple steps or methods can be implemented in software or firmware stored in memory and executed by a suitable instruction execution system. For example, if implemented in hardware, as in another embodiment, it can be implemented using any one or a combination of the following techniques known in the art: discrete logic circuits having logic gates for implementing logical functions on data signals, application-specific integrated circuits (ASICs) having suitable combinational logic gates, programmable gate arrays (PGAs), field-programmable gate arrays (FPGAs), etc.
[0078] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A visual perception and trajectory repair method for analyzing and detecting anomalies in chicken movement in large cage farms, characterized in that, include: Target detection is performed on chickens in video frames, target features are extracted, and spatial and channel attention mechanisms are used for fine feature extraction. Each target is tracked by combining fine features with Kalman filtering and Hungarian algorithm. The individual chicken identity is continuously tracked and adjusted by time series prediction and spatial matching, and the target bounding box is output. Based on tracking and adjusting the individual chicken identities, spline interpolation and Kalman filtering are used to smooth and repair interrupted and occluded trajectory segments, and biological kinematic constraints are used to reasonably restore the trajectory. Based on the target bounding box, a frequency domain feature analysis mechanism and deep learning coding technology are introduced to generate behavioral feature vectors, and health warnings are triggered based on the anomaly confidence level. Health alerts include statistical detection of behavioral characteristics, establishing a normal distribution baseline for each behavioral characteristic based on historical data using the Z-score algorithm, standardizing the real-time input feature values, identifying abnormal features that deviate from the normal range, integrating the confidence level with the abnormal confidence level using a weighted fusion algorithm, triggering a health alert when the anomaly detection reaches the confidence level threshold, and constructing a two-layer mechanism of individual baseline and group baseline to comprehensively obtain the degree of deviation of feature values from the baseline.
2. The visual perception and trajectory repair method for chicken movement analysis and anomaly detection in large cage farms as described in claim 1, characterized in that: The target detection includes using a YOLOv7 network backbone combined with an E-ELAN structure, extracting low-level, mid-level, and high-level features through multi-branch feature fusion and extended residual connections, and performing adaptive weighting processing on the input feature map using the CBAM attention mechanism.
3. The visual perception and trajectory repair method for chicken movement analysis and anomaly detection in large cage farms as described in claim 2, characterized in that: The CBAM attention mechanism includes a channel attention mechanism and a spatial attention mechanism; the channel attention mechanism includes extracting global information of feature channels through global pooling, and generating importance weights for each channel based on a multilayer perceptron mechanism, expressed as: ,in, Represents the input feature map The output after processing by the channel attention mechanism , Indicates the number of channels. Indicates the height of the image. Indicates the width of the image. This refers to the Sigmoid function, which maps the output value to the range of 0 to 1. Representing spatial dimension * Average pooling on top, Representing spatial dimension * Max pooling on This represents a multilayer perceptron; the spatial attention mechanism includes weighting the spatial distribution of each location in the feature map through convolution operations, enabling the network to focus on occluded and dense spatial regions of the target, as shown below: ,in, Represents the input feature map The output after attention mechanism processing This represents a 7×77×7 convolutional layer. Representation of feature map The Middle Features of each channel.
4. The visual perception and trajectory repair method for chicken movement analysis and anomaly detection in large cage farms as described in any one of claims 1 to 3, characterized in that: The tracking of each target includes: constructing a state-space model; generating a continuous trajectory sequence based on the target detection output of each frame; predicting the target's motion state using Kalman filtering; defining a matching cost for the detected and predicted targets; performing spatial matching using the Hungarian algorithm; and associating the continuity of each target's identity in cases of target occlusion, overlap, and illumination changes. The matching cost is expressed as: ,in, Indicates the first The first goal and the first The matching cost between prediction targets The intersection-over-union ratio (IoU) measures the degree of overlap between the predicted bounding box and the ground truth bounding box. Indicates the first Each target appearance feature vector Indicates the first Each predicted target appearance feature vector Indicates the displacement of the center point. 、 、 This represents the weighting coefficients, used to balance the different parts of the cost function.
5. The visual perception and trajectory repair method for chicken movement analysis and anomaly detection in large cage farms as described in claim 4, characterized in that: The continuous tracking and adjustment of individual chicken identities includes: constructing a time-series prediction model to predict the target state; using spatial matching to associate the target; if the detection result is not matched by any predicted target, a new trajectory is generated; if the predicted trajectory does not match for consecutive frames, the current target is marked as temporarily lost; if the loss continues for more than a set threshold number of frames, the trajectory is deleted; a matching confidence index is introduced; based on Re-ID features, individual appearance vectors are extracted through ResNet18 and MobileNet structures; and cosine similarity is used to re-associate the identity of the lost and newly detected targets.
6. The visual perception and trajectory repair method for chicken movement analysis and anomaly detection in caged chicken farms as described in any one of claims 1 to 3 and 5, characterized in that: The smoothing repair includes: constructing a kinematic constraint model based on the chicken's kinematic characteristics; using cubic spline interpolation to repair the trajectory when interruptions or occlusions occur; combining maximum speed and acceleration limits; performing high-precision interpolation on the missing parts based on information from the preceding and following valid trajectory segments; and predicting the trajectory position of the current frame based on the trajectory state of the previous frame using a state transition equation. ,in, Indicates the first The goal is at a certain moment Time to time The predicted location, Represents the state transition matrix. Represents the control matrix. Indicates at time step Time-based control input, Indicates the first The goal is in time step The actual position at any given time; combined with the observation data of the current frame, if some valid observations exist, the predicted position is corrected using the Kalman gain formula: ,in, Kalman gain is used to calculate the weights between the predicted location and the observed data. This represents the prediction error covariance, reflecting the uncertainty of the prediction result at the current moment. Represents the observation matrix. Represents the observation noise covariance. The transpose of the observation matrix is represented; constraints on velocity, acceleration, and rate of change of direction are applied during the repair process; the kinematic constraint model is represented as: velocity and acceleration constraints: , ,in, Indicates the current state Speed of motion at any moment Indicates the current state The acceleration of motion at any moment, Indicates in Always The instantaneous velocity component in the direction, Indicates in Always The instantaneous velocity component in the direction, Indicates the inter-frame time interval. This indicates the preset maximum speed of motion. Indicates the preset maximum acceleration; directional rate of change constraint: ,in, This indicates the maximum permissible turning angle for the chicken's movement direction. Indicates time The change in angle.
7. The visual perception and trajectory repair method for chicken movement analysis and anomaly detection in large cage farms as described in claim 6, characterized in that: The generation of behavioral feature vectors includes obtaining basic physical features based on continuous trajectory sequences, extracting main frequency and spectral energy features by combining frequency domain analysis, using a bidirectional long short-term memory network, encoding the temporal features through a Bi-LSTM network, and generating high-level behavioral representation vectors.
8. A visual perception and trajectory repair system for analyzing and detecting the movement of chickens in cage farms, employing the visual perception and trajectory repair method for analyzing and detecting the movement of chickens in cage farms as described in any one of claims 1 to 7, characterized in that: The system includes a target detection and feature extraction module, a multi-target tracking and trajectory restoration module, and an anomaly detection and health warning module. The target detection and feature extraction module uses a YOLOv7 network backbone combined with an E-ELAN structure to extract low-level, mid-level, and high-level features of chickens from video frames, and adaptively weights the feature maps using CBAM attention, channel attention, and spatial attention mechanisms. The multi-target tracking and trajectory restoration module generates a continuous trajectory sequence based on the target detection output of each frame, predicts the target's motion state using Kalman filtering, and employs the Hungarian algorithm for further analysis. Line space matching is used to repair interrupted or occluded trajectory segments through cubic spline interpolation and Kalman filtering, and the trajectory is restored by combining kinematic constraint models. The anomaly detection and health warning module is used to identify abnormal behaviors of chickens based on high-level behavioral representation vectors. The anomaly confidence is integrated into a final anomaly confidence through a weighted fusion algorithm. When a preset confidence threshold is reached, a health warning is triggered, and the anomaly type and related data are recorded. The Z-score algorithm is used to establish a statistical baseline of normal behavioral characteristics through historical data. An individual baseline and a group baseline dual-layer mechanism are used to comprehensively identify abnormal behaviors.
9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the visual perception and trajectory repair method for chicken movement analysis and anomaly detection in caged farms as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the visual perception and trajectory repair method for chicken movement analysis and anomaly detection in caged farms as described in any one of claims 1 to 7.
Citation Information
Cited By
A multi-modal perception cascade monitoring method and system for densely breeding sheldrake
CN122223064A