SUGISAKAMASANORI

Journal of Advances in Artificial Life Robotics
Vol. 4(1); June (2023), pp. 27–34
ON LINE ISSN 2435-8061; ISSN-L 2435-8061
https://alife-robotics.org/jallr.html

Research Article

Embedded Ball Launcher with Trajectory Path Analysis for
Empowering Junior Table Tennis Players
Mastaneh Mokayef, M.K.A Ahamed Khan, MHD Amen Summakieh, Lee Qi Jian, Miad Mokayef
Faculty of Engineering Technology and Built Environment, UCSI University, Kuala Lumpur, 56000, Malaysia

ARTICLE INFO
Article History
Received 15 December 2022
Accepted 04 September 2023
Keywords
Table tennis launcher
Trajectory path
Performance analysis
Ball recognition

ABSTRACTOne of the most popular sports in Asia is Table Tennis, it requires close supervision from a coachto assess the player's strengths and weaknesses. To address this need, a personal Table Tennis
trainer in the form of a pitcher machine has been developed. The machine analyzes the player's
practical performance by examining the trajectory path of the ball. The system incorporates acamera that tracks the movement of the table tennis ball. Images captured by the camera areprocessed using OpenCV software, enabling the prediction of the ball's flying trajectory based on
its X and Y coordinates. This analysis allows for an evaluation of the player's performance indifferent directions. By utilizing a smartphone, the pitcher machine can be adjusted to target thedirection where the player's performance is weak, thereby providing additional practice in thatspecific area. Although the proposed system does not currently include spinning serves, it offersa suitable platform for early-stage table tennis training. Experimental results demonstrate thesystem's ability to perform acceptable performance analysis in complex and clutteredenvironments.

© 2022 The Author. Published by Sugisaka Masanori at ALife Robotics Corporation Ltd.
This is an open access article distributed under the CC BY-NC 4.0 license(http://creativecommons.org/licenses/by-nc/4.0/).

sensors, in [10]. Researchers have also explored theprediction of a spinning ball's trajectory in [11] tounderstand its physical behavior. Various other methods
for predicting and generating trajectories have been
discussed and proposed [12], [13], [14]. In this particularpaper, we propose, design, and create a table tennis
launcher and performance analyzer. Our motivation
behind this work is to enhance the training experience forsolo ping pong players by analyzing the trajectory pathand helping them practice more in the direction where
they struggle. Moreover, the proposed Embedded Ball
Launcher offers a training experience that can bepersonalized by players and coaches. They have theability to adjust launch parameters such as ball speed,
spin, and trajectory, allowing them to create training
scenarios that are specifically designed for their skill
levels and training goals. The system can also be
programmed to simulate different opponents, match

1. Introduction
Table Tennis, a beloved physical activity enjoyed bymany, involves two or four players taking turns hitting aball. Just like any other sport, coaching plays a crucialrole in a player's performance, both before and during
competitions. Researchers have conducted several
studies to improve the performance of ping pong players.
They have integrated sensors and devices to analyze
various aspects of athletes' performance, such as gender,
fitness, blood lactate level and mental health [1], [2], [3],[4], [5], [6]. Additionally, thanks to rapid advancements
in technology and robotics, table tennis robots have beencreated. These robots are designed to generate andoptimize the ball's trajectory over time [2], [7], [8], [9].
An exciting development in this field is the introductionof an aggressive trajectory generator, controlled by

Corresponding author’s E-mail: mastaneh@ucsiuniversity.edu.my, URL: https://www.ucsiuniversity.edu.my/27

reach and maneuver. As the motor turns, the propellershaped disk holding the balls rotates, positioning them on
the shooting track. The speed of the motor can becontrolled to adjust the shooting speed. The ping pongballs travel from the propeller-shaped disc in the hopper
to the first horizontal track. To provide shooting indifferent directions, a second track is connected to thefirst track at a 30-degree angle. The prototype's side, front,
and top views can be seen in Fig.1.

conditions, and playing styles, providing a versatile anddynamic training environment. Finally, a bright future forthe ping pong ball launchers and trajectory path analyzers
can be predicted by implementing the real time feedback
and coaching during the training sessions, utilizing
Virtual Reality (VR) and Augmented Reality (AR), andthe integration of the smart portable ball launchers withsmart watches or any other wearable devices.
2. Hardware Architecture and Experimental
Setup
Computer stereovision system. Stereovision system is theextraction of 3D data from computerized pictures, forexample, those got by a CCD (Charged Couple Device)
camera. By looking at data about a scene from two
vantage focuses, 3D data can be separated by analysing
the general places of articles in the two boards. CCDs are
sensors utilized in advanced cameras and camcorders torecord still and moving pictures. The CCD catches lightand changes over it to computerized information that isrecorded by the camera. Thus, a CCD is frequently
viewed as the computerized adaptation of film. The
proposed embedded Table Tennis ball launcher withtrajectory path analyser design is based on the operationof a ball launcher attached at the end of the table tennis
table and the camera attached to the laptop beside thetable for path analysis. The various hardware elements ofa ping pong ball pitching machine collaborate to launch
the ball with precision and desired attributes. The specificcomponents employed in this project are ball hopper
stores that supply the balls to the machine. Stepper motor
is also employed to ensure accurate control over speed
and position. Finally, the control system of the pitchingmachine that consists of microcontrollers, circuit boards,
and related electronics. The entire launching system is
supported by a sturdy wooden frame stand, which acts as
the backbone of the system and ensures stability. One of
the key components is the actuator mechanism,
responsible for accurately shooting one ball at a time
when triggered. To achieve this, the ball container used
is a modified basket made from plastic. This basket has adisc with half-circle-shaped holders for the balls, which
is attached to a motor. The motor and disc combination
allows the launcher to rotate a full 360 degrees. A hole is
specially created at the bottom of the basket for a long
handlebar to be attached. Additionally, a second
handlebar, shorter than the first one, with some flexibility
is connected to the longer handlebar, making it easier toFig. 1. The (a) Side, (b) Front, (c) Top Views (d) Top View
while the Balls are Preparing to launch

In order to adhere to cost limitations and align with the
Sustainable Development Goals (SDGs), the proposed
prototype utilizes entirely recycled materials. the first andmost important step is to find and keep an eye on the ball.
To make sure we accurately detect the ball, we need totake some extra steps. One of these steps involves
converting the way we represent colors from RGB to
HSV. RGB is a color model commonly used in digital
displays and cameras, but it doesn't directly match howhumans perceive colors. HSV, on the other hand, is acolor model that better aligns with human perception. It
separates color information from brightness information,
making it easier to describe colors in a way that
resembles how our eyes see them. By converting the
RGB color representation to HSV, we can describe colors
in terms of hue, saturation, and value. Hue represents theactual color, saturation represents the intensity orvividness of the color, and value represents the brightness.
This allows us to capture the important color
characteristics of the ball in a more human-friendly way.
To achieve accurate ball detection, we have used either
manual tracking or detection-free trackers from the
OpenCV library. Manual tracking involves manuallyfollowing the ball's movement, while detection-freetrackers are algorithms that can track objects without
explicit detection. Both approaches have been employed28

impact on the analysis being performed. Hence, themeasurements of the contour area have been set up as
shown in Fig. 3.

to ensure that the ball is effectively identified and tracked
throughout the project. When estimating the trajectory ofa ping pong ball using OpenCV, there are typically two
main steps to follow: ball detection and ball tracking. In
ball detection, the system identifies the presence andlocation of the ball in each frame of the video or image.
Then, in ball tracking, the system continuously tracks theball's movement across subsequent frames, allowing forthe estimation of its trajectory over time. The trackbarPos
code is employed to filter the desired results. This code
facilitates the creation of a trackbar, which provides auser interface element for adjusting the required HSVlevels. By using the trackbar, one can easily modify the
HSV values to achieve the desired outcome. Fig. 2 shows
the outcome of altering the image threshold in runtime
from track bar code.

Fig. 3. Contour Area Measurements

When it comes to real world scenarios there are methods
to determine the location of a ping pong ball. In our
project we have devised an equation that allows us toaccurately measure and identify the balls position byusing the counter area as a point of reference. Thisequation serves as a tool in determining the balls positionon the table during gameplay and it is shown in Eq. (1):𝑦𝑦 = −4.963453 +5296.735 + 4.963453
0.4415413 . (1)
𝑥𝑥
�
1 + �
0.09193972

To accomplish this, the camera is positioned in astationary manner, and the distance between the camera
and the contour area is measured and recorded in an
Excel spreadsheet. Eq. (1) is derived by utilizing Excel
functions and Python code to estimate the separation
distance. Fig. 4 shows a plot of the trendline between thearea and the distance of the contour.

Fig. 2. TrackbarPos HSV Level Adjustment

The general overview of the steps involved in the processof ball tracking is as follows: in the first step, wetransform the image into black and white by convertingit to grayscale, and implement any required
preprocessing methods like blurring or thresholding to
improve the identification of outlines. Then we detect all
the contours involved in the image for the further use in
the image processing which is elimination of those
contours that meet the criteria specific to our Ping-Pongball such as size, circularity, and the color. Once thecontours are detected, it’s time to calculate the contour
area in square pixel. The last step is to monitor the
behavior of the Ping-Pong ball through accumulation ofcollected contour areas.
While color-based object detection offers several benefits,
it also has its limitations. One notable limitation is thepossibility of background tracking interruption. Thisoccurs when the tracking of the ping pong ball iscompromised because the background color closely
resembles the color of the ball. Consequently, thisinterruption can considerably decrease the accuracy ofthe detection process and consequently have a significant

Fig. 4. The Trendline Between Area and Distance of Contour

A physical measurement has been conducted to test thecontour measurement function using OpenCv and themeasurement accuracy as illustrated in Fig. 5. The
comparison indicates that the achieved accuracy is
acceptable and meets the desired standards.

29

𝑑𝑑𝑑𝑑𝑑𝑑𝑑𝑑 =𝜕𝜕2 𝑠𝑠𝑠𝑠𝑠𝑠
𝑑𝑑𝑑𝑑 2+𝜕𝜕2 𝑠𝑠𝑠𝑠𝑠𝑠
𝑑𝑑𝑑𝑑 2.

(2)where dest is the destination image and src is a source
image. In this project, we extract the HSV value of thesource image by using the OpenCV trackbar and apply
filtering techniques. We create a specialized mask that isdesigned to detect the color of the ball, specifically anorange ball mask in this case. By analyzing the contours
within the mask, we identify the largest contour, whichcorresponds to the ping pong ball.
To determine whether the ball has been hit or not, we
examine the y-coordinate value. If the y-coordinate is
negative, it indicates that the ball has been shot towards
the player. Conversely, if the y-coordinate becomes
positive, it indicates that the player has successfully hit
the ball back, causing the trajectory path to change
direction.The y-coordinate value result is shown in Fig.
6.

Fig. 5. Distance Measurement Accuracy Check

We have validated the accuracy of our results bycomparing physical measurements taken with a ruler tovirtual measurements obtained using OpenCV. To
effectively store and track the ball movement at various
points, we employ a deque datatype in Python, whichallows us to save each tracked point. This enables us tocreate longer trajectory paths and maintain a history ofpoints, represented as f(x,y). This comprehensive
tracking approach ensures that we capture the complete
movement of the ball. To ensure the ball is presented in
the most suitable manner for analysis and simulation, theframes are processed and resized to achieve the optimalheight and width. This ensures that the representation of
the moving ball is suitable for further analysis andaccurate simulation. Moving on, we utilize image
blurring or smoothing techniques to enhance the qualityof the detected ball image. Specifically, we apply aGaussian blur filter, which involves convolving theimage with a Low Pass Filter (LPF) Gaussian kernel.
This process effectively reduces noise in the image,resulting in a clearer and more refined appearance of theball. This step enhances the accuracy of our analysis andtracking procedures. To gain an understanding of the
intricacies within an image we can employ the blurtechnique to calculate the Laplacian. This method
involves examining the intensity gradient at each pixel
using the Sobel operator. By applying a Gaussian blur tothe image we effectively eliminate any noise or
irregularities that may be present. This process ofsmoothing allows, for calculations of the gradientresulting in a clearer and more accurate depiction of how
the images intensity changes. In terms employing
Gaussian blur helps us refine image quality and extract
details for further analysis. Therefore, at the same
location (x,y), the computed response is stored in thedestination image and is calculated by: Eq. (2)Fig. 6. Calculation of the Trajectory Path Based on Ycoordinate Values

To evaluate how well a player is doing, we can look at
the Y-coordinate of the ball's movement. By examining
both the coordinates of the ball's path X and Y, we canget a sense of the player's skill level. In particular, we
focus on the Y-coordinate values when they reach 150.
The player struggled to respond to the ball, indicating aweak performance if the overall value is negative. In
these cases, the trainer steps in and uses a machine pitcher
to launch the ball towards where the player haddifficulties. The pitcher machine allows for controlled
launches of the ping pong ball, and the direction can be
adjusted by the coach, trainer, or even by the player.
To simplify things, an infrared (IR) remote control isused to operate the pitcher machine, making it easy tocontrol and make adjustments. Additionally, thetrajectory of the ball is tracked and visually displayed,providing valuable insights into the player's playing style.
This tracking and visualization process allows forcontinuous monitoring and analysis of the player's

30acknowledge the significance of accurately detecting andtracking multiple balls, even when they are overlapping,as this is a common occurrence in real-world situations.
In this regard, we propose the object separation
segmentation technique to avoid or minimize theoverlapping problem. By utilizing segmentation
algorithms, we can effectively separate and segment
overlapping objects based on their unique visualcharacteristics. These algorithms can accurately
distinguish between the objects, even when they areoverlapping. Additionally, if depth information isavailable, it can be leveraged to further enhance theaccuracy of the segmentation process.
We have then created an additional Python file dedicatedto drawing the trajectory and facilitating the movementof the ping-pong ball. To enhance the accuracy of balldetection, we have implemented a rule that allows only
one ball to be counted at any given time. For example, if
there are multiple ping pong balls detected on the screen,
we consider the ball with the larger radius as the mainball. This selected ball is then chosen for further analysis
and tracking. By adopting this approach, we ensure amore precise and dependable ball detection process,contributing to the overall accuracy and reliability of thesystem. Object overlap has been implemented and thecorresponding tracking failure is shown in Fig. 8. Autoselection of the ball and tracking of a single object at atime is demonstrated in Fig. 9. In order to ensure accurateball detection, particularly in crowded environments,
several components have been integrated into the screen
setup. These additional elements have been carefully
implemented to enhance the system's ability to detect andtrack balls effectively, even in challenging scenarios withnumerous objects present. By incorporating theseelements, we aim to improve the accuracy and reliabilityof the ball detection process, ensuring optimal
performance in crowded environments.

performance, helping to identify areas for improvement
and enhance overall gameplay.
3. Results and Discussion
In order to analyze the results, this paper includes a preprocessing step called image thresholding. This
technique is used to remove unnecessary parts of theimage, allowing the representation of the ping pong ball
to be more accurate. Image thresholding is a simple
method of segmenting an image by dividing it to black
and white, these two groups represent the backgroundand the foreground respectively. In this project, manual
selection of the threshold is done. Any regions in theimage with a saturation level above the chosen threshold
are converted to white, while the remaining regions are
kept as black. This helps to isolate and highlight the pingpong ball in the image for further analysis. Fig. 7 shows
the threshold selection result for both background,foreground and the level adjustment.
In this project, object overlapping scenario is regarded asa false condition. The object overlapping scenario occurs
when multiple objects or regions of interest in an image
overlap or intersect with each other.

Fig. 7. Threshold Value Selection for (a)Background/Foreground, (b) Level Adjustment from 0 to 255

This situation can arise when objects are in close
proximity to each other or when their boundaries overlap
due to factors like complex shapes or occlusions. Whenobjects overlap, it presents a significant challenge to
track them individually over time, particularly when theobjects experience occlusions or undergo significant
shape changes during the tracking process. The balldetection process struggles to precisely identify and track
individual balls under such circumstances. As aconsequence, we exclude any instances where balls
overlap from our analysis and do not incorporate them inthe final results.
However, it is crucial for us to address the challenge ofball tracking in scenarios where balls overlap. We

31

Moreover, Due to using HSV value for tracking the pingpong ball, the balance of the light condition is important.
Fig. 11 shows that the light conditions are brighter on left
side. Therefore, when the ball is shooting with pitcher
machine, webcam still able to detect the location of pingpong ball, but when the ping pong ball went into brighter
place it will lose the target, due to the light change thecolour on ping pong ball surface.
Fig. 8. Objects Overlap Causing Tracking Failure

Fig. 9. Object Detection in a Crowded Area with Presence of
Two Balls

Fig. 11. Missing Ball in Bright Side

Color-based object detection, despite its advantages, has
certain limitations. One such limitation is the potential
interruption in background tracking, whereby thesimilarity between the background color and the pingpong ball will cause the ping pong ball tracking to be lost.
The analysis will be affected dramatically due to the
reduced accuracy. Fig. 10 is proof of the tracking
interruption due to the similarity of the background andthe ball. As illustrated in Fig. 10, the tracking of theyellow ping pong ball is lost at the moment the passes by
the container with similar background color. This issue isconsidered in this project and object detection
enhancement will be tackled in our future work.

4. Conclusion
A special table tennis launcher has been created to help
train players by analyzing their performance in real-timeusing ball tracking technology. The launcher consists ofa modified basket with a servo motor underneath, whichrotates to shoot the balls onto the table tennis board.
Segmentation based on color is used in this system todetect the ping pong ball. Once the segmentation iscomplete, various factors like ball shape, location, andmotion are taken into account to evaluate the player's
performance.
The ping pong ball tracking is achieved using OpenCV
software. The performance of the player is then assessedby calculating the trajectory path at every point
depending on the distance the ball travels. This analysis
allows for the identification of weaknesses in the player's
performance. To address these weaknesses, a smart table
tennis trainer utilizes a machine pitcher to launch pingpong balls specifically towards the areas that the player
struggled in. This targeted practice helps the player
improve their performance in that specific direction.
Additionally, the system enables ongoing monitoring of
the player's weaknesses and overall enhancement of theirFig. 10. Color Similarity with the Background Causing
Tracking Interruption

32

13. Andersson, Russell L. "Aggressive trajectory generator fora robot ping-pong player." IEEE Control Systems
Magazine 9.2 (1989): 15-21.
14. Huang, Yanlong, et al. "Trajectory prediction of spinningball for ping-pong player robot." 2011 IEEE/RSJ
International Conference on Intelligent Robots andSystems. IEEE, 2011.

performance. In a nutshell, The Embedded Ball Launcher
with Trajectory Path Analysis offers a wide range ofadvantages. It enables an objective and measurable
evaluation of a player's performance, facilitating focusedskill improvement and precise technique enhancement.
Additionally, the system allows players to analyze andcomprehend the effects of various shot parameters on ball
trajectory, promoting strategic decision-making andadaptability in real-game scenarios.

Authors Introduction
Dr. Mastaneh Mokayef
She completed her doctoral studies atthe Wireless Communication Centre
in the Faculty of ElectricalEngineering at the University
Technology
Malaysia(UTM).
Additionally, she earned her master's
degree from the engineering facultyat the same university. Since 2017,she has been a member of the Boardof Engineers Malaysia (BEM). She
has been working at UCSI University in Malaysia since2015, currently holding the position of Assistant Professor
in the Faculty of Engineering and Built Environment(FETBE). Her research focuses on various areas including
wireless communications, spectrum-sharing methods,
spectrum management, cellular communication systems,
and antenna design. Furthermore, she has been recognized
as a Chartered Engineer (C.Eng.) by the UK Engineering
Council.

References
1. Arnold Baca (2006) Innovative diagnostic methods inelite sport., International Journal of Performance Analysis
inSport, 6:2, 148156, DOI: 10.1080/24748668.2006.11868380
2. Z. Zhang, D. Xu and M. Tan, "Visual Measurement andPrediction of Ball Trajectory for Table Tennis Robot,"in IEEE Transactions on Instrumentation andMeasurement, vol. 59, no. 12, pp. 3195-3205, Dec. 2010,
doi: 10.1109/TIM.2010.2047128.
3. Pradas, Francisco, et al. "Analysis of Specific PhysicalFitness in High-Level Table Tennis Players—Sex
Differences." International Journal of Environmental
Research and Public Health 19.9 (2022): 5119.
4. Picabea, Jon Mikel, Jesús Cámara, and Javier Yanci.
"Physical fitness profiling of national category table tennis
players: Implication for health and performance."
International Journal of Environmental Research andPublic Health 18.17 (2021): 9362.
5. Mokayef, Miad, Mehrzad Moghadasi, and Reza Nuri.
"Effect of cold water immersion on blood lactate levels oftable tennis players." Int. J. Curr. Res. Aca. Rev 2.9(2014): 115-123.
6. L. Acosta, J. J. Rodrigo, J. A. Mendez, G. N. Marichal, and
M. Sigut, “Ping-pong player prototype,” IEEE Robot.
Autom. Mag., vol. 10, no. 4, pp. 44–52, Dec. 2003.
7. Yang, Luo, et al. "Ball motion control in the table tennis
robot system using time-series deep reinforcement
learning." IEEE Access 9 (2021): 99816-99827.
8. Zhao, Hongtu, and Fu Hao. "Target tracking algorithm fortable tennis using machine vision." Journal of Healthcare
Engineering 2021 (2021).
9. Zhang, Bo, Bingqiang Chen, and Yansong Deng. "Robotarm trajectory planning study for a table tennis robot." E3S
Web of Conferences. Vol. 260. EDP Sciences, 2021.
10. Cong, Vo Duy. "Real-time measurement and prediction ofball trajectory for ping-pong robot." 2020 5th International
Conference on Green Technology and Sustainable
Development (GTSD). IEEE, 2020.
11. Wang, Yilei, and Ling Wang. "Machine Vision-Based
Ping Pong Ball Rotation Trajectory Tracking Algorithm."Computational Intelligence and Neuroscience 2022 (2022).
12. Wang, Y. "Path trajectory prediction of rapidly rotatedping pong ball after hitting." The International Journal ofMultiphysics 13.4 (2019): 351-360.

Dr. M. KA. Ahamed Khan
He completed his undergraduate
degreeinElectronics
andCommunication Engineering andpostgraduate degree in Electronics
and Control Engineering in India.
Additionally, he obtained anadvanced diploma in PowerElectronics and Drives from LucasNuelle in Germany in 2002, and a
Diploma in Drives and Controls from Woo Sun in Korea
in 2014. He pursued a PhD in Robotics, Power Electronics,
and Controls in the United States and holds certifications
as a Professional Engineer (PEng) in the USA and aChartered Engineer (CEng) in the UK. He is a Senior
member of the IEEE in the USA and a member of MIETin the UK.
Mr. MHD Amen Summakieh
He received his degree incommunication and electronics
engineering from UCSI University,
Malaysia, in 2016. The M.Eng.Sc.
Degree from Multimedia University,
Malaysia, in 2020. His researchinterests include, user association,antennas design, and metaheuristic
algorithms.

33

Mr. Lee Qi Jian

Mr. Miad Mokayef

He received the B.Eng. degree(Hons.) in communication andelectronics engineering from UCSI
University, Malaysia, in 2020.

He currently serves as the Head
Coach of the Iranian Table Tennis
National Team. He obtained his
master's degree in Sport and Exercise
Physiology from the Science andResearch University in Iran.

34