5

使用以下非常简单的相机预览活动(来自此处的 google 示例),Nexus 4 相机明显慢于设备的标准相机应用程序:

public class LiveCameraActivity extends Activity implements TextureView.SurfaceTextureListener {
      private Camera mCamera;
      private TextureView mTextureView;

      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);

          mTextureView = new TextureView(this);
          mTextureView.setSurfaceTextureListener(this);

          setContentView(mTextureView);
      }

      public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
          mCamera = Camera.open();

          try {
              mCamera.setPreviewTexture(surface);
              mCamera.startPreview();
          } catch (IOException ioe) {
              // Something bad happened
          }
      }

      public void onSurfaceTextureSizeChanged(SurfaceTexture surface, int width, int height) {
          // Ignored, Camera does all the work for us
      }

      public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
          mCamera.stopPreview();
          mCamera.release();
          return true;
      }

      public void onSurfaceTextureUpdated(SurfaceTexture surface) {
          // Invoked every time there's a new Camera preview frame
      }
  }

我在 Nexus 4 上的应用程序的相机速度一直存在问题,但我在其他设备上没有看到这个问题。我担心这是 Jelly Bean 4.2 的差异,但运行 JB4.2 的 Galaxy Nexus 手机可以正常工作,没有延迟。我意识到这个示例代码使用了 TextureView,但是其他手机在这个示例中没有遇到延迟。

任何帮助将不胜感激。

4

2 回答 2

9

我发现通过将录制提示设置为 true可以将预览帧速率提高到正常速率,但这会严重降低相机性能,尤其是在色彩饱和度和对比度方面的中低光情况下(我对质量感到震惊考虑到这是谷歌与 iPhone 5 和她的优质相机竞争的最新和最伟大的尝试……等不及 X Phone 了)。

不是问题的解决方案,但对于希望避免令人震惊的帧速率的开发人员来说,它是一种创可贴。

于 2013-01-08T19:28:26.200 回答
1

如果您将图片大小设置为 3264x2448,这将解决它。即使您从不拍照,图片大小也很重要,因为默认情况下启用了 ZSL。默认图片大小为 640x480,这会导致预览帧速率变慢。禁用 ZSL 会使预览速度更快,这就是为什么将录制命中设置为 true 会有所帮助,启用 HDR 会做同样的事情。

于 2013-03-25T19:46:29.490 回答