/// <summary> /// Populate the settings. /// </summary> /// <param name="prepareHandle">A handle to the prepare capture camera.</param> /// <param name="captureType">The capture type</param> /// <returns> /// MLResult.Result will be <c>MLResult.Code.Ok</c> if the request completed successfully. /// MLResult.Result will be <c>MLResult.Code.UnspecifiedFailure</c> if failed due to internal error. /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if an invalid parameter was provided. /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if a required permission is missing. /// </returns> internal MLResult.Code PopulateSettings(ulong prepareHandle, MLCamera.CaptureType captureType) { MLResult.Code result = MLResult.Code.Ok; this.prepareHandle = prepareHandle; this.CaptureType = captureType; result = MLCameraNativeBindings.MLCameraMetadataGetColorCorrectionModeRequestMetadata(this.prepareHandle, ref this.colorCorrectionMode); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get color correction mode. Reason: {0}", result); return(result); } MLCameraNativeBindings.MLCameraMetadataRationalNative[] colorCorrectionTransform = new MLCameraNativeBindings.MLCameraMetadataRationalNative[9]; result = MLCameraNativeBindings.MLCameraMetadataGetColorCorrectionTransformRequestMetadata(this.prepareHandle, colorCorrectionTransform); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get color correction transform matrix. Reason: {0}", result); return(result); } this.ColorCorrectionTransform = new MLCamera.ColorCorrectionTransform( colorCorrectionTransform[0].ToFloat(), colorCorrectionTransform[1].ToFloat(), colorCorrectionTransform[2].ToFloat(), colorCorrectionTransform[3].ToFloat(), colorCorrectionTransform[4].ToFloat(), colorCorrectionTransform[5].ToFloat(), colorCorrectionTransform[6].ToFloat(), colorCorrectionTransform[7].ToFloat(), colorCorrectionTransform[8].ToFloat()); float[] colorCorrectionGains = new float[4]; result = MLCameraNativeBindings.MLCameraMetadataGetColorCorrectionGainsRequestMetadata(this.prepareHandle, colorCorrectionGains); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get color correction gains vector. Reason: {0}", result); return(result); } // The order of this, red, greenEven, greenOdd, blue, was taken from the android developer site for the color corrections gain vector // https://developer.android.com/reference/android/hardware/camera2/params/RggbChannelVector this.ColorCorrectionGains = new MLCamera.ColorCorrectionGains(colorCorrectionGains[0], colorCorrectionGains[1], colorCorrectionGains[2], colorCorrectionGains[3]); result = MLCameraNativeBindings.MLCameraMetadataGetColorCorrectionAberrationModeRequestMetadata(this.prepareHandle, ref this.colorCorrectionAberrationMode); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get color correction aberration mode. Reason: {0}", result); return(result); } result = MLCameraNativeBindings.MLCameraMetadataGetControlAEAntibandingModeRequestMetadata(this.prepareHandle, ref this.controlAEAntibandingMode); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get control AE antibanding mode. Reason: {0}", result); return(result); } result = MLCameraNativeBindings.MLCameraMetadataGetControlAEExposureCompensationRequestMetadata(this.prepareHandle, ref this.controlAECompensation); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get AE exposure compensation. Reason: {0}", result); return(result); } result = MLCameraNativeBindings.MLCameraMetadataGetControlAELockRequestMetadata(this.prepareHandle, ref this.controlAELock); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get control AE lock. Reason: {0}", result); return(result); } result = MLCameraNativeBindings.MLCameraMetadataGetControlAEModeRequestMetadata(this.prepareHandle, ref this.controlAEMode); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get control AE mode. Reason: {0}", result); return(result); } int[] controlAETargetFPSRangeArray = new int[2]; result = MLCameraNativeBindings.MLCameraMetadataGetControlAETargetFPSRangeRequestMetadata(this.prepareHandle, controlAETargetFPSRangeArray); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get control AE Target FPS Range. Reason: {0}", result); return(result); } this.ControlAETargetFPSRange = new MLCamera.ControlAETargetFPSRange(controlAETargetFPSRangeArray[0], controlAETargetFPSRangeArray[1]); result = MLCameraNativeBindings.MLCameraMetadataGetControlAWBLockRequestMetadata(this.prepareHandle, ref this.controlAWBLock); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get control AWB Lock. Reason: {0}", result); return(result); } result = MLCameraNativeBindings.MLCameraMetadataGetControlAWBModeRequestMetadata(this.prepareHandle, ref this.controlAWBMode); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get control AWB mode. Reason: {0}", result); return(result); } result = MLCameraNativeBindings.MLCameraMetadataGetSensorExposureTimeRequestMetadata(this.prepareHandle, ref this.sensorExposureTime); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get sensor exposure time. Reason: {0}", result); return(result); } result = MLCameraNativeBindings.MLCameraMetadataGetSensorSensitivityRequestMetadata(this.prepareHandle, ref this.sensorSensitivity); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get sensor sensitivity. Reason: {0}", result); return(result); } int[] scalerCropRegionArray = new int[4]; result = MLCameraNativeBindings.MLCameraMetadataGetScalerCropRegionRequestMetadata(this.prepareHandle, scalerCropRegionArray); if (!MLResult.IsOK(result)) { MLPluginLog.ErrorFormat("MLCamera.CaptureSettings.PopulateSettings failed to get scaler crop region. Reason: {0}", result); return(result); } this.ScalerCropRegion = new MLCamera.ScalerCropRegion(scalerCropRegionArray[0], scalerCropRegionArray[1], scalerCropRegionArray[2], scalerCropRegionArray[3]); return(result); }