# Using Camshift and Kalman Algorithm to Trajectory Characteristic Matching of Basketball Players

Authors: Shuang Liang; Yang Li
Journal: Complexity
 (2021)

---

## Abstract

Because of its unique charm, sports video is widely welcomed by the public in today’s society. Therefore, the analysis and research of sports game video data have high practical significance and commercial value. Taking a basketball game video as an example, this paper studies the tracking feature matching of basketball players’ detection, recognition, and prediction in the game video. This paper is divided into four parts to improve the application of the interactive multimodel algorithm to track characteristic matching: moving object detection, recognition, basketball track characteristic matching, and player track characteristic matching. The main work and research results of each part are as follows: firstly, the improvedK-means clustering algorithm is used to segment the golf field area; then, HSV is combined with the RGB Fujian value method to eliminate the field area; at last, straight field lines were extracted by Hough transform, and elliptical field lines were extracted by curve fitting, and the field lines were eliminated to realize the detection of moving objects. Seven normalized Hu invariant moments are used as the target features to realize the recognition of moving targets. By obtaining the feature distance between the sample and the template, the category of the sample is judged, which has a good robustness. The Kalman filter is used to match the characteristics of the basketball trajectory. Aiming at the occlusion of basketball, the least square method was used to fit the basketball trajectory, and the basketball position was predicted at the occlusion moment, which realized the occlusion trajectory matching. The matching of players’ track characteristics is realized by the CamShift algorithm based on the color model, which makes full use of players’ color information and realizes real-time performance. In order to solve the problem of occlusion between players in the track feature matching, CamShift and Kalman algorithms were used to determine the occlusion factor through the search window and then weighted Kalman and CamShift according to the occlusion degree to get the track feature matching result. The experimental results show that the detection time is greatly shortened, the memory space occupied is small, and the effect is very ideal.


---

## Body

## 1. Introduction

Sports video is a kind of important media data, which has a large audience and a huge application prospect and is widely concerned by the academic and industrial circles. In terms of the demand for sports video, users can be divided into two categories: ordinary users and professionals. Among them, ordinary users generally refer to the audience; professional users include athletes, coaches, and sports critics. They need to accurately extract certain information about teams and players in order to make game plans, evaluate performance, or analyze game strategies. These users are interested in target detection, track feature matching, motion track extraction, and semantic analysis on top of that. So the focus of the video is on the object of the sport, the ball, or the player.In the training video of athletes, coaches can obtain human motion parameters by adopting relevant processing methods such as segmentation and track characteristic matching. By collecting high-level athletes in training and competition at ordinary times a large number of video image data and analyzing the data information effectively, through the real-time trajectory feature matching of athletes, the analysis of the athletes’ movement can change the coaches with only the technique of artificial observation and experience for athletes’ action guide way of training and improve the standardization of the action. Compared with the traditional method of installing sensors on athletes to obtain the relevant parameters, the new method can obtain the sports parameters of athletes better because of the interference of sensors on athletes’ technical movements [1, 2]. Sports video analysis is driven by different requirements to produce a lot of valuable applications, including the sections in extraction and transmission, video, video browsing and retrieval, detection and track of the ball, athletes’ feature matching, behavior and action analysis and index, tactical statistics and strategy analysis, virtual content inserted, and virtual scene structure. These applications are often related to target detection and track feature matching, so it is the basis of subsequent video image analysis to quickly and effectively segment the objects in the video and realize track feature matching of interested targets. With the advent of the Olympic Games, more and more attention has been paid to the sports meeting, and the development of more and more advanced sports video processing technology has become a top priority. Among the numerous sports games, basketball has the largest number of spectators and the highest degree of attention. Therefore, it is of great practical value and significance to detect, extract, locate, and match the trajectory characteristics of moving objects in a basketball game video. This paper is based on this background environment to carry on the research [3–5].Li proposed a method of field color adaptive detection of the playing field area [6]. This method finds the main area in the histogram and then estimates the mean value and variance of this area. In detection, two color spaces are used to complement each other, the former as the control space and the latter as the basic space. Ahmed et al. used the Gaussian mixture model and EM algorithm to automatically obtain the color of the field in the sports video [7]. The automatic modeling and detection of the jersey color of players from both sides are tentatively tested in player recognition. Song et al. used the ground segmentation image as a mask [8–11]. In the AdaBoost test, the performance method has been greatly improved than before. It also collects samples through automatic detection, uses unsupervised clustering to learn colors, and then classifies players. This method realizes automatic classification of players and provides high performance for players and referees.In the early stage of ball detection, color template matching technology was basically adopted. Mo et al. proposed a new idea: firstly, the size of the ball area was inferred according to the size of the player area, and then, the nonball area was filtered out [12]. Finally, the Kalman filter was used to track and find the area containing the ball. Ahmed et al. used two stages to detect and identify the ball [13]. First, the Hough detection algorithm was used to detect the area that might contain the ball, and then, the neural network classifier was used to find the area that really contained the ball. In order to improve the speed, background subtraction method and ball tracking technology are introduced.The work done in this paper is as follows: (1) the improvedK-means clustering algorithm is adopted to segment the course. For the K-means clustering algorithm can automatically select the number of clustering and clustering results depending on the initial clustering points’ shortcomings, this paper proposes a K-means clustering algorithm based on fuzzy set theory, according to the original image histogram to determine the clustering number and initial clustering points, realizes the clustering number and the automatic selection of the initial clustering points, and has obtained the good segmentation effect. (2) In the aspect of extracting court lines, Hough’s detection ellipse has the disadvantages of occupying large memory and consuming long time. According to the actual characteristics of basketball ellipse court lines, this paper adopts a curve fitting method to achieve the extraction of ellipse court lines, thus greatly reducing the time required by rough transformation to extract the ellipse. (3) In the aspect of target recognition, 7 Hu invariant moments were used to identify players and balls, which improved the shortcomings of the original identification method that could not correctly identify objects with rotation and size changes. The 7 Hu characteristic moments are proved to be invariants for scaling, rotation, and reflection of the image, so the Hu invariant moments are robust for the recognition of players and balls, as well as for occluded players [14–17]. (4) Using the Kalman filter to achieve the basketball track characteristics matching. The Kalman filter is an algorithm for linear minimum variance error estimation of the state sequence of the dynamic system, which is calculated by the recursive filtering method. It has the characteristics of small computation amount and real-time computation and has quite good track characteristic matching effect for objects with approximately uniform speed motion. Aiming at the occlusion of basketball, the least square method was used to fit the basketball trajectory, and the position of the occlusion frame was deduced from the trajectory to achieve the matching of the trajectory characteristics of the occlusion. (5) Match players with CamShift trajectory characteristics. Aiming at the disadvantage that CamShift is easily disturbed by the surrounding environment, a weighted background histogram is adopted to reduce the interference. In addition, CamShift and Kalman algorithms are used to deal with the occlusion, and the occlusion factor is determined by searching the window size to achieve the occlusion processing. The structure of this paper is shown in Figure 1.Figure 1
The structure of this paper.This paper is divided into four sections, the content and organization of each section is as follows: Section1 introduces the purpose and significance of this research, the problems in this field, and the research status at home and abroad and gives the main work of this paper. Section 2 discusses moving target detection. Taking basketball as an example, this paper introduces the idea of moving object detection. First, the improved K-means clustering was used to separate the course area; then, the HSV combined with the RGB boundary value method was used to eliminate the field, and the moving target and the field line were obtained. Then, the straight field line was extracted by Hough, and the elliptical field line was extracted by curve fitting, and the extracted field line was eliminated, so as to realize the detection of moving target. Section 3 discusses target recognition based on Hu invariant moment. By discriminating 7 Hu invariant moments, the recognition of players and balls is realized. In addition, a method of segmentation and discrimination of multiple human adhesions is proposed. Section 4 discusses the summary and prospect. This paper summarizes the work of the whole paper and points out the existing problems and the next research direction.


## 2. Trajectory Matching of Basketball Players

### 2.1. Trajectories Matching of Basketball Players under the Color Model

In the existing basketball segmentation literature, most of the methods are based on the min value segmentation, such as the main color method; the first min value segmentation, after the segmentation of the court area, can be extracted to get the player area [18–21]. But this method reverses the order, because in the basketball video image, the audience and players, including the field, will be affected by the increase in the audience color when the entire image histogram is divided and counted to determine the closed distribution, resulting in deviations in the calculation of the minimum offset value. This results in the minimum value found for the segmentation of the entire image, not for the pitch region. Therefore, a more ideal method is to first segment the court area and then calculate the color histogram of the court area to find the closed value of the segmentation. In this way, the influence of the noncourt area on the dividing stop value is reduced. In addition, the presence of the audience will also have an impact on the subsequent target recognition. Therefore, this paper uses the method of dividing the field area first and then dividing the players by the min value.In general, the algorithm of closed value segmentation will involve the conversion of the color model [22–24]. Let us introduce the color model first. According to the computer color theory, for each color, there are different ways of expression in various theories, which forms a variety of different color spaces; the common color spaces are as follows: RGB, CMYK, YCRCB (YUV), and HSV. Each color space has its own background or application field, so different color spaces should be used according to the specific situation. Here is a brief introduction of the two color spaces often used in the study of video image processing: RGB space and HSV space. The RGB space is formed according to the spectral theory. In the RGB color space, all colors are realized by mixing the three components of red (R), green (G), and blue (B) in a certain proportion. Red (R), green (G), and blue (B) are the three primary colors that constitute all colors, and each component is called a color channel.In the RGB model, the chromaticity of light is proportional as follows:(1)s=H+C−SS+H+C,h=S+C−HS+H+C,c=S+H−CS+H+C,s+h+c=1.HSV space: The HSV space reflects the way people perceive colors. HSV separates Value from Hue and Saturation, two parameters that reflect the essential characteristics of colors. When we analyze the color image, the direct use of the color and saturation can reflect the nature of the color that will get better results. The following CamShift algorithm mainly uses Hue information in the HSV space, as shown in Figure2.Figure 2
The following CamShift algorithm mainly uses Hue information in the HSV space.The algorithm for converting RGB to HSV is shown as follows:(2)T=W−minS,H,CW+minS,H,C,W≠0,0,W=0,I=W−minS,H,CW+minS,H,C,W≠0,a+cb2+H−C+200,W=C,0,W=0.


### 2.2. Trajectional Characteristic Matching of Basketball Players under Court Segmentation

Generally speaking, the color characteristics of the pitch area are quite obvious, most of the pitch color is single and almost all is red. Therefore, we can segment the playing area according to the color characteristics. TheK-means clustering algorithm has the characteristics of simple operation, good real-time performance, and stable segmentation, so this paper selects the K-means clustering algorithm to segment the golf field area. Before K-means clustering segmentation, it is necessary to preprocess the image and use image equalization to enhance the contrast of the image.TheK-means algorithm, first proposed by Maceen, is a classic pattern recognition algorithm to solve clustering problems. K-means clustering has the advantages of simple calculation, fast calculation, effective processing of large amounts of data, dynamic clustering, and strong adaptability. It has a wide range of application fields, especially when solving the problem that the pattern distribution presents the agglomeration within the class, the algorithm can achieve good clustering results. This algorithm is one of the most common algorithms for iteratively adjusting the centroid of K clusters.Although this algorithm has been widely used, it also has some unavoidable problems: (1) like many clustering methods, theK-means algorithm is carried out under the premise of assuming the number of clusters in the data participating in clustering, which may not be consistent with the actual number of categories. (2) In terms of iterative technique, the K-means algorithm is particularly sensitive to initial clustering conditions. (3) The K-means algorithm may cause local minimum solution. The algorithm provides a unique one-to-one mapping relationship between the initial clustering center and the final clustering result.The determination of clustering numberK directly affects the results of image clustering. If the clustering number K is too small, the classification results are not accurate, resulting in many backgrounds being segmented into foreground targets. If the number of clustering K is too large, it will be seriously interfered by noise, and it is not easy to see the change of clustering center value rule, and the overhead of the algorithm will also increase. Therefore, it is necessary to determine the classification number according to the image statistical characteristics.Regarding the selection ofK, this paper adopts the fuzzy set theory and estimates K by means of the maximum value of the probability histogram of the H component. The probability histogram of the H component of a basketball image composed of pixels is generally distributed in the shape of valley and peak, with several maximum and minimum values. Let the extreme points be H-ex, D < I < t, where t is the number of extreme points. The maximum point H-ex, corresponding to the maximum value p, is the probability that the pixel brightness value is H-ex, as shown in Figure 3.Figure 3
The flow chart of dynamically obtaining the smoothing coefficient.After segmentation by theK-means clustering method proposed in this paper, the original image will be segmented into K parts, including the court, players, and audience seats. In this paper, each part is represented in different colors. However, K-means clustering will merge the pixels of other areas (such as the color areas of the audience and the court) into the court area, which will lead to inaccurate segmentation of the court area. Therefore, it is necessary to conduct image processing in the later period to segment a complete and accurate court area.The golf course has the following characteristics: (1) the area of the golf course in this image is generally the largest or relatively large area; (2) the edge line of the court is straight; (3) the color of the pitch area is usually green or similar, while the color of the auditorium is mixed; (4) the texture comparison rules of the course.We can judge whether the segmented area belongs to the court area according to the above characteristics because the judgment of court texture is relatively complex, and the court area can be judged by the previous several rules, so here we use the first three criteria to judge the court area. Here is the extraction of the golf course area after clustering above, and the extraction effect is shown in Figure4.Figure 4
The extraction effect of the golf course area after clustering.In video image processing, mathematical morphology is often used in the subsequent processing of various video images because of its features such as smooth contour, filling holes, and connecting split areas. Mathematical morphology represents a mathematical tool for video image analysis based on morphology. The basic idea of this method is to measure or extract the corresponding shapes of video images with certain structural elements in order to achieve the purpose of video image processing. It has four basic operations, namely, expansion, corrosion, open operation, and closed operation [25–27]. They are usually defined in terms of proper names and operate on images by defining specialized structural elements. Among them, the most commonly used structural elements are composed of 4 connected 3 × 3 neighborhoods (5 points) or 8 connected 3 × 3 neighborhoods (9 points). At the same time, other practical mathematical morphology algorithms can be combined based on these basic operations. In OpenCV, the mathematical morphology filtering algorithm has been encapsulated into several library functions, which are very convenient to use.


## 2.1. Trajectories Matching of Basketball Players under the Color Model

In the existing basketball segmentation literature, most of the methods are based on the min value segmentation, such as the main color method; the first min value segmentation, after the segmentation of the court area, can be extracted to get the player area [18–21]. But this method reverses the order, because in the basketball video image, the audience and players, including the field, will be affected by the increase in the audience color when the entire image histogram is divided and counted to determine the closed distribution, resulting in deviations in the calculation of the minimum offset value. This results in the minimum value found for the segmentation of the entire image, not for the pitch region. Therefore, a more ideal method is to first segment the court area and then calculate the color histogram of the court area to find the closed value of the segmentation. In this way, the influence of the noncourt area on the dividing stop value is reduced. In addition, the presence of the audience will also have an impact on the subsequent target recognition. Therefore, this paper uses the method of dividing the field area first and then dividing the players by the min value.In general, the algorithm of closed value segmentation will involve the conversion of the color model [22–24]. Let us introduce the color model first. According to the computer color theory, for each color, there are different ways of expression in various theories, which forms a variety of different color spaces; the common color spaces are as follows: RGB, CMYK, YCRCB (YUV), and HSV. Each color space has its own background or application field, so different color spaces should be used according to the specific situation. Here is a brief introduction of the two color spaces often used in the study of video image processing: RGB space and HSV space. The RGB space is formed according to the spectral theory. In the RGB color space, all colors are realized by mixing the three components of red (R), green (G), and blue (B) in a certain proportion. Red (R), green (G), and blue (B) are the three primary colors that constitute all colors, and each component is called a color channel.In the RGB model, the chromaticity of light is proportional as follows:(1)s=H+C−SS+H+C,h=S+C−HS+H+C,c=S+H−CS+H+C,s+h+c=1.HSV space: The HSV space reflects the way people perceive colors. HSV separates Value from Hue and Saturation, two parameters that reflect the essential characteristics of colors. When we analyze the color image, the direct use of the color and saturation can reflect the nature of the color that will get better results. The following CamShift algorithm mainly uses Hue information in the HSV space, as shown in Figure2.Figure 2
The following CamShift algorithm mainly uses Hue information in the HSV space.The algorithm for converting RGB to HSV is shown as follows:(2)T=W−minS,H,CW+minS,H,C,W≠0,0,W=0,I=W−minS,H,CW+minS,H,C,W≠0,a+cb2+H−C+200,W=C,0,W=0.


## 2.2. Trajectional Characteristic Matching of Basketball Players under Court Segmentation

Generally speaking, the color characteristics of the pitch area are quite obvious, most of the pitch color is single and almost all is red. Therefore, we can segment the playing area according to the color characteristics. TheK-means clustering algorithm has the characteristics of simple operation, good real-time performance, and stable segmentation, so this paper selects the K-means clustering algorithm to segment the golf field area. Before K-means clustering segmentation, it is necessary to preprocess the image and use image equalization to enhance the contrast of the image.TheK-means algorithm, first proposed by Maceen, is a classic pattern recognition algorithm to solve clustering problems. K-means clustering has the advantages of simple calculation, fast calculation, effective processing of large amounts of data, dynamic clustering, and strong adaptability. It has a wide range of application fields, especially when solving the problem that the pattern distribution presents the agglomeration within the class, the algorithm can achieve good clustering results. This algorithm is one of the most common algorithms for iteratively adjusting the centroid of K clusters.Although this algorithm has been widely used, it also has some unavoidable problems: (1) like many clustering methods, theK-means algorithm is carried out under the premise of assuming the number of clusters in the data participating in clustering, which may not be consistent with the actual number of categories. (2) In terms of iterative technique, the K-means algorithm is particularly sensitive to initial clustering conditions. (3) The K-means algorithm may cause local minimum solution. The algorithm provides a unique one-to-one mapping relationship between the initial clustering center and the final clustering result.The determination of clustering numberK directly affects the results of image clustering. If the clustering number K is too small, the classification results are not accurate, resulting in many backgrounds being segmented into foreground targets. If the number of clustering K is too large, it will be seriously interfered by noise, and it is not easy to see the change of clustering center value rule, and the overhead of the algorithm will also increase. Therefore, it is necessary to determine the classification number according to the image statistical characteristics.Regarding the selection ofK, this paper adopts the fuzzy set theory and estimates K by means of the maximum value of the probability histogram of the H component. The probability histogram of the H component of a basketball image composed of pixels is generally distributed in the shape of valley and peak, with several maximum and minimum values. Let the extreme points be H-ex, D < I < t, where t is the number of extreme points. The maximum point H-ex, corresponding to the maximum value p, is the probability that the pixel brightness value is H-ex, as shown in Figure 3.Figure 3
The flow chart of dynamically obtaining the smoothing coefficient.After segmentation by theK-means clustering method proposed in this paper, the original image will be segmented into K parts, including the court, players, and audience seats. In this paper, each part is represented in different colors. However, K-means clustering will merge the pixels of other areas (such as the color areas of the audience and the court) into the court area, which will lead to inaccurate segmentation of the court area. Therefore, it is necessary to conduct image processing in the later period to segment a complete and accurate court area.The golf course has the following characteristics: (1) the area of the golf course in this image is generally the largest or relatively large area; (2) the edge line of the court is straight; (3) the color of the pitch area is usually green or similar, while the color of the auditorium is mixed; (4) the texture comparison rules of the course.We can judge whether the segmented area belongs to the court area according to the above characteristics because the judgment of court texture is relatively complex, and the court area can be judged by the previous several rules, so here we use the first three criteria to judge the court area. Here is the extraction of the golf course area after clustering above, and the extraction effect is shown in Figure4.Figure 4
The extraction effect of the golf course area after clustering.In video image processing, mathematical morphology is often used in the subsequent processing of various video images because of its features such as smooth contour, filling holes, and connecting split areas. Mathematical morphology represents a mathematical tool for video image analysis based on morphology. The basic idea of this method is to measure or extract the corresponding shapes of video images with certain structural elements in order to achieve the purpose of video image processing. It has four basic operations, namely, expansion, corrosion, open operation, and closed operation [25–27]. They are usually defined in terms of proper names and operate on images by defining specialized structural elements. Among them, the most commonly used structural elements are composed of 4 connected 3 × 3 neighborhoods (5 points) or 8 connected 3 × 3 neighborhoods (9 points). At the same time, other practical mathematical morphology algorithms can be combined based on these basic operations. In OpenCV, the mathematical morphology filtering algorithm has been encapsulated into several library functions, which are very convenient to use.


## 3. An Improved Interactive Multimodel Algorithm Is Applied to Basketball Player Track Feature Matching

### 3.1. The Improved Interactive Multimodel Algorithm Is Applied to the Trajectory Characteristics

Moments are used in statistics to represent the distribution of random quantities and in mechanics to represent the spatial distribution of matter [28–30]. If the binary image or gray image is regarded as the distribution function of two-dimensional density, the moment technique can be applied to video image analysis. In this way, moments can be used to represent the features of a binary or grayscale image and extracted into features similar to those in statistics and mechanics. In recent years, the invariant property of moment values obtained from 2D and 3D shapes has attracted great attention in the field of image. Moment technology has been widely used in many aspects of image classification and recognition processing, such as scene matching, histogram matching, image reconstruction, object recognition, and image retrieval. In this section, on the basis of introducing the basic concepts of moment and invariant moment, Hu moment invariant is selected to identify the target, and the conclusion is drawn through the discussion of the experimental results.The basic idea of the moment invariant target recognition algorithm is to search all possible target regions in the preprocessed binary image, calculate the seven Hu moment invariant features of the region, and consider the region with a higher degree of matching with the template as the same type of target. The similarity is the characteristic distance. The characteristic distance between the template vectorY and sample X is defined as(3)Ei,j=A−BA=∬i=0∐jnai−biai+∑a+cb2.But in practice, since the goal of image segmentation after sometimes is not whole, it can be divided into several parts as well as a target is divided into every phase close to the independent area; how to put these few areas as a whole for target recognition is worth studying; this article creates a copy of the segmented image and takes multiple t(2). If several areas are put together as a whole after the expansion of t time, these areas are recognized as a whole, and this area is marked as a whole area on the original image to be detected. The expansion method sometimes connects some close distance targets into a whole to identify them. The identification process is shown in Figure5.Figure 5
The identification process.
(a)(b)(c)The recognition algorithm steps are as follows:Step 1. Initialize the current scanning point {x, y) as the starting point of the image {0, 0); Step 2. Scan the image. When a region to be detected is encountered, obtain 7 Hu moment invariant feature vectors of the current region, and calculate the characteristic distance D between this vector and each template vector; Step 3. If D is less than the given threshold value L, we take L = 0.7 in the experiment to determine that the corresponding target candidate region is found. Draw the rectangular box with the minimum connection of the target as the recognition box. The red box can be drawn for basketball, while the green box for human.The above methods will distinguish the player from the ball, but there is no way to distinguish a single body from an attached body, there is no way to separate two or more attached bodies into a single body, and there is no way to tell whether the same team is attached or the other team is attached. The following is to take the adhesion of two players as an example to explain the distinction and segmentation of the adhesion human body and the discrimination method of adhesion properties in this paper. Because even in the case of occlusion, the head of the human body still has obvious characteristics, multiple human bodies can be fitted or bitten into one human body, according to the characteristics of the human head. It can be seen that the position of the head corresponds to the maximum value of the image projection (the two largest peaks and the two human adhesion parts correspond to the valley bottom of the projection curve between the two peaks). Therefore, the image segmentation points can be determined to separate the adhesion bodies according to this feature.The Hough transform is also applicable to the curve detection with known equations. A known curve equation in the image coordinate space can also establish its corresponding parameter space. Thus, a point in the image coordinate space can be mapped to the corresponding trajectory curve or surface in the parameter space. If the curves or surfaces corresponding to each discontinuous point in the parameter space can intersect, the maximum value of the parameter space and the corresponding parameters can be found. If the curves or surfaces corresponding to each discontinuity point in the parameter space cannot intersect, it means that the discontinuity point does not conform to a given curve. When Hough transform does curve detection, the most important thing is to write the transformation formula from the image coordinate space to the parameter space.The method of segmenting the human body with adhesion by judging whether there is a lower bottom between two maxima is also applicable to the situation of multiple human bodies. After the rectangular representation window of foreground target is obtained by background extraction, the brightness of the target in the window is projected vertically, and the multibody images can be segmented into a series of single body images by the above method. Since the pixel distribution in the lower part of the human body is sparse, in order to avoid its influence on the image projection curve, we only use the part of the upper part of the image 112 for projection in practice.


### 3.2. Simulation Calculation of Basketball Player’s Trajectory Characteristics Based on the Improved Interactive Multimodel Algorithm

The adaptive interactive multimodel algorithm based on the angular rate is a further extension of the classical multimodel algorithm. The classical interactive multimodel algorithm does filtering in a stable Cartesian coordinate system and does not need to transform the measurement and target state. However, the algorithm proposed in this paper advances in an adaptive coordinate system.Line Filter. The adaptive coordinate system is an imaginary coordinate system which builds the target acceleration model along each coordinate axis of the radar antenna (line of sight coordinate system). It is assumed that the antenna frame is instantaneous fixed (i.e., does not rotate relative to the space during the measurement interval) and the coordinate system does not always correspond to the line of sight coordinate system.Only in the case of new measurement inputs (trajectory characteristics matching radar and rate gyro), the adaptive coordinate system is transformed and completely coincidences with the line of sight coordinate system, while the adaptive coordinate system is fixed in space at other times. The position and velocity of the target are measured by the interactive multimodel algorithm, just as the coordinate system of the line of sight is fixed at the moment when the target measurement is finally obtained. The target state estimator calculates the target position, velocity, and acceleration relative to the adaptive coordinate system. After each filtering process of the interactive multimodel, the current state estimation and error covariance of the target should be converted to the next corresponding new direction.For the basketball player’s short-range defense, the target short-range movement is usually a straight line movement. It is reasonable to choose the CV model, CA model, and CS model as the main linear motion model. In this paper, the combination of the CV model and CA model is used to introduce the adaptive interactive multimodel algorithm based on the angular rate. Model 1 is the CV model, and Model 2 is the CA model.This part mainly interacts with the output of the multimodel filter. In the adaptive interactive filtering model, the filtering output after interaction is the filtering output value in the adaptive coordinate system at the corresponding time, which is ready to be input into the interactive filtering and enter into the next cycle. In this process, it should be noted that the filter value before interaction should have two flow directions, which are used for the interactive output of the multimodel filter at the corresponding moment and converted to the interactive input of the multimodel filter in the adaptive coordinate system at the next moment.The above transformation is to transform the state output of the Model 1 filter to the next time adaptive coordinate system. Similarly, the state output of the Model 2 filter can be converted to an adaptive coordinate system at the next moment, which will not be detailed here.The filtered error covariance converted to the adaptive coordinate system at the next moment is only used as the input interaction of the filter at the next moment, and the error covariance of the filter at that moment should be used in the output interaction process of the filter error covariance at that moment. The Model 1 filter is taken as an example to introduce the error covariance transformation. Model 2’s error covariance transformation is similar to Simulation 1’s.If there is a large difference between the target and background gray levels in a given image, there are two peaks of gray distribution on the histogram. The gray value corresponding to the bottom position is selected as the threshold value of the binary image to achieve the segmentation of target and background. The threshold selection of this method is relatively intuitive and simple, but it is not applicable to complex background images, as shown in Figure6.Figure 6
The threshold selection of this method.
(a)(b)The experimental material here is culled from video of the 2019 World Cup basketball game between Brazil and the United States. From the 23rd minute, the track characteristic matches a Brazilian team member, as shown in Figure7. In this video, occlusion occurs at frame 24, the target is completely occluded at frame 33 to 37, and the occlusion ends at frame 39. The matching effect of trajectory characteristics shown in Figure 8 shows the curves of the search window and occlusion factor.Figure 7
The matching effect of trajectory characteristics.
(a)(b)Figure 8
The curves of the search window and occlusion factor. (a) Series 1. (b) Series 2. (c) Series 3. (d) Series 4. (e) Series 5. (f) Series 6.Result Analysis. Starting from the first frame, the upper body of the player was selected as the trajectory matching object, and the Kalman parameter was initialized. In the 12th frame, the search window day would not become larger when it was close to a team member, but there was no connection. The trajectory matching results were mainly CamShift trajectory matching results. In frame 24, players begin to be partially occluded, and the search window becomes smaller but the change is not large. Therefore, the occlusion coefficient is small at this time, and the track feature matching result is still dominated by the CamShift track feature matching result, as shown in Figure 9.Figure 9
The track feature matching result.Set Target Route Parameters. The initial distance from the target to the observation point is about 10 000 m, the altitude is 50 m, the route shortcut is 300 m, and the sampling period is T = 0.02 s. The target flies in a straight line at a constant speed of 300 m/s along N600 by E for 15 s and then flies in a straight line at an acceleration of 20 m/s to measure the noise. In the case of known theoretical values, the filtering convergence time and filtering error between the proposed algorithm and the standard single model Kalman filter algorithm are calculated. The horizontal axis represents the time, unit is s; the vertical axis represents the position, unit is m. Figure 9 shows the position filtering effect of the two algorithms in the ship’s geographic coordinate system on X-axis and Y-axis. As can be seen from Figure 9, the convergence time of the single model Kalman filter algorithm in this paper is significantly faster than that of the former, and the filtering accuracy of the latter algorithm is better than that of the former. Figure 10 is the filtering effect diagram of the two algorithms in the target maneuvering process. As can be seen from Figure 10, the former algorithm has begun to filter divergence after the target s maneuvers, while the latter maintains stable filtering of the maneuvering target. According to the comparison between Figures 9 and 10, in the process of maneuvering target tracking, the filtering effect of the proposed algorithm is obviously better than that of the single model Kalman filtering algorithm.Figure 10
The filtering effect diagram of the two algorithms in the target maneuvering process.We use the color histogram with weighted distance as the target feature to reduce the influence of target background pixels and increase the robustness of CamShift algorithm to partial occlusion. For blocking players, this section proposes a target tracking algorithm based on CamShift and Kalman filter. In the process of target tracking, CamShift algorithm does not consider the actual macromotion of the target, that is, it does not use the direction and speed information of the target in space. In the case of serious interference, it is easy to fail in tracking. In this section, the Kalman filter is reasonably combined with the color-based CamShift algorithm to predict the direction and speed of the target. For different interference conditions, the tracking results of the two algorithms are weighted by different scaling factors to get the final position of the target. In the case of weak interference, the tracking results of the CamShift algorithm account for a large proportion, while in the case of strong interference, the results of the Kalman filter account for a large proportion, so as to ensure the stability and robustness of the tracking effect.


## 3.1. The Improved Interactive Multimodel Algorithm Is Applied to the Trajectory Characteristics

Moments are used in statistics to represent the distribution of random quantities and in mechanics to represent the spatial distribution of matter [28–30]. If the binary image or gray image is regarded as the distribution function of two-dimensional density, the moment technique can be applied to video image analysis. In this way, moments can be used to represent the features of a binary or grayscale image and extracted into features similar to those in statistics and mechanics. In recent years, the invariant property of moment values obtained from 2D and 3D shapes has attracted great attention in the field of image. Moment technology has been widely used in many aspects of image classification and recognition processing, such as scene matching, histogram matching, image reconstruction, object recognition, and image retrieval. In this section, on the basis of introducing the basic concepts of moment and invariant moment, Hu moment invariant is selected to identify the target, and the conclusion is drawn through the discussion of the experimental results.The basic idea of the moment invariant target recognition algorithm is to search all possible target regions in the preprocessed binary image, calculate the seven Hu moment invariant features of the region, and consider the region with a higher degree of matching with the template as the same type of target. The similarity is the characteristic distance. The characteristic distance between the template vectorY and sample X is defined as(3)Ei,j=A−BA=∬i=0∐jnai−biai+∑a+cb2.But in practice, since the goal of image segmentation after sometimes is not whole, it can be divided into several parts as well as a target is divided into every phase close to the independent area; how to put these few areas as a whole for target recognition is worth studying; this article creates a copy of the segmented image and takes multiple t(2). If several areas are put together as a whole after the expansion of t time, these areas are recognized as a whole, and this area is marked as a whole area on the original image to be detected. The expansion method sometimes connects some close distance targets into a whole to identify them. The identification process is shown in Figure5.Figure 5
The identification process.
(a)(b)(c)The recognition algorithm steps are as follows:Step 1. Initialize the current scanning point {x, y) as the starting point of the image {0, 0); Step 2. Scan the image. When a region to be detected is encountered, obtain 7 Hu moment invariant feature vectors of the current region, and calculate the characteristic distance D between this vector and each template vector; Step 3. If D is less than the given threshold value L, we take L = 0.7 in the experiment to determine that the corresponding target candidate region is found. Draw the rectangular box with the minimum connection of the target as the recognition box. The red box can be drawn for basketball, while the green box for human.The above methods will distinguish the player from the ball, but there is no way to distinguish a single body from an attached body, there is no way to separate two or more attached bodies into a single body, and there is no way to tell whether the same team is attached or the other team is attached. The following is to take the adhesion of two players as an example to explain the distinction and segmentation of the adhesion human body and the discrimination method of adhesion properties in this paper. Because even in the case of occlusion, the head of the human body still has obvious characteristics, multiple human bodies can be fitted or bitten into one human body, according to the characteristics of the human head. It can be seen that the position of the head corresponds to the maximum value of the image projection (the two largest peaks and the two human adhesion parts correspond to the valley bottom of the projection curve between the two peaks). Therefore, the image segmentation points can be determined to separate the adhesion bodies according to this feature.The Hough transform is also applicable to the curve detection with known equations. A known curve equation in the image coordinate space can also establish its corresponding parameter space. Thus, a point in the image coordinate space can be mapped to the corresponding trajectory curve or surface in the parameter space. If the curves or surfaces corresponding to each discontinuous point in the parameter space can intersect, the maximum value of the parameter space and the corresponding parameters can be found. If the curves or surfaces corresponding to each discontinuity point in the parameter space cannot intersect, it means that the discontinuity point does not conform to a given curve. When Hough transform does curve detection, the most important thing is to write the transformation formula from the image coordinate space to the parameter space.The method of segmenting the human body with adhesion by judging whether there is a lower bottom between two maxima is also applicable to the situation of multiple human bodies. After the rectangular representation window of foreground target is obtained by background extraction, the brightness of the target in the window is projected vertically, and the multibody images can be segmented into a series of single body images by the above method. Since the pixel distribution in the lower part of the human body is sparse, in order to avoid its influence on the image projection curve, we only use the part of the upper part of the image 112 for projection in practice.


## 3.2. Simulation Calculation of Basketball Player’s Trajectory Characteristics Based on the Improved Interactive Multimodel Algorithm

The adaptive interactive multimodel algorithm based on the angular rate is a further extension of the classical multimodel algorithm. The classical interactive multimodel algorithm does filtering in a stable Cartesian coordinate system and does not need to transform the measurement and target state. However, the algorithm proposed in this paper advances in an adaptive coordinate system.Line Filter. The adaptive coordinate system is an imaginary coordinate system which builds the target acceleration model along each coordinate axis of the radar antenna (line of sight coordinate system). It is assumed that the antenna frame is instantaneous fixed (i.e., does not rotate relative to the space during the measurement interval) and the coordinate system does not always correspond to the line of sight coordinate system.Only in the case of new measurement inputs (trajectory characteristics matching radar and rate gyro), the adaptive coordinate system is transformed and completely coincidences with the line of sight coordinate system, while the adaptive coordinate system is fixed in space at other times. The position and velocity of the target are measured by the interactive multimodel algorithm, just as the coordinate system of the line of sight is fixed at the moment when the target measurement is finally obtained. The target state estimator calculates the target position, velocity, and acceleration relative to the adaptive coordinate system. After each filtering process of the interactive multimodel, the current state estimation and error covariance of the target should be converted to the next corresponding new direction.For the basketball player’s short-range defense, the target short-range movement is usually a straight line movement. It is reasonable to choose the CV model, CA model, and CS model as the main linear motion model. In this paper, the combination of the CV model and CA model is used to introduce the adaptive interactive multimodel algorithm based on the angular rate. Model 1 is the CV model, and Model 2 is the CA model.This part mainly interacts with the output of the multimodel filter. In the adaptive interactive filtering model, the filtering output after interaction is the filtering output value in the adaptive coordinate system at the corresponding time, which is ready to be input into the interactive filtering and enter into the next cycle. In this process, it should be noted that the filter value before interaction should have two flow directions, which are used for the interactive output of the multimodel filter at the corresponding moment and converted to the interactive input of the multimodel filter in the adaptive coordinate system at the next moment.The above transformation is to transform the state output of the Model 1 filter to the next time adaptive coordinate system. Similarly, the state output of the Model 2 filter can be converted to an adaptive coordinate system at the next moment, which will not be detailed here.The filtered error covariance converted to the adaptive coordinate system at the next moment is only used as the input interaction of the filter at the next moment, and the error covariance of the filter at that moment should be used in the output interaction process of the filter error covariance at that moment. The Model 1 filter is taken as an example to introduce the error covariance transformation. Model 2’s error covariance transformation is similar to Simulation 1’s.If there is a large difference between the target and background gray levels in a given image, there are two peaks of gray distribution on the histogram. The gray value corresponding to the bottom position is selected as the threshold value of the binary image to achieve the segmentation of target and background. The threshold selection of this method is relatively intuitive and simple, but it is not applicable to complex background images, as shown in Figure6.Figure 6
The threshold selection of this method.
(a)(b)The experimental material here is culled from video of the 2019 World Cup basketball game between Brazil and the United States. From the 23rd minute, the track characteristic matches a Brazilian team member, as shown in Figure7. In this video, occlusion occurs at frame 24, the target is completely occluded at frame 33 to 37, and the occlusion ends at frame 39. The matching effect of trajectory characteristics shown in Figure 8 shows the curves of the search window and occlusion factor.Figure 7
The matching effect of trajectory characteristics.
(a)(b)Figure 8
The curves of the search window and occlusion factor. (a) Series 1. (b) Series 2. (c) Series 3. (d) Series 4. (e) Series 5. (f) Series 6.Result Analysis. Starting from the first frame, the upper body of the player was selected as the trajectory matching object, and the Kalman parameter was initialized. In the 12th frame, the search window day would not become larger when it was close to a team member, but there was no connection. The trajectory matching results were mainly CamShift trajectory matching results. In frame 24, players begin to be partially occluded, and the search window becomes smaller but the change is not large. Therefore, the occlusion coefficient is small at this time, and the track feature matching result is still dominated by the CamShift track feature matching result, as shown in Figure 9.Figure 9
The track feature matching result.Set Target Route Parameters. The initial distance from the target to the observation point is about 10 000 m, the altitude is 50 m, the route shortcut is 300 m, and the sampling period is T = 0.02 s. The target flies in a straight line at a constant speed of 300 m/s along N600 by E for 15 s and then flies in a straight line at an acceleration of 20 m/s to measure the noise. In the case of known theoretical values, the filtering convergence time and filtering error between the proposed algorithm and the standard single model Kalman filter algorithm are calculated. The horizontal axis represents the time, unit is s; the vertical axis represents the position, unit is m. Figure 9 shows the position filtering effect of the two algorithms in the ship’s geographic coordinate system on X-axis and Y-axis. As can be seen from Figure 9, the convergence time of the single model Kalman filter algorithm in this paper is significantly faster than that of the former, and the filtering accuracy of the latter algorithm is better than that of the former. Figure 10 is the filtering effect diagram of the two algorithms in the target maneuvering process. As can be seen from Figure 10, the former algorithm has begun to filter divergence after the target s maneuvers, while the latter maintains stable filtering of the maneuvering target. According to the comparison between Figures 9 and 10, in the process of maneuvering target tracking, the filtering effect of the proposed algorithm is obviously better than that of the single model Kalman filtering algorithm.Figure 10
The filtering effect diagram of the two algorithms in the target maneuvering process.We use the color histogram with weighted distance as the target feature to reduce the influence of target background pixels and increase the robustness of CamShift algorithm to partial occlusion. For blocking players, this section proposes a target tracking algorithm based on CamShift and Kalman filter. In the process of target tracking, CamShift algorithm does not consider the actual macromotion of the target, that is, it does not use the direction and speed information of the target in space. In the case of serious interference, it is easy to fail in tracking. In this section, the Kalman filter is reasonably combined with the color-based CamShift algorithm to predict the direction and speed of the target. For different interference conditions, the tracking results of the two algorithms are weighted by different scaling factors to get the final position of the target. In the case of weak interference, the tracking results of the CamShift algorithm account for a large proportion, while in the case of strong interference, the results of the Kalman filter account for a large proportion, so as to ensure the stability and robustness of the tracking effect.


## 4. Conclusion

In this paper, the segmentation and track characteristic matching of the interested object-player in the basketball game, which is the most widely watched sports video, are studied, which lays a foundation for the further analysis of the sports video. Firstly, this paper discusses the method of moving object detection and recognition on a single picture of the basketball match. Then, we discuss the matching problem of basketball and players’ track characteristics and combine the two parts, that is, the target and position parameters obtained by segmentation, instead of the parameters passed manually so that the track characteristics matching can be automated. The main work of this paper includes the following parts. (1) In this paper, the improvedK-means clustering algorithm is adopted to segment the golf field area, and the color histogram is used to verify the results. The clustering number K and the initial clustering point are fixed, which solves the shortcoming that the clustering number and the initial clustering point cannot be selected automatically in the K-means clustering. Then, according to the color characteristics of the field, a complementary color model based on HSV and RGB is adopted to eliminate the field and realize the segmentation of the ball, players, and field line. (2) The elliptical court line in the basketball video is basically a fixed shape, so this paper uses a specific curve to fit the square. The ellipse field line was extracted by the method. The experimental results show that the detection time is greatly shortened, the memory space occupied is small, and the effect is very ideal. The Hough transform method provided in 4Pencv is still used for straight line detection. (3) In the aspect of target recognition, 7 Hu invariant moments with good robustness are selected to identify different targets. According to the characteristics of normalization of Hu moments, a discriminant formula is proposed in this paper to combine 7 Hu moments to determine the type of the detection region. Experiments show that this method is effective in distinguishing basketball from players. (4) Match players with CamShift trajectory characteristics. The movement speed of the players is a little slower, but the color features are rich. Besides, the players are a nonrigid body movement, which is suitable for the trajectory characteristic matching of the CamShift algorithm. The background weighted histogram was used to improve the CamShift algorithm to solve the defect that CamShift trajectory matching was easily disturbed by the surrounding environment. In addition, the method of CamShift combined with the Kalman filter is used to deal with player occlusion. A method of determining the occlusion factor based on search window and weighting Kalman and CamShift results by the occlusion factor is proposed, and some results are obtained.



---

*Source: 4728814-2021-06-16.xml*