这个成功了:
imgData = np.fromfile(image_name, dtype=np.uint8)
# 利用numpy中array的reshape函数将读取到的数据进行重新排列。
img_o = imgData.reshape(480, 640, 3)
cv2.imwrite(str(ok_count)+".png",img_o)
这个没成功
import cv2 #OpenCV包
import numpy as np
rows=480 #图像的行数
cols=640#图像的列数
channels =1# 图像的通道数,灰度图为1
# 利用numpy的fromfile函数读取raw文件,并指定数据格式
img=np.fromfile(r'G:\BaiduNetdiskDownload\2.raw', dtype='uint8')
img=img.reshape(rows, cols, channels)
cv2.imshow('Infared image-640*512-8bit',img)
# 如果是uint16的数据请先转成uint8。不然的话,显示会出现问题。
cv2.waitKey()
cv2.destroyAllWindows()
encodepng decodepng