如何获得的是专为Android设备的正面和背面摄像头的像素? [英] How to get front and back camera's megapixel that is designed for android device?
问题描述
如何识别正面和Android设备的使用Android code背面摄像头的像素?
我曾试图CameraInfo,但我没有得到万像素。例如,我们使用该 android.os.Build.MODEL
识别设备的型号。同样的任何方法来确定前和后摄像机的像素。先感谢您的帮助。
How to identify front and back camera's Megapixel of an android device by using Android code?
I had tried CameraInfo but am not getting megapixel. For example, To identify Model of device we are using this android.os.Build.MODEL
. Likewise any method to identify Megapixel of front and back camera. Advance thanks for any help.
如果该设备是Videocon的A53
功能(540x960像素)的显示屏,运行的Android 4.1果冻豆, 800万像素后置摄像头
, 200万像素的前置摄像头
。现在我想获取 800万像素和200万像素搭载Android code
If the device is "Videocon A53"
features are (540x960 pixel) display and runs Android 4.1 Jelly Bean, 8-megapixel rear camera
, 2-megapixel front-facing camera
. Now i want to get that 8 megapixel and 2 megapixel by android code
推荐答案
我结合了三种不同的堆栈溢出的朋友解答了百万像素。
I got megapixel by combining three different answers of stack overflow friends.
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();
有关获得万像素,(最大宽x高)/ 1024000 =百万像素
这篇关于如何获得的是专为Android设备的正面和背面摄像头的像素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!