欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

RAW12转RAW16

程序员文章站 2022-07-01 21:00:52
...
import bitstring
import numpy


with open(path, 'rb') as f:
     data = f.read()

ii=numpy.zeros(int(2*len(data)/3))
ic = 0
for oo in range(0,int(len(data)/3)):  
    aa = bitstring.Bits(bytes=data[oo:oo+3], length=24)
    ii[ic],ii[ic+1] = aa.unpack('uint:12,uint:12')
    ic=ic+2
b = numpy.reshape(ii,(3840,2160))
相关标签: python