我试图检索可用摄像头的图像大小,所以我能够调节相机给我的preferred图像分辨率。
要获取Android摄像头的大小,我用下面的code:
摄像头= Camera.open();
参数PARAMS = camera.getParameters();
列表大小= params.getSupportedPictureSizes();
的for(int i = 0; I< sizes.size();我++){
Log.i(PictureSize,支持的大小:+ sizes.get(一));
}
这给了我下面的输出,这我不知道如何翻译成大小。
支持大小:android.hardware.Camera$Size@65d4c50
支持大小:android.hardware.Camera$Size@65d4a70
支持大小:android.hardware.Camera$Size@3fe4e00
支持大小:android.hardware.Camera$Size@3fe4cd0
支持大小:android.hardware.Camera$Size@18f5600
支持大小:android.hardware.Camera$Size@13f7860
如果有人可以帮助我了解的输出,这将有助于我很多,非常感谢!
编辑:我最终通过执行下列操作解决我的问题:
摄像头= Camera.open();
参数PARAMS = camera.getParameters();
列表大小= params.getSupportedPictureSizes();
Camera.Size结果= NULL;
的for(int i = 0; I< sizes.size();我++){
结果=(尺寸)sizes.get(我);
Log.i(PictureSize,支持尺寸宽:+ result.width +的高度:+ result.height);
}
解决方案
getSupportedPictureSizes()
返回的列表
Camera.Size
的对象。 Camera.Size
的高度
和宽度
数据告诉成员您所支持的画面尺寸的高度和宽度。
下面是一个示例项目使用相关的 getSupported previewSizes()
找到preVIEW尺寸与比 SurfaceView
的较小面积最大大小。
I am trying to retrieve the available camera image sizes, so I able to adjust the camera to my preferred image resolution.
To retrieve the Android camera size I've used the following code:
camera=Camera.open();
Parameters params = camera.getParameters();
List sizes = params.getSupportedPictureSizes();
for (int i=0;i<sizes.size();i++){
Log.i("PictureSize", "Supported Size: " +sizes.get(i));
}
This gives me the following output, which I am not sure how to translate into a size.
"Supported size: android.hardware.Camera$Size@65d4c50"
"Supported size: android.hardware.Camera$Size@65d4a70"
"Supported size: android.hardware.Camera$Size@3fe4e00"
"Supported size: android.hardware.Camera$Size@3fe4cd0"
"Supported size: android.hardware.Camera$Size@18f5600"
"Supported size: android.hardware.Camera$Size@13f7860"
If anyone could help me understand the output it would help me a lot, thanks!
Edit: I ended up solving my problem by doing the following:
camera=Camera.open();
Parameters params = camera.getParameters();
List sizes = params.getSupportedPictureSizes();
Camera.Size result = null;
for (int i=0;i<sizes.size();i++){
result = (Size) sizes.get(i);
Log.i("PictureSize", "Supported Size. Width: " + result.width + "height : " + result.height);
}
解决方案
getSupportedPictureSizes()
returns a List
of Camera.Size
objects. Camera.Size
has height
and width
data members that tell you the height and width of the supported picture size.
Here is a sample project that uses the related getSupportedPreviewSizes()
to find the preview size with the largest area that is smaller than the SurfaceView
's size.