Design of Intelligent Assistant System for Billiards Hit Training

Image processing technology has increasing important applications in sports in recent years, such as result prediction, technical analysis, and foul determination. For most billiards beginners, how to hit the billiard ball into the ball belt is not a simple matter. In order to assist the beginners in billiards training, this article proposes an assisted hitting system. The system is divided into three parts: bag detection, billiard detection, and hitting suggestions. In the ball belt detection, double-peak histogram threshold segmentation, edge detection and Hough transform are used to detect the edge line, and then the ball belt position is detected. In billiard ball detection, the normalized RGB method is used to extract the foreground, the Hough transform circle detection method is used to detect the center and radius of the sphere, and the neural network is used to determine the white ball. In the shot suggestion, the force and angle of the shot are given by the dynamic formula, and the path simulation of the ball in the background is given. Experiments show that the recognition method is effective and the path simulation is consistent with reality, which can assist beginners in the training of billiards to a large extent.


Introduction
In recent years, with the advancement of technology, the application scope and value of artificial intelligence in the field of sports have become more and more extensive. In particular, image recognition technology has excellent applications in terms of predicting the outcome of events, technical analysis, and foul determination. Billiards as a sport has a history of more than 600 years and became an indoor game in the 20th century. For beginners, practicing how to hit the ball into the bag is a basic and important process, but for most people, due to the lack of professional guidance from the coach, it is inefficient and laborious to conduct groping training by themselves. Therefore, image recognition technology can greatly assist beginners in the training of playing billiards. The above studies only focus on the identification of the position and number of the billiard balls, and there is no overall design that combines billiard identification and hitting planning. At the same time, for the acquisition of billiards desktop photos, Liu, Gao, etc. need to obtain the entire billiards desktop photos, which is not easy for ordinary users to take pictures. [1] [3] Hsu uses VR eyes to acquire images, and the equipment is relatively expensive. [2] Compared with them, the research in this article has the following advantages: A. Only a smartphone can be used to capture the photos, and the equipment is simple and easy to obtain. B. The analysis of billiards in this article is not only to judge the position, but also to give corresponding hitting suggestions, which is of great help for beginners to improve their billiard skills. C. This article also gives a simulation of the path of the white ball and the ball being hit after hitting the ball.
In order to assist beginners in batting training, this article conducts position detection of billiard balls and ball belts, hitting suggestions and path simulations for desktop photos that beginners can take. The bag detection part is segmented by the bimodal histogram threshold, the edge detection method detects the border of the desktop, and the two boundary lines are detected by Hough, and then the position of the bag is detected. The billiard ball detection part uses the normalized RGB threshold segmentation method to segment the billiard ball and the desktop background, and obtains the boundary and position of the billiard ball through the Hough transform. The actual position of the two balls is determined by the ratio of the photo to the actual ball. The ball is recommended Part of the dynamic equations are used to calculate the strength and angle of the ball, and to simulate the billiard ball trajectory.

Billiard bag detection
In order to detect the position of the billiard bag, the edge detection of the billiard table is the first priority. For the edge detection of the billiard table, the bimodal histogram threshold selection method is used here. As viewed from the top of the billiard table, the billiard table is mainly composed of two parts of brown and green information, and its gray distribution histogram will show two main peaks. Select the gray value T corresponding to the valley point between the peaks as the segmentation boundary, and the image can be divided into two parts.
For each pixel I of the divided binary image, convolve with the operator in the x and y directions, and then the edge image of the billiard table after Sobel edge detection can be obtained.
In order to obtain the equation of the edge line, the Hough transform method is used to detect the straight line. Initialize the H-space iterator ℎ , to zero. For each edge point , represented by polar coordinates, convert it to H-space through equation (1), and add one to the iterator of the corresponding point. Then find the maximum value of the local iterator ℎ , in the H-space, and then map the corresponding ℎ , to the Cartesian coordinate system to obtain two mutually perpendicular straight lines. The intersection of the straight lines is the position of the billiard bag. (1)

Billiards detection
In this chapter, the normalized RGB method is used to preprocess the image. For each pixel Pi in the image, due to the different proportion of illumination, the size of the three components of R, G, and B will have an impact, but the proportion of each component in the total value remains unchanged. Therefore, according to equation (2) to extract the proportion of each component. ( Since the billiard background desktop is green, the distribution of r/g and b/g in any pixel pi in the background is within a certain range. It is similar to extracting the frequency distribution histogram through the gray image in the edge detection of billiards desktop, here the frequency distribution histogram is obtained by r/g and b/g. For this frequency distribution, it is similar to the Gaussian distribution. The higher the value, the higher the frequency. [1] Assuming the mean and standard deviation of the histogram of frequency distribution are respectively , , , , and are precision coefficients to better distinguish the foreground and background. For the equation (3) is the background, outside the range is the foreground. The binary image is obtained by threshold segmentation, and then the edge billiard ball image can be obtained by Sobel edge detection.
In order to detect the circle on the boundary image, this chapter uses the Hough transform method to detect the circle. Equation for circle: (4) , are the position coordinates of the orthographic projection of the corresponding billiard ball center on the desktop relative to the bag, and is the billiard ball radius. In the Hough transform method of detecting circles, any circle in the x-y space corresponds to a point , , in the three-dimensional space. For the entire image, any points on the circle in the x-y space correspond to curves in the ab-r space that intersect at one point. Therefore, any point on the binary image obtained by edge detection can be mapped into a curve in a-b-r space. Define , , as the intensity at , , in the a-b-r threedimensional space. For a curve passing through this position, , , will increase by one for each curve passing through. After the final mapping is completed, look for the local maximum point of , , , which is mapped to the x-y space to be the corresponding detected circle, and finally the position of the billiard ball in the picture is , and the radius .
Here, a convolutional neural network is used to determine which ball is a white ball. For a billiard photo, the three colors spaces of RGB, HSV, and LAB are obtained as the input layer, and whether it is a white ball as the output layer for training. Randomly select pixels within the range of the billiard ball. If most of them are considered to be white balls, the ball is judged to be a white ball.

Advice on hitting billiards
The position of the billiard ball and the judgment of the white ball have already been given in the previous article. Therefore, the motion trajectory of the billiard ball is simulated by the dynamic equation, and the billiard ball hitting advice is given.
1. The determination of hitting white ball Assuming that the initial speed of the white ball after hitting the ball is , the speed at the moment of the collision is , the speed of the hit ball after the collision is , and the speed of the white ball is . The distance from the hit to the ball belt is , The distance between the white ball and the target position is , μ is the sliding friction factor. In order to prevent the ball from being hit at too high speed and bounce back by the outer edge of the ball belt, take it here (6) Therefore, the velocity when the white ball collides is (7) The hitter exerts an impulse on the billiard ball to obtain the speed and angular velocity of the billiard ball. For the different heights of the billiard ball that the hitter hits, the billiard ball will have a corresponding angular velocity, which will affect the trajectory of the white ball after the collision. When the two balls collide, the center of mass velocity is exchanged, and the angular velocity remains unchanged, which can be regarded as a completely inelastic collision. After the collision, the directions of the two balls are perpendicular to each other, assuming that the direction along is , the direction along is . For the billiard ball from the direction after the collision, the time required to enter the pure rolling state is , when the billiard ball in the direction enters the pure rolling state ,the required time is . [4] (10) For the photographed image, firstly convert it into a grayscale image, and then perform threshold segmentation through the bimodal histogram method to obtain image. Then Sobel performs edge detection on the obtained binary image, and then passes Hough transform method of detecting straight lines can obtain two boundary straight lines, and the intersection point is the position of the bag.

Conclusion
The focus of this paper is to design a system that can automatically identify billiard balls and their positions, and can assist beginners in batting training. The important conclusions are summarized as follows: A. The inner edge of the billiard table is detected by the double-peak histogram gray threshold selection method and the Hough transform method of detecting straight lines, and the position of the ball bag is further detected. B. The normalized RGB method is used to extract the part of the billiard ball on the desktop, and the radius and position of the billiard ball are detected by the Hough transform method. C. According to the position of the billiard ball and the bag, the kinematics equations are used to give suggestions for beginners on the strength and direction of the ball, and the path of the ball is simulated. In our future work, we need to detect more balls, and give the entire tabletop hitting strategy as much as possible, so as to better assist billiard players in billiards training.