2013-07-02 34 views
7

我試圖將視頻捕獲功能添加到AR應用程序。 基本上記錄屏幕上發生了什麼,並將其保存爲視頻(允許用戶共享)。 AR APP是用Vuforia-Unity SDK編寫的。 我們已經在iOS平臺上成功實現了這一點。AR(Vuforia)在Android平臺上的統一視頻捕獲

但是,我們在Android平臺上做同樣的事情時遇到了很大的困難。 (我們希望用了生根的設備來實現這一點)

以下是我們的進步:

  1. 的照相機被Vuforia程序ocuppied,我無法訪問視頻流。

  2. 我已經嘗試捕獲每幀的screeshot,然後將它們組合到一些視頻輸出;但幀率非常差(小於1 fps)。捕捉屏幕截圖需要700ms。

我是從錯誤的方向思考的嗎?任何幫助將深表感謝! 非常感謝! 艾薩克

以下是我的測試代碼:

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(); 
    } 

} 
+0

你有沒有機會得到解決方案:) –

+0

尚未.....>< – user2542563

+0

有什麼進展?到目前爲止,我做的事情完全一樣,沒有運氣。 – vmachacek

回答

0

我們以前使用的一些英特爾的插件,以實現相機記錄。

Video Capturing for Unity3d* Applications on Android*

它是實現相當簡單。希望你會發現它們有用。

+0

這看起來不再受支持。你還在使用這個或其他解決方案嗎? –