Camera#

Introduction#

The VEX AIR Drone includes two Vision Sensors that serve as its onboard cameras—one on the front and one on the bottom. These can capture both images and video during flight. In VEXcode AIR, the word “camera” always refers to one of these Vision Sensors. For example, in a command like drone.camera.start_recording(FORWARD_CAMERA), camera refers to the Vision Sensors, and FORWARD_CAMERA selects the front-facing one.

Below is a list of all available methods:

Actions

Mutators

Getters

Actions#

start_recording#

start_recording records video from the selected Vision Sensor.

Usage:

drone.camera.start_recording(camera)

Parameters

Description

camera

The Vision Sensor to record with:

  • DOWNWARD_CAMERA
  • FORWARD_CAMERA
# Record with a camera after taking off
drone.take_off(500)

while not controller.button5.pressing():
    wait (0.1, SECONDS)

controller.screen.print("Recording...")
wait(2, SECONDS)
drone.camera.start_recording(FORWARD_CAMERA)
controller.screen.show_camera(FORWARD_CAMERA)

stop_recording#

stop_recording stops recording from the selected Vision Sensor.

Usage:

drone.camera.stop_recording(camera)

Parameters

Description

camera

The Vision Sensor to stop recording with:

  • DOWNWARD_CAMERA
  • FORWARD_CAMERA
# Record with a camera after taking off
drone.take_off(500)

while True:
    controller.screen.clear_screen()
    controller.screen.set_cursor(1, 1)
    if controller.button5.pressing():
        controller.screen.print("Recording:")
        wait(1, SECONDS)
        drone.camera.start_recording(FORWARD_CAMERA)
        controller.screen.show_camera(FORWARD_CAMERA)
    elif controller.button6.pressing():
        controller.screen.hide_camera()
        drone.camera.stop_recording(FORWARD_CAMERA)
        controller.screen.print("Recording stopped.")
    else:
        wait(0.1, SECONDS)

capture_image#

Documentation Coming Soon

Mutators#

show_camera#

show_camera sets the current screen mode to the specified Vision Sensor feed.

Usage:

controller.screen.show_camera(camera)

Parameters

Description

camera

The Vision Sensor feed to display:

  • DOWNWARD_CAMERA
  • FORWARD_CAMERA
# Record with a camera after taking off
drone.take_off(500)

while True:
    controller.screen.clear_screen()
    controller.screen.set_cursor(1, 1)
    if controller.button5.pressing():
        controller.screen.print("Recording:")
        wait(1, SECONDS)
        drone.camera.start_recording(FORWARD_CAMERA)
        controller.screen.show_camera(FORWARD_CAMERA)
    elif controller.button6.pressing():
        controller.screen.hide_camera()
        drone.camera.stop_recording(FORWARD_CAMERA)
        controller.screen.print("Recording stopped.")
    else:
        wait(0.1, SECONDS)

hide_camera#

hide_camera sets the current screen mode to the print area.

Usage:

controller.screen.hide_camera()

Parameters

Description

This method has no parameters.

# Record with a camera after taking off
drone.take_off(500)

while True:
    controller.screen.clear_screen()
    controller.screen.set_cursor(1, 1)
    if controller.button5.pressing():
        controller.screen.print("Recording:")
        wait(1, SECONDS)
        drone.camera.start_recording(FORWARD_CAMERA)
        controller.screen.show_camera(FORWARD_CAMERA)
    elif controller.button6.pressing():
        controller.screen.hide_camera()
        drone.camera.stop_recording(FORWARD_CAMERA)
        controller.screen.print("Recording stopped.")
    else:
        wait(0.1, SECONDS)

set_overlay_reticle#

set_overlay_reticle enables or disables the overlay reticle.

Usage:
controller.screen.set_overlay_reticle(state)

Parameters

Description

state

The state of the overlay reticle:

  • True – Enables the overlay reticle.
  • False – Disables the overlay reticle.
# Record with a camera after taking off
drone.take_off(500)

while True:
    if controller.button5.pressing():
        controller.screen.set_overlay_reticle(True)
    elif controller.button6.pressing():
        controller.screen.set_overlay_reticle(False)
    else:
        wait(0.1, SECONDS)

set_overlay_vision_objects#

Documentation Coming Soon

set_overlay_telemetry#

set_overlay_telemetry enables or disables the visibility of the drone’s telemetry data on the controller’s screen.

Usage:
controller.screen.set_overlay_telemetry(state)

Parameters

Description

state

The state of the telemetry data:

  • True – Enables viewing telemetry data on the screen.
  • False – Disables viewing telemetry data on the screen.
# Record with a camera after taking off
drone.take_off(500)

while True:
    if controller.button5.pressing():
        controller.screen.set_overlay_telemetry(True)
    elif controller.button6.pressing():
        controller.screen.set_overlay_telemetry(False)
    else:
        wait(0.1, SECONDS)

Getters#

is_recording#

is_recording returns a Boolean indicating whether a specified Vision Sensor is currently recording.

  • True – The specified Vision Sensor is recording.

  • False – The specified Vision Sensor is not recording.

Usage:

drone.camera.is_recording(camera)

Parameters

Description

camera

The Vision Sensor to check recording status of:

  • DOWNWARD_CAMERA
  • FORWARD_CAMERA
# Record with a camera after taking off
drone.take_off(500)

while True:
    controller.screen.clear_screen()
    controller.screen.set_cursor(1, 1)
    if controller.button5.pressing():
        if drone.camera.is_recording():
            controller.screen.print("Already recording.")
        controller.screen.print("Recording:")
        wait(1, SECONDS)
        drone.camera.start_recording(FORWARD_CAMERA)
        controller.screen.show_camera(FORWARD_CAMERA)
    elif controller.button6.pressing():
        controller.screen.hide_camera()
        drone.camera.stop_recording(FORWARD_CAMERA)
        controller.screen.print("Recording stopped.")
        wait(1, SECONDS)
    else:
        wait(0.1, SECONDS)

get_recording_time#

get_recording_time returns the amount of time a specific Vision Sensor has been recording for in seconds.

Usage:

drone.camera.get_recording_time(camera)

Parameters

Description

camera

The Vision Sensor to check recording time of:

  • DOWNWARD_CAMERA
  • FORWARD_CAMERA
drone.take_off(500)

drone.camera.start_recording(FORWARD_CAMERA)
while drone.camera.is_recording:
    controller.screen.clear_screen()
    controller.screen.set_cursor(1, 1)
    if controller.button5.pressing():
        drone.camera.stop_recording(FORWARD_CAMERA)
    else:
        controller.screen.print("Recording for: {} seconds.".format(drone.camera.get_recording_time(FORWARD_CAMERA)))
    wait(0.1, SECONDS)