/// <summary>
            /// Update the MLCamera characteristics.
            /// </summary>
            /// <returns>
            /// MLResult.Result will be <c>MLResult.Code.Ok</c> if obtained camera characteristic handle successfully.
            /// MLResult.Result will be <c>MLResult.Code.InvalidParam</c> if failed to obtain camera characteristic handle due to invalid input parameter.
            /// MLResult.Result will be <c>MLResult.Code.MediaGenericUnexpectedNull</c> if failed to capture raw image due to null pointer.
            /// MLResult.Result will be <c>MLResult.Code.AllocFailed</c> if failed to allocate memory.
            /// MLResult.Result will be <c>MLResult.Code.PrivilegeDenied</c> if a required permission is missing.
            /// </returns>
            internal MLResult PopulateCharacteristics()
            {
                MLResult.Code resultCode;

                ulong cameraCharacteristicsHandle = MagicLeapNativeBindings.InvalidHandle;

                resultCode = MLCameraNativeBindings.MLCameraGetCameraCharacteristics(ref cameraCharacteristicsHandle);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get camera characteristics for MLCamera. Reason: {0}", result);
                    return(result);
                }

                ulong  controlAEModeCount          = 0;
                IntPtr controlAEAvailableModesData = IntPtr.Zero;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAEAvailableModes(cameraCharacteristicsHandle, ref controlAEAvailableModesData, ref controlAEModeCount);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get camera control AE available modes for MLCamera. Reason: {0}", result);
                    return(result);
                }

                this.ControlAEModesAvailable = new List <MLCamera.MetadataControlAEMode>();
                int[] controlAEModeArray = new int[controlAEModeCount];
                Marshal.Copy(controlAEAvailableModesData, controlAEModeArray, 0, (int)controlAEModeCount);
                for (int i = 0; i < controlAEModeArray.Length; ++i)
                {
                    this.ControlAEModesAvailable.Add((MLCamera.MetadataControlAEMode)controlAEModeArray[i]);
                }

                ulong  colorCorrectionAberrationModeCount = 0;
                IntPtr colorCorrectionAberrationModesData = IntPtr.Zero;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetColorCorrectionAvailableAberrationModes(cameraCharacteristicsHandle, ref colorCorrectionAberrationModesData, ref colorCorrectionAberrationModeCount);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get color correction aberration modes available for MLCamera. Reason: {0}", result);
                    return(result);
                }

                this.ColorCorrectionAberrationModesAvailable = new List <MLCamera.MetadataColorCorrectionAberrationMode>((int)colorCorrectionAberrationModeCount);
                int[] aberrationModeArray = new int[colorCorrectionAberrationModeCount];
                Marshal.Copy(colorCorrectionAberrationModesData, aberrationModeArray, 0, (int)colorCorrectionAberrationModeCount);
                for (int i = 0; i < aberrationModeArray.Length; ++i)
                {
                    this.ColorCorrectionAberrationModesAvailable.Add((MLCamera.MetadataColorCorrectionAberrationMode)aberrationModeArray[i]);
                }

                int[] compensationRange = new int[2];
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAECompensationRange(cameraCharacteristicsHandle, compensationRange);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get control AE compensation range. Reason: {0}", result);
                    return(result);
                }

                this.AECompensationRange = new AECompensationRangeValues(compensationRange[0], compensationRange[1]);

                MLCameraNativeBindings.MLCameraMetadataRationalNative rational = new MLCameraNativeBindings.MLCameraMetadataRationalNative();
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAECompensationStep(cameraCharacteristicsHandle, ref rational);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get control AE compensation step. Reason: {0}", result);
                    return(result);
                }

                this.AECompensationStepNumerator   = rational.Numerator;
                this.AECompensationStepDenominator = rational.Denominator;

                this.AECompensationStep = (float)this.AECompensationStepNumerator / (float)this.AECompensationStepDenominator;

                float availableMaxDigitalZoom = 0.0f;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetScalerAvailableMaxDigitalZoom(cameraCharacteristicsHandle, ref availableMaxDigitalZoom);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get max available digital zoom. Reason: {0}", result);
                    return(result);
                }

                this.AvailableMaxDigitalZoom = availableMaxDigitalZoom;

                int sensorOrientation = 0;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetSensorOrientation(cameraCharacteristicsHandle, ref sensorOrientation);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get sensor orientation. Reason: {0}", result);
                    return(result);
                }

                this.SensorOrientation = sensorOrientation;

                MLCamera.MetadataControlAELock controlAELockAvailable = 0;
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAELockAvailable(cameraCharacteristicsHandle, ref controlAELockAvailable);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get control AE lock available. Reason: {0}", result);
                    return(result);
                }

                this.ControlAELockAvailable = controlAELockAvailable;

                ulong  controlAWBModeCount          = 0;
                IntPtr controlAWBAvailableModesData = IntPtr.Zero;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAWBAvailableModes(cameraCharacteristicsHandle, ref controlAWBAvailableModesData, ref controlAWBModeCount);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get camera control ABW available modes for MLCamera. Reason: {0}", result);
                    return(result);
                }

                this.ControlAWBModesAvailable = new List <MLCamera.MetadataControlAWBMode>();
                int[] awbModeArray = new int[controlAWBModeCount];
                Marshal.Copy(controlAWBAvailableModesData, awbModeArray, 0, (int)controlAWBModeCount);
                for (int i = 0; i < awbModeArray.Length; ++i)
                {
                    this.ControlAWBModesAvailable.Add((MLCamera.MetadataControlAWBMode)awbModeArray[i]);
                }

                MLCamera.MetadataControlAWBLock controlAWBLockAvailable = 0;
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetControlAWBLockAvailable(cameraCharacteristicsHandle, ref controlAWBLockAvailable);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get control AWB lock available. Reason: {0}", result);
                    return(result);
                }

                this.ControlAWBLockAvailable = controlAWBLockAvailable;

                int[] sensorInfoActiveArraySize = new int[4];

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetSensorInfoActiveArraySize(cameraCharacteristicsHandle, sensorInfoActiveArraySize);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get sensor info active array size. Reason: {0}", result);
                    return(result);
                }

                this.SensorInfoActiveArraySize = new SensorInfoActiveArraySizeValues(
                    sensorInfoActiveArraySize[0],
                    sensorInfoActiveArraySize[1],
                    sensorInfoActiveArraySize[2],
                    sensorInfoActiveArraySize[3]);

                ulong  scalerProcessedSizesCount = 0;
                IntPtr scalerProcessedSizesData  = IntPtr.Zero;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetScalerProcessedSizes(cameraCharacteristicsHandle, ref scalerProcessedSizesData, ref scalerProcessedSizesCount);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get scaler processed sizes. Reason: {0}", result);
                    return(result);
                }

                int[] scalerProcessedSizesDataArray = new int[scalerProcessedSizesCount];
                Marshal.Copy(scalerProcessedSizesData, scalerProcessedSizesDataArray, 0, (int)scalerProcessedSizesCount);
                this.ScalerProcessedSizes = new List <ScalerProcessedSize>((int)scalerProcessedSizesCount);
                for (int i = 0; i < (int)scalerProcessedSizesCount; i += 2)
                {
                    int width  = scalerProcessedSizesDataArray[i];
                    int height = scalerProcessedSizesDataArray[i + 1];
                    ScalerProcessedSize newSize = new ScalerProcessedSize(width, height);
                    this.ScalerProcessedSizes.Add(newSize);
                }

                ulong  streamConfigurationsCount = 0;
                IntPtr streamConfigurationsData  = IntPtr.Zero;

                resultCode = MLCameraNativeBindings.MLCameraMetadataGetScalerAvailableStreamConfigurations(cameraCharacteristicsHandle, ref streamConfigurationsData, ref streamConfigurationsCount);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get scaler available stream configurations. Reason: {0}", result);
                    return(result);
                }

                int[] streamConfigurationsDataArray = new int[streamConfigurationsCount];
                Marshal.Copy(streamConfigurationsData, streamConfigurationsDataArray, 0, (int)streamConfigurationsCount);

                this.ScalerAvailableStreamConfigurations = new List <StreamConfiguration>();
                for (int i = 0; i < (int)streamConfigurationsCount; i += 4)
                {
                    StreamConfiguration config = new StreamConfiguration(
                        (MLCamera.MetadataScalerAvailableFormats)streamConfigurationsDataArray[i],
                        streamConfigurationsDataArray[i + 1],
                        streamConfigurationsDataArray[i + 2],
                        (MLCamera.MetadataScalerAvailableStreamConfigurations)streamConfigurationsDataArray[i + 3]);

                    this.ScalerAvailableStreamConfigurations.Add(config);
                }

                int[] sensorInfoSensitivityRange = new int[2];
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetSensorInfoSensitivityRange(cameraCharacteristicsHandle, sensorInfoSensitivityRange);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get sensor info sensitivity range. Reason: {0}", result);
                    return(result);
                }

                this.SensorInfoSensitivityRange = new SensorInfoSensitivityRangeValues(sensorInfoSensitivityRange[0], sensorInfoSensitivityRange[1]);

                long[] sensorInfoExposureTimeRange = new long[2];
                resultCode = MLCameraNativeBindings.MLCameraMetadataGetSensorInfoExposureTimeRange(cameraCharacteristicsHandle, sensorInfoExposureTimeRange);

                if (!MLResult.IsOK(resultCode))
                {
                    MLResult result = MLResult.Create(resultCode);
                    MLPluginLog.ErrorFormat("MLCamera.GeneralSettings.PopulateCharacteristics failed to get sensor info exposure time range. Reason: {0}", result);
                    return(result);
                }

                this.SensorInfoExposureTimeRange = new SensorInfoExposureTimeRangeValues(sensorInfoExposureTimeRange[0], sensorInfoExposureTimeRange[1]);

                return(MLResult.Create(MLResult.Code.Ok));
            }