Ask Your Question

Arminius's profile - activity

2015-03-24 06:18:54 -0600 commented question Encoding corrupts image!

Yes, I can save the image after it was transferred. However, the sending part is omitted in the above code to rule out problems concerning the connection.

The predict method gives back an ID and a distance with respect to the recognized image in the trainingsdatabase. Both ID and distance are different before and after encoding. The prediction before encoding is always correct, whereas the prediction after the encoding ist incorrect most of the times.

If I look at the images before and after the encoding with cv2.imshow(), they look the same, so the .jpg encoding is not complete nonsense but somehow still destroys the pattern. (I'm using Local Binary Pattern Histograms for Recognition) Is there a way to encode img losless without altering it, so that img = decimg.

2015-03-23 16:30:07 -0600 asked a question Encoding corrupts image!


I am using OpenCV for Face Recognition. For some reason I have to encode the face image into a string and send it to a server where the recognition part is done. However, the results are not the same as if I did the recognition directly on the taken picture.

import cv2

img = cv2.imread('/path/to/file.jpg')

recognizer.predict(img) # returns some id

#encode data
result, imgencode = cv2.imencode('.jpg', img, encode_param)
data = numpy.array(imgencode)
stringData = data.tostring()

data = numpy.fromstring(stringData, dtype='uint8')
decimg = cv2.imdecode(data,1)

recognizer.predict(decimg) # should return the same id, but does not

What could be the problem?

Thanks a lot in advance. :) Arminius