import numpy as np
import cv2
# 读取NV12文件
with open('nv12_file.nv12', 'rb') as f:
nv12_data = np.fromfile(f, dtype=np.uint8)
# 获取图像宽度和高度
width = 640
height = 480
# 将NV12数据转换为BGR格式
yuv = nv12_data.reshape((height * 3 // 2, width))
bgr = cv2.cvtColor(yuv, cv2.COLOR_YUV2BGR_NV12)
# 保存为png
cv2.imwrite('output.png', bgr)
NV12转BGR
猜你喜欢
转载自blog.csdn.net/qq_31638535/article/details/130720169
今日推荐
周排行