Exposure indicator#

The exposure indicator gives the current camera shutter speed and iso sensitivity. For Camera2, it also gives information on current exposure lock region.

These values may change very often in automatic exposure mode.

Camera 1#

For drones supporting Camera1 API, exposure values are monitored with a separated instrument: Instruments.cameraExposureValues.

Sample code to monitor exposure indicator:

/// Keep reference on CameraExposureValues instrument to get notified of changes.
private var exposureValuesRef: Ref<CameraExposureValues>?

/// Monitors and prints exposure indicator.
func monitorExposureIndicator(drone: Drone) {
    exposureValuesRef = drone.getInstrument(Instruments.cameraExposureValues) { exposureValues in
        if let exposureValues = exposureValues {
            print("Shutter speed: \(exposureValues.shutterSpeed)")
            print("Iso sensitivity: \(exposureValues.isoSensitivity)")
        } else {
            print("Exposure values instrument not available")
        }
    }
}

Example of output:

Shutter speed: oneOver10000
Iso sensitivity: iso50

Camera 2#

Exposure values are monitored with sub-component Camera2Components.exposureIndicator.

Note: You need to keep a reference on the Camera2Components.exposureIndicator sub-component to get notified of changes.

Sample code to monitor exposure indicator:

/// Keep reference on Camera2ExposureIndicator sub-component to get notified of changes.
private var exposureIndicatorRef: Ref<Camera2ExposureIndicator>?

/// Monitors and prints exposure indicator.
func monitorExposureIndicator(drone: Drone) {
    if let camera = drone.getPeripheral(Peripherals.mainCamera2) {
        // get exposure indicator component reference and register listener
        exposureIndicatorRef = camera.getComponent(Camera2Components.exposureIndicator) { exposureIndicator in
            if let exposureIndicator = exposureIndicator {
                // print exposure values
                print("Shutter speed: \(exposureIndicator.shutterSpeed)")
                print("Iso sensitivity: \(exposureIndicator.isoSensitivity)")
                print("Lock region: \(String(describing: exposureIndicator.lockRegion))")
            } else {
                // exposure indicator unavailable
                print("Exposure indicator not available at present")
            }
        }
    }
}

Example of output:

Shutter speed: 1/15s
Iso sensitivity: iso100
Lock region: Optional((centerX: 0.0, centerY: 0.0, width: 1.0, height: 1.0))