synesthesiam / magicpy

An autostereogram (MagicEye) image generator written in Python
71 stars 18 forks source link

TypeError: 'float' object cannot be interpreted as an integer #1

Open Foxy6670 opened 1 year ago

Foxy6670 commented 1 year ago

Every time I try to run ./example.sh, this happens:

Traceback (most recent call last):
  File "/home/user/magicpy/magicpy.py", line 53, in <module>
    pattern = gen_pattern(pattern_width, depth_map.size[1])
  File "/home/user/magicpy/magicpy.py", line 27, in gen_pattern
    return numpy.random.randint(0, 256, (width, height))
  File "mtrand.pyx", line 765, in numpy.random.mtrand.RandomState.randint
  File "_bounded_integers.pyx", line 1256, in numpy.random._bounded_integers._rand_int64
TypeError: 'float' object cannot be interpreted as an integer
cmahnke commented 1 year ago

This is related to the fact, that the calculation of the patterns with returned a float value, replace:

pattern_width = depth_map.size[0] / args.pattern_div

with:

pattern_width = int(depth_map.size[0] / args.pattern_div)

You are almost certainly are using Python 3 the code is written for Python 2, you'll need to fix few more things: