android采集的视频进行旋转
来源:互联网 发布:红楼梦 知乎 编辑:程序博客网 时间:2024/06/07 00:56
最近在做android视频实时采集,由于android摄像头默认是旋转90度的,所以采集到的视频会有一些问题,因此在采集到数据帧之后,首先需要在onPreviewFrame方法中对yuv格式的原始帧进行一次旋转。
参考了http://stackoverflow.com/questions/14167976/rotate-an-yuv-byte-array-on-android
以下为旋转90度的代码
<span style="white-space: pre;"></span>private byte[] rotateYUV420Degree90(byte[] data, int imageWidth,<span style="white-space: pre;"></span>int imageHeight) {<span style="white-space: pre;"></span>byte[] yuv = new byte[imageWidth * imageHeight * 3 / 2];<span style="white-space: pre;"></span>// 旋转Y int i = 0;<span style="white-space: pre;"></span>for (int x = 0; x < imageWidth; x++) {<span style="white-space: pre;"></span>for (int y = imageHeight - 1; y >= 0; y--) {<span style="white-space: pre;"></span>yuv[i] = data[y * imageWidth + x];<span style="white-space: pre;"></span>i++;<span style="white-space: pre;"></span>}<span style="white-space: pre;"></span>}<span style="white-space: pre;"></span>// 旋转U和V<span style="white-space: pre;"></span>i = imageWidth * imageHeight * 3 / 2 - 1;<span style="white-space: pre;"></span>for (int x = imageWidth - 1; x > 0; x = x - 2) {<span style="white-space: pre;"></span>for (int y = 0; y < imageHeight / 2; y++) {<span style="white-space: pre;"></span>yuv[i] = data[(imageWidth * imageHeight) + (y * imageWidth) + x];<span style="white-space: pre;"></span>i--;<span style="white-space: pre;"></span>yuv[i] = data[(imageWidth * imageHeight) + (y * imageWidth)<span style="white-space: pre;"></span>+ (x - 1)];<span style="white-space: pre;"></span>i--;<span style="white-space: pre;"></span>}<span style="white-space: pre;"></span>}<span style="white-space: pre;"></span>return yuv;<span style="white-space: pre;"></span>}
0 0
- android采集的视频进行旋转
- android采集的视频进行旋转
- android视频采集YUV420旋转角度算法
- 使用JMF进行视频、音频的采集与实时传送
- 使用JMF进行视频、音频的采集与实时传送
- Window7系统 opencv 利用DirectShow 进行视频采集的解决方案
- iOS 摄像头,进行音视频的数据采集
- Android视频采集
- Android视频采集
- android 视频流采集
- Android视频采集
- android 视频流采集
- Android视频采集
- android视频采集
- android 视频采集
- Android视频采集
- Android 实时视频采集
- android 实时视频采集
- 清理Xcode缓存
- Ubuntu如何安装Adobe Flash Player
- 在对象之间搬移特性(一)
- javascript 原生进行时
- 跑男寻宝游戏,AR,及基于地理位置的移动广告技术
- android采集的视频进行旋转
- http状态码
- android studio中怎样修改jdk和sdk路径
- Activity详解
- HDU 5807 Keep In Touch(dp)
- 自己动手写Kinect程序(一)
- Fragment详解
- java替换掉字符串中的特殊字符
- window对象--JavaScript 计时器