A basketball auxiliary shooting player position acquisition method
By collecting shooting training videos in basketball and using the circumscribed rectangle and perspective transformation algorithms, the problems of large computational complexity and jump error in obtaining the shooting player's position in basketball are solved, and accurate shooting player position identification is achieved.
Patent Information
- Application Number
- CN202211681849.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-27
- Publication Date
- 2025-10-21
- Estimated Expiration
- 2042-12-27
AI Technical Summary
In basketball, existing technologies have difficulty in effectively reducing the amount of calculation required to determine the occurrence of a shooting action based on human body movements, and are unable to accurately handle position errors caused by jumping.
A camera is used to capture shooting training videos, and the shooting frames are obtained through tracing. The position of the shooting player is calculated using the circumscribed rectangle and perspective transformation algorithm, combined with the key points of the three-second zone on the court, to reduce the amount of calculation and correct the errors caused by the jump.
It greatly reduces the amount of calculation required when multiple people appear on the screen at the same time, accurately handles position errors caused by jumping, and improves the accuracy and efficiency of obtaining the shooting player's position.
Smart Images

Figure CN115966019B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of sports image recognition, and in particular to a method for obtaining the position of a basketball assisted shooting player. Background Art
[0002] In basketball, different players often have significant differences in their shooting accuracy at different shooting points. Generating a statistical report on shooting position accuracy has become an essential part of basketball shooting training. The shooting data output method and electronic device disclosed in Chinese Patent Publication No. CN110942022A primarily involves acquiring a shooting video; identifying a user's shooting position on the court and the corresponding shooting result; and outputting the shooting data based on the identified shooting position and shooting result. This method tracks the user's shooting action, detects the position of the user's feet on the court, and determines this position as the shooting position. In real-world applications, multiple people often appear simultaneously in a video. The computational complexity of determining the movement of each person increases as the number of people present increases. Chinese Patent Publication No. CN115171219A discloses a basketball-assisted shooting accuracy statistics method that uses the relationship between the basketball and the basket to infer whether a shooting action has occurred. This method significantly reduces the computational complexity of the human action recognition process. At the same time, the present invention also addresses the situation of jumping shots. In real-world applications, jumping shots are very common. A straight line drawn between the camera and the soles of a person's feet would intersect the court at a point far from the camera due to the jump. Therefore, simply using the soles of the feet to calculate a player's position is problematic. Summary of the Invention
[0003] The technical problem to be solved by the embodiments of the present invention is to provide a method for obtaining the position of a basketball assisted shooting player, which can greatly reduce the amount of calculation required to determine the shooting action during human body movement and can also address the position error problem caused by jumping.
[0004] In order to solve the above technical problems, an embodiment of the present invention provides a method for obtaining a player's position in a basketball assisted shooting game, comprising the following steps:
[0005] S1: Use a camera to collect shooting training videos and use the tracing method to obtain all shot frames;
[0006] S2: adding one to the number of players with the smallest distance between their hands and the basketball in each of the N frames preceding the shooting frame, and recording the player with the most occurrences as the shooting player;
[0007] S3: Get the pixel coordinates of the four key points in the three-second zone of the court in the image;
[0008] S4: Calculate the human body node data and circumscribed rectangle of the basketball shooter, and calculate its position in the image;
[0009] S5: Based on the shooting player position obtained in S4, the player's court coordinates are calculated using the perspective transformation algorithm.
[0010] Wherein, the S2 further includes the following steps:
[0011] S2-1: Obtain the position of the basketball and the direction of the basketball shot corresponding to the shot frame obtained in S1;
[0012] S2-2: Take the area formed by forming an acute angle with the vertical direction of the basketball downwards, with the height of the image being h;
[0013] S2-3: parse the hand frame and reshape all human body images in the previous N frames, and record the circumscribed rectangle as bodyn;
[0014] S2-4: extracting a human body circumscribed rectangle that intersects the angle region of S2-2 in the human body image;
[0015] S2-5: Identify the key human node data in all the circumscribed rectangles in S2-4 respectively, obtain the wrist node position and the distance to the basketball position respectively, and use the voting method to determine the pitching player.
[0016] Wherein, the S2 further includes the following steps:
[0017] S2-1: Obtain the position of the basketball and the direction of the basketball shot corresponding to the shot frame obtained in S1;
[0018] S2-2: Take the area formed by forming an acute angle with the vertical direction of the basketball downwards, with the height of the image being h;
[0019] S2-3: parse the hand frame and reshape all human body images in the previous N frames, and record the circumscribed rectangle as bodyn;
[0020] S2-4: extracting a human body circumscribed rectangle that intersects the angle region of S2-2 in the human body image;
[0021] S2-5: Identify the key human node data in all the circumscribed rectangles in S2-4 respectively, obtain the wrist node position and the distance to the basketball position respectively, and use the voting method to determine the pitching player.
[0022] Wherein, the S3 further includes the following steps:
[0023] S3-1: Perform labeling training on the four key points of the three-second zone of the court in two situations: T-shaped and L-shaped, and save the model file;
[0024] S3-2: Preload the model file to identify the rectangular area of the four key points of the three-second zone of the court;
[0025] S3-3: Extract the coordinate positions of four key points in the rectangular area;
[0026] S3-4: Convert the rectangular area coordinates of the four key points into image coordinates.
[0027] Wherein, the S3-3 further includes the steps of:
[0028] Use the Laplace edge detection algorithm to obtain the edge discrete point matrix of the key point image, and then use the Hough line detection algorithm to obtain the k and b coefficient pairs of four straight line equations. Then calculate the midpoint of the quadrilateral surrounded by the four straight line equations, record this midpoint as the midpoint of this key point image, calculate the remaining three key midpoints in turn, and finally get the coordinates of the rectangular area of the four key points.
[0029] Wherein, the S4 further includes the following steps:
[0030] S4-1: Calculating the position coordinates of the player based on the human body key node data and the human body circumscribed rectangle;
[0031] S4-2: Trace back the midpoint of the shooter's feet in the previous M frames, and take the point with the largest y value as the landing point.
[0032] Wherein, the S5 further includes the following steps:
[0033] S5-1: Create a 1400x1500 half-court standard image based on the size of a basketball half-court;
[0034] S5-2: Use the perspective transformation principle to transform the shooting player's position in the image into the position on this standard image;
[0035] S5-3: Obtain the court coordinates of the shooting player based on the mapping relationship between the court coordinates in S5-1 and the pixels of the standard image.
[0036] The S5-3 further comprises the following steps:
[0037] The mapping relationship between the court coordinates and the standard map pixel points , combined with the shooting player's position on the standard map , get the court coordinates of the shooter:
[0038]
[0039] Among them, G is the conversion relationship between the stadium coordinates and the standard map pixel points.
[0040] The implementation of the embodiments of the present invention has the following beneficial effects: the present invention takes the tracking of the basketball trajectory as a prerequisite for determining the shooting action, and does not use the traditional method of tracking the shooting action, which can greatly reduce the amount of computing consumption when multiple people appear in the picture at the same time; in the present invention, the key points of the court take into account the problem of the line width of the court, reducing the error caused by the line width; in addition, the present invention takes into account the situation where both feet are off the ground when calculating the shooting position, and solves the problem of position error caused by jumping. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 Schematic diagram of an area enclosed by an acute angle formed vertically downward with the basketball in the opposite direction of the basketball shot of the present invention;
[0042] Figure 2 is a schematic diagram of a human body circumscribed rectangle of the present invention;
[0043] Figure 3 There are two situations: T-shaped and L-shaped for the four key points of the three-second zone of the court;
[0044] Figure 4 It is a schematic diagram of a T-shaped image;
[0045] Figure 5 It is a schematic diagram of an L-shaped image;
[0046] Figure 6 It is a diagram of the midpoints of the quadrilateral formed by the equations of four lines;
[0047] Figure 7 This is a schematic diagram of a standard basketball half-court size of 1400x1500. DETAILED DESCRIPTION
[0048] In order to make the objectives, technical solutions and advantages of the present invention more clear, the present invention will be described in further detail below with reference to the accompanying drawings.
[0049] A method for obtaining a basketball shooting player's position in an embodiment of the present invention is implemented by the following steps.
[0050] S1: Set up a camera and shooting equipment outside the basketball court to collect shooting training videos, and use the tracing method in a basketball-assisted shooting hit rate statistics method disclosed in Chinese Patent Publication No. CN115171219A to obtain all shot frames.
[0051] The specific steps include:
[0052] S1-1: Set up a camera outside the basketball court, collect shooting training videos and extract each frame image to add it to the recognition queue.
[0053] S1-2: Optimizing small object detection using image segmentation.
[0054] S1-3: Get the image from the S1-1 recognition queue, mark the location of the basketball, the basket, and the moment of the goal, segment the image using the segmentation method of S1-2, and train and save the model using YOLOv5.
[0055] S1-4: Use Zhang Zhengyou calibration method to calculate the camera intrinsic parameter matrix, perspective projection matrix and scale factor respectively.
[0056] S1-5: Use the model of S1-3 to identify the coordinates of the basketball, the basket, and the moment of goal in the segmented sub-images.
[0057] S1-6: Convert the coordinates in S1-5 into large image coordinates and then into three-dimensional coordinates;
[0058] S1-7: Based on the three-dimensional coordinates, the frame number interval of each shooting trajectory is decomposed using the tracing method, where the starting position of the sequence number interval is the shooting frame.
[0059] S2: Get the shooting frame from S1, add one to the count of the player with the smallest distance between his hand and the basketball in each frame before the shooting frame, and record the player with the most occurrences as the shooting player.
[0060] The specific steps include:
[0061] S2-1: From the shot frame obtained in S1, obtain the basketball position and shooting direction corresponding to the shot.
[0062] Get all the shooting trajectory frame number intervals from S1, take the starting frame of an interval as i0, and the basketball pixel coordinates corresponding to the shot are marked as bb0=(bb x0 ,bb y0 ); The next frame is recorded as i1, and the basketball pixel coordinates corresponding to the shot are marked as bb1=(bb x1 ,bb y1 ). The direction of the shot is Dir bb0 =bb1-bb0.
[0063] S2-2: Take the direction opposite to the shot and form an acute angle with the basketball vertically downward, let the image height be h, take the area formed by this angle, refer to Figure 1 Schematic diagram of the area enclosed in the figure.
[0064]
[0065] S2-3: parse the hand frame and trace all the human body images in the previous N frames, and record the circumscribed rectangle as body n ,like Figure 2 The human body is circumscribed in a rectangle as shown.
[0066] The hand frame image obtained from S1 is numbered i, and the circumscribed rectangle of the human image is detected based on the human target detection method of yolov5:
[0067]
[0068] The four sides of the circumscribed rectangle of the human body image are ( bl n ,bt n ,br n ,bb n ).
[0069] Similarly, all the inscribed rectangles in the previous N frames can be traced:
[0070]
[0071] Where m is the frame number, i is the shot frame number corresponding to the shot, bod y (n,m) represents the set of all inscribed rectangles from frame iN to frame i.
[0072] S2-4: From the human body image in S2-3, extract the human body circumscribed rectangle that intersects with the angle region in S2-2.
[0073] Since at the moment the shooter releases the ball, there must be part of the body in the opposite direction of the ball, so the shooting player must intersect with the area in S2-3.
[0074]
[0075] Among them, Area is the area obtained by S2-2, bo dy(n,m) is the set of human body circumscribed rectangles obtained by S2-3, bo dy sub Indicates bo dy(n,m) The intersection with Area.
[0076] Then there is a human body circumscribed rectangle that intersects with the region, which may be the pitcher's human body circumscribed rectangle shootBody It can be expressed as:
[0077]
[0078] in body i (n) is the inscribed rectangle of the nth person in the i-th frame, body sub (n,m)It represents the intersection of the set of all human pixel points and the area formed by S2-2, and B(n) is the set of pixel points of the nth human body. This formula can be understood as taking all the human body circumscribed rectangles that intersect with the S2-3 area in the mth frame.
[0079] S2-5: Identify the key human node data in all the circumscribed rectangles in S2-4 respectively, obtain the wrist node position and the distance to the basketball position respectively, and use the voting method to determine the pitching player.
[0080] Based on the 2D human key point detection algorithm f, the key nodes of the human body are obtained respectively. Let the positions of the two wrist nodes of the a-th player in the m-th frame be w(m,a), and their image coordinates are respectively ( wl x ,wl y )and( wr x , wr y ), let the position of the basketball be ( bb x ,bb y ), then the shortest distance between the wrist node and the basketball can be expressed as:
[0081]
[0082] in, dis (n,a) represents the distance between the wrist node closest to the ball and the basketball.
[0083] Vote for the player with the smallest distance between wrist and basketball in each of the first N frames. The player with the most votes will be the shooter:
[0084]
[0085] Where dis(n,a) represents the distance between the wrist node of player a, closest to the ball, and the basketball in frame m; count represents the method of voting and counting the number of times player a has the shortest wrist-ball distance among all players in frame m (if yes, count is incremented by 1, otherwise, no increment is made); filterMax Represents a method for filtering out the players with the largest number of votes.
[0086] S3: Based on the image recognition method in S1 and using a specific image processing method, the pixel coordinates of four key points in the three-second zone of the court in the image are obtained.
[0087] S3-1: Based on the training and saving model method in S1, the four key points of the three-second zone of the court are respectively arranged in T-shaped and L-shaped conditions (such as Figure 3 Perform annotation training and save the model file.
[0088] S3-2: Preload the S3-1 model file, obtain the video image of the shooting training from S1, and identify the rectangular areas of the four key points in the three-second zone of the court.
[0089] Preload the S3-1 model, obtain the shooting training video image from S1, and use the model for recognition to obtain the rectangular area of the four key points in the three-second zone. Figure 4 As shown), L-shaped images (such as Figure 5 shown).
[0090] S3-3: Use a specific image processing method to extract the coordinate positions of the four key points in the rectangular area.
[0091] The image processing method is performed as follows: the images of the four key points are obtained from S3-2. Taking the T-shaped key point image as an example, the edge discrete point matrix of the key point image is obtained by using the Laplace edge detection algorithm, and then the k and b coefficient pairs of four straight line equations are obtained by using the Hough line detection algorithm. Then, the midpoint of the quadrilateral surrounded by the four straight line equations is calculated, and this midpoint is recorded as the midpoint of this key point image (such as Figure 6 Similarly, calculate the remaining three key midpoints in sequence, and finally get the coordinates of the rectangular area of the four key points.
[0092] S3-4: Convert the rectangular area coordinates of the four key points into image coordinates.
[0093] The image coordinates of the upper left corners of the rectangular area of the four key points are obtained from S3-2. The image coordinates of the upper left corners of the rectangular area of the four key points in S3-3 are added to the image coordinates of their respective upper left corners to obtain the image coordinates of the four key points, which are recorded as:
[0094]
[0095] S4: Calculate the position of the shooter in the image based on the shooter's body node data and circumscribed rectangle obtained in S2.
[0096] S4-1: Calculate the position coordinates of the shooting player using the human body node data and circumscribed rectangle obtained from S2-5.
[0097] From S2-5, we get the human body node data of the basketball shooter, and let the left foot node image coordinates be ( flx,fly ), the image coordinates of the right foot node are ( frx,fry ), take the midpoint image coordinates of the line connecting the two foot node position coordinates ( fcx,fcy ), then the graph fc can be expressed as:
[0098]
[0099] Combined with the lower edge of the circumscribed rectangle bb n y , estimate the height difference between the foot node and the sole:
[0100]
[0101] Then, the midpoint position of the two soles, bf, can be expressed as:
[0102]
[0103] S4-2: According to the tracing method of S2-5, the midpoint position of the sole of the shooting player in the previous M frames is traced back, and the point with the largest y value is taken as the landing point.
[0104] From S2-5, we know that the midpoint of the bottom of the foot of the shooter in the kth frame can be expressed as:
[0105]
[0106] Since the shooter's feet are off the ground at the release frame when the shooting action is a jump shot, it is necessary to use the tracing method to trace back to the position before the jump. According to the tracing method of S2-5, trace back to the midpoint of the shooter's feet in the previous M frames, and take the point with the largest y value (the larger the y value in the image, the lower the position is), and let its image coordinates be ( bp x ,bp y ), record this coordinate point as landing point b p :
[0107]
[0108] Where k is the frame number, and i is the shot frame number. This formula can be understood as traversing the y-values of the midpoints of the shooter's feet between the M frames before the shot frame and the shot frame to form a set, and then taking the midpoint with the largest median value in the set.
[0109] S5: Based on the shooting player position obtained in S4, the player's court coordinates are calculated using the perspective transformation algorithm.
[0110] S5-1: Create a 1400x1500 half-court standard image based on the size of a basketball half-court.
[0111] Create a standard image of 1400x1500 according to the size of a standard basketball half court ( Figure 7 ). Let there be a transformation relationship G between the court coordinate p and the standard image pixel b, which can be expressed as:
[0112]
[0113] S5-2: Use the perspective transformation principle to transform the shooting player’s position in the image into the position on this standard image.
[0114] According to the perspective transformation formula:
[0115]
[0116] Among them, (u,v) is the coordinate of the original image, is the transformation matrix of the coordinates (x, y) in the transformed image, and there is a relationship:
[0117]
[0118] Among them, aH is the 3*3 transformation matrix:
[0119]
[0120] in m 11 、m 12 、 m 13 、m 21 、m 22 、m 23 、m 31 、m 32 、m 33 There are 9 elements in the matrix.
[0121] Substituting the coordinates (x, y) and aH in the transformed image into the above equation yields:
[0122]
[0123] We can also get:
[0124]
[0125] The rectangular area coordinates of the four key points are obtained from S3-4, and the coordinates of the four key points in the 1400*1500 standard map are known:
[0126]
[0127] Substituting these 8 points into the above formula one by one, we can get:
[0128]
[0129] Add constraints:
[0130]
[0131] Solving the above equation gives the transformation matrix aH.
[0132] From S4-2, we know the landing point bp of the shooter and its image coordinates ( bpx,bpy ), let the shooting player’s position on the standard diagram be (b x ,b y ), substitute into the above formula:
[0133]
[0134] S5-3: Obtain the court coordinates of the shooting player based on the mapping relationship between the court coordinates in S5-1 and the pixels of the standard image.
[0135] The mapping relationship between S5-1 court coordinates and standard map pixels , combined with the position of the shooter in the standard diagram obtained by S5-2 , get the court coordinates p of the shooting player:
[0136]
[0137] Among them, G is the conversion relationship between the stadium coordinates defined in S5-1 and the pixel points of the standard map.
[0138] The above disclosure is only a preferred embodiment of the present invention and certainly cannot be used to limit the scope of the present invention. Therefore, equivalent changes made according to the claims of the present invention are still within the scope of the present invention.
Claims
1. A method for obtaining a basketball shooting assisted player position, characterized in that: The following steps are involved: S1: Use a camera to collect shooting training videos and use the tracing method to obtain all shot frames; S2: adding one to the number of players with the smallest distance between their hands and the basketball in each of the N frames preceding the shooting frame, and recording the player with the most occurrences as the shooting player, including the following steps: S2-1: Obtain the position of the basketball and the direction of the basketball shot corresponding to the shot frame obtained in S1; S2-2: Take the area formed by forming an acute angle with the vertical direction of the basketball downwards, with the height of the image being h; S2-3: parse the hand frame and reshape all human body images in the previous N frames, and record the circumscribed rectangle as bodyn; S2-4: extracting a human body circumscribed rectangle that intersects the angle region of S2-2 in the human body image; S2-5: Identify the key human node data in all the inscribed rectangles in S2-4, obtain the distance between the wrist node position and the basketball position, and use the voting method to determine the pitching player; S3: Get the pixel coordinates of the four key points in the three-second zone of the court in the image; S4: Calculate the human body node data and circumscribed rectangle of the basketball shooter and calculate its position in the image, including the following steps: S4-1: Calculating the position coordinates of the player based on the human body key node data and the human body circumscribed rectangle; S4-2: trace back the midpoint of the shooter's foot in the previous M frames, and take the point with the largest y value as the landing point; S5: Based on the shooting player position obtained in S4, the player's court coordinates are calculated using the perspective transformation algorithm.
2. The basketball assist shooting player position acquisition method according to claim 1, characterized in that: The S3 further comprises the following steps: S3-1: Perform labeling training on the four key points of the three-second zone of the court in two situations: T-shaped and L-shaped, and save the model file; S3-2: Preload the model file to identify the rectangular area of the four key points of the three-second zone of the court; S3-3: Extract the coordinate positions of four key points in the rectangular area; S3-4: Convert the rectangular area coordinates of the four key points into image coordinates.
3. The basketball assist shooting player position acquisition method according to claim 2, characterized in that: The S3-3 further comprises the steps of: Use the Laplace edge detection algorithm to obtain the edge discrete point matrix of the key point image, and then use the Hough line detection algorithm to obtain the k and b coefficient pairs of four straight line equations. Then calculate the midpoint of the quadrilateral surrounded by the four straight line equations, record this midpoint as the midpoint of this key point image, calculate the remaining three key midpoints in turn, and finally get the coordinates of the rectangular area of the four key points.
4. The basketball assist shooting player position acquisition method according to claim 1, characterized in that: The S5 further comprises the following steps: S5-1: Create a 1400x1500 half-court standard image based on the size of a basketball half-court; S5-2: Use the perspective transformation principle to transform the shooting player's position in the image into the position on this standard image; S5-3: Obtain the court coordinates of the shooting player based on the mapping relationship between the court coordinates in S5-1 and the pixels of the standard image.
5. The basketball assist shooting player position acquisition method according to claim 4, characterized in that: The following perspective transformation formula is used in S5-2: Among them, (u,v) is the coordinate of the original image, is the transformation matrix of the coordinates (x, y) in the transformed image, and there is a relationship: Among them, aH is the 3*3 transformation matrix: in m 11 、m 12 、 m 13 、m 21 、m 22 、m 23 、m 31 、m 32 、m 33 There are 9 elements in the matrix; The S5-3 further comprises the following steps: The mapping relationship between the court coordinates and the standard map pixel points , combined with the shooting player's position on the standard map , get the court coordinates of the shooter: Among them, G is the conversion relationship between the stadium coordinates and the standard map pixel points. bpx,bpy are the image coordinates of the shooting player.
Citation Information
Patent Citations
Shooting data output method and electronic equipment
CN110942022A
Basketball auxiliary shooting hit rate statistical method
CN115171219A
Automatic generation method and system for defense areas at basketball scoring moment
CN111104851A
Player tracking and holder identification method and device, and storage medium
CN115272918A