def yuv2rgb(yuvfilename, W, H):
with open(yuvfilename, 'rb') as fp:
raw = fp.read()
yuv = np.frombuffer(raw,'B')
yuv = yuv.reshape([H, W, 2])
bgr = cv2.cvtColor(yuv, cv2.COLOR_YUV2BGR_UYVY)
cv2.imwrite(yuvfilename.replace('.yuv', '.png'), bgr)
if __name__ == '__main__':
video = yuv2rgb(r'video_0.yuv', 1920, 1080)
【python 程序读取YUYV格式文件并转换成 .png 格式文件保存】
最新推荐文章于 2024-04-19 16:50:03 发布