https://stackoverflow.com/questions/2978095/android-camera-api-iso-setting

exif this.mCameraParameter.get("cur-iso");

you should take a look at the methods flatten()unflatten()get(String key)set(String key, String value) in android.hardware.Camera.Parameters. Also consider the source code of that class. It might make things clearer.

First you need to obtain the Camera.Parameters. Unflatten it to a String and investigate it. I am developing on a HTC Desire as well an get the following String:

sharpness-max=30;zoom=0;taking-picture-zoom=0;zoom-supported=true;sharpness-min=0;sharpness=10;contrast=5;whitebalance=auto;jpeg-quality=100;preview-format-values=yuv420sp;jpeg-thumbnail-quality=75;preview-format=yuv420sp;preview-size=640x480;focal-length=3.53;iso=auto;meter-mode=meter-center;front-camera-mode=mirror;flash-mode-values=off,auto,on,torch;preview-frame-rate-values=15;preview-frame-rate=15;focus-mode-values=auto,infinity;jpeg-thumbnail-width=640;jpeg-thumbnail-size-values=640x480,512x384,384x288,0x0;zoom-ratios=100,114,131,151,174,200;saturation-def=5;preview-size-values=1280x720,800x480,768x432,720x480,640x480,576x432,480x320,400x240,384x288,352x288,320x240,272x272,240x240,240x160,176x144,160x120;smart-contrast=off;picture-size-values=2592x1952,2592x1456,2592x1936,2592x1728,2592x1552,2048x1536,2048x1360,2048x1216,2048x1152,1600x1200,1584x1056,1280x960,1280x848,1280x768,1280x720,1024x768,640x480,640x416,640x384,640x368,512x384,400x400,272x272;contrast-min=0;min-exposure-compensation=-4;brightness-min=0;antibanding=auto;taking-picture-zoom-min=0;saturation-min=1;contrast-max=10;vertical-view-angle=42.5;taking-picture-zoom-max=21;contrast-def=5;brightness-max=6;horizontal-view-angle=54.8;brightness=3;jpeg-thumbnail-height=480;cam-mode=0;focus-mode=auto;sharpness-def=10;front-camera-mode-values=mirror,reverse;picture-format-values=jpeg;saturation-max=10;max-exposure-compensation=4;exposure-compensation=0;exposure-compensation-step=0.5;flash-mode=off;effect-values=none,mono,negative,solarize,sepia,posterize,aqua;meter-mode-values=meter-average,meter-center,meter-spot;picture-size=2592x1952;max-zoom=5;effect=none;saturation=5;whitebalance-values=auto,incandescent,fluorescent,daylight,cloudy-daylight;picture-format=jpeg;brightness-def=3;iso-values=auto,deblur,100,200,400,800,1250;enable-caf=off;antibanding-values=off,50hz,60hz,auto

So basically there is a key called iso-values to retrieve the supported values and a key iso which holds the current value.

You can do the following:

Camera cam = Camera.open();
Camera.Parameters camParams = cam.getParameters();
String supportedIsoValues = camParams.get("iso-values"); //supported values, comma separated String
camParams.set("iso", (String)newValue);
cam.setParameters(camParams);

And with reference to the unflattened parameters I would assume that there is a difference between the iso and exposure compensation settings.

answered Mar 8 '11 at 20:23
szia

20527
 
    
parameters.get("iso-values") returns NULL on a HTC Desire. Any other ideas? – radhoo Oct 5 '11 at 11:22
    
@radhoo Desire should support ISO. See my answer below to retrieve a list of valid ISO values (and the keywords) from camera.parameters.flatten(). – j.c May 9 '14 at 14:38

By now (KK 4.4.2) android has no official APIs to manage ISO.
ISO management is a totally device dependant matter, and 8/18 devices i tested so far doesn't support ISO settings at all.
Investigate Camera.getParameters().flatten() String to check valid keywords, every device can use different keywords!!
Most devices use "iso-values" keyword to define a comma separated list-of-possible-values to use with "iso" keyword, like this:

param.set("iso", valid_value_from_list);

Some other devices uses "iso-mode-values" and "iso" keywords (Galaxy Nexus).
I found also a device that uses "iso-speed-values" and "iso-speed" (Micromax A101).
Another one that make me sad is "nv-picture-iso-values" -> "nv-picture-iso" (LG dual P990).

Follow szia answer on how to use these keywords.

Here's some code i use to get a list of valid values using known keywords:

String flat = param.flatten();
String[] isoValues = null;
String values_keyword=null;
String iso_keyword=null;
if(flat.contains("iso-values")) {
// most used keywords
values_keyword="iso-values";
iso_keyword="iso";
} else if(flat.contains("iso-mode-values")) {
// google galaxy nexus keywords
values_keyword="iso-mode-values";
iso_keyword="iso";
} else if(flat.contains("iso-speed-values")) {
// micromax a101 keywords
values_keyword="iso-speed-values";
iso_keyword="iso-speed";
} else if(flat.contains("nv-picture-iso-values")) {
// LG dual p990 keywords
values_keyword="nv-picture-iso-values";
iso_keyword="nv-picture-iso";
}
// add other eventual keywords here...
if(iso_keyword!=null) {
// flatten contains the iso key!!
String iso = flat.substring(flat.indexOf(values_keyword));
iso = iso.substring(iso.indexOf("=")+1); if(iso.contains(";")) iso = iso.substring(0, iso.indexOf(";")); isoValues = iso.split(","); } else {
// iso not supported in a known way
}
answered May 9 '14 at 14:26
j.c

1,26711130
 
    
Shouldn't iso_keyword be "iso-mode" instead of "iso" for google galaxy nexus keywords? – Fatih Ozcan Jun 21 at 6:39

since I had the same problem of finding if the device has an ISO parameter I looked at this answer https://stackoverflow.com/a/23567103/3976589 and saw that @j.c had solved the problem for 8/18 devices by listing some parameters that he had found on different devices. Based on that listing I found that each paramter contains the words iso and values (sometimes only those words, sometimes something additional).

So if I list all of the camera parameters and search for a strings that contain both words I will know what is the name of the ISO parameter, if it exists. Furthermore if the parameter exists I can take the supported ISO values and if I want to set one of those values i.e. change the camera parameter, I can just remove the -values at the end of the iso-values parameter and then I can change the ISO value successfully.

I will now share my code for this task. First a snippet that retrieves a list with supported ISO values.

    private String ISOValuesParameter = null;
private String ISOParameter = null;
private String ISOValues = null; private void initCamera() {
Camera mCamera = Camera.open(); // this will list supported values
String ISOvalues = getISOValues();
textViewISO = (TextView) findViewById(R.id.viewISO);
textViewISO.setText(ISOvalues); // setting Minimum ISO value
if(ISOValuesParameter != null) {
Camera.Parameters params = mCamera.getParameters(); ISOParameter = ISOValuesParameter.replace("-values", "");
params.set(ISOParameter, getMinISO()); mCamera.setParameters(params); // get the updated ISO value
params = mCamera.getParameters(); String ISO = params.get(ISOParameter); Toast.makeText(this,"ISO set to: " + ISO, Toast.LENGTH_SHORT).show();
} } // returns a list with supported ISO values
private String getISOValues() {
ISOValuesParamter = getISOValuesParameter();
Camera.Parameters params = mCamera.getParameters();
ISOValues = params.get(ISOValuesParamter); return ISOValues!=null ? ISOValues : "ISO not supported";
} // this will return the name of the ISO parameter containing supported ISO values
private String getISOValuesParameter() {
Camera.Parameters params = mCamera.getParameters(); String flatten = params.flatten();
String[] paramsSeparated = flatten.split(";");
for(String cur : paramsSeparated) {
if(cur.contains("iso") && cur.contains("values")) {
return cur.substring(0,cur.indexOf('='));
}
} return null;
}

This snippet only lists the supported ISO values. In my application I needed to pick the lowest ISO. Here is my solution:

private String getMinISO() {
if(ISOValues == null) {
return null;
} String[] ISOarray = ISOValues.split(",");
Arrays.sort(ISOarray, myComparator); String minISO = ISOarray[ISOarray.length-1]; return minISO;
}

Here myComparator is a class that compares two strings and sorts the array in descending order. All alphabet words are at the beginning and all numbers are at the end. Here is my implementation:

// Singelton class
public class MyComparator implements Comparator<String> { private static MyComparator myComparator = null; private MyComparator() {} @Override
public int compare(String a, String b) {
return compareString(a,b);
} public static int compareString(String a, String b) {
if (a.length() > b.length())
return -1;
if (a.length() == b.length()) {
if (a.compareTo(b) > 0)
return -1;
else if (a.compareTo(b) == 0)
return 0;
} return 1;
} public static synchronized MyComparator getInstance() {
if(myComparator==null) {
myComparator = new MyComparator();
} return myComparator;
} }

I hope my answer helps other people. :)

Cheers! @ee3509

answered Jun 1 '16 at 11:21
 

szias answer is correct.

Only

String supportedIsoValues = camParams.get("iso-values");

returns null on some devices.

Nevertheless you can set the iso by

Camera cam = Camera.open();
Camera.Parameters camParams = cam.getParameters();
camParams.set("iso", "400"); // values can be "auto", "100", "200", "400", "800", "1600"
cam.setParameters(camParams);

I do not know whether "800" or "1600" is supported on all devices

you can check what you did by

String newVAlue = camParams.get("iso");
answered Dec 4 '12 at 7:04
tmanthey

3,43712537
 
    
For reference, on my two phones (both samsung models), the acceptable values are prefixed "ISO", and 800 is available on one but not both while neither support 1600. – Jules Feb 28 '14 at 15:19

Forgive my ignorance, but how is this different from "exposure compensation" set via setExposureCompensation()? Wikipedia has some of the conversion formulas you might find useful.

answered Jun 4 '10 at 22:25
Charles Merriam

8,50744152
 
    
I am not entirely sure if the exposure setting would achieve the same results with the iso setting, it could be possible. However the desire is running 2.1 and the setExposureCompensation is available to API level 8 which is 2.2 So there must be another way in 2.1 to do it. Thanks for your answer – ee3509 Jun 4 '10 at 23:20

Android Camera API ISO Setting的更多相关文章

  1. Android Camera API/Camera2 API 相机预览及滤镜、贴纸等处理

    Android Lollipop 添加了Camera2 API,并将原来的Camera API标记为废弃了.相对原来的Camera API来说.Camera2是又一次定义的相机 API,也重构了相机 ...

  2. Android Camera Api的心得

    (一) 前言最近看Camera的api,觉得写的真的不错.现在翻译过来,给大家分享分享,译文可能不太好,大家将就着看哈. (二) 正文1. CameraCamera是Android framework ...

  3. Android 新老两代 Camera API 大起底

    https://blog.csdn.net/Byeweiyang/article/details/80515192 0.背景简介 最近有一部分相机相关的需求,专注于对拍摄的照片.视频的噪点.色温.明暗 ...

  4. Android 音视频开发(四):使用 Camera API 采集视频数据

    本文主要将的是:使用 Camera API 采集视频数据并保存到文件,分别使用 SurfaceView.TextureView 来预览 Camera 数据,取到 NV21 的数据回调. 注: 需要权限 ...

  5. 【Android】Android Camera原始帧格式转换 —— 获取Camera图像(一)

     概述: 做过Android Camera图像采集和处理的朋友们应该都知道,Android手机相机采集的原始帧(RawFrame)默认是横屏格式的,而官方API有没有提供一个设置Camera采集图像的 ...

  6. Android Camera 相机程序编写

    Android Camera 相机程序编写 要自己写一个相机应用直接使用相机硬件,首先应用需要一个权限设置,在AndroidManifest.xml中加上使用设备相机的权限: <uses-per ...

  7. 摄像头(5)使用Camera2 替代过时的Camera API

    转自: http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2015/0428/2811.html 概要 从5.0开始(API Level 21 ...

  8. Android Camera详解

    相关的类 android.hardware.camera2 Camera SurfaceView---这个类用于向用户呈现实时相机预览. MediaRecorder---这个类用于从摄像机录制视频. ...

  9. Android学习十---Android Camera

    Android camera用来拍照和拍摄视频的先看一下最后实现的效果图             最后的效果图 一.准备 在你的应用程序上使用android拍照设备,需要考虑以下几个方面 1. 是否是 ...

随机推荐

  1. 在Hyper-V Linux VM如何选择LIS Linux集成服务

    导读 很多工程师都知道,如果你选择在 Hyper-V 中运行 Linux guest VM,要获得最好的使用体验,必需针对你所使用的 Linux 发行版和使用场景选择 Linux Integratio ...

  2. 如何用Project2010制作WBS

    如何用Project2010制作WBS: http://www.projectup.net/blog/index.php?option=com_content&view=article& ...

  3. 【BZOJ1135】[POI2009]Lyz 线段树

    [BZOJ1135][POI2009]Lyz Description 初始时滑冰俱乐部有1到n号的溜冰鞋各k双.已知x号脚的人可以穿x到x+d的溜冰鞋. 有m次操作,每次包含两个数ri,xi代表来了x ...

  4. oracle怎么把一个用户下的表复制给另一个用户?(授予表权限)

    //把system读写权限 授权给scottselect 'Grant all on '||table_name||' to scott;' from all_tables where owner = ...

  5. mybatis的一对多,多对一,以及多对对的配置和使用

    1.本文章是无意中看见易百教程的Mybatis教程才注意到这个问题,平时都仅仅是在用CRUD,忽略了这方面的问题,真实十分羞愧   2.首先我们开始对mybatis的一对多的探究   根据这个应用场景 ...

  6. 160419、CSS3实现32种基本图形

    CSS3可以实现很多漂亮的图形,我收集了32种图形,在下面列出.直接用CSS3画出这些图形,要比贴图性能更好,体验更加,是一种非常好的网页美观方式. 这32种图形分别为圆形,椭圆形,三角形,倒三角形, ...

  7. 160414、java上传文件以流方式判断类型

    public enum FileType {       /**        * JEPG.        */       JPEG("FFD8FF"),          / ...

  8. Struts2数据验证与使用Java代码进行数据验证

    Struts2数据验证 使用Java代码进行数据验证 重写ActionSupport的validate()方法 对Action类的中所有请求处理方法都会进行验证! 对Action类的数据属性进行检查, ...

  9. 20165330 2017-2018-2 《Java程序设计》第1周学习总结

    教材学习内容总结 java的历史,地位,特点. java的平台介绍 java应用程序的开发及源文件的编写规则 java反编译特点 安装JDK Windows上 在安装JDK后设置系统环境变量,因为我的 ...

  10. Python中的编码与解码(转)

    Python中的字符编码与解码困扰了我很久了,一直没有认真整理过,这次下静下心来整理了一下我对方面知识的理解. 文章中对有些知识没有做深入的探讨,一是我自己也没有去深入的了解,例如各种编码方案的实现方 ...