Android的摄像机2加速 [英] Android camera2 speed-up

查看:1251
本文介绍了Android的摄像机2加速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要以加快摄像机2 API的捕获。我试图建立从谷歌样Android的Camera2Basic项目。对于默认捕获请求从例如:

I need to speed-up capturing of camera2 API. I tried to build "android-Camera2Basic" project from google samples. For default capture request from example:

 if (null == activity || null == mCameraDevice) {
            return;
        }
        // This is the CaptureRequest.Builder that we use to take a picture.
        final CaptureRequest.Builder captureBuilder =
                mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
        captureBuilder.addTarget(mImageReader.getSurface());

        // Use the same AE and AF modes as the preview.
        captureBuilder.set(CaptureRequest.CONTROL_AF_MODE,
                CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
        captureBuilder.set(CaptureRequest.CONTROL_AE_MODE,
                CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);

        // Orientation
        int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
        captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATIONS.get(rotation));

        CameraCaptureSession.CaptureCallback CaptureCallback
                = new CameraCaptureSession.CaptureCallback() {

            @Override
            public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
                                           TotalCaptureResult result) {
                showToast("Saved: " + mFile);
                unlockFocus();
            }
        };

        mCaptureSession.stopRepeating();
        mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);

这需要200-300ms从发送请求

It takes 200-300ms from send request

mCaptureSession.capture(captureBuilder.build(), CaptureCallback, null);

和GET导致

onImageAvailable(ImageReader reader)

时可以减少这个时间呢?我试着设置捕获请求不同的参数,如TEMPLATE_ZERO_SHUTTER_LAG,NOISE_REDUCTION_MODE_OFF,EDGE_MODE_OFF等,但它没有任何效果。
如果我尝试捕捉突发,那么所有的图像,除了第一类是涉及非常快,没有更多然后30-40ms。我怎样才能减少拍摄时间,第一形象?

Is it possible to reduce this time? I tried set different parameters for capture request, such as TEMPLATE_ZERO_SHUTTER_LAG, NOISE_REDUCTION_MODE_OFF, EDGE_MODE_OFF, etc. But it has no any effect. If I try to capture burst, then all images, except first are comes very fast, no more then in 30-40ms. How can I reduce capturing time for first image?

推荐答案

回答您的意见,但使它成为一个合适的回答:

replying to your comment, but making it into a proper answer:

如果您从三星开发检查这些幻灯片。幻灯片#22会议它显示了摄像机2的模式。正如你所看到的,是几个队列:

If you check those slides from the Samsung dev. conference on slide #22 it shows the camera2 model. As you can see, there're several queues:


  • 暂停请求队列

  • 在飞行捕获队列

  • 输出图像队列表面显示相机preVIEW

  • 和回调 onCaptureComplete

  • Pending Request queue
  • In flight capture queue
  • output image queue to the Surface showing the camera preview
  • and the callback to onCaptureComplete

这解释了为什么第一个捕获是缓慢的,但在突发模式下一个图像来非常快。请求和处理进行排队和第一需要300ms以内一路到达回到了回调,但下一个已经是正确的后面。

that explains why the 1st capture is slow, but in burst mode the next images comes very fast. The requests and processing are queued and the 1st takes 300ms to arrive all the way back on the callback but the next one is already "right behind it".

如果你有兴趣的新的API中(谁也不会1,摄像机是惊人的),你也可以检查的全由三星开发的​​视频。会议在YouTube上。和官方文档。很多在这些好消息的。

If you're interested in the new API (and who wouldn't be, camera2 is amazing), you can also check the full video from the Samsung Dev. conference on YouTube. And the official docs. Lot's of good info on those.

这篇关于Android的摄像机2加速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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