Photo mode#

Photo capture can operate in different modes that can be configured with Camera APIs:

  • single: take a single photo

  • bracketing: take a burst of multiple photos, each using different EV compensation values

  • burst: take a burst of photos

  • timeLapse: take frames at a regular time interval

  • gpsLapse: take frames at a regular GPS position interval

Camera 1#

Photo mode is get and set with methods CameraPhoto.Setting.mode() and CameraPhoto.Setting.setMode(). The list of supported modes is given by CameraPhoto.Setting.supportedModes().

Each photo mode (except single mode) is configured with another setting:

  • bracketing

    • configured with method CameraPhoto.Setting.setBracketingValue()

    • supported values given by CameraPhoto.Setting.supportedBracketingValues()

  • burst

    • configured with field CameraPhoto.Setting.setBurstValue()

    • supported values given by CameraPhoto.Setting.supportedBurstValues()

  • timeLapse

    • configured with field CameraPhoto.Setting.setTimelapseInterval()

    • supported values given by CameraPhoto.Setting.timelapseIntervalRange()

  • gpsLapse

    • configured with field CameraPhoto.Setting.setGpslapseInterval()

    • supported values given by CameraPhoto.Setting.gpslapseIntervalRange()

Sample code to monitor photo mode:

/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null

/** Monitors and prints photo mode. */
fun monitorPhotoMode(drone: Drone) {
    cameraRef = drone.getPeripheral(MainCamera::class.java) { camera ->
        // called on main thread when the camera peripheral changes
        camera?.photo()?.run {
            if (supportedModes().isEmpty()) {
                // setting value is not relevant if there is no supported value
                println("No supported value")
            } else {
                // get setting value
                when (mode()) {
                    CameraPhoto.Mode.SINGLE ->
                        println("Photo mode: single")

                    CameraPhoto.Mode.BRACKETING ->
                        println("Photo mode: bracketing ${bracketingValue()}")

                    CameraPhoto.Mode.BURST ->
                        println("Photo mode: burst ${burstValue()}")

                    CameraPhoto.Mode.GPS_LAPSE ->
                        println("Photo mode: gpsLapse ${gpslapseInterval()}")

                    CameraPhoto.Mode.TIME_LAPSE ->
                        println("Photo mode: timeLapse ${timelapseInterval()}")
                }
                // updating flag
                println("Updating: $isUpdating")
            }
        }
    }
}

Example of output:

Photo mode: burst BURST_10_OVER_4S

Sample code to modify photo mode:

/** Sets photo mode. */
fun setPhotoMode(drone: Drone, mode: CameraPhoto.Mode) {
    drone.getPeripheral(MainCamera::class.java)?.run {
        // set setting value
        photo().setMode(mode)
    }
}

Trying to change the setting value to an unsupported value has no effect. Values supported by the camera are provided by CameraPhoto.Setting.supportedModes().

For bracketing mode, the bracketing value can be configured as follows:

/** Sets bracketing value. */
fun setBracketingValue(drone: Drone, bracketing: CameraPhoto.BracketingValue) {
    drone.getPeripheral(MainCamera::class.java)?.run {
        // set setting value
        photo().setBracketingValue(bracketing)
    }
}

For burst mode, the burst value can be configured as follows:

/** Sets burst value. */
fun setBurstValue(drone: Drone, burst: CameraPhoto.BurstValue) {
    drone.getPeripheral(MainCamera::class.java)?.run {
        // set setting value
        photo().setBurstValue(burst)
    }
}

For gpsLapse mode, the interval can be configured as follows:

/** Sets location interval. */
fun setGpsLapseInterval(drone: Drone, interval: Double) {
    drone.getPeripheral(MainCamera::class.java)?.run {
        // set setting value
        photo().setGpslapseInterval(interval)
    }
}

For timeLapse mode, the interval can be configured as follows:

/** Sets time interval. */
fun setTimeLapseInterval(drone: Drone, interval: Double) {
    drone.getPeripheral(MainCamera::class.java)?.run {
        // set setting value
        photo().setTimelapseInterval(interval)
    }
}

Camera 2#

Photo mode is configured with parameter Camera2Params.photoMode.

Each photo mode (except single mode) is configured with another parameter:

  • bracketing: configured with parameter Camera2Params.photoBracketing

  • burst: configured with parameter Camera2Params.photoBurst

  • timeLapse: configured with parameter Camera2Params.photoTimelapseInterval

  • gpsLapse: configured with parameter Camera2Params.photoGpslapseInterval

Sample code to monitor photo mode:

/** Reference on MainCamera peripheral. */
private var cameraRef: Ref<MainCamera>? = null

/** Monitors and prints photo mode. */
fun monitorPhotoMode(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.PHOTO_MODE].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 when (value) {
                    Camera.PhotoMode.SINGLE ->
                        println("Photo mode: single")

                    Camera.PhotoMode.BRACKETING -> {
                        // get bracketing configuration
                        val bracketing = config[Camera.Config.PHOTO_BRACKETING].value
                        println("Photo mode: bracketing $bracketing")
                    }

                    Camera.PhotoMode.BURST -> {
                        // get burst configuration
                        val burst = config[Camera.Config.PHOTO_BURST].value
                        println("Photo mode: burst $burst}")
                    }

                    Camera.PhotoMode.GPS_LAPSE -> {
                        // get location interval
                        val interval = config[Camera.Config.PHOTO_GPS_LAPSE_INTERVAL].value
                        println("Photo mode: gpsLapse $interval")
                    }

                    Camera.PhotoMode.TIME_LAPSE -> {
                        // get time interval
                        val interval = config[Camera.Config.PHOTO_TIME_LAPSE_INTERVAL].value
                        println("Photo mode: timeLapse $interval")
                    }
                }
            }
        }
    }
}

Example of output:

Photo mode: bracketing BURST_14_OVER_4S

Sample code to modify photo mode:

/** Sets photo mode. */
fun setPhotoMode(drone: Drone, photoMode: Camera.PhotoMode) {
    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.PHOTO_MODE].let { configParam ->
            // change parameter value,
            // and unset other parameters conflicting with this new value
            configParam.value = photoMode
            // 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 provided by the parameter method configParam.supportedValues(onlyCurrent = false).

For bracketing mode, the brarketing value can be configured as follows:

/** Sets bracketing value. */
fun setBracketingValue(drone: Drone, bracketing: Camera.BracketingValue) {
    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.PHOTO_BRACKETING].let { configParam ->
            // change parameter value,
            // and unset other parameters conflicting with this new value
            configParam.value = bracketing
            // complete configuration, by setting missing parameters values
            editor.autoComplete()
            // send new configuration to drone
            editor.commit()
        }
    }
}

For burst mode, the burst value can be configured as follows:

/** Sets burst value. */
fun setBurstValue(drone: Drone, burst: Camera.BurstValue) {
    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.PHOTO_BURST].let { configParam ->
            // change parameter value,
            // and unset other parameters conflicting with this new value
            configParam.value = burst
            // complete configuration, by setting missing parameters values
            editor.autoComplete()
            // send new configuration to drone
            editor.commit()
        }
    }
}

For gpsLapse mode, the interval can be configured as follows:

/** Sets location interval. */
fun setGpsLapseInterval(drone: Drone, interval: Double) {
    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.PHOTO_GPS_LAPSE_INTERVAL].let { configParam ->
            // change parameter value,
            // and unset other parameters conflicting with this new value
            configParam.value = interval
            // complete configuration, by setting missing parameters values
            editor.autoComplete()
            // send new configuration to drone
            editor.commit()
        }
    }
}

For timeLapse mode, the interval can be configured as follows:

/** Sets time interval. */
fun setTimeLapseInterval(drone: Drone, interval: Double) {
    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.PHOTO_TIME_LAPSE_INTERVAL].let { configParam ->
            // change parameter value,
            // and unset other parameters conflicting with this new value
            configParam.value = interval
            // complete configuration, by setting missing parameters values
            editor.autoComplete()
            // send new configuration to drone
            editor.commit()
        }
    }
}