Video recording resolution¶
Camera 1¶
Sample code to monitor video recording resolution:
/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null
/** Monitors and prints video recording resolution. */
fun monitorVideoResolution(drone: Drone) {
cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
// called on main thread when the camera peripheral changes
camera?.recording()?.run {
if (supportedResolutions().isEmpty()) {
// setting value is not relevant if there is no supported value
println("No supported value")
} else {
// get setting value
val resolution = resolution()
println("Current value: $resolution")
// updating flag
println("Updating: $isUpdating")
}
}
}
}
Example of output:
Current value: RES_UHD_4K
Updating: false
Sample code to modify video recording resolution:
/** Sets photo video recording resolution. */
fun setVideoResolution(drone: Drone, resolution: CameraRecording.Resolution) {
drone.getPeripheral(MainCamera::class.java)?.run {
// set setting value
recording().setResolution(resolution)
}
}
Trying to change the setting value to an unsupported value has no effect.
Values supported by the camera are provided by CameraRecording.Setting.supportedResolutions().
Camera 2¶
Video recording resolution is configured with parameter Camera.Config.VIDEO_RECORDING_RESOLUTION.
Sample code to monitor video recording resolution:
/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null
/** Monitors and prints video recording resolution. */
fun monitorVideoResolution(drone: Drone) {
cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
// called on main thread when the camera peripheral changes
camera?.run {
// get configuration parameter
config[Camera.Config.VIDEO_RECORDING_RESOLUTION].run {
if (supportedValues(onlyCurrent = true).isEmpty()) {
// parameter value is not relevant
// if there is not supported values in current configuration
println("No supported value in current configuration")
} else {
println("Current value: $value")
}
}
}
}
}
Example of output:
Current value is: RES_UHD_8K
Sample code to modify video recording resolution:
/** Sets video recording resolution. */
fun setVideoResolution(drone: Drone, resolution: Camera.VideoResolution) {
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.VIDEO_RECORDING_RESOLUTION].let { configParam ->
// change parameter value,
// and unset other parameters conflicting with this new value
configParam.value = resolution
// complete configuration, by setting missing parameters values
editor.autoComplete()
// send new configuration to drone
editor.commit()
}
}
}
Trying to change the parameter value to an unsupported value has no effect.
Values supported by the camera are retrieved by calling configParam.supportedValues(onlyCurrent = false).