Volleyball sport tactics analysis method based on machine vision
Technical Field
The application belongs to the field of image processing, and particularly relates to a volleyball sport tactical analysis method based on machine vision.
Background
Volleyball sports are team ball sports which are increasingly popular with the public, wherein not only the exertion of the player's own abilities is required, but also the application of a number of tactics and strategies is required. Some tactics are prepared before some volleyball games with great significance, but how to judge whether a player on a court has the ability to contribute to the winning of the games and how to arrange the tactics needs to rely on a coach to analyze the play of teams in the past games, and further needs to continuously observe and analyze videos.
At present, some methods for detecting and tracking people exist, but the detection effect of volleyball sports videos is not good, and the problems of low accuracy, high ID exchange rate and the like exist.
Disclosure of Invention
In view of the existing problems, the present application aims to provide a volleyball sport tactical analysis method based on machine vision, which is characterized by comprising the following steps: s1: training a volleyball player and volleyball model by using a Yolov5 target detection algorithm, identifying the volleyball player and volleyball in a volleyball video, and respectively outputting the coordinate positions of the detection frames of the volleyball player and volleyball and the appearance characteristic matrix of the detection frames; s2: tracking volleyball players through an improved deep tracking algorithm; 3: tracking volleyball through area search; s4: repairing the track of volleyball players and volleyball by using a difference frame method; s5: calculating a batting point and a landing point; s6: and carrying out two-dimensional mapping on the volleyball sports scene.
Preferably, step S2 specifically includes the following steps:
s21: by passing throughDescribing the motion state of a volleyball player at a certain moment, wherein u and v respectively represent an abscissa and an ordinate of the central coordinate of a detection frame of a target, gamma represents the ratio of the width to the height of the detection frame, and h represents the height of the detection frame;The four parameters are the relative speeds of the first four parameters in the image coordinates; updating state information of a target through a Kalman filter, wherein the Kalman filter adopts a constant speed model and a linear prediction model, and the predicted value of the Kalman filter is (u, v, gamma, h);
s22: by the formula:calculating the association degree between the predicted value of the Markov distance measurement predicted by Kalman filtering and the detection value of the detector at the motion information level; wherein d (1) (i, j) represents the degree of matching of the motion state between the detected position of the jth frame and the predicted position of the ith frame, d j Representing the detected position of the j-th frame, y i Representing the predicted position of the ith frame, S i Representing a covariance matrix between the ith detected position and the average predicted position; extracting appearance characteristics of the detection frame and the prediction frame by using a characteristic extraction network at the appearance information layer, and passing through the formula:
calculating the association degree between the detection frame and the prediction frame; wherein d (2) (i, j) represents the minimum cosine distance between the jth detection frame and the ith prediction frame, r j To detect frame d j Calculating a descriptor corresponding to the appearance characteristic of the frame, provided that |r j |=1; for each successfully associated track, a repository is created which can store the last n descriptors simultaneously>Wherein n is a set super parameter;if d (2) (i, j) is less than the association threshold, then the association is considered successful; by the formula: c i,j =λd (1) (i,j)+(1-λ)d (2) (i, j) fusing two measurement values of the mahalanobis distance and the cosine distance in a linear weighting mode to be used as a final measurement, wherein lambda is a set weight; setting an updating time parameter and a survival period for all tracks, wherein the survival period value is +1 when the tracks are updated by using Kalman filtering once, clearing the survival period if the tracks are matched, and discarding the tracks if the survival period is greater than the updating time parameter;
s23: setting a set of unmatched tracks of volleyball playersThe center coordinates of the last detection frame of the track which is not matched after IoU matching are stored, and a unmatched track number sigma, a track number epsilon and a track number limiting parameter gamma are set; wherein, the initial values of sigma and epsilon are all 0, and the initial value of gamma is set as volleyball player target number 12. When the unmatched detection frame is judged to be a new track through 10 cycles, if epsilon < gamma, the new track is classified into a track set, and epsilon is added with 1; judging sigma if epsilon=gamma, and deleting a new track if sigma=0; if σ > 0, then the formula is passed:
wherein ,ui ,v i Is the center coordinate of the ith detection frame, s i,j For the i-th detection frame center coordinate and volleyball player unmatched track setThe minimum Euclidean distance of the center coordinates of the jth detection frame; if the matching condition is satisfied, s i,j If the track number is smaller than the set threshold value, the unmatched track is considered to be successfully matched with the new track, and the ID number of the track is given to the new track;
preferably, step S3 judges whether the detected ball is within the judgment area in the case where the volleyball can be detected in the continuous frame images: first, theDetection frame of volleyball ball detected by i frames whereinThe horizontal coordinate and the vertical coordinate of the upper left point and the horizontal coordinate and the vertical coordinate of the lower right point of the ith frame ball detection frame are respectively;Is the judgment area of the ball of the i-th frame,is the ratio of the area of the intersection area of the detection frame of the volleyball of the ith+1st frame and the judgment area to the area of the detection frame of the volleyball, and is +.>Andcalculated from the following formula:
wherein ,w b ,h b detecting the length and width of the image for the first frame, lambda being the set super parameter,/for->A detection frame for the detected sphere of frame i+1; setting track set K of ball b When->When the ball is judged to be correctly recognized, the detection frame of the ball is added>Added to ball trajectory set K b In (a) and (b); when->And if the detection is judged to be false, discarding the detection and not tracking.
Preferably, in the case where no ball is detected in the presence of the intermediate frame image, step S3 uses the region of the adjacent frame as the judgment region, then
Wherein n is the difference between the serial number of the ball detected by the frame and the serial number of the ball detected by the previous frame, the phi is a settable super parameter,detecting an area of an image for a first frame; when->When the ball is judged to be correctly recognized, the detection frame of the ball is added>Added to track set K b In (a) and (b); when->If the error detection is judged, the frame is abandoned and is not tracked.
The step S4 specifically comprises the following steps: the last detection frame before each track missing detection frame is set as follows:
Box i =[x i1 ,y i1 ,x i2 ,y i2 ]the first detection frame after each track missing frame is:
Box i+n =[x (i+n)1 ,y (i+n)1 ,x (i+n)1 ,y (i+n)2 ]where i is the frame number, x i1 ,y i1 ,x i2 ,y i2 The detection frames of the missed detection frames with the track frame serial numbers of i+m are respectively the horizontal coordinate and the vertical coordinate of the upper left point and the horizontal coordinate and the vertical coordinate of the lower right point of the detection frame:
preferably, step S5 is specifically:
setting a j volleyball player detection frame in the i frame as follows:the height of the volleyball player detection frame is +.>Selecting a ball striking point by detecting the ratio of the area where the minimum point is located to one third of the area on the volleyball player detection frame; by the formula: bk=localmin { K b Finding out the minimum value point of the ball track, wherein BK is the set of detection frames corresponding to the minimum value point, and localmin { K b The sphere trajectory set K is represented b Obtaining minimum values of center coordinates of detection frames of all balls in the ball detecting frame;
setting upDetecting the upper third area of the frame for the jth volleyball player in the ith frame, then the jth volleyball player and +.>Area of intersection->The percentage of the area of the detection frame of the ball is as follows:
wherein ,the frame number is i, which is the detection frame of the ball in BK; ioU ijmax IoU for maximum screening of ith frame ij :IoU imax =max{IoU ij }, where { IoU } ij All of the ith frame }IoU ij ;
Coordinates of a center point of a lower frame of the ith frame ball detecting frameThe formula is as follows:
wherein ,for the i frame j volleyball player the abscissa of the upper left point of the detection frame,/for the j-th volleyball player>The horizontal and vertical coordinates of the lower right point of the frame are detected for the jth volleyball player in the ith frame;For the upper left point of the i-th frame sphere, the abscissa of the frame, is->The horizontal and vertical coordinates of the lower right point of the frame are detected for the ith frame ball;
when IoU ijmax When > 0, judgeIs the batting point, and the coordinates of the center point of the lower frame of the j volleyball player detection frame of the ith frame are +.>As coordinates in the corresponding two-dimensional image of the ball point; ioU ijmax When the number of the ball points is =0, the ball point is determined as the center coordinate of the lower frame of the corresponding ball detection frame +.>
Preferably, step S6 is specifically: describing coordinates g= (x, y, 1) from the course model with a planar map T To the original frame image coordinates g' = (u, v, 1) T Is mapped to: g' =hg, noted:
the beneficial technical effects of the application are as follows:
the application uses the YOLOv5 algorithm to detect the players and the balls, the algorithm has high reasoning speed and high accuracy, the accuracy of detecting the targets of the players is effectively improved, and the recognition speed is also accelerated; the improved deep SORT multi-target tracking algorithm is used for tracking the player, the algorithm is combined with motion information and appearance characteristics to track the player, a track re-matching module is added, the accuracy of tracking the player target is improved, and the probability of losing the target caused by shielding of the player is reduced; the homography transformation algorithm is used, so that the movement track of the player is more concrete, and the method is more suitable for analyzing the track of the player.
Drawings
FIG. 1 is a schematic flow chart of a volleyball sport tactical analysis method based on machine vision provided by the application;
FIG. 2 is an example of the output results of a preferred embodiment provided by the present application;
fig. 3 is a flow chart of the deep start tracking algorithm in a preferred embodiment provided by the present application.
Detailed Description
The following examples of the present application are described in detail, and are given by way of illustration of the present application, but the scope of the present application is not limited to the following examples. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments without conflict.
In view of the prior art, as shown in fig. 1, the present application provides a volleyball sport tactical analysis method based on machine vision, which is characterized by comprising the following steps: s1: training a volleyball player and volleyball model by using a Yolov5 target detection algorithm, identifying the volleyball player and volleyball in a volleyball video, and respectively outputting the coordinate positions of the detection frames of the volleyball player and volleyball and the appearance characteristic matrix of the detection frames; s2: tracking volleyball players through an improved deep tracking algorithm; 3: tracking volleyball through area search; s4: repairing the track of volleyball players and volleyball by using a difference frame method; s5: calculating a batting point and a landing point; s6: and carrying out two-dimensional mapping on the volleyball sports scene.
The step S2 specifically comprises the following steps:
s21: by passing throughDescribing the motion state of a volleyball player at a certain moment, wherein u and v respectively represent an abscissa and an ordinate of the central coordinate of a detection frame of a target, gamma represents the ratio of the width to the height of the detection frame, and h represents the height of the detection frame;The four parameters are the relative speeds of the first four parameters in the image coordinates; updating state information of a target through a Kalman filter, wherein the Kalman filter adopts a constant speed model and a linear prediction model, and the predicted value of the Kalman filter is (u, v, gamma, h);
s22: by the formula:calculating the association degree between the predicted value of the Markov distance measurement predicted by Kalman filtering and the detection value of the detector at the motion information level; wherein d (1) (i, j) represents the detection bit of the j-th frameA degree of matching of the motion state between the position and the predicted position of the ith frame, d j Representing the detected position of the j-th frame, y i Representing the predicted position of the ith frame, S i Representing a covariance matrix between the ith detected position and the average predicted position; extracting appearance characteristics of the detection frame and the prediction frame by using a characteristic extraction network at the appearance information layer, and passing through the formula:
calculating the association degree between the detection frame and the prediction frame; wherein d (2) (i, j) represents the minimum cosine distance between the jth detection frame and the ith prediction frame, r j To detect frame d j Calculating a descriptor corresponding to the appearance characteristic of the frame, provided that |r j |=1; for each successfully associated track, a repository is created which can store the last n descriptors simultaneously>Wherein n is a set super parameter; if d (2) (i, j) is less than the association threshold, then the association is considered successful; by the formula: c i,j =λd (1) (i,j)+(1-λ)d (2) (i, j) fusing two measurement values of the mahalanobis distance and the cosine distance in a linear weighting mode to be used as a final measurement, wherein lambda is a set weight; setting an updating time parameter and a survival period for all tracks, wherein the survival period value is +1 when the tracks are updated by using Kalman filtering once, clearing the survival period if the tracks are matched, and discarding the tracks if the survival period is greater than the updating time parameter;
s23: setting a set of unmatched tracks of volleyball playersThe center coordinates of the last detection frame of the track which is not matched after IoU matching are stored, and a unmatched track number sigma, a track number epsilon and a track number limiting parameter gamma are set; wherein, the initial values of sigma and epsilon are all 0, and the initial value of gamma is set as volleyball player target number 12. Detection of a mismatchWhen the frame is judged to be a new track through 10 cycles, if epsilon < gamma, the new track is classified into a track set, and epsilon is added with 1; judging sigma if epsilon=gamma, and deleting a new track if sigma=0; if σ > 0, then the formula is passed:
wherein ,ui ,v i Is the center coordinate of the ith detection frame, s i,j For the i-th detection frame center coordinate and volleyball player unmatched track setThe minimum Euclidean distance of the center coordinates of the jth detection frame; if the matching condition is satisfied, s i,j If the track number is smaller than the set threshold value, the unmatched track is considered to be successfully matched with the new track, and the ID number of the track is given to the new track;
step S3, judging whether the detected volleyball is in a judging area or not under the condition that volleyball can be detected in continuous frame images: volleyball detection frame that ith frame detected whereinThe horizontal coordinate and the vertical coordinate of the upper left point and the horizontal coordinate and the vertical coordinate of the lower right point of the ith frame ball detection frame are respectively;Judging area for the ball of the i-th frame, < >>Is the ratio of the area of the intersection area of the detection frame of the volleyball of the ith+1st frame and the judgment area to the area of the detection frame of the volleyball, and is +.> andCalculated from the following formula:
wherein ,w b ,h b detecting the length and width of the image for the first frame, lambda being the set super parameter,/for->A detection frame for the detected sphere of frame i+1; setting track set K of ball b When->When the ball is judged to be correctly recognized, the detection frame of the ball is added>Added to ball trajectory set K b In (a) and (b); when->And if the detection is judged to be false, discarding the detection and not tracking.
Step S3, in the case that no ball is detected in the intermediate frame image, using the area adjacent to the frame as the judgment area, then
Wherein n is the difference between the serial number of the ball detected by the frame and the serial number of the ball detected by the previous frame, the phi is a settable super parameter,detecting an area of an image for a first frame; when->When the ball is judged to be correctly recognized, the ball is thenDetection frame->Added to track set K b In (a) and (b); when->If the error detection is judged, the frame is abandoned and is not tracked.
The step S4 specifically comprises the following steps: the last detection frame before each track missing detection frame is set as follows:
Box i =[x i1 ,y i1 ,x i2 ,y i2 ]the first detection frame after each track missing frame is:
Box i+n =[x (i+n)1 ,y (i+n)1 ,x (i+n)1 ,y (i+n)2 ]where i is the frame number, x i1 ,y i1 ,x i2 ,y i2 The detection frames of the missed detection frames with the track frame serial numbers of i+m are respectively the horizontal coordinate and the vertical coordinate of the upper left point and the horizontal coordinate and the vertical coordinate of the lower right point of the detection frame:
the step S5 specifically comprises the following steps:
setting a j volleyball player detection frame in the i frame as follows:the height of the volleyball player detection frame is +.>Selecting a ball striking point by detecting the ratio of the area where the minimum point is located to one third of the area on the volleyball player detection frame; by the formula: bk=localmin { K b Finding out the minimum value point of the ball track, wherein BK is the set of detection frames corresponding to the minimum value point, and localmin { K b The sphere trajectory set K is represented b Obtaining minimum values of center coordinates of detection frames of all balls in the ball detecting frame;
setting upDetecting the upper third area of the frame for the jth volleyball player in the ith frame, then the jth volleyball player and +.>Area of intersection->The percentage of the area of the detection frame of the ball is as follows:
wherein ,the frame number is i, which is the detection frame of the ball in BK; ioU ijmax IoU for maximum screening of ith frame ij :IoU imax =max{IoU ij }, where { IoU } ij IoU for the ith frame ij ;
Coordinates of a center point of a lower frame of the ith frame ball detecting frameThe formula is as follows:
wherein ,for the i frame j volleyball player the abscissa of the upper left point of the detection frame,/for the j-th volleyball player>The horizontal and vertical coordinates of the lower right point of the frame are detected for the jth volleyball player in the ith frame;For the upper left point of the i-th frame sphere, the abscissa of the frame, is->The horizontal and vertical coordinates of the lower right point of the frame are detected for the ith frame ball;
when IoU ijmax When > 0, judgeIs the batting point, and the coordinates of the center point of the lower frame of the j volleyball player detection frame of the ith frame are +.>As coordinates in the corresponding two-dimensional image of the ball point; ioU ijmax When the number of the ball points is =0, the ball point is determined as the center coordinate of the lower frame of the corresponding ball detection frame +.>
The step S6 specifically comprises the following steps: describing coordinates g= (x, y, 1) from the course model with a planar map T To the original frame image coordinates g' = (u, v, 1) T Is mapped to: g' =hg, noted as:
the foregoing describes in detail preferred embodiments of the present application. It should be understood that numerous modifications and variations can be made in accordance with the concepts of the application without requiring creative effort by one of ordinary skill in the art. Therefore, all technical solutions which can be obtained by logic analysis, reasoning or limited experiments based on the prior art by a person skilled in the art according to the inventive concept shall be within the scope of protection defined by the claims.