如何通过libyuv将NV21格式的Android摄像机预览数据转换为i420? [英] How to convert android camera preview data in NV21 format to i420 by libyuv?
本文介绍了如何通过libyuv将NV21格式的Android摄像机预览数据转换为i420?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我通过以下方式接收NV21格式的预览数据:
I receive the preview data in NV21 format by:
public void onPreviewFrame(byte[] data, Camera camera)
我想通过 libyuv 将data
转换为I420格式.看来include/libyuv/convert.h
中的NV21ToI420
或ConvertToI420
是我所需要的.
I want to convert data
to I420 format by libyuv. It seems NV21ToI420
or ConvertToI420
in include/libyuv/convert.h
is what i need.
// Convert NV21 to I420.
LIBYUV_API
int NV21ToI420(const uint8* src_y, int src_stride_y,
const uint8* src_vu, int src_stride_vu,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int width, int height);
// Convert camera sample to I420 with cropping, rotation and vertical flip.
LIBYUV_API
int ConvertToI420(const uint8* src_frame, size_t src_size,
uint8* dst_y, int dst_stride_y,
uint8* dst_u, int dst_stride_u,
uint8* dst_v, int dst_stride_v,
int crop_x, int crop_y,
int src_width, int src_height,
int dst_width, int dst_height,
enum RotationMode rotation,
uint32 format);
有一些例子可以做到吗?
Are there some examples to do that?
推荐答案
最后,我找到了一个演示:
Finally, i found a demo:
https://github.com/zenith22/libyuvDemo.git
希望这会有所帮助!
更新:
我添加了一个项目:
https://github.com/jpxiong/NV21CameraPreviewToI420Demo.git
更多详细信息,请阅读 README.md
More details, please read the README.md
这篇关于如何通过libyuv将NV21格式的Android摄像机预览数据转换为i420?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文