相机setFocusAreas()不工作的Andr​​oid 4.0 [英] Camera setFocusAreas() not working Android 4.0

查看:1323
本文介绍了相机setFocusAreas()不工作的Andr​​oid 4.0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要创建一个摄像头应用程序,将使用触摸对焦的功能,就像许多标准摄像头的应用程序配备的。我第一次拿到(X,Y)坐标触摸事件,那么实现这一价值的用户界面。于是,我尝试设置的对焦区域,像这样的:

I'm creating a camera app that will use a tap to focus function, much like many of the standard camera apps come with. I first get the (x,y) coordinate of a touch event, then deliver this value to the UI. Then, I try to set the focus area, like this:

Rect newRect = new Rect(left,top,right, bottom);
Camera.Parameters params = mCamera.mCameraInstance.getParameters();
Camera.Area focusArea = new Camera.Area(newRect, 1000);
List<Camera.Area> focusAreas = new ArrayList<Camera.Area>();
focusAreas.add(focusArea);
params.setFocusAreas(focusAreas);

然而,似乎没有任何效果。所以,我很难codeD一些值的矩形(这样一来,我可以排除从触摸事件坏坐标)。 <一href="http://developer.android.com/reference/android/hardware/Camera.Parameters.html#getFocusAreas%28%29">According该文档,它正在寻找的空间(-1000,-1000)(左上)到(1000,1000)(右下)的坐标。

However, it appears to have no effect. So, I hardcoded some values into the rectangle (this way, I can rule out bad coordinates from the touch event). According to the docs, it is looking for a coordinate in the space (-1000, -1000)(upper left) to (1000, 1000)(bottom right).

所以我代替我的矩形上方有这样一句:

So I replaced my rectangle above with this one:

//should target a 100x100 square in the center of the screen
Rect newRect = new Rect(-50,-50,50, 50);

和还在,似乎没有任何效果。我知道我的相机设置支持的重点领域,因为首先,摄像头的应用程序成功地使用它,也params.getMaxNumFocusAreas()返回1。

And still, seems to have no effect. I know my camera supports setting focus areas, because first of all, the camera app uses it successfully, and also params.getMaxNumFocusAreas() returns 1.

如果任何人有过去的成功使用此,请让我知道!

If anyone has used this with success in the past, please let me know!!

我发现这个<一href="http://stackoverflow.com/questions/10649788/android-in-camera-how-to-set-focusable-area-in-api-14-or-greater?rq=1">similar 这个问题似乎也表明该API根本没有在Android 4.0设备(4.1.1,银河S3 IM测试)工作并起来。然而,在这些设备上的摄像头应用程序还是绝对有自来水对焦的功能。我在想什么???

I found this similar question that seems to also indicate that this API simply doesn't work on Android 4.0 devices and up (im testing on 4.1.1, Galaxy S3). And yet, the camera apps on these devices still definitely has tap-to-focus functionality. What am I missing???

推荐答案

我今天有这个问题:/

I had this problem today :/

和挣扎了几个小时之后,我找到了解决办法!

And after hours of struggling, I found the solution!

很奇怪,但现在看来,设置对焦模式为宏观之前正确设置焦点领域解决了这个问题;)

It's strange, but it appears that setting focus-mode to "macro" right before setting focus-areas solved the problem ;)

params.setFocusMode(Camera.Parameters.FOCUS_MODE_MACRO);
params.setFocusAreas(focusAreas);
mCamera.setParameters(params);

我的Galaxy S3采用Android 4.1.2

I have Galaxy S3 with Android 4.1.2

我希望这会为您:)

这篇关于相机setFocusAreas()不工作的Andr​​oid 4.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆