rhsimplex / image-match

🎇 Quickly search over billions of images
2.94k stars 405 forks source link

'ascii' codec can't decode byte 0xc6 in position 0: ordinal not in range(128) #112

Open randolchance opened 5 years ago

randolchance commented 5 years ago

Hey there,

Let me say up front that I'm far from the most experience coder. But I'm doing my best! Let me also say that this is more likely not to be an issue with image-match. but rather my inexperience, so I completely understand if this is not something you have interest in helping me resolve.

I've had some good success with image-match over the past week, but lately I've been having a really hard time. I have managed to add and match images by passing both a path and a bytestream to the appropriate SignatureES member functions.

However, now I am trying to generate images by taking screenshots from a webcam to pass to my server (and then to image-match) to find matches. It does not appear to matter if I try to pass the image using a local path, a URL path, or a bytestream. No matter what I try I always receive the error:

'ascii' codec can't decode byte <_some hex value_> in position <usually a number from 0 to 3>: ordinal not in range(128)

Initially I suspected Flask was encoding my base64 string funny upon reception from my Javascript, but saving the file to the server and using the path to that file still generates the quoted error. I've also written the raw base64 to a .txt file to make sure /. + and = where coming through properly, which they appear to be. If I open the image file I've made from the canvas base64 string, the image appears to be perfectly fine.

I know this is not likely an issue with image-match, but rather myself and a lack of understanding of some aspect of string encoding in Flask/Python. I have spent quite some time trying different encodings, or decoding things in different ways, just in case something was being done under the hood by Flask/Python.

Flask version: 1.0.2 Python version: 2.7.12

Apologies in advance for leaving out any necessary info you might like.

Thanks for your time!

randolchance commented 5 years ago

Update:

I've actually managed to use both the path and bytestream methods to add and match images from the console and using the same Python environment that my Flask app runs in, but if I use EITHER the path or bytestream in ses.search_image within my running Flask app, it gives me the error I mention above.