使用 open()
函数读取的图片是二进制的变量,并且没有数组的shape。
with open(img_path, "rb") as image_file:
image_buff = image_file.read()
这时想要把它转化为numpy数组
image = cv2.imdecode(np.fromstring(image_buff, np.uint8), 1)
cv2.imshow('cv',image)
cv2.waitKey(1)
使用 open()
函数读取的图片是二进制的变量,并且没有数组的shape。
with open(img_path, "rb") as image_file:
image_buff = image_file.read()
这时想要把它转化为numpy数组
image = cv2.imdecode(np.fromstring(image_buff, np.uint8), 1)
cv2.imshow('cv',image)
cv2.waitKey(1)