2

如何使用Android代码识别Android设备的前后摄像头百万像素?我试过CameraInfo,但没有得到百万像素。例如,要识别我们正在使用的设备型号android.os.Build.MODEL。同样,任何识别前后摄像头百万像素的方法。提前感谢您的帮助。

如果设备的"Videocon A53"功能是(540x960 像素)显示并运行 Android 4.1 Jelly Bean 8-megapixel rear camera,. 2-megapixel front-facing camera现在我想得到那个8 megapixel and 2 megapixel by android code

4

1 回答 1

4

通过结合堆栈溢出朋友的三个不同答案,我得到了百万像素。

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

为了获得百万像素,(Biggest Width x Height) / 1024000 = Megapixel

于 2013-10-19T09:10:56.023 回答