opencv bytesio
转不转bytesio,opencv都能读取文字成图片:
str_encode opencv也能解析
def a():
path='d:/1.jpg'
for i in range(10):
img=cv2.imread(path)
start=time.time()
img_encode = cv2.imencode('.jpg', img) # 可以看出第二个元素是矩阵 print(img_encode)
str_encode = img_encode[1].tostring()
buf_str = BytesIO(str_encode).getvalue()
encode_t=time.time()-start
nparr = np.fromstring(buf_str, np.uint8)
img_decode = cv2.imdecode(nparr, 1)
print('time', encode_t, time.time() - start)
# cv2.imshow('',img_decode)
# cv2.waitKey(1)