Exposure mode¶
Cameras can operate in different exposure modes that can be configured with Camera APIs:
automatic: Automatic exposure mode.
automaticPreferIsoSensitivity: Automatic exposure mode, prefer increasing iso sensitivity.
automaticPreferShutterSpeed: Automatic exposure mode, prefer reducing shutter speed.
manualIsoSensitivity: Manual ISO sensitivity mode.
manualShutterSpeed: Manual shutter speed mode.
manual: Manual mode.
Camera 1¶
The exposure mode is controlled with CameraExposure.Setting
get with method
CameraExposure.Setting.mode()set with method
CameraExposure.Setting.setMode()supported modes are given by method
CameraExposure.Setting.supportedModes()
Some exposure modes are configured with other settings:
automatic, automaticPreferIsoSensitivity and automaticPreferShutterSpeed
configured with method
CameraExposure.Setting.setManualIsoSensitivity()supported values given by
CameraExposure.Setting.supportedManualIsoSensitivities()also configured with method
CameraExposure.Setting.setAutoExposureMeteringMode()supported values given by
CameraExposure.Setting.supportedAutoExposureMeteringModes()
manualIsoSensitivity
configured with method
CameraExposure.Setting.setManualIsoSensitivity()supported values given by
CameraExposure.Setting.supportedManualIsoSensitivities()
manualShutterSpeed
configured with method
CameraExposure.Setting.setManualShutterSpeed()`supported values given by
CameraExposure.Setting.supportedManualShutterSpeeds()
manual
configured with method
CameraExposure.Setting.setManualShutterSpeed()`supported values given by
CameraExposure.Setting.supportedManualShutterSpeeds()configured with method
CameraExposure.Setting.setManualIsoSensitivity()supported values given by
CameraExposure.Setting.supportedManualIsoSensitivities()
Sample code to monitor exposure settings:
/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null
/** Monitors and prints exposure settings. */
fun monitorExposureSettings(drone: Drone) {
cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
// called on main thread when the camera peripheral changes
// get exposure settings
camera?.exposure()?.run {
// exposure mode
if (supportedModes().isEmpty()) {
println("Exposure mode: no supported value")
} else {
println("Exposure mode: ${mode()}")
}
// maximum ISO sensitivity
if (supportedMaximumIsoSensitivities().isEmpty()) {
println("Maximum ISO sensitivity: no supported value")
} else {
println("Maximum ISO sensitivity: ${maxIsoSensitivity()}")
}
// auto metering mode
if (supportedAutoExposureMeteringModes().isEmpty()) {
println("Auto metering mode: no supported value")
} else {
println("Auto metering mode: ${autoExposureMeteringMode()}")
}
// manual ISO sensitivity
if (supportedManualIsoSensitivities().isEmpty()) {
println("Manual ISO sensitivity: no supported value")
} else {
println("Manual ISO sensitivity: ${maxIsoSensitivity()}")
}
// manual shutter speed
if (supportedManualShutterSpeeds().isEmpty()) {
println("Manual shutter speed: no supported value")
} else {
println("Manual shutter speed: ${manualShutterSpeed()}")
}
// updating flag
println("Updating: $isUpdating")
}
}
}
Example of output:
Exposure mode: AUTOMATIC
Maximum ISO sensitivity: ISO_3200
Auto metering mode: STANDARD
Manual ISO sensitivity: ISO_500
Manual shutter speed: ONE_OVER_1000
Updating: false
Sample code to modify exposure settings:
/** Sets exposure mode. */
fun setExposureMode(drone: Drone, mode: CameraExposure.Mode) {
drone.getPeripheral(MainCamera::class.java)?.run {
exposure().setMode(mode)
}
}
/** Sets manual shutter speed. */
fun setManualShutterSpeed(drone: Drone, manualShutterSpeed: CameraExposure.ShutterSpeed) {
drone.getPeripheral(MainCamera::class.java)?.run {
exposure().setManualShutterSpeed(manualShutterSpeed)
}
}
/** Sets manual ISO sensitivity. */
fun setManualIsoSensitivity(drone: Drone, manualIsoSensitivity: CameraExposure.IsoSensitivity) {
drone.getPeripheral(MainCamera::class.java)?.run {
exposure().setManualIsoSensitivity(manualIsoSensitivity)
}
}
/** Sets maximum ISO sensitivity. */
fun setMaxIsoSensitivity(drone: Drone, maxIsoSensitivity: CameraExposure.IsoSensitivity) {
drone.getPeripheral(MainCamera::class.java)?.run {
exposure().setMaxIsoSensitivity(maxIsoSensitivity)
}
}
/** Sets auto exposure metering mode. */
fun setAutoExposureMeteringMode(drone: Drone, autoExposureMeteringMode: CameraExposure.AutoExposureMeteringMode) {
drone.getPeripheral(MainCamera::class.java)?.run {
exposure().setAutoExposureMeteringMode(autoExposureMeteringMode)
}
}
Camera 2¶
Exposure mode is configured with parameter Camera.Config.EXPOSURE_MODE.
Some exposure modes are configured with other settings:
automatic, automaticPreferIsoSensitivity and automaticPreferShutterSpeed
configured with parameters
Camera.Config.MAX_ISO_SENSITIVITYandCamera.Config.EXPOSURE_METERING
manualIsoSensitivity
configured with parameter
Camera.Config.ISO_SENSITIVITY
manualShutterSpeed
configured with parameter
Camera.Config.SHUTTER_SPEED`
manual
configured with parameters
Camera.Config.SHUTTER_SPEEDandCamera.Config.ISO_SENSITIVITY
Sample code to monitor exposure settings:
/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null
/** Monitors and prints exposure settings. */
fun monitorExposureSettings(drone: Drone) {
cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
// called on main thread when the camera peripheral changes
camera?.run {
// exposure mode
config[Camera.Config.EXPOSURE_MODE].run {
if (supportedValues(onlyCurrent = true).isEmpty()) {
// parameter value is not relevant
// if there is not supported values in current configuration
println("Exposure mode: no supported value in current configuration")
} else {
println("Exposure mode: $value")
}
}
// maximum ISO sensitivity
config[Camera.Config.MAX_ISO_SENSITIVITY].run {
if (supportedValues(onlyCurrent = true).isEmpty()) {
// parameter value is not relevant
// if there is not supported values in current configuration
println("Maximum ISO sensitivity: no supported value in current configuration")
} else {
println("Maximum ISO sensitivity: $value")
}
}
// metering mode
config[Camera.Config.EXPOSURE_METERING].run {
if (supportedValues(onlyCurrent = true).isEmpty()) {
// parameter value is not relevant
// if there is not supported values in current configuration
println("Metering mode: no supported value in current configuration")
} else {
println("Metering mode: $value")
}
}
// manual ISO sensitivity
config[Camera.Config.ISO_SENSITIVITY].run {
if (supportedValues(onlyCurrent = true).isEmpty()) {
// parameter value is not relevant
// if there is not supported values in current configuration
println("Manual ISO sensitivity: no supported value in current configuration")
} else {
println("Manual ISO sensitivity: $value")
}
}
// manual shutter speed
config[Camera.Config.SHUTTER_SPEED].run {
if (supportedValues(onlyCurrent = true).isEmpty()) {
// parameter value is not relevant
// if there is not supported values in current configuration
println("Manual shutter speed: no supported value in current configuration")
} else {
println("Manual shutter speed: $value")
}
}
}
}
}
Example of output:
Exposure mode: AUTOMATIC
Maximum ISO sensitivity: ISO_1600
Metering mode: STANDARD
Manual ISO sensitivity: ISO_50
Manual shutter speed: ONE_OVER_10000
Sample code to modify exposure settings:
/** Sets exposure mode. */
fun setExposureMode(drone: Drone, mode: Camera.ExposureMode) {
drone.getPeripheral(MainCamera::class.java)?.run {
// create configuration editor, starting from current configuration
val editor = config.edit(fromScratch = false)
// get configuration parameter
editor[Camera.Config.EXPOSURE_MODE].let { configParam ->
// change parameter value,
// and unset other parameters conflicting with this new value
configParam.value = mode
// complete configuration, by setting missing parameters values
editor.autoComplete()
// send new configuration to drone
editor.commit()
}
}
}
/** Sets manual shutter speed. */
fun setManualShutterSpeed(drone: Drone, manualShutterSpeed: Camera.ShutterSpeed) {
drone.getPeripheral(MainCamera::class.java)?.run {
// create configuration editor, starting from current configuration
val editor = config.edit(fromScratch = false)
// get configuration parameter
editor[Camera.Config.SHUTTER_SPEED].let { configParam ->
// change parameter value,
// and unset other parameters conflicting with this new value
configParam.value = manualShutterSpeed
// complete configuration, by setting missing parameters values
editor.autoComplete()
// send new configuration to drone
editor.commit()
}
}
}
/** Sets manual ISO sensitivity. */
fun setManualIsoSensitivity(drone: Drone, manualIsoSensitivity: Camera.IsoSensitivity) {
drone.getPeripheral(MainCamera::class.java)?.run {
// create configuration editor, starting from current configuration
val editor = config.edit(fromScratch = false)
// get configuration parameter
editor[Camera.Config.ISO_SENSITIVITY].let { configParam ->
// change parameter value,
// and unset other parameters conflicting with this new value
configParam.value = manualIsoSensitivity
// complete configuration, by setting missing parameters values
editor.autoComplete()
// send new configuration to drone
editor.commit()
}
}
}
/** Sets maximum ISO sensitivity. */
fun setMaxIsoSensitivity(drone: Drone, maxIsoSensitivity: Camera.IsoSensitivity) {
drone.getPeripheral(MainCamera::class.java)?.run {
// create configuration editor, starting from current configuration
val editor = camera.config.edit(fromScratch = false)
// get configuration parameter
editor[Camera.Config.MAX_ISO_SENSITIVITY].let { configParam ->
// change parameter value,
// and unset other parameters conflicting with this new value
configParam.value = maxIsoSensitivity
// complete configuration, by setting missing parameters values
editor.autoComplete()
// send new configuration to drone
editor.commit()
}
}
}
/** Sets exposure metering mode. */
fun setExposureMeteringMode(drone: Drone, meteringMode: Camera.ExposureMetering) {
drone.getPeripheral(MainCamera::class.java)?.run {
// create configuration editor, starting from current configuration
val editor = camera.config.edit(fromScratch = false)
// get configuration parameter
editor[Camera.Config.EXPOSURE_METERING].let { configParam ->
// change parameter value,
// and unset other parameters conflicting with this new value
configParam.value = meteringMode
// complete configuration, by setting missing parameters values
editor.autoComplete()
// send new configuration to drone
editor.commit()
}
}
}