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

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

视频在线观看:

加入知识星球与更多Camera同学交流
– 星球名称:深入浅出Android Camera
– 星球ID: 17296815

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());
    }
}
赞(2)
未经允许不得转载:极客笔记 » 第19讲 Android Camera2 API App如何实现ZSL功能
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

Android Camera2 API