如何更改摄像头preVIEW回调缓冲区的方向? [英] How to change orientation of camera preview callback buffer?

查看:1120
本文介绍了如何更改摄像头preVIEW回调缓冲区的方向?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个问题的变化经常问这儿附近的,但我没有看到这个确切的情况,所以我把它扔在那里。

This is a variation on a question often asked hereabouts but I don't see this exact situation, so I'll throw it out there.

我有一个在previewFrame回调成立。这得到一个byte []与它NV21数据。我们H.264连接code,并将其发送出去作为视频流。在另一边,我们看到视频歪斜,或者90或270度,这取决于在手机上。

I have an onPreviewFrame callback set up. This gets a byte[] with NV21 data in it. We h.264 encode it and send it out as a video stream. On the other side, we see the video skewed, either 90 or 270 degrees, depending on the phone.

所以现在的问题是,如何旋转的数据的,不只是preVIEW形象? Camera.Parameters.setRotation只影响拍摄照片,没有录像。 Camera.setDisplayOrientation具体说,这不仅影响了显示preVIEW,而不是框架字节:

So the question is, how to rotate the data, not just the preview image? Camera.Parameters.setRotation only affects taking the picture, not video. Camera.setDisplayOrientation specifically says it only affects the displaying preview, not the frame bytes:

这不会影响字节数组上previewFrame(byte []的,摄像头),JPEG图片或录制的视频传递的顺序。

This does not affect the order of byte array passed in onPreviewFrame(byte[], Camera), JPEG pictures, or recorded videos.

那么,有没有一种方式,在任何API级别,改变字节数组的方向?如果做不到这一点,你甚至可以旋转的NV21(YVU)格式,这进来,或者我需要首先rgb呢?

So is there a way, at any API level, to change the orientation of the byte array? Failing that, can you even rotate the NV21 (YVU) format that this come in, or do I need to RGB it first?

推荐答案

原来,你需要自己在发送前关闭旋转每个帧。我们结束了使用libyuv,其中有一个非常方便的功能,这两个旋转并把它转换 - libyuv :: ConvertToI420

Turns out you do need to rotate each frame yourself before sending it off. We ended up using libyuv, which has a very convenient function that both rotates and converts it - libyuv::ConvertToI420

的https://$c$c.google.com/p/libyuv/

这篇关于如何更改摄像头preVIEW回调缓冲区的方向?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆