opencvのメモリから画像を読み取る簡単な方法があります。
cvの使用(バージョン1)
import cv
# First get the compressed image data. This can be retrieved from
# a socket, a file, or whatever you want.
jpegdata = open('myimage.jpg','r').read()
# Create an opencv matrix to hold the compressed data
cvmat = cv.CreateMatHeader(1, len(jpegdata), cv.CV_8U)
cv.SetData(cvmat, jpegdata, len(jpegdata))
# Now let opencv decompress your image
cvimage = cv.DecodeImage(cvmat, cv.CV_LOAD_IMAGE_COLOR)
cv2(およびnumpy)の使用
import cv2
import numpy as np
# First get the compressed image data. This can be retrieved from
# a socket, a file, or whatever you want.
jpegdata = open('myimage.jpg','r').read()
# Convert your compressed data to a numpy array
nparr = np.fromstring(jpegdata, np.uint8)
# Now use imdecode to decompress it
cvimage = cv2.imdecode(nparr, cv2.CV_LOAD_IMAGE_COLOR)