Galaxy S5 上的 FOCUS_MODE_CONTINUOUS_PICTURE 出现问题 [英] Trouble with FOCUS_MODE_CONTINUOUS_PICTURE on Galaxy S5

查看:28
本文介绍了Galaxy S5 上的 FOCUS_MODE_CONTINUOUS_PICTURE 出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个使用相机预览和拍照的 Android 应用.我在 Galaxy S4 上使用 FOCUS_MODE_CONTINUOUS_PICTURE,发现对焦效果很好.

I'm working on an Android app that uses the camera to preview and take pictures. I use FOCUS_MODE_CONTINUOUS_PICTURE with the galaxy S4 and find that the focusing works very well.

然而,在 Galaxy S5 上,FOCUS_MODE_CONTINUOUS_PICTURE 很少能正确找到焦点.相机会放大对焦,但随后会反复缩小对焦.

However, on the galaxy S5 the FOCUS_MODE_CONTINUOUS_PICTURE rarely ever finds the focus properly. The camera will zoom into focus, but then zoom back out of focus repeatedly.

有没有人知道为什么 FOCUS_MODE_CONTINUOUS_PICTURE 在 S5 上效果这么差,或者任何人都可以确认他们是否有同样的问题?

Does anyone have an idea of why the FOCUS_MODE_CONTINUOUS_PICTURE works so poorly on the S5, or can anyone confirm whether or not they have the same issue?

推荐答案

我也遇到过同样的问题.

I too have experienced these same issues.

Galaxy S5 以及可能的其他设备在连续图片对焦模式下似乎没有可靠的行为.这对于开发人员来说非常令人沮丧,因为代码在大多数设备上都能完美运行,但随之而来的是 S5(非常流行的设备),我们看起来很糟糕.

The Galaxy S5, and possibly other devices, don't seem to have reliable behavior in continuous picture focus mode. This is very frustrating as a developer, when code works perfectly on most devices, but then along comes the S5 (a very popular device) and we look pretty bad.

在头疼之后,我认为我有一个运行良好的解决方案(更多的是一种解决方法).

After much head scratching, I think I have a solution (more of a workaround) that is working well.

  1. 将相机设置为 FOCUS_MODE_CONTINUOUS_PICTURE
  2. 在拍照的手势处理程序中(例如按钮点击、触摸事件),将相机切换到 FOCUS_MODE_AUTO,然后以延迟方式调用 Camera.autoFocus()

这在照片预览期间提供了不错的连续对焦 UI,但在可靠的自动对焦模式下拍摄照片.

this provides the nice continuous focus UI during photo preview, but takes the picture in reliable auto-focus mode.

代码如下:

 protected void onTakePicture()
 {

  // mCamera is the Camera object
  // mAutoFocusCallback is a Camera.AutoFocusCallback handler

  try
  {

   // determine current focus mode
   Camera.Parameters params = mCamera.getParameters();
          if (params.getFocusMode().equals(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE))
   {
    mCamera.cancelAutoFocus();      // cancels continuous focus

    List<String> lModes = params.getSupportedFocusModes();
    if (lModes != null)
    {
     if (lModes.contains(Camera.Parameters.FOCUS_MODE_AUTO))
     {
      params.setFocusMode(Camera.Parameters.FOCUS_MODE_AUTO); // auto-focus mode if supported
      mCamera.setParameters(params);        // set parameters on device
     }
    }

    // start an auto-focus after a slight (100ms) delay
    new Handler().postDelayed(new Runnable() {

     public void run()
     {
      mCamera.autoFocus(mAutoFocusCallback);    // auto-focus now
     }

    }, 100);

    return;
   }

   mCamera.autoFocus(mAutoFocusCallback);       // do the focus, callback is mAutoFocusCallback

  }
  catch (Exception e)
  {
   Log.e("myApp", e.getMessage());
  }
}

请尝试一下并报告您的结果

please give this a try and report back your results

这篇关于Galaxy S5 上的 FOCUS_MODE_CONTINUOUS_PICTURE 出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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