use*_*563 9 video android unity-game-engine augmented-reality vuforia
我正在尝试为AR应用添加视频捕获功能.基本上记录屏幕上发生的事情,并将其保存为视频(允许用户共享).AR APP使用Vuforia-Unity SDK编写.我们在iOS平台上成功实现了这一点.
但是,在Android平台上做同样的事情我们遇到了很大的困难.(我们希望通过生根设备实现这一目标)
以下是我们的进展:
Vuforia程序使摄像机失灵,我无法访问视频流.
我尝试捕获每帧的screeshot,然后将它们组合成一些视频输出; 但帧率很差(小于1 fps).拍摄屏幕截图需要700毫秒.
我是从错误的方向思考的吗?任何帮助将深表感谢!非常感谢!艾萨克
以下是我的测试代码:
public void acquireScreenshot() {
DisplayMetrics metrics = new DisplayMetrics();
WindowManager WM = (WindowManager) MainActivity.this.getSystemService(Context.WINDOW_SERVICE);
Display display = WM.getDefaultDisplay();
display.getMetrics(metrics);
int height = metrics.heightPixels; // screen height
int width = metrics.widthPixels; // screen width
int pixelformat = display.getPixelFormat();
PixelFormat localPixelFormat1 = new PixelFormat();
PixelFormat.getPixelFormatInfo(pixelformat, localPixelFormat1);
int deepth = localPixelFormat1.bytesPerPixel;
byte[] arrayOfByte = new byte[height* width* deepth];
long tmp = System.currentTimeMillis();
try {
for(int i = 0 ; i < 10 ; i++){
InputStream localInputStream = readAsRoot();
DataInputStream localDataInputStream = new DataInputStream(
localInputStream);
android.util.Log.e("mytest", "-----read start-------");
localDataInputStream.readFully(arrayOfByte);
android.util.Log.e("mytest", "-----read end-------time = " + (System.currentTimeMillis() -tmp ));
localInputStream.close();
File mid = new File("/mnt/sdcard/AAA");
if(!mid.exists()){
mid.mkdir();
}
FileOutputStream out = new FileOutputStream(new File(
"/mnt/sdcard/AAA/"+System.currentTimeMillis()+".png"));
int[] tmpColor = new int[width * height];
int r, g, b;
tmp = System.currentTimeMillis();
android.util.Log.e("mytest", "-----bitmap start-------");
for (int j = 0; j < width * height * deepth; j+=deepth) {
b = arrayOfByte[j]&0xff;
g = arrayOfByte[j+1]&0xff;
r = arrayOfByte[j+2]&0xff;
tmpColor[j/deepth] = (r << 16) | (g << 8) | b |(0xff000000);
}
Bitmap tmpMap = Bitmap.createBitmap(tmpColor, width, height,
Bitmap.Config.ARGB_8888);
android.util.Log.e("mytest", "-----bitmap end-------time = " + (System.currentTimeMillis() -tmp ));
tmp = System.currentTimeMillis();
android.util.Log.e("mytest", "-----compress start-------");
tmpMap.compress(Bitmap.CompressFormat.PNG, 100, out);
android.util.Log.e("mytest", "-----compress end-------time = " + (System.currentTimeMillis() -tmp ));
out.close();
Thread.sleep(40);
}
} catch (Exception e) {
android.util.Log.e("mytest", "Exception");
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3897 次 |
| 最近记录: |