Search code examples
c++tiffdijkstraslam

Get the shortest Path in .tiff map


I am working with SLAM to build of an environment. I do this with a Lidar sensor and it's working pretty cool. Now I have a map of the environment in .tiff format. I want to find the shortest path(Dijkstra) from a point A to B, but my problem is I don't know how to convert this .tiff map in a format I can work with. I code in C++.

Do anyone has an idea how I could do this?

Thanks :)

edit:

The map looks like this. The black pixels are obstacles and the grey ones are space to move.


Solution

  • As an alternative, if you are allowed to diddle your data "pre-flight", you could use ImageMagick to convert your TIFF file to an extremely simple PGM file. ImageMagick is installed on most Linux distros and is available for OSX and Windows.

    The PGM format is very simple, and is described here. As your image is 400x300, it will look like this:

    P5
    400 300
    255
    120,000 unsigned char bytes of image data - uncompressed, unpadded
    

    You would convert your TIFF file like this:

    convert map.tif -normalize -threshold 1 map.pgm
    

    and then you can read 3 lines of header and then directly read your 120,000 bytes into an array. This way, you have no need for extra libraries or software on your platform.

    enter image description here