long_filepath = 'xxx.RAW'
short_filepath = 'ccc.RAW'
fp1 = open(long_filepath, 'rb')
fp2 = open(short_filepath, 'rb')
size = 1920 * 1080 #分辨率
longdata = []
shortdata = []
for i in range(size):
data = fp1.read(2)
curlong = struct.unpack('H', data)[0] #[0]表示第一张图片 一个burst里有很多帧
longdata.append(curlong)
data = fp2.read(2)
curshort = struct.unpack('H', data)[0]
shortdata.append(curshort)
rawlong = np.array(longdata).reshape((1080, 1920))
rawshort = np.array(shortdata).reshape((1080, 1920))
#下面代码是做高低亮度统一操作 如果不需要调节曝光比就取消下面的代码。
rawlong = rawlong - 240
rawlong = rawlong / 3.99 #3.99为曝光比
rawshort = rawshort - 240
rawlong[rawlong < 0] = 0
rawshort[rawshort < 0] = 0
raw = raw.astype(np.uint16)
raw2 = raw2.astype(np.uint16)
cv2.namedWindow('a')
cv2.imshow('a',raw_long/4095) #cv2可视化
cv2.imshow('b',raw_rawshort/4095)
cv2.waitkey(0)
rawlong.tofile('out_L.raw')
rawshort.tofile('out_M.raw')
print(rawlong.shape)
print(rawlong)
输入是原始的raw图,不带头信息的raw图,将其读取成numpy格式,