第19讲 App如何实现ZSL功能 - Android Camera2 API

本讲是Android Camera专题系列的第19讲,我们介绍Android Camera2 API专题的实战_App如何实现ZSL功能。

更多资源:

资源 描述
在线课程 极客笔记在线课程
知识星球 星球名称:深入浅出Android Camera
星球ID: 17296815
Wechat 极客笔记圈

Reprocessable Architecture

Reprocessable Architecture

Reprocessable Flow

Reprocessable Flow

GeekCamera2 ZSL

判断是否支持Reprocess

mStaticMetadata = new StaticMetadata(manager.getCameraCharacteristics(cameraIdS));
mIsReprocesableSupport =
        mStaticMetadata.isCapabilitySupported(
                CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_YUV_REPROCESSING) ||
                mStaticMetadata.isCapabilitySupported(
                        CameraCharacteristics.REQUEST_AVAILABLE_CAPABILITIES_PRIVATE_REPROCESSING);

获取Input Size和Format

private void setupInputSizeAndFormat() {
    if (mIsReprocesableSupport) {
        mMaxInputStreams =
                mStaticMetadata.getValueFromKeyNonNull(CameraCharacteristics.REQUEST_MAX_NUM_INPUT_STREAMS);
    }
    if (MyDebug.LOG) {
        Log.i(TAG, "[ZSL] max supported input streams:" + mMaxInputStreams +
                        ",mIsReprocesableSupport:" + mIsReprocesableSupport +
                        ",mEnableReprocessable:" + mEnableReprocessable);
    }
    try {
        if (mEnableReprocessable && mIsReprocesableSupport) {
            if (isOpaqueReprocessSupported(cameraIdS)) {
                mInputFormat = ImageFormat.PRIVATE;
                mInputSize = getMaxSize(mInputFormat, StaticMetadata.StreamDirection.Input);
                Log.i(TAG, "[ZSL] choose private reprocess.");
                return;
            }
            if (isYuvReprocessSupported(cameraIdS)) {
                mInputFormat = ImageFormat.YUV_420_888;
                mInputSize = getMaxSize(mInputFormat, StaticMetadata.StreamDirection.Input);
                Log.i(TAG, "[ZSL] choose yuv reprocess.");
                return;
            }
        }
    } catch (Exception e) {
    }

    if (MyDebug.LOG) {
        Log.i(TAG, "Reprocess not enabled.");
    }
}

创建InputConfiguration

if (mEnableReprocessable && mMaxInputStreams > 0 && mIsReprocesableSupport) {
    Log.i(TAG, "[ZSL] new InputConfiguration.");
    inputConfiguration = new InputConfiguration(mInputSize.getWidth(),
            mInputSize.getHeight(),
            mInputFormat);
}

获取Reprocess CaptureRequest

if (mEnableReprocessable && mMaxInputStreams > 0 && mIsReprocesableSupport) {
    try {
        Log.i(TAG, "[ZSL] createReprocessCaptureRequest begin");
        Image inputImage = mInputImageReaderListener.getImage(3000);
        Log.i(TAG, "[ZSL] createReprocessCaptureRequest");
        stillBuilder = mCameraDevice.createReprocessCaptureRequest(
                mZslResultListener.getCaptureResult(3000, inputImage.getTimestamp()));
        Log.i(TAG, "[ZSL] Image writer queueInputImage, timestamp:" + inputImage.getTimestamp());
        mInputImageWriter.queueInputImage(inputImage);
        inputImage.close();
        Log.i(TAG, "[ZSL] createReprocessCaptureRequest end");
    } catch (Exception e) {
        Log.e(TAG, "createReprocessCaptureRequest failed:" + e.toString());
    }
}

Camera课程

Python教程

Java教程

Web教程

数据库教程

图形图像教程

办公软件教程

Linux教程

计算机教程

大数据教程

开发工具教程

Android Camera2 API