tancik / StegaStamp

Invisible Hyperlinks in Physical Photographs
http://www.matthewtancik.com/stegastamp
MIT License
676 stars 191 forks source link

decode valueError issues #1

Closed yfeiwu closed 5 years ago

yfeiwu commented 5 years ago

When I run decode python code on both images and videos, it comes to this problem. Traceback (most recent call last): File "decode_image.py", line 64, in main() File "decode_image.py", line 57, in main bitflips = bch.decode_inplace(data, ecc) ValueError: invalid parameters I am not familar with bch, so how can I solve this?

tancik commented 5 years ago

What exact commands are you running to encode and decode the data? Have you modified the code at all? Did you change BCH_POLYNOMIAL or BCH_BITS?

yfeiwu commented 5 years ago

I use the same command as README. The encode command outputs the encoded image and residual one successfully. But when run decode, it comes to this problem. I don’t modify the code or the BCH numbers at all.

tancik commented 5 years ago

Hmmm, interesting, so far I have tested the SteagaStamp install procedure on 3 machines and haven't run into this issue. Your encoded message is just "Hello", correct?

The BCH library being used is the following - https://github.com/jkent/python-bchlib Can you verify that you are able to run their example script without any issues? Can you also verify that this variable is set to a list of 100 integers that are either 0 or 1.

For a little background, BCH is used to for error correcting and is not core to the method. If you want to skip using BCH, you can modify the encoder here, and set the secret to be a 100 element list of 0/1 ints. During decoding, this will associate the the decoded list of ints.

yfeiwu commented 5 years ago

Yes, I just encoded the string Hello. The BCHlib seems to be correct when I ran the example.

The secret variable in both encode and decode is correct as you say, and packet_binary ouputs the 96 numbers into string. When checking the encode outputs, I found the problem. The packet value is a format like <generator object <genexpr> at 0x7f09b0350550> So data outputs <generator object <genexpr> at 0x7f09b035 and ecc outputs 0550>.

When I test on another machine with Python3 and tf 1.19, the decode works.

tancik commented 5 years ago

Ahh, this may be a python 2 vs 3 issue. I've been testing everything with python 3. Let me know if that fixes things, if so I will update the readme.

tancik commented 5 years ago

I was able to replicate your error with python 2, so it indeed a py2/3 compatibility error. Adding python 2 support is not a priority, I would suggest using python 3 for the time being.

The readme has been updated to specify the python3 requirement.