基于opencv对图片的二进制流进行编解码

2023-05-16

import cv2
import numpy as np


img1 = cv2.imread("img.jpg", 1)
#retval, buffer = cv2.imencode('.png', img1)

# img1_bytes = np.array(buffer).tostring()

with open("img.jpg", "rb") as fid:
    img1_bytes = fid.read()

# Decoding CV2
decoded = cv2.imdecode(np.frombuffer(img1_bytes, np.uint8), 1)
cv2.imwrite("cv2.png", decoded)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

基于opencv对图片的二进制流进行编解码 的相关文章

随机推荐