Multi-modal group pig individual tracking method and system based on space prior guidance
By mapping the IMU signal and video image data to the same space, using particle filtering algorithm and cross attention mechanism detection box decoder, the accuracy of multi-objective tracking of group pig farming under factors such as lighting and occlusion is solved, and the accuracy of multi-objective tracking in groups is achieved. High-precision individual tracking and behavior recognition.
Patent Information
- Application Number
- CN202410931370.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-07-12
AI Technical Summary
The existing multi-objective tracking technology for group pig farming is difficult to achieve accurate tracking under factors such as changing lighting, similar appearance of pigs and occlusion interaction. In addition, the data of IMU sensors are susceptible to noise interference in complex scenarios and cannot provide high-precision spatial position boundaries. .
Using multimodal group pig individual tracking method based on spatial prior guidance, high-frequency IMU signals and video image data are mapped to the same space, and two modes are established through particle filtering algorithm and detection box decoder of cross attention mechanism The complementary relationship between state data enables robust individual tracking.
It effectively alleviates the problems of missed detection, missed detection and ID jump in video monitoring technology, improves tracking accuracy and real-time in complex scenarios, combines the initial position estimation of the IMU signal and the boundary positioning of the video image, and reduces noise Interference improves the accuracy of behavior recognition.
Smart Images

Figure CN118968542A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of multi-target tracking, and in particular relates to a multi-modal group pig individual tracking method and system based on spatial priori guidance. Background Art
[0002] China is the world's leading producer of live pigs and consumer of pork, with pork consumption accounting for about 60% of the country's total meat consumption. [1] Shen Mingxia, Chen Jinxin, Ding Qian, et al. Research progress and prospects of automated pig breeding equipment and technology [J]. Journal of Agricultural Machinery, 2022, 53(12): 1-19.). However, the top of my country's pig breeding industry chain - the supply of high-quality breeding pigs, has long been highly dependent on imports. According to statistics, in recent years, my country's annual import volume from abroad has exceeded 20,000 heads ( [1] Zhang Haifeng, Xie Kengzheng, Liu Xiaohong, et al. Utilization of imported breeding pigs in my country and existing problems [J]. China Animal Husbandry Magazine, 2023, 59(01): 330-332. DOI: 10.19556 / j.0258-7033.20220918-20.). Excessive reliance on external resources has led to the dilemma of "stuck neck" in the domestic pig breeding industry, that is, key technologies and resources are controlled by others. Breaking this constraint and achieving independent control of the breeding industry is crucial to promoting the transformation of my country's pig industry from scale advantage to technology and quality. At the same time, the health status of breeding pigs directly affects the quality of domestic breeding pigs, and also affects the economic benefits and sustainable development of the entire industry.
[0003] During the growth process of pigs, their daily behaviors, such as eating, drinking and excretion, contain rich health information and are important indicators for measuring their health status and welfare level ( [1] Shen Mingxia, Chen Jinxin, Ding Qian, et al. Research progress and prospects of automated pig breeding equipment and technology [J]. Transactions of the Chinese Society of Agricultural Machinery, 2022, 53(12): 1-19.). Traditional pig behavior monitoring mainly relies on manual work, which is time-consuming and labor-intensive and poses the risk of cross-infection between humans and animals. The rapid development of digital technologies such as computer vision and wearable sensors, as well as artificial intelligence technologies such as machine learning and deep learning, has now successfully promoted the innovation and upgrading of automated and intelligent pig behavior recognition systems, greatly improving the efficiency of breeding pigs, while reducing labor costs and effectively suppressing the risk of pig disease transmission ( [3] He Peitong, Zhang Jianhua, Zhang Ning, Xia Xue, Chai Xiujuan. Research progress in intelligent livestock and poultry breeding management and disease diagnosis based on visual perception [J]. Journal of China Agricultural University, 2023, 28(10): 141-165.).
[0004] Multi-target tracking of group-raised pigs is the basis for accurate identification and statistical analysis of individual pig behaviors, and plays an important role in promoting the improvement of refined and digital management of pigs. The current mainstream multi-target tracking of group-raised pigs relies on video imaging technology. Among them, the multi-target tracking algorithm is gradually being applied to pig video monitoring because it can effectively locate multiple targets in the video based on biometrics and track the movement path of each pig. [2] Chen, C., Zhu, W., Steibel, J., Siegford, J., Han, J., & Norton, T. (2020). Recognition of feeding behavior of pigs and determination of feeding time of each pig by a video-based deep learning method. Computers and Electronics in Agriculture, 176, 105642.). Multi-target tracking is mainly divided into tracking by detection (TBD) and joint detection and embedding (JDE). The former performs detection and tracking in stages, resulting in the inference speed of the model being unable to achieve real-time effects. In contrast, the JDE algorithm uses an end-to-end network to simultaneously perform target detection and tracking, which can achieve higher accuracy and faster target tracking effects ( [3] Wang, Z., Zheng, L., Liu, Y., Li, Y., & Wang, S. (2020, August). Towards real-time multi-object tracking. In European Conference on Computer Vision (pp. 107-122). Cham: Springer International Publishing.). Professor Liang Yun’s team ( [4] Tu Shuqin, Huang Lei, Liang Yun, Huang Zhengxin, Li Chengjie, & Liu Xiaolong. (2022). Multi-target tracking of group-raised pigs based on JDE model. Transactions of the Chinese Society of Agricultural Engineering, 38(17), 186-195.) confirmed that the pig multi-target tracking model using the JDE algorithm has a 340% improvement in the number of frames per second compared to the TBD algorithm model. Nevertheless, most of the detectors in the existing JDE models use an anchor frame mechanism, which is prone to the problem of a single frame covering multiple targets due to overlapping detection frames in pig adhesion and occlusion scenarios ( [5]Guo, Q., Sun, Y., Orsini, C., Bolhuis, JE, de Vlieg, J., Bijma, P., & de With, PH (2023). Enhanced camera-based individual pig detection and tracking for smart pig farms. Computers and Electronics in Agriculture, 211, 108009.). In response to this, the researchers further optimized the JDE algorithm and proposed the FairMOT algorithm ( [6] Zhang, Y., Wang, C., Wang, X., Zeng, W., Liu, W., 2021. Fairmot: On the fairness of detection and re-identification in multiple object tracking. Int. J. Comput. Vis. 129 (11), 3069–3087.), uses the anchor-free object detection network CenterNet as its object detection branch, and simultaneously extracts the object center ReID feature. Professor Tomas Norton's team at the University of Leuven in Belgium ( [7] Wang, M., Larsen, ML, Liu, D., Winters, JF, Rault, JL, & Norton, T. (2022). Towards reidentification for long-term tracking of group housed pigs. Biosystems Engineering, 222, 71-81.) optimized the FairMOT algorithm to achieve accurate re-identification of pigs when they reappear after occlusion. However, in actual farming scenarios, due to factors such as the similar appearance of pigs, mutual occlusion, and variable lighting conditions, the existing methods will inevitably have problems such as missed detection, false detection, and frequent ID jumps. At the same time, the tracking process relies too much on inter-frame data association, which increases the difficulty of real-time tracking under conditions of fast movement of pigs and low frame rates.
[0005] Another target tracking technology is to use wearable devices, such as electronic pedometers, RFID tags and inertial measurement units (IMUs). These devices are usually fixed to different parts of the target's body to obtain individual identity, physiological indicators and behavioral characteristics data, thereby realizing intelligent monitoring of individuals ( [8]He Peitong, Zhang Jianhua, Zhang Ning, Xia Xue, Chai Xiujuan. Research progress in intelligent livestock and poultry breeding management and disease diagnosis based on visual perception [J]. Journal of China Agricultural University, 2023, 28(10): 141-165.). Among them, the IMU sensor integrates an accelerometer, a gyroscope and a magnetometer. Because of its small size, portability, independence from external facilities, easy deployment, and unaffected by environmental factors such as occlusion and light, it has been widely used in the field of indoor pedestrian positioning. The original inertial navigation system ( [9] Weston J, Titterton D. Modern inertial navigation technology and its application [J]. Electronics Communication Engineering Journal, 2000, 12 (2): 49-64.) (Strapdown inertial navigation integration, SINS) is based on the integration of acceleration and angular velocity for positioning, but due to sensor noise interference, the error during independent dead reckoning will accumulate rapidly. In response to this, researchers proposed a pedestrian dead reckoning based on step length (
[10] Kang W, Han Y. SmartPDR: Smartphone-based pedestrian dead reckoning for indoor localization [J]. IEEE Sensors Journal, 2014, 15 (5): 2906-2916.) (Pedestrian Dead Reckoning, PDR) algorithm uses an accelerometer to detect the number of steps and estimate the step length, while using a gyroscope and a magnetometer to calculate the pedestrian's heading angle to obtain the relative position of the pedestrian and achieve positioning. However, because it relies on prior knowledge of human walking patterns and needs to adjust parameters according to the user's individual gait characteristics, this hinders its widespread application in real life. Wang and Shkel et al. (
[11] Wang Y, Shkel AM. Adaptive threshold for zero-velocity detector in ZUPT-aided pedestrian inertial navigation [J]. IEEE Sensors Letters, 2019, 3 (11): 1-4.) proposed to apply the Bayesian method to pedestrian dead reckoning to determine the adaptive threshold estimation step information. In addition, the magnetometer signal is easily interfered by ferromagnetic materials, and the gyroscope angle measurement has drift, which may affect the accuracy of heading estimation. To improve the accuracy of heading estimation, a common solution is to use a Kalman filter to integrate the magnetometer and gyroscope readings (
[12] Shang J, Gu F, Hu X, et al. APFiLoc: An Infrastructure-Free Indoor Localization Method Fusing Smartphone Inertial Sensors, Landmarks and Map Information [J]. Sensors, 2015, 15 (10): 27251-27272.), but the classical Kalman filter can only achieve optimal estimation in an ideal linear Gaussian system. Although the extended Kalman filter and the unscented Kalman filter solve the nonlinear problem, they are still limited by the fact that the system is Gaussian noise. In order to solve the problem of nonlinear non-Gaussian system, the particle filter algorithm based on the Monte Carlo method was proposed (
[13] Liu H, Li Q, Li C, et al. Application research of an array distributed IMU optimization processing method in personal positioning in large span blind environment [J]. IEEE Access, 2020, 8: 48163-48176.), this algorithm uses a large number of particles to approximate the true posterior distribution. Due to its reliable performance, it has been widely used in indoor positioning fields such as integrated navigation. At present, IMU sensors are mainly used for indoor positioning of humans, and their application in the field of animals has yet to be developed. Given the successful case of this technology in human positioning, it has great potential and broad prospects to apply it to breeding farms to achieve indoor positioning of animals.
[0006] In summary, the advantage of the method based on video image technology is that it can continuously capture scene dynamics and provide high-resolution pixel-level information, but it cannot effectively overcome the influence of pigs' similar appearance, occlusion interaction, and changing lighting conditions. In contrast, the method based on IMU sensors does not rely on external facilities and is not affected by factors such as occlusion and changing lighting. It can provide accurate identification and preliminary location estimation for the target, and is expected to provide accurate identification and preliminary location estimation for individual pigs; however, this method does not have the fine-grained spatial resolution characteristics of images, and the data collected in complex scenes are easily interfered by measurement noise and hardware noise.
[0007] Video monitoring technology faces many challenges in actual farming scenarios. First, external conditions such as changing lighting can reduce image quality and blur the target outline, resulting in missed detection and tracking of individuals. Second, internal factors such as similar appearance, mutual occlusion, and changing postures of pigs can lead to false detection and frequent ID jumps. Third, high-precision behavior recognition often relies on high-frame rate video, which not only increases the operating cost of the equipment, but also poses a significant challenge to the real-time nature of pig behavior recognition.
[0008] IMU sensors also face many challenges in actual farming scenarios. First, IMU sensors cannot provide users with intuitive and easy-to-understand visualization results; second, IMU sensors do not have the ability to capture pixel-level spatial information and cannot be used to accurately calibrate the position boundaries of pigs in space; third, although IMU sensors can perceive subtle changes in the timing of individual pig behaviors, they cannot capture global spatial changes, and motion signals are easily interfered by noise, which in turn affects the accuracy of behavior recognition.
[0009] Based on the above situation, the present invention innovatively combines video images and IMU signals, models the complementary relationship between the two, and designs a multimodal group pig individual tracking technology solution based on spatial prior guidance. Summary of the invention
[0010] In order to solve the above-mentioned technical problems existing in the prior art, the present invention provides a multimodal group pig individual tracking method and system based on spatial prior guidance. The present invention maps two modal data, video images and motion signals, to the same space and models the complementary relationship between the two to achieve robust group pig individual tracking.
[0011] The present invention adopts the following technical scheme:
[0012] The multimodal group pig individual tracking method based on spatial prior guidance is as follows:
[0013] S1, establish a momentum-corrected particle filter algorithm based on high-frequency IMU signals, convert the high-frequency IMU signals into spatial position coordinates, so as to map the IMU signals and video images to the same space;
[0014] S2, establish a group pig individual tracking algorithm guided by spatial position prior, extract the features of the spatial position obtained in step S1 and the features of the corresponding video frame image, construct a detection frame decoder based on the cross-attention mechanism, and establish a complementary relationship between the two modal data to achieve continuous and accurate tracking of group pig individuals.
[0015] Preferably, step S1 is specifically as follows:
[0016] S1.1, set the starting position coordinates of the pig target and initialize the particle swarm probability, and obtain the speed and direction information of the target by performing equal-interval integration operations on the motion signals collected by the IMU sensor;
[0017] S1.2. The uncorrected speed and direction values at the current moment are uniformly recorded as Ω t , the updated value after the momentum equation is corrected is recorded as The correction value at the previous moment is expressed as Initialization setting is 0; the correction relationship is expressed as follows:
[0018]
[0019] Among them, α represents the degree of correction;
[0020] S1.3, perform zero-speed detection on the collected motion signal data to obtain a zero-speed interval; use the acceleration modulus, angular velocity modulus and angular velocity modulus standard deviation to perform threshold judgment;
[0021] S1.4. Take the speed value solved in the zero-speed interval as the observation value, establish the observation equation and discretize it to obtain:
[0022] Z vk =H(X k )+V vk (5)
[0023] Z vk =[V e ,V n ,V u ] (6)
[0024] V vk =[ΔV e ,ΔV n ,ΔV u ] (7)
[0025] Where V e、V n 、V u are the speeds in the east, north and sky directions respectively; H is the system observation matrix; ΔV e , ΔV n , ΔV u are the velocity observation noises in the east, north, and sky directions, respectively;
[0026] S1.5. Use particle filter algorithm to calculate the individual position coordinates of pigs.
[0027] Preferably, in step S1.3:
[0028] Acceleration modulus conditions:
[0029]
[0030] In the formula, |a i | is the axis acceleration modulus; a xi ,a yi ,a zi are the acceleration measurements of the x, y, and z axes respectively; a min ,a max are the upper and lower limits of the acceleration range respectively;
[0031] Angular velocity modulus conditions:
[0032]
[0033] In the formula, |ω i | is the angular velocity modulus; ω xi ,ω yi ,ω zi are the angular velocity measurements of the x, y, and z axes respectively; ω max is the angular velocity interval threshold;
[0034] Acceleration variance condition:
[0035]
[0036] In the formula, For |a i | is the standard deviation of the acceleration modulus at the sampling midpoint, and 2n+1 is the length of the sampling interval; is the mean value of the acceleration modulus; σ a is the acceleration modulus standard deviation threshold;
[0037] When C1, C2, and C3 conditions meet all three conditions at the same time, that is, C1(i)C2(i)C3(i)=1, the sampling point i is determined to be a zero-speed point, and continuous zero-speed points constitute a zero-speed interval.
[0038] Preferably, step S1.5 is as follows:
[0039] S1.5.1. At the initial time t = 0, the initial particles x0 ~ p(x0) are sampled according to the sampling distribution p(x0) to obtain the initial particle set Take the number of particles N = 100, and the initial weight of each particle is 1 / N;
[0040] S1.5.2. Constructing the importance probability density function Each particle is calculated according to the following formula The corresponding weight
[0041]
[0042] In the formula, is the posterior probability density function; is the likelihood function of the observed quantity; is the state transition probability; is the proposed distribution function, satisfying is the weight at the k-1 moment; is the weight of particle k at time;
[0043] Normalize to get:
[0044]
[0045] In the formula, is the weight of the i-th particle at the k-th moment; is the weight sum of all particles at time k; is the value after weight normalization;
[0046] S1.5.3. According to the normalized particle set, the state value at time k is obtained from the state value at time k-1, that is, the optimal estimate. The state estimate is:
[0047]
[0048] In the formula, is the particle at time k;
[0049] S1.5.4. Discard particles with weights less than the set value from the particle set, re-extract particles with weights greater than the set value and copy them to establish a new particle set.
[0050] Preferably, in step S1.5.4, an adaptive threshold method is used to select new particles, and the specific steps are as follows:
[0051] 1) Select an adaptive threshold M; M satisfies equation (11);
[0052]
[0053] Where: The value range of M is [M a ,M b ]; M b is the upper limit; M a is the initial value of the threshold, t is the number of iterations; N e is the effective particle number; K e is the proportional coefficient; the threshold M is proportional to the number of iterations t and the number of effective particles N e Inversely proportional to N e Satisfies formula (12);
[0054]
[0055] Using the effective number of particles N e To measure the degree of degradation of particle weights, N is the number of particles, is the particle weight variance; Substituting (12) into (11) we get:
[0056]
[0057] When M reaches the upper limit M b When M=M a ;
[0058] 2) Keep the particle judgment; if Keep otherwise
[0059] 3) Make a secondary judgment on particle degradation phenomenon:
[0060]
[0061] When H1+H2=1 is satisfied, return to step S1.5.1 to resample the particles. The weight of the resampled particles is 1 / N, where N is the number of particles. The new particle set As the initial particle at the next moment; otherwise, return to step S1.5.2 for the next iteration until the loop ends; the position of the corresponding particle at the end of the loop is the final target position.
[0062] Preferably, step S2 is specifically as follows:
[0063] S2.1, project the position and image into a feature space of the same dimension;
[0064] S2.2, establish the complementary relationship between IMU signal and video image; With location features They are input together into the detection box decoder based on the cross attention mechanism, and the individual detection box features corresponding to the M-dimensional position feature vector are output. In order to achieve the integration of information between the two; the specific process is as follows:
[0065] P′=LN(Attn(P,P,P)+P) (19)
[0066] P″=LN(Attn(P,Z,Z)+P′) (20)
[0067] P″′=LN(MLP(P″)+P″) (21)
[0068] Z′=LN(Attn(Z,P″′,P″′)+Z) (22)
[0069] B=LN(Attn(P″′,Z′,Z″)+P″′) (23)
[0070] In the formula, LN(·) denotes layer normalization, and MLP(·) denotes multilayer perceptron;
[0071] The operation module in the middle of the decoder includes two position-image attention modules, one image-position attention module and a multi-layer perceptron. The position-image attention module replaces the multi-head self-attention block with a cross attention block based on the Transformer layer. Realization, Q = w Q P, K = w K Z, V = w V Z; in the image-position attention module, Q = w′ Q Z, K = w′ K P, V = w′ V ·P, w Q , w K , w V , w′ Q , w′ K , and w′ V Represents the mapping matrix that can be learned;
[0072] S2.3. Obtained individual detection frame features Input to the multi-layer perceptron, and output the key point coordinate pairs of each pig's individual bounding box, denoted as and They represent the upper left corner coordinates and lower right corner coordinates of the mth pig's bounding box respectively.
[0073] Preferably, step S2.1 is as follows:
[0074] S2.1.1, based on the position coordinates p of the individual pig at a certain moment obtained in step S1 m =(x m ,y m ), m = 1, 2, ..., M, and input it into the learnable position encoder to generate the position features corresponding to M pigs
[0075] The position encoder is composed of a function Y based on a random Fourier feature map and a multilayer perceptron with a ReLU activation function; Function Υ is expressed as:
[0076]
[0077] In the formula, Represents the parameters that can be learned, basis vector w i It is randomly sampled from a Gaussian distribution with 0 as mean and σ as standard deviation, that is
[0078] S2.2.2. Select the video frame image at the corresponding moment from the video, divide it into N fixed-size image blocks, generate a vector representation of dimension N×D through flattening and mapping operations, add it to the corresponding N×D-dimensional position embedding vector and input it into the Transformer encoder to obtain the image feature vector
[0079] Preferably, the specific process of step S2.2.2 is as follows:
[0080] S2.2.2.1 Video frame image is divided into N fixed-size (P 2 ×C), denoted as N=HW / P 2 , C represents the number of channels; each image block is flattened into a one-dimensional vector, and a set of image block vector representations with dimension D is generated through linear mapping Vectorize the position of the image patch to the same dimension as the Add up to get the input tokens, denoted as
[0081] S2.2.2.2. Input into the Transformer encoder with L layers to get a new set of image block encodings Recorded as image feature vector Each Transformer layer mainly consists of a multi-head self-attention block and a multi-layer perceptron block, each of which contains a layer normalization layer and a residual connection:
[0082]
[0083] The present invention also discloses a multi-modal group pig individual tracking system based on spatial priori guidance, based on the above method, including the following modules:
[0084] Position acquisition module: A momentum-corrected particle filter algorithm is established based on high-frequency IMU signals to convert high-frequency IMU signals into spatial position coordinates, so as to map the IMU signals and video images to the same space;
[0085] Tracking module: Establish a group-raised pig individual tracking algorithm guided by spatial position prior, extract the features of the obtained spatial position and the features of the corresponding video frame image, construct a detection box decoder based on the cross-attention mechanism, and establish a complementary relationship between the two modal data to achieve continuous and accurate tracking of group-raised pig individuals.
[0086] The present invention is based on a multi-modal group pig individual tracking method and system guided by spatial priors. The spatial position of individual pigs is preliminarily estimated through IMU signals, and this spatial prior information is used to guide the detection of individual pigs in the corresponding video frame image, so as to achieve continuous tracking of group pigs in the video stream. The present invention gives full play to the advantages of IMU signals in the initial estimation of individual positions and the advantages of video images in framing target boundaries, and effectively alleviates the problems of missed detection, false detection and ID jump that may occur in video monitoring technology. BRIEF DESCRIPTION OF THE DRAWINGS
[0087] Figure 1 It is a general flow chart of a multimodal group pig individual tracking method based on spatial prior guidance according to a preferred embodiment of the present invention.
[0088] Figure 2 It is a principle flow chart of the particle filtering algorithm of the preferred embodiment.
[0089] Figure 3 It is a schematic diagram of a particle filter algorithm based on momentum correction in a preferred embodiment.
[0090] Figure 4 It is a schematic diagram of an algorithm for tracking individual pigs in a group guided by spatial position prior in a preferred embodiment.
[0091] Figure 5 It is a block diagram of a multimodal group pig individual tracking system based on spatial prior guidance according to a preferred embodiment of the present invention. DETAILED DESCRIPTION
[0092] The preferred embodiments of the present invention are described in detail below with reference to the accompanying drawings.
[0093] In actual farming scenarios, the video-based group pig individual tracking technology is easily affected by factors such as the similar appearance of pigs, occlusion interaction, and changes in lighting conditions. The IMU signal is not easily affected by these factors and can accurately provide individual pig position information, but it cannot directly and accurately define the target boundary of the pig in the visual space. In addition, given that motion signals are lighter than video data, in order to reduce the computational burden of multimodal data on the model, and taking into account the requirements for real-time performance in practical applications, the present invention adopts a combination of low-frame-rate video and high-frequency motion signals to establish a spatial prior-guided multimodal group pig individual tracking method, such as Figure 1 shown.
[0094] Firstly, a momentum-corrected particle filter algorithm is established based on the high-frequency IMU signal, and the high-frequency IMU timing signal is converted into spatial position coordinates, so as to map the IMU signal and the video image to the same space. On this basis, a group-raised pig individual tracking algorithm guided by spatial position prior is established, and the features of the above-mentioned prior position and the features of the corresponding video frame image are extracted. A detection box decoder based on the cross-attention mechanism is constructed, and the complementary relationship between the two modal data is modeled to promote their deep fusion, thereby realizing continuous and accurate tracking of group-raised pig individuals.
[0095] The specific technical solution of this embodiment is as follows:
[0096] S1. Establish a particle filter algorithm based on momentum correction
[0097] In the field of indoor positioning based on IMU signals, the widely used algorithm for solving the position of the positioning target is the particle filter algorithm based on the Monte Carlo method. This algorithm uses a particle swarm to represent probability and approximates the target motion equation by finding particles propagating in the state space, thereby obtaining the target position. Figure 2 As shown, its working principle is to estimate the state of a dynamic system from a set of observation sequences using a set of particles with different weights. The observation sequence used may contain noise, or even be incomplete, and the weights of the particles will be continuously iterated and updated. The particle filter algorithm can be applied to any state space model, and the noise distribution can also be in any form, which has great advantages in the scenario of nonlinear non-Gaussian systems. In combination with the application scenarios of the present invention, considering that the data collected by the IMU sensor is easily disturbed by measurement noise and hardware noise, and the daily life of pigs is mainly static behaviors such as lying down and sleeping, the present invention proposes and adopts a particle filter algorithm based on momentum correction to preliminarily estimate the spatial position of individual pigs at equal intervals. The steps are as follows Figure 3 As shown, the specific description is:
[0098] S1.1, obtain the speed and direction information of the target. First, set the starting position coordinates of the pig target and initialize the particle swarm probability, and then perform equal-interval integration operations on the motion signals collected by the IMU sensor to obtain the speed and direction information of the target.
[0099] S1.2, Error correction. Considering that the instability of the IMU signal will generate noisy data points and the errors generated by these data points will gradually accumulate over time, the present invention uses the momentum equation to correct the errors of speed and direction information after integral calculation. The uncorrected speed and direction values at the current moment are uniformly recorded as Ω t , the updated value after the momentum equation is corrected is recorded as The correction value at the previous moment is expressed as Initialization setting is 0. The specific correction relationship is expressed as follows:
[0100]
[0101] Among them, α represents the degree of correction, and the updated It does not depend only on the current value, but accumulates the historical information of the target's movement trajectory.
[0102] S1.3, perform zero-speed detection on the collected data. Considering that pigs mainly lie down and sleep in their daily life, in order to improve the positioning accuracy, the collected motion signal data is firstly tested for zero speed, and then the zero-speed interval is obtained. The acceleration modulus, angular velocity modulus and angular velocity modulus standard deviation are used for threshold judgment. In this step,
[0103] S1.3.1. Acceleration modulus conditions:
[0104]
[0105] In the formula, |a i | is the axis acceleration modulus; a xi ,a yi ,a zi are the acceleration measurements of the x, y, and z axes respectively; a min ,a max are the upper and lower limits of the acceleration range respectively.
[0106] S1.3.2, Angular velocity modulus conditions:
[0107]
[0108] In the formula, |ω i | is the angular velocity modulus; ω xi ,ω yi ,ω ziare the angular velocity measurements of the x, y, and z axes respectively; ω max is the angular velocity interval threshold.
[0109] S1.3.3 Acceleration variance condition:
[0110]
[0111] In the formula, For |a i | is the standard deviation of the acceleration modulus at the sampling midpoint, and 2n+1 is the length of the sampling interval; is the mean value of the acceleration modulus; σ a is the acceleration modulus standard deviation threshold.
[0112] When C1, C2, and C3 conditions meet all three conditions at the same time, that is, C1(i)C2(i)C3(i)=1, the sampling point i is determined to be a zero-speed point, and continuous zero-speed points constitute a zero-speed interval.
[0113] S1.4, obtain the observation equation of the zero-speed correction algorithm. Take the speed value solved in the zero-speed interval as the observation value, establish the observation equation of the system and discretize it to obtain:
[0114] Z vk =H(X k )+V vk (5)
[0115] Z vk =[V e ,V n ,V u ] (6)
[0116] V vk =[ΔV e ,ΔV n ,ΔV u ] (7)
[0117] Where V e ,V n ,V u are the speeds in the east, north and sky directions respectively; H is the system observation matrix; ΔV e ,ΔV n ,ΔV u are the velocity observation noise in the east, north and sky directions respectively.
[0118] S1.5. Use the particle filter algorithm to calculate the individual position coordinates of the pigs. The present invention finds a set of particles to approximate the probability density function based on the motion model of the zero-speed interval. The optimal estimate of the state vector is obtained by continuously updating the particle values and weights. The algorithm flow is as follows:
[0119] S1.5.1. Initial particle calculation. At the initial time t = 0, the initial particles x0 ~ p(x0) are sampled according to the sampling distribution p(x0) to obtain the initial particle set The number of particles N is taken as 100, and the initial weight of each particle is 1 / N.
[0120] S1.5.2. Importance sampling updates particles and weights. Construct importance probability density function Each particle is calculated according to the following formula The corresponding weight
[0121]
[0122] In the formula, is the posterior probability density function; is the likelihood function of the observed quantity; is the state transition probability; is the proposed distribution function, satisfying is the weight at the k-1 moment; is the weight of particle k at time instant.
[0123] Normalize to get:
[0124]
[0125] In the formula, is the weight of the i-th particle at the k-th moment; is the weight sum of all particles at time k; is the value after weight normalization.
[0126] S1.5.3, Calculate the filter value. According to the normalized particle set, the value at time k can be obtained from the state value at time k-1, that is, the optimal estimate. The state estimate is:
[0127]
[0128] In the formula, is the particle at time k.
[0129] S1.5.4, Particle resampling. Discard particles with smaller weights from the particle set, re-extract particles with larger weights and replicate them to create a new particle set. Make the mean of the particle set approach the mathematical expectation with the maximum probability.
[0130] The weight of particles gradually increases during the iteration process. When a fixed weight threshold is used to select particles, if there are particles with small weights among the retained particles, the particle degradation speed will be faster when the weight threshold is large, resulting in filtering failure. Therefore, the present invention adopts an adaptive threshold method to select new particles, and the specific steps are as follows:
[0131] 1) Select an adaptive threshold M. M satisfies equation (11);
[0132]
[0133] Where: The value range of M is [M a ,M b ]; M b is the upper limit; M a is the initial value of the threshold, t is the number of iterations; N e is the effective particle number; K e is the proportional coefficient; the threshold M is proportional to the number of iterations t and the number of effective particles N e Inversely proportional to N e Satisfies formula (12);
[0134]
[0135] Using the effective number of particles N e To measure the degree of degradation of particle weights, N is the number of particles, is the particle weight variance. N e The larger the value, the more serious the degradation. Substituting (12) into (11) we get:
[0136]
[0137] When M reaches the upper limit M b When M=M a .
[0138] 2) Keep the particle judgment. If Keep otherwise
[0139] 3) Make a secondary judgment on particle degradation phenomenon:
[0140]
[0141] When H1+H2=1, return to step S1.5.1 to resample the particles. The weight of the resampled particles is 1 / N, where N is the number of particles. As the initial particle at the next moment. Otherwise, return to step S1.5.2 for the next iteration until the loop ends. The position of the corresponding particle at the end of the loop is the final target position.
[0142] S2. Establishment of an algorithm for tracking individual pigs in groups guided by spatial position priors
[0143] The algorithm proposed in the present invention first uses the preliminary position coordinates of the individual pigs in the visual space obtained above, projects the position prior and the information of the corresponding video frame image into the feature space of the same dimension, and designs a detection frame decoder to model the complementary relationship between the two to promote the deep fusion of the two, and realize the detection of individual pigs at the level of single-frame images; then, based on the preset individual identity association information between video frames, combined with the detection results of single-frame images, individual detection and tracking in the video stream are realized. The specific process steps are as follows: Figure 4 shown.
[0144] S2.1. Project the position and image to the feature space of the same dimension. The details are as follows:
[0145] S2.1.1, based on the position coordinates p of the individual pig at a certain moment obtained in step S1 m =(x m ,y m ), m = 1, 2, ..., M, and input it into the learnable position encoder to generate the position features corresponding to M pigs
[0146] The position encoder is composed of a function Y based on a random Fourier feature map and a multilayer perceptron with a ReLU activation function. Function Υ is expressed as:
[0147]
[0148] In the formula, represents the learnable parameters, basis vector w i It is randomly sampled from a Gaussian distribution with 0 as mean and σ as standard deviation, that is Fourier feature mapping uses Bochner's theorem to efficiently construct a representation of an approximate translation-invariant kernel, which enhances the model's ability to handle translation invariance and its robustness to image position perception.
[0149] S2.2.2 At the same time, select the video frame image at the corresponding moment from the video, divide it into N fixed-size image blocks, generate a vector representation with a dimension of N×D after flattening and mapping operations, add it to the corresponding N×D-dimensional position embedding vector and input it into the Transformer encoder to obtain the image feature vector The specific process is as follows:
[0150] S2.2.2.1 Video frame image is divided into N fixed-size (P 2 ×C) patches, denoted as N=HW / P 2, C represents the number of channels. Each patch is flattened into a one-dimensional vector and a set of patch vector representations with dimension D is generated through linear mapping. Vectorize patches to their same dimensions Add up to get the input tokens, denoted as
[0151] S2.2.2.2, then, Input into the Transformer encoder with L layers to get a new set of patch codes Recorded as image feature vector Each Transformer layer mainly consists of a multi-headed self-attention (MSA) block and a multi-layer perceptron (MLP) block, each of which contains a layer normalization layer and a residual connection:
[0152]
[0153] S2.2, Model the complementary relationship between IMU signals and video images. With location features They are input together into the detection box decoder based on the cross attention mechanism, and the individual detection box features corresponding to the M-dimensional position feature vector are output. Realize the deep integration of information between the two. The specific process is as follows:
[0154] P′=LN(Attn(P,P,P)+P) (19)
[0155] P″=LN(Attn(P,Z,Z)+P′) (20)
[0156] P″′=LN(MLP(P″)+P″) (21)
[0157] Z′=LN(Attn(Z,P″′,P″′)+Z) (22)
[0158] B= LN(Attn(P″′,Z′,Z″)+P″′) (23)
[0159] In the equation, LN(·) denotes layer normalization, and MLP(·) denotes multi-layer perceptron.
[0160] The operation module in the middle of the decoder includes two position-image attention modules, one image-position attention module and a multi-layer perceptron. The position-image attention module replaces the multi-head self-attention block with a cross attention block based on the Transformer layer. Realization, Q = w Q P, K = w K Z, V = w V ·Z. Similarly, in the image-position attention module, Q = w′ Q Z, K = w′ K P, V = w′ V ·P, w Q , w K , w V , w′ Q , w′ K , and w′ V Represents a learnable mapping matrix. The decoder is built based on the attention mechanism and can flexibly adapt to the variable-length input of the number of position features. By utilizing the prior information of the individual positions of pigs, the constraint of the actual number of pigs is implicitly introduced, which helps to reduce missed detection and false detection. It is also suitable for breeding scenarios with different numbers of pigs and has significant practical value.
[0161] S2.3, realize group pig individual tracking. Input to the multi-layer perceptron, and output the key point coordinate pairs of each pig's individual bounding box, denoted as and Respectively represent the upper left corner coordinates and lower right corner coordinates of the mth pig’s bounding box. So far, we can simultaneously achieve target detection and identity recognition of individual pigs in a single frame image. Based on the above group pig individual detection results in a single frame image, combined with the individual identity association between video frames established in advance by the IMU signal, robust group pig individual tracking is achieved.
[0162] like Figure 5 As shown, this embodiment discloses a multi-modal group pig individual tracking system based on spatial prior guidance, based on the above method embodiment, including the following modules:
[0163] Position acquisition module: A momentum-corrected particle filter algorithm is established based on high-frequency IMU signals to convert high-frequency IMU signals into spatial position coordinates, so as to map the IMU signals and video images to the same space;
[0164] Tracking module: Establish a group-raised pig individual tracking algorithm guided by spatial position prior, extract the features of the obtained spatial position and the features of the corresponding video frame image, construct a detection box decoder based on the cross-attention mechanism, and establish a complementary relationship between the two modal data to achieve continuous and accurate tracking of group-raised pig individuals.
[0165] For other contents of this embodiment, please refer to the above method embodiment.
[0166] The above are preferred embodiments of the present invention. Those skilled in the art may make several improvements and modifications without departing from the principles of the present invention. These improvements and modifications should also be considered as within the scope of protection of the present invention.
Claims
1. A multimodal group pig individual tracking method based on spatial prior guidance, characterized by: Follow these steps: S1, establish a momentum-corrected particle filter algorithm based on high-frequency IMU signals, convert the high-frequency IMU signals into spatial position coordinates, so as to map the IMU signals and video images to the same space; S2, establish a group pig individual tracking algorithm guided by spatial position prior, extract the features of the spatial position obtained in step S1 and the features of the corresponding video frame image, construct a detection frame decoder based on the cross-attention mechanism, and establish a complementary relationship between the two modal data to achieve continuous and accurate tracking of group pig individuals.
2. The multimodal group pig individual tracking method based on spatial prior guidance as claimed in claim 1 is characterized in that: Step S1 is specifically as follows: S1.1, set the starting position coordinates of the pig target and initialize the particle swarm probability, and obtain the speed and direction information of the target by performing equal-interval integration operations on the motion signals collected by the IMU sensor; S1.
2. The uncorrected speed and direction values at the current moment are uniformly recorded as Ω t , the updated value after the momentum equation is corrected is recorded as The correction value at the previous moment is expressed as Initialization setting is 0; the correction relationship is expressed as follows: Among them, α represents the degree of correction; S1.3, perform zero-speed detection on the collected motion signal data to obtain a zero-speed interval; use the acceleration modulus, angular velocity modulus and angular velocity modulus standard deviation to perform threshold judgment; S1.
4. Take the speed value solved in the zero-speed interval as the observation value, establish the observation equation and discretize it to obtain: Z vk =H(X k )+V vk (5) With vk =[In e ,In n ,In u ] (6) V vk =[ΔV e ,ΔV n ,ΔV u ] (7) Where V e 、V n 、V u are the speeds in the east, north and sky directions respectively; H is the system observation matrix; ΔV e , ΔV n , ΔV u are the velocity observation noises in the east, north, and sky directions, respectively; S1.
5. Use particle filter algorithm to calculate the individual position coordinates of pigs.
3. The multi-modal group pig individual tracking method based on spatial prior guidance as claimed in claim 2 is characterized in that the steps In S1.3: Acceleration modulus conditions: In the formula, |a i | is the axis acceleration modulus; a xi ,a yi ,a zi are the acceleration measurements of the x, y, and z axes respectively; a min ,a max are the upper and lower limits of the acceleration range respectively; Angular velocity modulus conditions: In the formula, |ω i | is the angular velocity modulus; ω xi ,ω yi ,ω zi are the angular velocity measurements of the x, y, and z axes respectively; ω max is the angular velocity interval threshold; Acceleration variance condition: In the formula, For |a i | is the standard deviation of the acceleration modulus at the sampling midpoint, and 2n+1 is the length of the sampling interval; is the mean value of the acceleration modulus; σ a is the acceleration modulus standard deviation threshold; When C1, C2, and C3 conditions meet all three conditions at the same time, that is, C1(i)C2(i)C3(i)=1, the sampling point i is determined to be a zero-speed point, and continuous zero-speed points constitute a zero-speed interval.
4. The multi-modal group pig individual tracking method based on spatial prior guidance as claimed in claim 3 is characterized in that the steps S1.5 is as follows: S1.5.
1. At the initial time t = 0, the initial particles x0 ~ p(x0) are sampled according to the sampling distribution p(x0) to obtain the initial particle set Take the number of particles N = 100, and the initial weight of each particle is 1 / N; S1.5.
2. Constructing the importance probability density function Each particle is calculated according to the following formula The corresponding weight In the formula, is the posterior probability density function; is the likelihood function of the observed quantity; is the state transition probability; is the proposed distribution function, satisfying is the weight at the k-1 moment; is the weight of particle k at time; Normalize to get: In the formula, is the weight of the i-th particle at the k-th moment; is the weight sum of all particles at time k; is the value after weight normalization; S1.5.
3. According to the normalized particle set, the state value at time k is obtained from the state value at time k-1, that is, the optimal estimate. The state estimate is: In the formula, is the particle at time k; S1.5.
4. Discard particles with weights less than the set value from the particle set, re-extract particles with weights greater than the set value and copy them to establish a new particle set.
5. The multi-modal group pig individual tracking method based on spatial prior guidance as claimed in claim 4 is characterized in that: In step S1.5.4, an adaptive threshold method is used to select new particles. The specific steps are as follows: 1) Select an adaptive threshold M; M satisfies equation (11); Where: The value range of M is [M a ,M b ]; M b is the upper limit; M a is the initial value of the threshold, t is the number of iterations; N e is the effective particle number; K e is the proportional coefficient; the threshold M is proportional to the number of iterations t and the number of effective particles N e Inversely proportional to N e Satisfies formula (12); Using the effective number of particles N e To measure the degree of degradation of particle weights, N is the number of particles, is the particle weight variance; Substituting (12) into (11) we get: When M reaches the upper limit M b When M=M a ; 2) Keep the particle judgment; if Keep otherwise 3) Make a secondary judgment on particle degradation phenomenon: When H1+H2=1 is satisfied, return to step S1.5.1 to resample the particles. The weight of the resampled particles is 1 / N, where N is the number of particles. The new particle set As the initial particle of the next moment; Otherwise, return to step S1.5.2 for the next iteration until the loop ends; the position of the corresponding particle at the end of the loop is the final target position.
6. The multi-modal group pig individual tracking method based on spatial prior guidance as claimed in claim 5 is characterized in that: Step S2 is specifically as follows: S2.1, project the position and image into a feature space of the same dimension; S2.2, establish the complementary relationship between IMU signal and video image; With location features They are input together into the detection box decoder based on the cross attention mechanism, and the individual detection box features corresponding to the M-dimensional position feature vector are output. In order to achieve the integration of information between the two; the specific process is as follows: P′=LN(Attn(P,P,P)+P) (19) P″=LN(Attn(P,Z,Z)+P′) (20) P″′=LN(MLP(P″)+P″) (21) Z′=LN(Attn(Z,P″′,P″′)+Z) (22) B=LN(Attn(P″′,Z ′ ,Z″)+P″′) (23) In the formula, LN(·) denotes layer normalization, and MLP(·) denotes multilayer perceptron; The operation module in the middle of the decoder includes two position-image attention modules, one image-position attention module and a multi-layer perceptron. The position-image attention module replaces the multi-head self-attention block with a cross attention block based on the Transformer layer. Realization, Q = w Q P, K = w K Z, V = w V Z; in the image-position attention module, Q = w′ Q Z, K = w′ K P, V = w′ V ·P, w Q , w K , w V , w′ Q , w′ K , and w′ V Represents the mapping matrix that can be learned; S2.
3. Obtained individual detection frame features Input to the multi-layer perceptron, and output the key point coordinate pairs of each pig's individual bounding box, denoted as and They represent the upper left corner coordinates and lower right corner coordinates of the mth pig's bounding box respectively.
7. The multi-modal group pig individual tracking method based on spatial prior guidance as claimed in claim 6 is characterized in that: Step S2.1 is as follows: S2.1.1, based on the position coordinates p of the individual pig at a certain moment obtained in step S1 m =(x m ,y m ), m = 1, 2, ..., M, and input it into the learnable position encoder to generate the position features corresponding to M pigs The position encoder is composed of a function γ based on a random Fourier feature map and a multilayer perceptron with a ReLU activation function; The function γ is expressed as: In the formula, Represents the parameters that can be learned, basis vector w i It is randomly sampled from a Gaussian distribution with 0 as mean and σ as standard deviation, that is S2.2.
2. Select the video frame image at the corresponding moment from the video, divide it into N fixed-size image blocks, generate a vector representation of dimension N×D through flattening and mapping operations, add it to the corresponding N×D-dimensional position embedding vector and input it into the Transformer encoder to obtain the image feature vector 8. The multi-modal group pig individual tracking method based on spatial prior guidance as claimed in claim 7 is characterized in that: The specific process of step S2.2.2 is as follows: S2.2.2.1 Video frame image is divided into N fixed-size (P 2 ×C), denoted as N=HW / P 2 , C represents the number of channels; each image block is flattened into a one-dimensional vector, and a set of image block vector representations with dimension D is generated through linear mapping Vectorize the position of the image patch to the same dimension as the Add up to get the input tokens, denoted as S2.2.2.
2. Input into the Transformer encoder with L layers to get a new set of image block encodings Recorded as image feature vector Each Transformer layer mainly consists of a multi-head self-attention block and a multi-layer perceptron block, each of which contains a layer normalization layer and a residual connection: Among them, l=1,…,L.
9. A multi-modal group pig individual tracking system based on spatial prior guidance, based on the method described in any one of claims 1 to 8, characterized in that: Includes the following modules: Position acquisition module: A momentum-corrected particle filter algorithm is established based on high-frequency IMU signals to convert high-frequency IMU signals into spatial position coordinates, so as to map the IMU signals and video images to the same space; Tracking module: Establish a group-raised pig individual tracking algorithm guided by spatial position prior, extract the features of the obtained spatial position and the features of the corresponding video frame image, construct a detection box decoder based on the cross-attention mechanism, and establish a complementary relationship between the two modal data to achieve continuous and accurate tracking of group-raised pig individuals.
Citation Information
Patent Citations
A three-dimensional wire frame structure method and system fusing a binocular camera and IMU positioning
CN109166149A
Cross-video target tracking method and system, electronic equipment and storage medium
CN114842028A
Visual tracking method based on attention adaptive selection Transform
CN116485839A
Transformer target tracking method and tracker based on symmetric cross attention and position information enhancement
CN116862949A
Radar vision fusion data target detection method and system based on cross attention
CN117523514A
Cited By
Multi-modal unified target tracking method based on modal unified representation
CN119672071A
Rehabilitation training upper limb movement measuring method based on depth track coding
CN119917938A
An upper limb movement measurement method for rehabilitation training based on deep trajectory encoding
CN119917938B
Pig farm anomaly detection system based on multi-sensor data fusion
CN120123958A
