android camera setMeteringArea详解
摘要: 本文为作者原创,未经允许不得转载;原文由作者发表在博客园:http://www.cnblogs.com/panxiaochun/p/5802814.html
setMeteringArea()
android camera 类里的meteringArea可以用来设置自动白平衡和自动曝光补偿,自动对焦区域。
在此之前,我必须指出百度里关于setMeteringArea的一些错误的文章:
http://blog.csdn.net/candycat1992/article/details/21617741/
这里面的代码设计应该坑了不少人,毕竟拿来就能用,但是使用之后发现并不能准确的选择对焦区域,会跑偏。于是查阅了一下官方的说明文档。
首先,作为天朝的网民,不能用google真是个悲剧,连个官方文档都看不到,为此特意翻墙才能找到准确的说明文档:
https://developer.android.com/guide/topics/media/camera.html
有梯子的可以看一下,没有的可以看这篇,这个是国内有人翻译过来了:
http://blog.csdn.net/think_soft/article/details/7998478
getMeteringAreas注释
在Android的camera类里的getMeteringAreas函数的注释是这样的:
* <p>Gets the current metering areas. Camera driver uses these areas to
* <p>Each metering area is a rectangle with specified weight. The
* direction is relative to the sensor orientation, that is, what the
* sensor sees. The direction is not affected by the rotation or
* mirroring of {@link #setDisplayOrientation(int)}. Coordinates of the
* rectangle range from -1000 to 1000. (-1000, -1000) is the upper left
* point. (1000, 1000) is the lower right point.
这里面只说到-1000,-1000对应视图的左上角,1000,1000对应右下角,但是没说到是映射还是从视图中点往左上1000个像素点。所以导致了第一个链接里那份错误的代码。按照那份代码的理解,是按照视图中点分别往四个方向的1000个像素点为对焦区,超过了就没有效了。但实际是映射关系,不管屏幕的分辨率是多少,竖屏还是横屏,这1000都是映射到图像预览图上的。这在area类里面有提到:
* <p>The Area class is used for choosing specific metering and focus areas for
* <p>Each Area consists of a rectangle specifying its bounds, and a weight
* that determines its importance. The bounds are relative to the camera's
* current field of view. The coordinates are mapped so that (-1000, -1000)
* is always the top-left corner of the current field of view, and (1000,
* 1000) is always the bottom-right corner of the current field of
实际上意思就是以下官方文档里面的图所示:

在此,我们知道点击位置后要转化成图像预览图里面的坐标再转化成1000的坐标值,再设置setMaertingArea才能正确,要不然,点击了一个亮的区域白平衡和曝光补偿没有正确调整,很大原因就是点击的坐标没有正确对应到预览图中,所以导致错误。由于预览图是不是正方形的,而设置的1000个坐标值是被拉伸了,如果要设置成正方形还要对设置的区域拉伸。


以上两个截图中红色方框中的区域是选择区域,事实证明这是对的。
android camera setMeteringArea详解的更多相关文章
- android:ToolBar详解
android:ToolBar详解(手把手教程) 泡在网上的日子 发表于 2014-11-18 12:49 第 124857 次阅读 ToolBar 42 来源 http://blog.mosil.b ...
- Android之canvas详解
首先说一下canvas类: Class Overview The Canvas class holds the "draw" calls. To draw something, y ...
- 【转】Android Canvas绘图详解(图文)
转自:http://www.jcodecraeer.com/a/anzhuokaifa/androidkaifa/2012/1212/703.html Android Canvas绘图详解(图文) 泡 ...
- Android 核心分析 之八Android 启动过程详解
Android 启动过程详解 Android从Linux系统启动有4个步骤: (1) init进程启动 (2) Native服务启动 (3) System Server,Android服务启动 (4) ...
- Android GLSurfaceView用法详解(二)
输入如何处理 若是开发一个交互型的应用(如游戏),通常需要子类化 GLSurfaceView,由此可以获取输入事件.下面有个例子: java代码: package eoe.ClearTes ...
- Android编译过程详解(一)
Android编译过程详解(一) 注:本文转载自Android编译过程详解(一):http://www.cnblogs.com/mr-raptor/archive/2012/06/07/2540359 ...
- android屏幕适配详解
android屏幕适配详解 官方地址:http://developer.android.com/guide/practices/screens_support.html 一.关于布局适配建议 1.不要 ...
- Android.mk文件详解(转)
源:Android.mk文件详解 从对Makefile一无所知开始,折腾了一个多星期,终于对Android.mk有了一个全面些的了解.了解了标准的Makefile后,发现Android.mk其实是把真 ...
- Android Studio 插件开发详解四:填坑
转载请标明出处:http://blog.csdn.net/zhaoyanjun6/article/details/78265540 本文出自[赵彦军的博客] 在前面我介绍了插件开发的基本流程 [And ...
随机推荐
- C#仿google日历asp.net简单三层版本
网上搜了很多xgcalendar的例子都是Php开发的,而且官方站上的asp.net/MVC版 在vs10 08 都报错. 所以自己重新用三层写了一下希望对大家有帮助 废话不多说了 先看看它都有些什么 ...
- jQuery构造函数init参数分析(二)
接着上一篇随笔讨论. 如果selector是其他字符串情况就比较多了比较复杂了 // Handle HTML strings if ( typeof selector === "string ...
- SharePoint 2013 JavaScript API 记录
1.获取创建者字段(Author),oListItem为SPListItem对象 oListItem.get_item('Author')只能获取到对象,获取用户名要用oListItem.get_it ...
- VPN常见错误码(633,628,691)的意思及修复方法
因为工作原因经常上国外网站需要用到VPN,在这里总结一下使用中可能遇到的一些常见问题.(目前用Nydus觉得还不错) 1.633错误 :由于Windows系统本身的问题,在PPTP协议连接多次并断开之 ...
- CAGradientLayer的一些属性解析
CAGradientLayer的一些属性解析 iOS中Layer的坐标系统: 效果: - (void)viewDidLoad { [super viewDidLoad]; CAGradientLaye ...
- UI键盘通知
#import "ViewController.h" @interface ViewController () @property (nonatomic,strong) UITex ...
- iOS开发常用小技巧记录(持续更新)
以下问题都是自己在项目中遇到的,解决问题的方法肯定有多种,我所列举的不一定就是最好的解决办法.如有问题欢迎大家指正,补充,交流. 解决同时按两个按钮进两个view的问题.[button setExcl ...
- SQL Server日期时间格式转换字符串
在SQL Server数据库中,SQL Server日期时间格式转换字符串可以改变SQL Server日期和时间的格式,是每个SQL数据库用户都应该掌握的.本文我们主要就介绍一下SQL Server日 ...
- 在线研讨会webinars
我是怎么一步一步找到这里的? jedox-jedox Webinars (不懂意思)--->google [ webinars open source ],->htt ...
- 前端 初识angularJS的基本概念
DEMO1演示地址:http://webenh.chinacloudsites.cn/default/demo1 今天在这里分享分享我个人学习angular的知识点总结.在还没有接触到angula ...