Python读取YUV格式文件,并使用opencv显示的方法
opencv可以读取的图片类型比较多,但大多是比较常见的类型,比如”.jpg”和”.png”,但它不能直接读取YUV格式的文件,需要通过python...PIL的image格式,那么只需在main函数中,进行稍微的处理。...YY=data[0][0]
im=Image.frombytes('L',(720,1280),YY.tostring())
另外,如果PIL的image想转换为opencv的mat格式,只需将PIL...转换为矩阵的形式。...im_array = np.array(im)
# 也可以用 np.asarray(im) 区别是 np.array() 是深拷贝,np.asarray() 是浅拷贝
以上这篇Python读取YUV文件