I420ToRGB24
1.接口定义:
int I420ToRGB24(const uint8* src_y, int src_stride_y,
const uint8* src_u, int src_stride_u,
const uint8* src_v, int src_stride_v,
uint8* dst_frame, int dst_stride_frame,
int width, int height);
2.实际使用
首先弄清楚两种图片格式的存储格式:
rgb24图像格式:
1个像素为3个字节,b\g\r三个通道分别1个字节
const uint8 *nv12_y = (const uint8*)image->data;
int nv12_y_stride = image->width;
const uint8 *nv12_uv = nv12_y + nv12_y_stride * image->height;
int nv12_uv_stride = nv12_y_stride;
uint8 *i420_image = NULL;
i420_image = (uint8*)malloc(image->width * image->height * 1.5);
uint8* i420_image_y_ptr = i420_image;
uint8* i420_image_u_ptr = i420_image_y_ptr + (image->width * image->height);
uint8* i420_image_v_ptr = i420_image_u_ptr + (int)(image->width * image->height * 0.25);
out_cv_mat.create(image->height, image->width, CV_8UC3);
libyuv::I420ToRGB24(
i420_image_y_ptr, image->width,
i420_image_u_ptr, (image->width >> 1),
i420_image_v_ptr, (image->width >> 1),
out_cv_mat.data, (image->width * 3),//三通道,1个通道为1个字节
image->width, image->height);