Vision - Based in Line Follow Robot
Vision - Based in Line Follow Robot
Abstract — Line following robot is one of the popular robots camera as the main component to be able to move
commonly used for educational purposes. The most widely used autonomously. Visual-based robot movements have become
sensors for the robots are photoelectric sensors. However, it is a research trend in the field of robotics. The visual
irrelevant, along with the development of autonomous vehicles representation of the environment that is similar to reality is
and robotic vision. Robotic vision is a robot that can obtain
information through image processing by the camera. The
an essential part of image-based control [13]. It is processed
camera installed on the line following robot aims to detect as feedback to move the robot from the starting point to the
image-based lines and to navigate the robot to follow the path. destination point. In the paper, the camera is utilized as a
This paper proposed a method of image preprocessing along sensor to detect the path or line that will be traversed by the
with its robot action for line-following robots. This includes robot. The robot will follow the relative position of black and
image preprocessing such as dilation, erosion, Gaussian white processed-image.
filtering, contour search, and centerline definition to detect path Webots simulator is a simulator of a virtual environment
lines and to determine the proper robot action. The that can be used as a robotic vision simulator [14][15]. This
implementation of the robot is simulated using Webots paper will also use the Webots simulator virtual environment
simulator. OpenCV and Python are utilized to design line
detection systems and robot movements. The simulation result
with KepheraIV as line following robot. OpenCV will be used
shows that the method is implemented properly, and the robot for image processing of robotic cameras.
can follow a different type of path lines such as zigzag, dotted, The control system of the camera robot has an important
and curved line. The resolution of the cropped-image frame is role in the application of image-based autonomous robot
the fundamental parameter in detecting path lines. motion systems [16]. Image-based systems can provide
detailed information related to the environment and
Keywords—Webots, line-following, robot, OpenCV, vision navigation that obtained by image processing.
I. I NTRODUCTION There were some researches related to the line following
robots, such as one that is conducted by Li-Hong Juang et al.
Rapid advances in robotics make robots to be able to do [17]. They aimed to get visual navigation for humanoid
some specific tasks such as monitoring [1], delivering goods robots. Their proposed method was a square searching to
[2], football [3][4][5], sorting fruit based on the type of fruit extract lines from line images. The method not only improves
or the fruit color, or automatic watering plants [6]. Another the navigation performance of NAO robots in real-time but
kind of robot which is line following robot is one of the also increases the accuracy of detecting lines. The robot can
popular robots commonly used for educational purposes [7]. walk along with different line shapes with low deviations
Line-following robots are popular to be used as an using PID control.
introduction for students on how to program the robot in a Visual based line detection was also studied by Jianye et
computer moving in a specific direction or with controlled al. [18] using multiple line detection algorithm based on pixel
speed. histogram. Lines are the bird view to obtain bend pixels and
Line following robots are robots that can follow or track ignore horizontal lines that intersect each other. Image-based
particular lines autonomously. The most commonly used robot control was also carried out by Chun et al. [19], who
sensors for the robots are photoelectric sensors such as proposed the IP camera and MATLAB toolbox as image
photodiode [8] or light-dependent resistors (LDR) [9]. processing to detect black lines. The cascade intelligent
However, photoelectric sensors are no longer relevant to control system is also used to stabilize the robot and to
be used for advanced line following robots along with the achieve the desired tracking performances.
development of autonomous vehicles. Photoelectric sensors The following line robots also had a task as assistant
have some tricky limitations. The basic design of the robots, such as one conducted by Abdul Kader et al. [20] to
photoelectric sensor for detecting lines is profoundly affected deliver particular objects. This robot uses the PID controller
by external or additional lights, hard to recognize varying and infrared to detect paths [21][22]. Line following robots
colors and minimal distance range of senses. using artificial neural networks proposed by Roy et al. [23]
Some modified-designs of photoelectric sensors for line based on infrared sensors. The robot can follow the curve path
following have been proposed. However, it is only suitable smoothly. Besides Arduino [24][25], line-following robots
for specific conditions [10][11]. Along with the era of robotic can also use the microcontroller ATMega32A [26][27] and
vision, optical cameras are now considered as the alternative ATMega328 Pro [28].
use for line following robots [12]. The first section of the paper is about the introduction. The
This paper proposed an image processing method and its second section is about modeling a mobile robot. The third
implementation to the line following robot. The robot has a section discusses the proposed method. The fourth section is
978-1-7281-9434-9/20/$31.00
Authorized ©2020
licensed use limited to: Auckland University IEEE
of Technology. 24 on December 23,2020 at 06:02:14 UTC from IEEE Xplore. Restrictions apply.
Downloaded
about results and discussion. The last section is conclusions Meanwhile, the binary image dilation equation can be
and future work. written as (4), where 𝐴𝑏 is the translation of 𝐴 with respect to
II. P ROPOSED M ETHOD 𝑏, 𝐴 is a binary image, and 𝐵 is an element of the Euclidean
The research used Python 3.7 and OpenCV 4 to build the distance.
visual simulation of KheperaIV as a line following robot. The 𝐴 ⊕ 𝐵 = ⋃ 𝐴𝑏 (4)
proposed method consists of three main steps, which are 𝑏∈𝐵
initialization, image processing, and robot action.
The result of the dilation and erosion process is the result
Initialization is done based on parameters of the robot and
of image preprocessing. The data will get into image
the environment, such as the camera selection and the
processing steps. After the dilation and erosion process, the
generated path line. In other words, initialization is done to
contour values will be determined. In other words, this is the
define each parameter used in the simulation, including the
process to find and to detect the edge contour of any shapes
robot's and virtual environment parameters.
found in the image. The contour values are used as a curve
In image preprocessing, the image of the path line is
that connects all continuous points, which has the same color
captured by the robot's camera. The image is used as an input
and light intensity.
and then cropped to a specific width and length of the frame.
These data will be processed in further image processing
After that, the image which is still in RGB color, is converted
steps to obtain the parameter of the centerline point, which
into a greyscale image.
will determine the robot action or movement. The equation
The RGB image is converted into greyscale by using (1),
used to find the central or centroid line equation with
where variable 𝑅𝑒𝑑 is the red value, variable 𝐺𝑟𝑒𝑒𝑛 is the
375×752 resolution can be written as (5) and (6).
green value, and the variable 𝐵𝑙𝑢𝑒 is the blue value of each
pixel. The result is shown in Figure 1. 𝑚𝑗𝑖 = ∑(𝑎𝑟𝑟𝑎𝑦(𝑥, 𝑦) ∙ (𝑥 − 𝑥̅ ) 𝑗 ∙ (𝑦 − 𝑦̅)𝑖 (5)
𝐺𝑟𝑎𝑦 = 0.3 ∗ 𝑅𝑒𝑑 + 0.59 ∗ 𝐺𝑟𝑒𝑒𝑛 + 0.11 ∗ 𝐵𝑙𝑢𝑒 (1) 𝑥,𝑦
The next step is to reduce the noise found in the image. 𝑚01 𝑚01
Gaussian blur filtering is used for blurring in image
𝑥̅ = , 𝑦̅ = (6)
𝑚00 𝑚00
preprocessing. It creates the autofocus effect by reducing Where 𝑥̅ and 𝑦̅ are center of 𝑥-axis and center of 𝑦-axis
details and adding the foggy effect.
respectively, 𝑚𝑗𝑖 is the central momentum. The result of the
The equation of Gaussian filtering can be written as (2),
where variable 𝜎 is the standard deviation. The result of process is shown in Figure 4.
image preprocessing based on the applied 2-dimensional The simulation in Webots displays KepheraIV as the
robot, the black-colored line as the path to be followed by the
Gaussian filter equation is shown in Figure 2.
robot, and the camera display as the robot vision of the
1 𝑥2+ 𝑦2
𝐺=
−
𝑒 2𝜎 2 (2) environment. The robot vision and the line detection
2𝜋𝜎 2 algorithm are shown in Figure 5 and Figure 6.
Then, the grayscale image is converted into binary form. Based on Figure 6, robot action is the robot movement,
The binary threshold is used for segmentation so that the such as move forward, turn left, turn right, and turn around as
robot's path line can be obtained from a black and white the response to detected lines based on the result of the image
image. The result is shown in Figure 3.
The next step is the dilation and erosion process. Dilation
is the process of adding pixels to the edges of objects in the
image, while erosion is the process of removing pixels. The
equation of the erosion process is shown as (3). (a)
𝐴 ⊖ 𝐵 = {𝑧 ∈ 𝐸|𝐵𝑧 ⊆ 𝐴 (3)
Where 𝐵𝑧 is 𝐵 translation of the vector 𝑧, 𝐸 is Euclidean,
𝐴 is a binary image.
(b)
(c)
(d)
Curved
True
Image CenterX > Max_Threshold Turn Right
Preprocessing False
CenterX<Max_Threshold True
& Forward
Find Countour of frame CenterX>Min_Threshold
Dotted
False
Countours == 1 True
CenterY >
True Turn Around
Min_Threshold
False False
No Line Detected
True
CenterX < Mid_Threshold Turn Left
Line path 1
False