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

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

问题描述

我正在使用一个Android应用程序,该应用程序使用相机预览和拍照.我在银河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.

但是,在星系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天全站免登陆