An app that can solve a maze based on its image.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.


MazeSolver solves mazes, which are automatically read and interpreted from jpg images. As input it takes a jpg image and the coordinates of the beginning and end of the maze. It outputs a file called "output.jpg" with the path through the maze drawn on top of the input maze image.

The maze images need to fulfill some conditions:

  • the walls need to be black or at least darker than the background,
  • there cen be no "tunnels" or "overpassess" in the maze.

If you do not want to compile the app yourself, you can download the Windows binaries from my website:


There are three example mazes included in the project. All are distributed under the creative commons license, the original images are available here:

Below you can see the maze3.jpg example file along with its solution.

How to run it

MazeSolver is a console application, to run it you need to open the console and browse to the location of the app.
The program can be ran with the following command:


IMAGE_FILE_NAME.jpg is the name of the image file with the maze.
START_X/Y are the pixel coordinates of the maze entrance.
END_X/Y are the pixel coordinates of the maze exit.
[SAVE_COST_MAP] is an additional paramter, if added the program saves the maze cost map instead of the path through the maze.

So to run the app with one of the example mazes you need to write: MazeSolver.exe ../maze1.jpg 224 177 633 620
or for another example:
MazeSolver.exe ../maze2.jpg 1 1 4000 3999


All of the code except the jpg compression/decompression is licensed under the MIT license. The jpgd library which is used for reading and writing jpg images is in the public domain, more info here: