2016-11-14 6 views
0

私は自分の活動で前と後ろの両方のカメラ解像度を使用したいので、画像を区別することができます。アクティビティ内のデバイスのカメラ解像度を取得する方法は? (アンドロイド)

+0

これはhttp://stackoverflow.com/questions/19463858/how-to-get-front-and-back-cameras-megapixel-that-is-designed-for-android-deviceあなたを助けることができます。 – katmanco

+0

助けていない........カメラが償却されているためです。 –

+0

カメラの代わりに何か他のものを置いてはいませんか?通常、減価償却されたものは、新しく頑強なものに置き換えられます。 – katmanco

答えて

0
  Camera camera=Camera.open(0); // For Back Camera 
     android.hardware.Camera.Parameters params = camera.getParameters(); 
     List sizes = params.getSupportedPictureSizes(); 
     Camera.Size result = null; 

     ArrayList<Integer> arrayListForWidth = new ArrayList<Integer>(); 
     ArrayList<Integer> arrayListForHeight = new ArrayList<Integer>(); 

     for (int i=0;i<sizes.size();i++){ 
      result = (Size) sizes.get(i); 
      arrayListForWidth.add(result.width); 
      arrayListForHeight.add(result.height); 
      Log.debug("PictureSize", "Supported Size: " + result.width + "height : " + result.height); 
      System.out.println("BACK PictureSize Supported Size: " + result.width + "height : " + result.height); 
     } 
     if(arrayListForWidth.size() != 0 && arrayListForHeight.size() != 0){ 
      System.out.println("Back max W :"+Collections.max(arrayListForWidth));    // Gives Maximum Width 
      System.out.println("Back max H :"+Collections.max(arrayListForHeight));     // Gives Maximum Height 
         System.out.println("Back Megapixel :"+(((Collections.max(arrayListForWidth)) * (Collections.max(arrayListForHeight)))/1024000)); 
     } 
     camera.release(); 

     arrayListForWidth.clear(); 
     arrayListForHeight.clear(); 

     camera=Camera.open(1);  // For Front Camera 
     android.hardware.Camera.Parameters params1 = camera.getParameters(); 
     List sizes1 = params1.getSupportedPictureSizes(); 
     Camera.Size result1 = null; 
     for (int i=0;i<sizes1.size();i++){ 
      result1 = (Size) sizes1.get(i); 
      arrayListForWidth.add(result1.width); 
      arrayListForHeight.add(result1.height); 
      Log.debug("PictureSize", "Supported Size: " + result1.width + "height : " + result1.height); 
      System.out.println("FRONT PictureSize Supported Size: " + result1.width + "height : " + result1.height); 
     } 
     if(arrayListForWidth.size() != 0 && arrayListForHeight.size() != 0){ 
      System.out.println("FRONT max W :"+Collections.max(arrayListForWidth)); 
      System.out.println("FRONT max H :"+Collections.max(arrayListForHeight)); 
         System.out.println("FRONT Megapixel :"+(((Collections.max(arrayListForWidth)) * (Collections.max(arrayListForHeight)))/1024000)); 
     } 

     camera.release(); 
+0

カメラのオブジェクトが減価償却されていることを示しています。「残念なことにアクティビティが機能しなくなりました。」 –

+0

https://developer.android.com/reference/android/hardware/camera2/package-summary.html – MonkeyEdict

+0

これを見てください – MonkeyEdict

関連する問題