Я пытаюсь добавить функцию захвата видео в приложение AR. В основном записывает, что происходит на экране, и сохраняет его как видео (позволяя пользователю делиться им). AR APP написан с SDK Vuforia-Unity. Мы добились этого на платформе iOS.Видеозахват на AR (Vuforia) с единством в платформе Android
Однако у нас большие трудности с тем же делом на платформе Android. (Мы надеемся добиться этого из укоренения устройства)
Ниже наш прогресс:
Камера ocuppied программой Vuforia, я не могу получить доступ к видеопотока.
Я попытался захватить снимок каждого кадра и затем объединить их с некоторым видеовыходом; но частота кадров очень низкая (менее 1 кадра в секунду). Для захвата снимка экрана требуется 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();
}
}
если вдруг у вас есть решение :) –
еще не .....>< – user2542563
Прогресс? Я делаю то же самое без везения. – vmachacek