# Posture Recognition and Behavior Tracking in Swimming Motion Images under Computer Machine Vision

Authors: Zheng Zhang; Cong Huang; Fei Zhong; Bote Qi; Binghong Gao
Journal: Complexity
 (2021)

---

## Abstract

This study is to explore the gesture recognition and behavior tracking in swimming motion images under computer machine vision and to expand the application of moving target detection and tracking algorithms based on computer machine vision in this field. The objectives are realized by moving target detection and tracking, Gaussian mixture model, optimized correlation filtering algorithm, and Camshift tracking algorithm. Firstly, the Gaussian algorithm is introduced into target tracking and detection to reduce the filtering loss and make the acquired motion posture more accurate. Secondly, an improved kernel-related filter tracking algorithm is proposed by training multiple filters, which can clearly and accurately obtain the motion trajectory of the monitored target object. Finally, it is proposed to combine the Kalman algorithm with the Camshift algorithm for optimization, which can complete the tracking and recognition of moving targets. The experimental results show that the target tracking and detection method can obtain the movement form of the template object relatively completely, and the kernel-related filter tracking algorithm can also obtain the movement speed of the target object finely. In addition, the accuracy of Camshift tracking algorithm can reach 86.02%. Results of this study can provide reliable data support and reference for expanding the application of moving target detection and tracking methods.


---

## Body

## 1. Introduction

Computer vision technology has developed rapidly in recent years. The human visual system can be simulated by using the computer vison technology, which can realize the processing of relevant information from the outside world, of which moving target tracking and object recognition are popular research directions in the field of computer vision [1, 2]. At present, computer vision technology has been applied in many traditional industries. Fish activities include swimming behaviors and nonswimming behaviors. Based on the study of fish behaviors, it is possible to explore the laws of their activities [3, 4]. In the past, the monitoring and processing of fish behaviors were generally based on manual recording, which was not only inefficient but also difficult to guarantee the accuracy.At present, related scholars have conducted many research studies on the tracking of moving targets in computer vision. Ko and Sim proposed a unified framework based on a deep convolution framework to detect the abnormal behaviors in standard red, green, and blue (RGB) images and found that the method based on deep learning has good performance in the detection of abnormal behaviors in real scenes [5]. Huang et al. discussed the performance of the Kalman filter in target tracking based on computer vision and found that this method has high efficiency, and the adaptive particle filter has high robustness and high precision, which provide references for fruit recognition and tracking as well as robot navigation and control [6]. Kim et al. applied the interframe difference method, introduced a method to track the players in football videos, combined with the multiscale sampling, calculated the difference between the sampled image block and the tracking player, and verified the efficiency and robustness of the proposed method [7]. Desai and Lee introduced computer vision to explore the target tracking of drones [8].In summary, the moving target tracking has been applied in many fields currently, but the research work on its application in swimming target tracking is still relatively less. Based on this, medaka is undertaken as the research object to explore the tracking and motion recognition of swimming motion images. The modified nuclear-related filtering tracking algorithm and optimized Camshift tracking algorithm are adopted to track and recognize the swimming motion image of medaka, aiming to provide a certain reference for the tracking and analysis of features for the moving target image and the application of moving target detection and tracking methods. This study aims to track and analyze the image features of moving targets and to be able to understand the real-time dynamics of the target objects being tracked. It lays a good foundation for the application of moving target detection and tracking algorithms or related technologies based on computer machine vision, avoiding some redundant works, so it can provide a reliable reference value for the posture and behavior recognition of underwater moving objects in the future.


## 2. Materials and Methods

### 2.1. Moving Target Detection and Tracking

The so-called moving target detection refers to the application of image segmentation algorithms to achieve the segmentation of the moving target and background image. Through target detection, it is possible to obtain relevant information corresponding to the size, direction, and position of the moving target. Generally speaking, the detection of moving targets is affected by the background and illumination. The current moving target detection algorithms are frame difference, Gaussian mixture method, and background difference [9–11], of which the frame difference is achieved by calculating the difference between adjacent frames between the video image sequence and the threshold processing of the difference graph to realize the extraction of the image moving target. The calculation equation based on this method is given as follows:(1)Dx,y=1ifIt−It−1>T,0,others.In the above equation,D (x, y) represents the differential image, I (t) represents the image corresponding to the time t, I (t − 1) represents the image corresponding to the time t − 1, T refers to the threshold selected for the binarization of the differential image, and D (x, y) = 1 refers to the foreground, and D (x, y) = 0 represents the background. This method has good real-time performance and can be updated fast, but it is not very sensitive to targets with low moving speed, which can cause image hollowing. In addition, it is hard to extract all information for targets with too uniform color distribution. The background difference is obtained by calculating the difference between the corresponding frame of the video image sequence and the background frame, and then the moving target is extracted after threshold processing [12–14]. The calculation equation based on this method can be expressed as follows:(2)Dx,y=1iffx,y−Bx,y>T,0,others.In the above equation,D (x, y) represents the difference image corresponding to the previous frame and the background frame image, f (x, y) corresponds to the current frame, B (x, y) corresponds to the background frame, T refers to the threshold, D (x, y) = 1 refers to the foreground, and D (x, y) = 0 represents the background. This method is featured with simple and fast operation, can obtain a more comprehensive target image, and is less affected by light, but it is not applicable in the case of large background jitter.The so-called moving target tracking is to track the moving target in the video image sequence through the use of related algorithms and then analyze and evaluate the movement and behavior of the moving target relying on the obtained position and speed parameter information [15, 16]. The current moving target tracking methods mainly include feature-based, area-based, and detection-based tracking methods.The first method focuses on studying the feature changes of moving targets. Usually, color, optical flow, and texture are more common. This method is not sensitive to changes in the shape, brightness, and scale of moving objects. The tracking effect can be affected, and the corresponding accuracy can be reduced if the tracking target is blocked or the image is blurred.The second method is to use the image of the starting area of the research target as a tracking template, calculate the actual location of the image, and then realize the tracking of target image matching. This method can extract more comprehensive moving target template to obtain more relevant information and have higher accuracy. However, when the target suffers severe occultation or is extensively large, the accuracy will be reduced accordingly.The third method is mainly to get the target detector through training to realize the detection of moving targets. This method can still realize the tracking of the target under the premise that the target does not suffer occultation. However, the tracking effect can be greatly reduced when the moving speed of the research object is too fast or the degree of deformation is relatively high.Based on the above three methods, medaka fish can be undertaken as the research object. The gesture recognition and motion tracking of the swimming motion image of medaka fish are performed in this study, and the specific experimental conditions are given as follows [17, 18]. Three research fish are put in a water environment at 26°C (with pH of 7.6). The selected medaka corresponds to a growth period of about 6 months, and the corresponding sizes are approximately 1.7 cm, 3.0 cm, and 3.5 cm, respectively. For the swimming image extraction results of the research moving target medaka, the interframe difference in the moving target detection method is adopted to analyze the target extraction results of the research moving target swimming image. In addition, the gesture recognition and action behavior of medaka fish are analyzed in the improved kernel-related filter tracking algorithm, which are compared with the conventional kernel-related filter tracking algorithm. Based on the optimized Camshift moving target tracking algorithm, the results of moving target tracking recognition with or without occlusion are compared, and the changes in tracking accuracy before and after the optimization of the Camshift algorithm are compared.


### 2.2. Swimming Target Extraction Based on the Gaussian Mixture Model

The Gaussian mixture model is applied to target extraction. When modeling the background, its advantages lie in that it can filter noises such as light and impurities and can obtain the foreground target of swimming [19]. Medaka is taken as an example. The Gaussian mixture model can extract the features of medaka’s swimming motion image and recognize its posture, which mainly includes image preprocessing, moving target detection and recognition, and morphological operations. The image preprocessing mainly refers to the filtering operation of the video image, which is to improve the extraction effect of the moving target of medaka. In the application of the Gaussian filtering method, the two-dimensional Gaussian function is usually applied as the smoothing filter of image preprocessing, which is inseparable from the rotational symmetry characteristic of the two-dimensional Gaussian function and consistency of the smoothness in all directions. The corresponding equation expression is as follows:(3)Gx,y=12πσ2e−x2+y2/2σ2.In the above equation,x and y represent the row and column values of the corresponding pixels in the image, and σ represents the standard deviation. For the detection and recognition of moving targets, the Gaussian probability density function can be applied, and the corresponding calculation equation is expressed as follows:(4)fx,E,σ=12πσe−x−E2/2σ2.In the above equation,x is a random variable, E corresponds to the expected value, and σ refers to the variance. Considering that only using the single Gaussian model for background modeling cannot eliminate the impact of fluctuations in the water surface and water plants, a Gaussian mixture model is introduced in the detection and recognition of moving targets. Based on this, if m Gaussian models are applied for modeling of the background b, the probability at time t can be calculated with the following equation:(5)Pbt=∑m=1mWmtfbtEmtσR2t.In the above equation,Wmt is the weight, and Emt is the expected value of the distribution. Then, the discrimination of foreground information and background information can be realized with the following equation:(6)bt−Emt<2.5σmt.Then, the model is updated. The related operations for update can be expressed as the following equations:(7)Wi,t+1=1−αWit+α,Em,t+1=1−βEm,t+βbt,σm2t+1=1−βδm2t+βEmt−bt22.Thus,α and β can affect the update speed of the background.


### 2.3. Filter Tracking Algorithm Based on Swimming Target Recognition

The kernel-related filter tracking algorithm converts the target tracking into a linear regression model and then completes the training through the multichannel histogram feature, which can realize the tracking and recognition of the research object [20–22]. If the corresponding input of the research target image is z, the corresponding weight coefficient is w, and the corresponding output is fz=wTz. Thus, the key to using this method for target tracking is to find the corresponding numerical results of f (z). Through the use of training sample xi,yi and minimization of the square error target function, the filter can be obtained. The corresponding equation expression is expressed as follows:(8)∑wi=1minNfxi−yi2+λW2.In the above equation,λ refers to the regularization coefficient, fxi corresponds to the output value, and yi refers to the expected value of regression. On this basis, the calculation of the filter W can be written as follows:(9)W=xHx+λI−1xHy.In the above equation,xH is the complex conjugate transpose matrix.The training sample corresponding to the kernel-related filter tracking algorithm is obtained through the cycle offset corresponding to the target sample so that the overall effect of training the classifier can be improved. After Fourier transform, the equation expression of the linear regression coefficient corresponding to the filtering algorithm is described as(10)W=x∗⊙yx∗⊙x+λ.Due to the actual scene of the swimming exercise in this study, it is actually a nonlinear problem. Introduction of the kernel function can transform it into a nonlinear space and map the related operations in the low-dimensional space to the high-dimensional space. Combination of the linear regression coefficients obtained above with the even space can transform the regression, as shown in the following equation:(11)fz=WTz=∑i=1nαiφxiφzi=∑i=1nαimz,xi.In the above equation,φxiφzi refers to the kernel function. After integration, the regression detection response value fz for all areas can be obtained:(12)fz=Kxz⊙α.In the above equation,K represents the construction matrix. The obtained response value is converted into the spatial domain through Fourier transform; then, the maximum value in the area can be found, which also corresponds to the tracking result.The principle of the enhanced kernel-related filter tracking algorithm is the same as that of the traditional kernel-related filter tracking algorithm. The enhanced kernel-related filter tracking algorithm trainsm − 1 more kernel-related filters in the first frame than the traditional kernel-related filter tracking algorithm (m is an integer greater than 1). The calculation is performed based on the new input frame. The calculated response value can be used as the predicted tracking result, and the highest response value is the highest probability of tracking the object. The advantages lie in that, on the basis of the conventional nuclear correlation filtering algorithm, more corresponding filters are trained in the first frame in this study; the response value obtained is regarded as the tracking result of posture recognition prediction after calculating with the correlation of the newly inputted frame to complete the modification of the kernel-related filter tracking algorithm [23, 24]. At this time, the object corresponding to the maximum response value may be the tracking object.The specific implementation process is shown in Figure1. Firstly, the number of training video frames is inputted, and the relevant features in the video are extracted. After several times of training, kernel-related filters 1, 2, and 3 are obtained. After the new input is given, the output response of the new kernel-related filter can be adopted to predict the tracking object, and the feature is extracted again to repeat the training step. Finally, the improvement of the algorithm is realized.Figure 1
Implementation process of the modified kernel-related filter tracking algorithm.


### 2.4. Optimized Camshift Algorithm Based on Swimming Moving Target Tracking

Camshift algorithm is also one of the target tracking algorithms. Its advantages can be summarized as follows. With the color histogram model, the algorithm can convert the moving target image into a color probability distribution map. On this basis, it can complete the tracking and recognition of the moving target through the initialization of the search window based on the actual situation of the search window during the calculation of one frame [25]. The tracking algorithm specifically tracks the acquisition of subgraphs during the implementation process, and the corresponding equation expressions are as follows:(13)S00=∑x∑yIx,y,S10=∑x∑yxIx,y,S01=∑x∑yyIx,y.In the above equations,S00 represents the zero-order matrix of the corresponding subgraph, and S10 and S01 refer to the first-order matrix in direction x and direction y of the corresponding subgraph, respectively. Then, the equation for the center of mass of the tracked moving target is expressed in the following equation:(14)xc,yc=S01S00,S10S00.Width of the search windoww can be expressed as follows:(15)w=2S00256.Then, the length of the search windowl can be calculated with the following equation:(16)l=1.2w.Based on the size and location of the search window obtained above, the color probability distribution map corresponding to the search window can be calculated. The calculation should be repeated until the convergence of the corresponding operation is realized. However, the conventional Camshift algorithm is prone to losing the tracking object when the moving target moves faster and the occlusion is serious.Kalman algorithm can realize accurate prediction for the location of the moving target based on the linear state equation by using the observation data of the input and output of the system. Implementation of the algorithm application process consists mainly of two key steps: prediction and correction [26], of which the prediction can be expressed as equation (17) and calculated with equation (18).(17)xt=Axt−1+Bμt−1,(18)Et=AEt−1AT+P.The correction process can be illustrated as follows:(19)Kt=EtHTHEtHT+R−1,xt=xt+ttzt−Hxt,Et=I−KtHEt.In the above equations,xt represents the state of the moving target at the moment t, A represents the state transition matrix, μt−1 refers to the impact of the outside world on the system at the moment t − 1, B represents the control matrix, Et refers to the error matrix, and P indicates the covariance matrix related to the identification noise. R refers to the covariance matrix related to the measurement noise, H represents the observation matrix, Kt indicates the Kalman gain at the moment t, and zt corresponds to the observed value at the moment t. In general, the Kalman algorithm can quickly and accurately predict and recognize the location of the moving target, thereby overcoming the shortcomings of the conventional Camshift algorithm.Based on this, the conventional Camshift algorithm is combined with the Kalman algorithm to optimize the Camshift algorithm. The moving target of this study (medaka) is undertaken as an example. The swimming behavior of medaka is tracked with Camshift algorithm firstly, a histogram model including the moving target and search window is established, and the occlusion of the moving target is determined with the Bhattacharyya coefficient. Specifically speaking, when the discrimination coefficient is greater than the threshold, it means that the studied moving target is not occluded [27, 28]. Thus, when the discrimination coefficient is less than the threshold, the predicted value of Kalman algorithm can be undertaken as the real value for tracking and motion recognition of the studied moving target.The optimized Camshift algorithm is shown in Figure2. Firstly, the size and position of the search window have to be adjusted. Secondly, the color histogram of the search area is calculated, and then the back projection image is calculated. The object position is calculated in the search window and is adjusted according to the size of the search window. Finally, the target can be found and divided into two cases: the target is occluded and the target is not occluded. The former can use the predicted value of the Kalman algorithm as the output, and the latter uses the Camshift algorithm. The above steps can be repeated by taking the predicted position as the position of the new window. Finally, the two algorithms are compared to show the superiority of the optimized Camshift algorithm.Figure 2
Modified Camshift algorithm.


## 2.1. Moving Target Detection and Tracking

The so-called moving target detection refers to the application of image segmentation algorithms to achieve the segmentation of the moving target and background image. Through target detection, it is possible to obtain relevant information corresponding to the size, direction, and position of the moving target. Generally speaking, the detection of moving targets is affected by the background and illumination. The current moving target detection algorithms are frame difference, Gaussian mixture method, and background difference [9–11], of which the frame difference is achieved by calculating the difference between adjacent frames between the video image sequence and the threshold processing of the difference graph to realize the extraction of the image moving target. The calculation equation based on this method is given as follows:(1)Dx,y=1ifIt−It−1>T,0,others.In the above equation,D (x, y) represents the differential image, I (t) represents the image corresponding to the time t, I (t − 1) represents the image corresponding to the time t − 1, T refers to the threshold selected for the binarization of the differential image, and D (x, y) = 1 refers to the foreground, and D (x, y) = 0 represents the background. This method has good real-time performance and can be updated fast, but it is not very sensitive to targets with low moving speed, which can cause image hollowing. In addition, it is hard to extract all information for targets with too uniform color distribution. The background difference is obtained by calculating the difference between the corresponding frame of the video image sequence and the background frame, and then the moving target is extracted after threshold processing [12–14]. The calculation equation based on this method can be expressed as follows:(2)Dx,y=1iffx,y−Bx,y>T,0,others.In the above equation,D (x, y) represents the difference image corresponding to the previous frame and the background frame image, f (x, y) corresponds to the current frame, B (x, y) corresponds to the background frame, T refers to the threshold, D (x, y) = 1 refers to the foreground, and D (x, y) = 0 represents the background. This method is featured with simple and fast operation, can obtain a more comprehensive target image, and is less affected by light, but it is not applicable in the case of large background jitter.The so-called moving target tracking is to track the moving target in the video image sequence through the use of related algorithms and then analyze and evaluate the movement and behavior of the moving target relying on the obtained position and speed parameter information [15, 16]. The current moving target tracking methods mainly include feature-based, area-based, and detection-based tracking methods.The first method focuses on studying the feature changes of moving targets. Usually, color, optical flow, and texture are more common. This method is not sensitive to changes in the shape, brightness, and scale of moving objects. The tracking effect can be affected, and the corresponding accuracy can be reduced if the tracking target is blocked or the image is blurred.The second method is to use the image of the starting area of the research target as a tracking template, calculate the actual location of the image, and then realize the tracking of target image matching. This method can extract more comprehensive moving target template to obtain more relevant information and have higher accuracy. However, when the target suffers severe occultation or is extensively large, the accuracy will be reduced accordingly.The third method is mainly to get the target detector through training to realize the detection of moving targets. This method can still realize the tracking of the target under the premise that the target does not suffer occultation. However, the tracking effect can be greatly reduced when the moving speed of the research object is too fast or the degree of deformation is relatively high.Based on the above three methods, medaka fish can be undertaken as the research object. The gesture recognition and motion tracking of the swimming motion image of medaka fish are performed in this study, and the specific experimental conditions are given as follows [17, 18]. Three research fish are put in a water environment at 26°C (with pH of 7.6). The selected medaka corresponds to a growth period of about 6 months, and the corresponding sizes are approximately 1.7 cm, 3.0 cm, and 3.5 cm, respectively. For the swimming image extraction results of the research moving target medaka, the interframe difference in the moving target detection method is adopted to analyze the target extraction results of the research moving target swimming image. In addition, the gesture recognition and action behavior of medaka fish are analyzed in the improved kernel-related filter tracking algorithm, which are compared with the conventional kernel-related filter tracking algorithm. Based on the optimized Camshift moving target tracking algorithm, the results of moving target tracking recognition with or without occlusion are compared, and the changes in tracking accuracy before and after the optimization of the Camshift algorithm are compared.


## 2.2. Swimming Target Extraction Based on the Gaussian Mixture Model

The Gaussian mixture model is applied to target extraction. When modeling the background, its advantages lie in that it can filter noises such as light and impurities and can obtain the foreground target of swimming [19]. Medaka is taken as an example. The Gaussian mixture model can extract the features of medaka’s swimming motion image and recognize its posture, which mainly includes image preprocessing, moving target detection and recognition, and morphological operations. The image preprocessing mainly refers to the filtering operation of the video image, which is to improve the extraction effect of the moving target of medaka. In the application of the Gaussian filtering method, the two-dimensional Gaussian function is usually applied as the smoothing filter of image preprocessing, which is inseparable from the rotational symmetry characteristic of the two-dimensional Gaussian function and consistency of the smoothness in all directions. The corresponding equation expression is as follows:(3)Gx,y=12πσ2e−x2+y2/2σ2.In the above equation,x and y represent the row and column values of the corresponding pixels in the image, and σ represents the standard deviation. For the detection and recognition of moving targets, the Gaussian probability density function can be applied, and the corresponding calculation equation is expressed as follows:(4)fx,E,σ=12πσe−x−E2/2σ2.In the above equation,x is a random variable, E corresponds to the expected value, and σ refers to the variance. Considering that only using the single Gaussian model for background modeling cannot eliminate the impact of fluctuations in the water surface and water plants, a Gaussian mixture model is introduced in the detection and recognition of moving targets. Based on this, if m Gaussian models are applied for modeling of the background b, the probability at time t can be calculated with the following equation:(5)Pbt=∑m=1mWmtfbtEmtσR2t.In the above equation,Wmt is the weight, and Emt is the expected value of the distribution. Then, the discrimination of foreground information and background information can be realized with the following equation:(6)bt−Emt<2.5σmt.Then, the model is updated. The related operations for update can be expressed as the following equations:(7)Wi,t+1=1−αWit+α,Em,t+1=1−βEm,t+βbt,σm2t+1=1−βδm2t+βEmt−bt22.Thus,α and β can affect the update speed of the background.


## 2.3. Filter Tracking Algorithm Based on Swimming Target Recognition

The kernel-related filter tracking algorithm converts the target tracking into a linear regression model and then completes the training through the multichannel histogram feature, which can realize the tracking and recognition of the research object [20–22]. If the corresponding input of the research target image is z, the corresponding weight coefficient is w, and the corresponding output is fz=wTz. Thus, the key to using this method for target tracking is to find the corresponding numerical results of f (z). Through the use of training sample xi,yi and minimization of the square error target function, the filter can be obtained. The corresponding equation expression is expressed as follows:(8)∑wi=1minNfxi−yi2+λW2.In the above equation,λ refers to the regularization coefficient, fxi corresponds to the output value, and yi refers to the expected value of regression. On this basis, the calculation of the filter W can be written as follows:(9)W=xHx+λI−1xHy.In the above equation,xH is the complex conjugate transpose matrix.The training sample corresponding to the kernel-related filter tracking algorithm is obtained through the cycle offset corresponding to the target sample so that the overall effect of training the classifier can be improved. After Fourier transform, the equation expression of the linear regression coefficient corresponding to the filtering algorithm is described as(10)W=x∗⊙yx∗⊙x+λ.Due to the actual scene of the swimming exercise in this study, it is actually a nonlinear problem. Introduction of the kernel function can transform it into a nonlinear space and map the related operations in the low-dimensional space to the high-dimensional space. Combination of the linear regression coefficients obtained above with the even space can transform the regression, as shown in the following equation:(11)fz=WTz=∑i=1nαiφxiφzi=∑i=1nαimz,xi.In the above equation,φxiφzi refers to the kernel function. After integration, the regression detection response value fz for all areas can be obtained:(12)fz=Kxz⊙α.In the above equation,K represents the construction matrix. The obtained response value is converted into the spatial domain through Fourier transform; then, the maximum value in the area can be found, which also corresponds to the tracking result.The principle of the enhanced kernel-related filter tracking algorithm is the same as that of the traditional kernel-related filter tracking algorithm. The enhanced kernel-related filter tracking algorithm trainsm − 1 more kernel-related filters in the first frame than the traditional kernel-related filter tracking algorithm (m is an integer greater than 1). The calculation is performed based on the new input frame. The calculated response value can be used as the predicted tracking result, and the highest response value is the highest probability of tracking the object. The advantages lie in that, on the basis of the conventional nuclear correlation filtering algorithm, more corresponding filters are trained in the first frame in this study; the response value obtained is regarded as the tracking result of posture recognition prediction after calculating with the correlation of the newly inputted frame to complete the modification of the kernel-related filter tracking algorithm [23, 24]. At this time, the object corresponding to the maximum response value may be the tracking object.The specific implementation process is shown in Figure1. Firstly, the number of training video frames is inputted, and the relevant features in the video are extracted. After several times of training, kernel-related filters 1, 2, and 3 are obtained. After the new input is given, the output response of the new kernel-related filter can be adopted to predict the tracking object, and the feature is extracted again to repeat the training step. Finally, the improvement of the algorithm is realized.Figure 1
Implementation process of the modified kernel-related filter tracking algorithm.


## 2.4. Optimized Camshift Algorithm Based on Swimming Moving Target Tracking

Camshift algorithm is also one of the target tracking algorithms. Its advantages can be summarized as follows. With the color histogram model, the algorithm can convert the moving target image into a color probability distribution map. On this basis, it can complete the tracking and recognition of the moving target through the initialization of the search window based on the actual situation of the search window during the calculation of one frame [25]. The tracking algorithm specifically tracks the acquisition of subgraphs during the implementation process, and the corresponding equation expressions are as follows:(13)S00=∑x∑yIx,y,S10=∑x∑yxIx,y,S01=∑x∑yyIx,y.In the above equations,S00 represents the zero-order matrix of the corresponding subgraph, and S10 and S01 refer to the first-order matrix in direction x and direction y of the corresponding subgraph, respectively. Then, the equation for the center of mass of the tracked moving target is expressed in the following equation:(14)xc,yc=S01S00,S10S00.Width of the search windoww can be expressed as follows:(15)w=2S00256.Then, the length of the search windowl can be calculated with the following equation:(16)l=1.2w.Based on the size and location of the search window obtained above, the color probability distribution map corresponding to the search window can be calculated. The calculation should be repeated until the convergence of the corresponding operation is realized. However, the conventional Camshift algorithm is prone to losing the tracking object when the moving target moves faster and the occlusion is serious.Kalman algorithm can realize accurate prediction for the location of the moving target based on the linear state equation by using the observation data of the input and output of the system. Implementation of the algorithm application process consists mainly of two key steps: prediction and correction [26], of which the prediction can be expressed as equation (17) and calculated with equation (18).(17)xt=Axt−1+Bμt−1,(18)Et=AEt−1AT+P.The correction process can be illustrated as follows:(19)Kt=EtHTHEtHT+R−1,xt=xt+ttzt−Hxt,Et=I−KtHEt.In the above equations,xt represents the state of the moving target at the moment t, A represents the state transition matrix, μt−1 refers to the impact of the outside world on the system at the moment t − 1, B represents the control matrix, Et refers to the error matrix, and P indicates the covariance matrix related to the identification noise. R refers to the covariance matrix related to the measurement noise, H represents the observation matrix, Kt indicates the Kalman gain at the moment t, and zt corresponds to the observed value at the moment t. In general, the Kalman algorithm can quickly and accurately predict and recognize the location of the moving target, thereby overcoming the shortcomings of the conventional Camshift algorithm.Based on this, the conventional Camshift algorithm is combined with the Kalman algorithm to optimize the Camshift algorithm. The moving target of this study (medaka) is undertaken as an example. The swimming behavior of medaka is tracked with Camshift algorithm firstly, a histogram model including the moving target and search window is established, and the occlusion of the moving target is determined with the Bhattacharyya coefficient. Specifically speaking, when the discrimination coefficient is greater than the threshold, it means that the studied moving target is not occluded [27, 28]. Thus, when the discrimination coefficient is less than the threshold, the predicted value of Kalman algorithm can be undertaken as the real value for tracking and motion recognition of the studied moving target.The optimized Camshift algorithm is shown in Figure2. Firstly, the size and position of the search window have to be adjusted. Secondly, the color histogram of the search area is calculated, and then the back projection image is calculated. The object position is calculated in the search window and is adjusted according to the size of the search window. Finally, the target can be found and divided into two cases: the target is occluded and the target is not occluded. The former can use the predicted value of the Kalman algorithm as the output, and the latter uses the Camshift algorithm. The above steps can be repeated by taking the predicted position as the position of the new window. Finally, the two algorithms are compared to show the superiority of the optimized Camshift algorithm.Figure 2
Modified Camshift algorithm.


## 3. Results

### 3.1. Extraction Results of the Moving Target

Results for posture recognition of the swimming motion image for medaka are analyzed with the frame difference method, as shown in Figure3.Figure 3
Results for posture recognition based on the frame difference method.Results of the moving target extraction reveal that the introduction of the Gaussian mixture model can effectively reduce the impact of noise. After the Gaussian mixture model is introduced, the contour information of the swimming target is studied, and it is found that it is basically complete without few missing edge features.


### 3.2. Tracking Results Based on the Kernel-Related Filter Tracking Algorithm

On the premise that the corresponding swimming video image sequence is 1032 frames, the actual tracking effect presented by the modified kernel-related filter tracking algorithm is shown in Figure4.Figure 4
Actual tracking effect of the kernel-related filtering algorithm before and after modification.Figure4 suggests that tracking loss is not found in the modified kernel-related filter tracking algorithm, and the image data are very specific, which can be found in the conventional kernel-related filter tracking algorithm. Thus, the modified filtering algorithm has a better effect.After the modified kernel-related filter tracking algorithm is adopted, the trajectory distribution of medaka’s swimming movement is obtained, as shown in Figure5.Figure 5
Moving trajectory of medaka’s swimming motion.Figure5 suggests that the actual swimming trajectories generated by the studied medakas are basically consistent with the trajectory curves obtained by the modified filtering tracking algorithm, which shows that the modified kernel-related filter tracking algorithm can obtain the effective position information and proves the superiority of the algorithm.Under the premise that the corresponding swimming video image sequence is 100 frames, the statistical analysis results of the swimming speed data of medaka and the corresponding curves of speed changes are shown in Figures6(a) and 6(b), respectively.Figure 6
Swimming moving speed of medaka: (a) the statistical data of speed; (b) the speed curve.
(a)(b)Analysis on the data changes in the figure reveals that speed of the studied moving target changes with the number of frames. When the size of the research target medaka becomes larger and larger, its movement speed will decrease, which is in line with the actual situation. For example, the initial speed of object 1 is uniform, it increases rapidly when the number of frames increases to 18 frames, and it shows a downward trend when the frame number is 60. Thus, the speed state of the moving object can be obtained through the change of speed, so as to provide a basis for tracking the change of swimming motion.


### 3.3. Comparison of Camshift Algorithm before and after Optimization

Tables1 and 2 reveal that compared to the traditional Camshift algorithm, the optimized Camshift algorithm has a higher success rate no matter when the object is moving freely or when the object is occluded, which can be as high as more than 30%. The tracking success rate of the optimized Camshift algorithm in the motion state is 93.96%, and the success rate in the case of being occluded is 86.02%.Table 1
The tracking success rate of the two algorithms under the object motion state.
AlgorithmNumber of tracked objectsNumber of successfully tracked objectsSuccess rateConventional Camshift5000324364.86Optimized Camshift5000469893.96Table 2
The tracking success rate under severe occlusion of moving objects.
AlgorithmNumber of tracked objectsNumber of successfully tracked objectsSuccess rate (%)Conventional Camshift5000268953.79Optimized Camshift5000430186.02


### 3.4. Tracking Results Based on the Optimized Camshift Algorithm

With and without occultation, the tracking results of Camshift algorithm before and after optimization are analyzed, as shown in Figure7.Figure 7
Tracking results of Camshift algorithm before and after optimization (in the figure, -N means without occultation, while -Y means with severe occultation).The figure indicates the tracking accuracy of the optimized Camshift algorithm before and after occultation is significantly higher than that of the conventional Camshift algorithm, and the tracking accuracy of the conventional Camshift algorithm drops from 68.31% to 54.85% under a severe occultation. The tracking accuracy of the conventional Camshift algorithm decreases from 64.86% to 53.79%. Although the tracking accuracy of the optimized Camshift algorithm has been reduced (from 93.96% to 86.02%), the tracking efficiency is still significantly higher than that of the conventional algorithm.


## 3.1. Extraction Results of the Moving Target

Results for posture recognition of the swimming motion image for medaka are analyzed with the frame difference method, as shown in Figure3.Figure 3
Results for posture recognition based on the frame difference method.Results of the moving target extraction reveal that the introduction of the Gaussian mixture model can effectively reduce the impact of noise. After the Gaussian mixture model is introduced, the contour information of the swimming target is studied, and it is found that it is basically complete without few missing edge features.


## 3.2. Tracking Results Based on the Kernel-Related Filter Tracking Algorithm

On the premise that the corresponding swimming video image sequence is 1032 frames, the actual tracking effect presented by the modified kernel-related filter tracking algorithm is shown in Figure4.Figure 4
Actual tracking effect of the kernel-related filtering algorithm before and after modification.Figure4 suggests that tracking loss is not found in the modified kernel-related filter tracking algorithm, and the image data are very specific, which can be found in the conventional kernel-related filter tracking algorithm. Thus, the modified filtering algorithm has a better effect.After the modified kernel-related filter tracking algorithm is adopted, the trajectory distribution of medaka’s swimming movement is obtained, as shown in Figure5.Figure 5
Moving trajectory of medaka’s swimming motion.Figure5 suggests that the actual swimming trajectories generated by the studied medakas are basically consistent with the trajectory curves obtained by the modified filtering tracking algorithm, which shows that the modified kernel-related filter tracking algorithm can obtain the effective position information and proves the superiority of the algorithm.Under the premise that the corresponding swimming video image sequence is 100 frames, the statistical analysis results of the swimming speed data of medaka and the corresponding curves of speed changes are shown in Figures6(a) and 6(b), respectively.Figure 6
Swimming moving speed of medaka: (a) the statistical data of speed; (b) the speed curve.
(a)(b)Analysis on the data changes in the figure reveals that speed of the studied moving target changes with the number of frames. When the size of the research target medaka becomes larger and larger, its movement speed will decrease, which is in line with the actual situation. For example, the initial speed of object 1 is uniform, it increases rapidly when the number of frames increases to 18 frames, and it shows a downward trend when the frame number is 60. Thus, the speed state of the moving object can be obtained through the change of speed, so as to provide a basis for tracking the change of swimming motion.


## 3.3. Comparison of Camshift Algorithm before and after Optimization

Tables1 and 2 reveal that compared to the traditional Camshift algorithm, the optimized Camshift algorithm has a higher success rate no matter when the object is moving freely or when the object is occluded, which can be as high as more than 30%. The tracking success rate of the optimized Camshift algorithm in the motion state is 93.96%, and the success rate in the case of being occluded is 86.02%.Table 1
The tracking success rate of the two algorithms under the object motion state.
AlgorithmNumber of tracked objectsNumber of successfully tracked objectsSuccess rateConventional Camshift5000324364.86Optimized Camshift5000469893.96Table 2
The tracking success rate under severe occlusion of moving objects.
AlgorithmNumber of tracked objectsNumber of successfully tracked objectsSuccess rate (%)Conventional Camshift5000268953.79Optimized Camshift5000430186.02


## 3.4. Tracking Results Based on the Optimized Camshift Algorithm

With and without occultation, the tracking results of Camshift algorithm before and after optimization are analyzed, as shown in Figure7.Figure 7
Tracking results of Camshift algorithm before and after optimization (in the figure, -N means without occultation, while -Y means with severe occultation).The figure indicates the tracking accuracy of the optimized Camshift algorithm before and after occultation is significantly higher than that of the conventional Camshift algorithm, and the tracking accuracy of the conventional Camshift algorithm drops from 68.31% to 54.85% under a severe occultation. The tracking accuracy of the conventional Camshift algorithm decreases from 64.86% to 53.79%. Although the tracking accuracy of the optimized Camshift algorithm has been reduced (from 93.96% to 86.02%), the tracking efficiency is still significantly higher than that of the conventional algorithm.


## 4. Discussion

Actually, analysis and discussion of fish swimming behavior are to explore the life habits and behavior of fish from the side. Application of the Gaussian mixture model clearly shows the effectiveness of the moving target detection method in target information extraction. The edge information of the swimming motion image of medaka is missing, which is analyzed through the obtained binary image. Then, the outline circumscribed rectangle is obtained, and it is possible to achieve the extraction of complete target feature information. Previous studies have shown that the traditional kernel-related filter tracking algorithm is a moving target tracking algorithm with high-speed tracking [29, 30]. The comparative analysis results suggest that the tracking effect of the modified kernel-related filter tracking algorithm is significantly improved. It not only can more accurately extract the position information of the swimming target and realize the effective tracking of the target object but also can accurately fit the swimming trajectory of the research target. Based on the tracking results, the effectiveness and applicability of the modified kernel-related filter tracking algorithm are verified completely in swimming target image posture recognition and motion behavior analysis. This is also an extension of machine vision based on computer vision in the field of extraction and recognition of motion feature information.The moving target tracking based on the combination of the Camshift algorithm and the Kalman algorithm reveals that the combination of the two algorithms can effectively improve the tracking effect and solve the conventional Camshift algorithm’s shortcoming which is easily affected by occultation or speed. In addition, the advantage of Kalman algorithm can be played fully, which shows that the collaborative processing method in a specific scenario can promote solving some thorny problems that are not easy to be solved by conventional methods and also provides a feasible method for the processing and solving of similar problems. Furthermore, analysis of the speed characteristics of the moving target is conductive to understand the real-time motion status of the moving target, which also lays a good prerequisite for the application of the moving target detection and tracking algorithm based on computer machine vision or related technologies to avoid repeated operations.


## 5. Conclusions

In this study, the swimming motion of medaka is taken as the research object. Based on the theory of moving target detection and tracking, the frame difference method and Gaussian mixture model are applied to the extraction of the swimming moving target image, and the kernel-related filter tracking algorithm and Camshift tracking algorithm are optimized. Through comparative analysis, it is found that the Gaussian mixture model can effectively remove noise information, and the modified kernel-related filter tracking algorithm can accurately fit the trajectory curve and ensure the integrity of the extracted position information. The optimized Camshift algorithm can reach the tracking accuracy of 85.73% even in the case of severe occultation.However, there are still some shortcomings in the research process of this study. The noise elimination in the application of the Gaussian filtering method is not thorough enough; the modified kernel-related filter tracking algorithm can still decrease the tracking effect in the case of large differences in the size of moving objects and severe occultation; the combination of the optimized Camshift algorithm and Kalman algorithm solves the occultation to a certain extent, but the Kalman algorithm itself is easily affected by noise. In follow-up research, the algorithm will be further modified and optimized, and the variety and size of the moving target can be comprehensively considered to further enhance the performance and applicability of the algorithm.



---

*Source: 5526831-2021-05-20.xml*