Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

See discussions, stats, and author profiles for this publication at: https://www.researchgate.

net/publication/321121617

Intelligent Maze Solving Robot Based on Image Processing and Graph Theory
Algorithms

Conference Paper · October 2017


DOI: 10.1109/ICPET.2017.15

CITATIONS READS
7 5,097

6 authors, including:

Mohammad O.A. Aqel Ahmed Issa


Al-Azhar University - Gaza Al-Azhar University - Gaza
21 PUBLICATIONS   97 CITATIONS    49 PUBLICATIONS   176 CITATIONS   

SEE PROFILE SEE PROFILE

Majde Elhabbash
Synaptic Solar, United State
1 PUBLICATION   7 CITATIONS   

SEE PROFILE

Some of the authors of this publication are also working on these related projects:

Rehabilitation Engineering View project

PhD Research Work View project

All content following this page was uploaded by Mohammad O.A. Aqel on 05 February 2018.

The user has requested enhancement of the downloaded file.


2017 International Conference on Promising Electronic Technologies

Intelligent Maze Solving Robot Based on Image


Processing and Graph Theory Algorithms
Mohammad O.A. Aqel, Ahmed Issa, Mohammed Khdair, Majde ElHabbash,
Mohammed AbuBaker, Mohammed Massoud
Department of Engineering, Faculty of Engineering and Information Technology,
Al-Azhar University-Gaza,
Gaza P.O Box 1277, Palestine
m.aqel@alazhar.edu.ps, a.issa@alazhar.edu.ps, eng.mohammed.o.kh@gmail.com, majdereda3@gmail.com,
eng.mhabubaker@gmail.com, mohed_massoudd12@hotmail.com

Abstract— The most important task for maze solving robots is


maze [1]. A path between two specific locations existed in the
the fast and reliable finding of its shortest path from its initial maze should be well planned and the planned path should be
point to its final destination point. This paper proposes an collision-free and the shortest one. Applications of maze
intelligent maze solving robot that can determine its shortest path solving systems include intelligent traffic control that helps
on a line maze based on image processing and artificial ambulances, fire fighters, or rescuing robots to find accurately
intelligence algorithms. The image of the line maze is captured by their shortest path to their destination.
a camera and sent to the computer to be analyzed and processed
by a program developed using Visual C++ and OpenCV libraries
The traditional technique that maze solving robots use is
and based on graph theory algorithms. The developed program based on trial and error which the robot should try each
solves the captured maze by examining all possible paths exist in available path in the maze until finding its destination point.
the maze that could convey the robot to the required destination This traditional technique is a time consuming and could trap
point. After that, the best shortest path is determined and then the robot in infinite loops. Moreover, the traditional technique
the instructions that guide the car-like robot to reach its desired does not always give the shortest path. The proposed approach
destination point are sent to the robot through Bluetooth. The
robot follows the received guide path to reach its destination. The
for maze solving avoids the aforementioned problems. It is an
proposed approach works faster than the traditional methods intelligent technique based on image processing and artificial
which push the robot to move through the maze cell by cell in intelligence algorithm that can reduce the maze solving time
order to find its destination point. Moreover, the proposed and find the shortest path. The image of the entire maze is
method allows the maze solving robot to avoid trapping and captured by a camera and sent to the computer to be analyzed
falling in infinity loops. Applications of maze solving systems and processed by a developed program using Visual C++ and
include intelligent traffic control that helps ambulances, fire
fighters, or rescuing robots to find their shortest path to their
OpenCV libraries. The developed program is based on a graph
destination. theory algorithm as one of the most efficient artificial
intelligent (AI) algorithms that can analyze mazes and find the
Keywords — maze solving; artificial intelligence; autonomous shortest path to the goal destination available in the maze.
robotic; graph theory algorithm; image processing. There are many types of graph theory algorithms can be
used for maze solving. In order to find the best algorithm that
I. INTRODUCTION can solve the captured maze image, three types of graph theory
The rapid growth in the technology in our times is greater algorithms are implemented and tested which are Breadth First
than ever. Many autonomous robotic devices are invented to Search , Best First Search and A* algorithms [2]. These
make lives of people easier. Autonomous mobile robots to this algorithms are tested on many mazes with variant complexity
trend have a tremendous role and they can be the best option and their results compared based on the required solving time
for various and specific tasks. They can be deployed in the and the resulted path length from each method. Based on the
industries for accurate and quick transportation of parts and results, the Breadth First Search algorithm was the most
goods from one station to another. They have also been used accurate one that find the shortest path for each tested maze.
for rescuing to save lives and reach dangerous areas that Therefore, Breadth First Search algorithm was implemented in
peoples cannot reach. Furthermore, mobile robots can be the final developed maze solving program. Our evaluation has
implemented for home automation such as autonomous proved that the proposed intelligent technique is fast and
vacuum cleaners which need to navigate itself in the house and efficient in solving any maze, whatever its complexity, and
clean it at the same time. allows the mobile robot to reach its destination point
For most mobile robot applications, path planning is an accurately by following the shortest path.
important task. Any structure of multiple paths can be called a This paper is organized as follows. Section 2 discusses

978-1-5386-2269-8/17 $31.00 © 2017 IEEE 48


DOI 10.1109/ICPET.2017.15
previous related works. Section 3 describes the proposed time.
design of the system and its implementation. Section 4 There are maze-solving algorithms in literatures were
presents and discusses the results of several experiments. developed using graph theory algorithms such as Breadth First
Finally, Section 5 summarizes the conclusions of this work. Search, Best First Search and A* algorithms [2]. Breadth First
Search is a weighted graph search uses cost storage to
II. LITERATURE REVIEW determine the order of cells visited [9]. It is able to find the
A maze is a journey puzzle consists of shortest path by working in two phases: “the filling phase”, the
a confusing network of interconnected paths and hedges which cells are marked and “the retrace phase”, uses a concept of
a solver must find a route from start point to the end point [1]. backtracking.
The process of finding a route through the maze from an initial The approach proposed in this paper finds the shortest path
to final point is called maze solving. There are two main types in maze from a start point to end destination point using image
of maze solving methods. The first one depends on performing processing and based on AI graph theory algorithms.
the maze solving process inside the maze by a rover with no
prior knowledge about the details of the maze. The second III. DESIGN AND IMPLEMENTATION
type of maze solving methods needs to employ a camera that This section describes the design and implementation of an
can capture the entire maze to be analyzed and solved intelligent maze-solving robotic system based on image
immediately through a program run on a computer [3]. processing techniques and AI algorithms. The block diagram
There are many different maze solving algorithms have been of the proposed system is shown in Fig. 1. The system consists
proposed in the literature. Most of researchers care of of a mobile car-like robot, downward-facing camera mounted
development of algorithms can accurately and within short above the maze, computer for processing and analyzing the
time solve the maze by finding the shortest path between the maze image using graph theory algorithms, and Bluetooth
start and the end point. The simplest maze-solving technique is module for communications between robot and computer.
the wall-follower technique based on left-hand rule or right- The proposed method involves image processing and graph
hand rule. However, it can’t work well with complex mazes theory algorithm; which works faster than traditional
and only can find the solution if the maze is simply connected, techniques. The traditional techniques depend on performing
that is, all its dividers are joined together [2,4]. the maze solving process inside the maze by a rover moving
In [5,6], path planning problem for mobile robot was solved through the maze cell by cell with no prior knowledge about
by implementing an Ant Colony Optimization ACO approach. the details of the maze. In the proposed system the entire
To solve this problem, many maps with different complexities image of maze should be captured by a camera and then the
were implemented and each map was represented as grid of maze solving process is performed completely outside the
equal number of rows and columns with starting and maze by a computer. The computer processes and analyses the
destination point. As presented in this work, the robot found captured maze. The resulted maze solution which consists of
the shortest path to its destination by avoiding obstacles and the shortest path data is sent to robot wirelessly for guiding it
walls. Another approach based on image processing was to reach its target destination point accurately.
proposed in [7]. In this approach an algorithm was developed The process of the proposed maze-solving robotic system as
to examine the entire maze instead of an area of the current shown in Fig. 1 includes the following main steps:
position of robot. As the entire maze map is known to robot,
A. Capturing of Maze Image
this approach provides robot the opportunity for preplanning
and avoids faults such as infinity loop or dead ends. The process of maze-solving is started by capturing the top
A maze-solving approach based on flood-fill algorithm was view of the maze using a camera and the captured maze image
proposed in [8] and it enhanced by skipping some steps not is saved in the desired folder in computer for further
needed in certain situations. This flood-fill technique depends
on the concept of water always flowing from a higher height to
a lower one and this concept is applied by assigning a value for
each cell in the maze that represents how far the cell is from
the center. The algorithm needs to perform four steps of maze-
solving which are updating the walls, flooding the maze,
determining which turn to be taken and moving to the next
cell. However, in some passages of the maze where the robot
is enforced to move only in straight forward direction, when
the robot is inside these passages, it is not required to perform
all four aforementioned algorithm steps. In this case, the
algorithm is enhanced by only flood the maze when there is a
turn and skipping the other steps in order to reduce execution
Fig. 1. The proposed maze-solving robotic system.

49
processing. The camera should be calibrated in order to get its (2)
intrinsic and extrinsic parameters. Camera calibration is a
necessary step in computer vision which provides the ability to
(2) (1) (2)
establish a relation between 2D image pixels coordinates and (2) (1) (0) (1) (2)
real-world coordinates [10-12]. (2) (1) (2)
B. Preprocessing of Maze Image (2)
This is an important step which involves image pre- Fig. 4. Cell traversal manner using breadth first search.
processing to prepare the maze image to be analyzed using one
of graph theory algorithms. This step includes image filtering time in order to be implemented in this proposed maze-solving
and detection of starting and end points of maze. The code is robotic system.
developed using Visual C++ and OpenCV libraries. First, the Breadth First Search is an algorithm for searching graph
code imports the captured maze image and applies some filters data structures. It can be used for searching the maze cells or
for image enhancement. After that and from the colored maze nodes [13]. The job of this algorithm is to reach the goal cell
image, the starting location and end location of the maze are from the starting cell. It starts at starting cell of the maze and
detected. The red colored line represents the starting location explores the neighbor cells first before moving to the next
or the maze entrance while the yellow colored line represents level neighbors. It uses cost storage to determine the order of
the end location of maze or the maze exit gate as shown in Fig. cells visited as shown in Fig. 4 and keeps records of which cell
2. Finally and after detection of maze entrance and exit are immediate neighbors of starting cell. Starting cell is
locations and based on color intensity thresholds, the colored labeled as (0). The algorithm expands cells in order of their
image is converted into binary image as shown in Fig. 3 and distance from the starting cell, generating one level of the tree
becomes ready for applying one of graph theory algorithms on at a time. It traverses the tree by layer through creating a list of
it as described in the next step. nodes/cells to traverse and adding the children of each node in
the list at the end of the generated list. This cell expanding
C. Finding Shortest Path Using Graph Theory Algorithms continues until finding the goal or the end cell. By this way,
For solving the maze and finding the shortest path between the breadth-first search can find the shortest path to the goal
the starting and end points, three types of graph theory cell and the time required to find this path is proportional to
algorithms are implemented and their results are compared in the number of cells generated as each cell can be generated in
order to select the best one. Breadth First Search, Best First constant time.
Search and A* algorithms are implemented and tested on A* is a search algorithm that can be used in path-finding.
different simple and complex mazes and their results compared A* searches among all possible maze paths from start point to
based on the required solving time and the resulted path length end point in order to find the path that needs the smallest cost
from each method. The goal of this comparison is to select the according to the Equation (1) [14]:
best algorithm that can provide the shortest path with the least f(n) = g(n) + h(n) (1)
where n is the last node on the path, h(n) is the distances to
each node from the goal node and g(n) is the path cost from
start node to n. A* starts from a specific node of a graph and
constructs a tree of paths starting from that node. It keeps
expanding paths one step at a time by taking the node with
least value of evaluation function f(n), until one of its paths
ends at the predetermined goal node (Fig. 5).
Best First Search algorithm can also be used for path
Fig. 2. Original colored image of maze finding. To find the best path to the target destination node, at
each node of the graph it evaluates which node to be expanded

Fig. 3. Converting colored image to binary image


based on thresholding Fig. 5. A* algorithm sequence.

50
Fig. 6. Best first search algorithm sequence. a. Maze 1 b. Solution of Breadth First Search
(Path: 31 steps, time: 3.2ms)
next based on the lowest cost using evaluation function which
measures the distance from the node in concern to the goal as
shown in Fig. 6 [14].
The graph theory algorithms are applied on the binary image
of maze to find the shortest solution path between starting
point and end point. The flowchart of the developed Visual
C++ code is shown in Fig. 7.

D. Converting the Shortest Path from Image Coordinates to c. Solution of Best First Search d. Solution of A* Search
(Path: 33 steps, time: 1.1ms) (Path: 33 steps, time: 2.8ms)
Real World coordinates and Sending it to Robot
Fig. 8. Results of maze solving using AI search algorithms
The found shortest solution path is converted from pixel
coordinates (in pixels) to real world coordinates (in cm) by maze. In the experiments conducted for this study a Lego
applying a camera calibration processes using NI Vision Mindstorms NXT2 Robot was used.
Assistant Module which powered by LabVIEW [15]. The AI graph theory algorithms (Breadth First Search, Best First
constructed path is translated to a guiding path to be sent to Search, A* search) are tested on different mazes as shown in
robot through Bluetooth. The guiding path consists of group of Figs. 8 and 9. The solution path length and solving time are
sequence instructions as translation distance in cm and computed from start point to the end point of each maze to
movement directions (turn right, turn left, move forward, and determine which algorithm is the most efficient in finding the
move reverse). Finally, these guiding path instructions are shortest path. Fig. 8 illustrates results of testing the three
exported to text file and sent to the robot wirelessly via algorithms on a maze. The blue cell and red cell represents the
Bluetooth to guide it through the maze to reach its final target start point and end point; respectively. The green cells
destination. represent the resulted shortest solution path.
Based on Figs. 10 and 11, it is found that Breadth First
IV. RESULTS AND DISCUSSION Search gives always the shortest path in all tested mazes and
Several experiments have been conducted to evaluate the Best First search was the fastest. Finally, because the most
accuracy of the developed maze-solving robot system. A important factor in maze solving systems is finding the
single consumer-grade 15 megapixel Logitech C920 webcam
has been employed in this system and mounted above the

Import the captured maze image

Determine start and end point

Image thresholding a. Maze 2 b. Maze 3

Apply graph theory algorithm

Find the shortest path

Export path to text file and send to robot

c. Maze 4 d. Maze 5
Fig 7. Program flowchart.
Fig. 9. Different shape of mazes solved using AI search algorithms

51
Fig. 10. Mazes solving time using AI search algorithms

Fig. 15. NXT2 Lego robot follows the received solution path

Fig. 11. Resulted solution-path length using AI search algorithms

shortest solution path, it is decided to implement the Breadth


First Search algorithm in the final maze-solving program as it
is the best algorithm that can generate the shortest solution
path and it has a good trade-off between processing time cost
and reliability of finding maze solutions.
The final code is written based on Breadth First Search
algorithms and developed to be able to process and analyze Fig. 16. Maze solving using wall-follower technique (left-hand rule)
any captured maze image in the real world. The developed
code is tested on different real mazes with variant complexity, final destination line as shown in Fig. 15. The maze in Fig. 15
different solution paths, and different wall shapes (straight is the same maze that was processed and analyzed and its
walls and curved walls) as shown in Figs. 12 to 14. The solution path is presented in Fig.13. The robot followed the
developed code was successfully able to solve these mazes guiding path accurately and reached successfully to its final
precisely and correctly with no missing ways or longer paths. destination line (yellow color) from its start line (red color).
It always gives the shortest solution path for every tested The proposed intelligent approach was practically compared
maze. The resulted solution path is sent to the NXT2 Lego with the traditional maze-solving method (wall-follower
robot through Bluetooth as a guiding path for the robot to its technique based on left-hand rule) as shown in Fig. 16. It is

a. The captured maze before finding solution path a. The captured maze before finding solution path a. The captured maze before finding solution path

b. The maze after finding the solution path b. The maze after finding the solution path b. The maze after finding the solution path

Fig. 12. Simple maze with one solution Fig. 13. Maze with multiple solutions Fig. 14. Complex maze with multiple solutions

52
TABLE I. COMPARISON BETWEEN TRADITIONAL AND PROPOSED Technology Summit (Confluence), 2014 5th International Conference-,
METHODS 2014, pp. 323-328.
[4] A. Singh and G. S. Sekhon, "A New Shortest Path Finding Algorithm
Travelled
Time to reach goal For a Maze Solving Robot With Simulator," International Journal of
distance to Computer Science and Communication, vol. 2, (2), pp. 445-449, 2011.
Method (maze analysis+
reach goal
travelling) (second) [5] Y. Z. Cong and S. Ponnambalam, "Mobile robot path planning using ant
(cm)
Traditional method 387 50.2 colony optimization," in Advanced Intelligent Mechatronics, 2009. AIM
The proposed method 213 29.6 2009. IEEE/ASME International Conference on, 2009, pp. 851-856.
[6] S. Chia et al, "Ant colony system based mobile robot path planning,"
in Genetic and Evolutionary Computing (ICGEC), 2010 Fourth
found that the proposed intelligent approach based on Breadth International Conference on, 2010, pp. 210-213.
First Search algorithm is so far better than the traditional [7] B. Rahnama, A. Elçi and S. Metani, "An image processing approach to
method in term of the path length (travelled distance) and time solve labyrinth discovery robotics problem," in Computer Software and
consumed to reach the goal as illustrated in Table I. Applications Conference Workshops (COMPSACW), 2012 IEEE 36th
Annual, 2012, pp. 631-636.
From Table I, it is clear that the robot could reach its goal
[8] H. Dang, J. Song and Q. Guo, "An efficient algorithm for robot maze-
destination using the proposed approach in less time and solving," in Intelligent Human-Machine Systems and Cybernetics
travelled distance comparing to the traditional method. That is (IHMSC), 2010 2nd International Conference on, 2010, pp. 79-82.
because the traditional method pushes the mobile robot to [9] M. Sharma, "Algorithms for micro-mouse," in Future Computer and
move through the maze cell by cell until finding its destination Communication, 2009. ICFCC 2009. International Conference on, 2009,
point. The proposed approach provides the robot system the pp. 581-585.
opportunity for preplanning the travelling path and avoids its [10] M. O. Aqel et al, "Estimation of image scale variations in monocular
visual odometry systems," IEEJ Transactions on Electrical and
trapping and falling in infinity loops that may be happened Electronic Engineering, vol. 12, (2), pp. 228-243, 2017.
with the traditional technique. [11] M. O. Aqel et al, "Optimal Configuration of a Downward-Facing
Monocular Camera for Visual Odometry," Indian Journal of Science and
V. CONCLUSION Technology, vol. 8, (32), 2016.
[12] M. O. Aqel et al, "Adaptive-search template matching technique based
In this paper, a maze-solving robot system with an intelligent on vehicle acceleration for monocular visual odometry system," IEEJ
approach based on image processing and a graph theory Transactions on Electrical and Electronic Engineering, vol. 11, (6), pp.
algorithm was introduced. The efficiency of three algorithms 739-752, 2016.
in solving mazes, with a variant complexity, was compared. [13] J. Silvela and J. Portillo, "Breadth-first search and its application to
The results of maze solving using Breadth First Search, Best image processing problems," IEEE Trans. Image Process., vol.
10, (8), pp. 1194-1199, 2001.
First Search and A* algorithms were compared based on the
[14] R. Dechter and J. Pearl, "Generalized best-first search strategies and the
consumed solving time and length of the resulted solution optimality of A," Journal of the ACM (JACM), vol. 32, (3), pp. 505-536,
path. Although Best first search was the fastest one, the 1985.
Breadth First Search algorithm was the most accurate one in [15] T. Klinger, Image processing with LabVIEW and IMAQ Vision. Prentice
finding the shortest path for all tested mazes. Therefore, the Hall Professional, 2003.
final program that can solve real mazes was developed based
on Breadth First Search algorithm.
The developed system determines the best path for a car-like
robot from its start position to its final destination position
while navigating through a real maze. In order to find the
shortest path, the whole image of maze is captured by a camera
and then processed and analyzed by the developed program
based on Breadth First Search algorithm. The resulted shortest
path data is sent to the robot through Bluetooth as a guiding
path to reach its target destination. The results proved that the
proposed intelligent technique is fast and efficient in solving
any maze, whatever its complexity, and allows the mobile
robot to reach its destination accurately through the shortest
path.
REFERENCES
[1] H. Kern and J. Saward, Through the Labyrinth: Designs and Meanings
Over 5,000 Years. Prestel New York, 2000.
[2] A. M. Sadik et al, "A comprehensive and comparative study of maze-
solving techniques by implementing graph theory," in Artificial
Intelligence and Computational Intelligence (AICI), 2010 International
Conference on, 2010, pp. 52-56.
[3] B. Gupta and S. Sehgal, "Survey on techniques used in autonomous
maze solving robot," in Confluence the Next Generation Information

53

View publication stats

You might also like