Java – Android Camera2 is too slow to capture bursts

I'm trying to modify the Android - Camera 2 basic code to capture a series of pictures However, running l 5.0 on my nexus 5 1. I can't get the delay between pictures at a speed of more than 200-300ms

I've tried a lot of things, but it's the most basic This is the only part of the Camera2 basic code I modified My preview TextureView is only 50x50dp, but it doesn't matter, does it?

For what is worth it, this code has only a delay of about 50-100ms in my nexus 6, with L 5.1

private void captureStillPicture() {
    try {
        List<CaptureRequest> captureList = new ArrayList<CaptureRequest>();
        mPreviewRequestBuilder.addTarget(mImageReader.getSurface());

        for (int i=0;i<10;i++) {
            captureList.add(mPreviewRequestBuilder.build());
        }

        mCaptureSession.stopRepeating();
        mCaptureSession.captureBurst(captureList,cameraCaptureCallback,null);
        mPreviewRequestBuilder.removeTarget(mImageReader.getSurface());
    } catch (CameraAccessException e) {
        e.printStackTrace();
    }
}

CameraCaptureSession.CaptureCallback cameraCaptureCallback = new CameraCaptureSession.CaptureCallback() {
    @Override
    public void onCaptureCompleted(CameraCaptureSession session,CaptureRequest request,TotalCaptureResult result) {
        Log.d("camera","saved");
        mPictureCounter++;
        if (mPictureCounter >= 10)
            unlockFocus();
    }
};

Solution

The problem you encounter is the artifact of the image output format you requested The JPEG encoding process imposes a large pause time on the camera pipeline, so there is a lot of downtime between the end of one exposure and the beginning of the next when encoding occurs

The referenced 30 FPS rate can be achieved by setting the output image format on the imagereader to YUV, because this is the "native" output of the camera This will be how the image is stored when it is captured, and then you will need to perform JPEG encoding to separate the camera's inline processing

For example, on nexus 5, the output stop time of JPEG encoding is 243ms, which you have observed For YUV_ 420_ 888 output, 0 Ms Similarly, due to its large size, raw_ Sensor code introduces a pause time of 200 ms

Also note that even if you remove pause time obstacles by selecting the "faster" format, there is still a minimum frame time, depending on the output image size But for the full resolution output of nexus 5, this is 33ms, which is what you expect

The relevant information is in the streamconfigurationmap object here of the camera metadata Check getoutputstallduration (int format, size) and getoutputminframeduration (int format, size) methods for confirmation

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>