mikepound / mazesolving

A variety of algorithms to solve mazes from an input image
The Unlicense
1.74k stars 410 forks source link

Core dumped on vertical15k #3

Closed guruevi closed 7 years ago

guruevi commented 7 years ago

python ../solve.py vertical15k.png vertical15k_out.png

Loading Image /usr/lib/python2.7/dist-packages/PIL/Image.py:2224: DecompressionBombWarning: Image size (225030001 pixels) exceeds limit of 89478485 pixels, could be decompression bomb DOS attack. DecompressionBombWarning) Creating Maze ('Node Count:', 18716772) ('Time elapsed:', 271.5947608947754, '\n') ('Starting Solve:', 'Breadth first search') ('Nodes explored: ', 16954823) ('Path found, length', 14820) ('Time elapsed: ', 83.27104091644287, '\n') Saving Image Segmentation fault (core dumped)

It didn't run out of memory (6%)

I was able to do the perfect2k.png without a problem in a few seconds.

tomudding commented 7 years ago

You have two options (I'd recommend the first option):

  1. Increase the MAX_IMAGE_PIXELS value from Pillow (replace 'aVeryBigNumber' with something like '15000*15000'):
    from PIL import Image
    Image.MAX_IMAGE_PIXELS = aVeryBigNumber
  2. Or suppress the exception with warnings.simplefilter('ignore', Image.DecompressionBombWarning) (check the documentation for more information)
mikepound commented 7 years ago

It could be that Pillow is causing a problem i'm not aware of, I'm on python 2 so am not using it. I have looked into this, though, and it seems numpy wasn't playing nicely with images of this size. I've removed numpy from the image output code, and it should also be faster now. the 15k image works for me, though I have replaced the vertical one as there was something wrong with the solution (down the edge for some reason).

If you have the ram for it, the new perfect15k image is worth a shot.

Edit: I managed to solve the 15k using my workstation at work. 25Gb RAM, about 600seconds in total. It worked though!