You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.1 KiB

Algorithm Explanation

  1. Load.

    First we load the image. At this stage we convert the image to gray scale and run AprilTag detection to find all the markers.

    step 1 - image
  2. Normalization.

    The we use a median blur to extract the background and then remove it from the image. Then we normalize the image.

    step 2 - normalized
  3. Erosion.

    Then we draw some white rectangles over all the markers to hide them as they would occlude the maze. Then we erode the image to remove noise and make the maze lines thicker.

    step 3 - eroded
  4. Threshold.

    Now we binarize the image using a threshold (a good number I found is about ~200)

    step 4 - threshold
  5. Dilate.

    Then we dilate the image to make the lines even thicker.

    step 5 - dilated
  6. Cropping.

    We crop the image using markers 1 and 2 to get the maze region.

    step 6 - cropped
  7. Maze.

    We draw the maze with the start (red) and end (green) points in the new coordinates.

    step 7 - maze
  8. Bitmap.

    We create a bitmap of the maze where 0 is a free cell and 1 is a wall. Then we convert it to a NetworkX graph and run the A* algorithm.

    step 8 - maze bitmap
  9. Path.

    We draw the path found by the A* algorithm on the maze bitmap.

    step 9 - maze path
  10. Solution.

    Finally we transform the path back to the original image coordinates and draw it on the image.

    step 10 - solution