libyuv接口I420ToRGB24的实际使用

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);
  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值