Κάμερα#

Εισαγωγή#

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.

Για να μεταφέρετε εγγραφές βίντεο και εικόνες από το χειριστήριο VEX AIR Drone, συνδέστε το χειριστήριο στον υπολογιστή σας. Θα εμφανιστεί ως συσκευή μαζικής αποθήκευσης (παρόμοια με μια μονάδα USB), επιτρέποντάς σας να αντιγράφετε αρχεία απευθείας. Αφού ολοκληρώσετε ένα έργο, περιμένετε περίπου ένα λεπτό για να ολοκληρώσει το χειριστήριο τη λήψη οποιωνδήποτε εικόνων ή εγγραφών από το drone πριν επιχειρήσετε να τα αντιγράψετε.

Παρακάτω είναι μια λίστα με όλες τις διαθέσιμες μεθόδους:

Ενέργειες

Μεταλλαγμένοι

Αποκτητές

Ενέργειες#

start_recording#

start_recording starts a recording with the specified Vision Sensor.

Για πληροφορίες σχετικά με την προβολή και ανάκτηση εγγραφών, μεταβείτε εδώ.

Χρήση:

drone.camera.start_recording(camera)

Παράμετροι

Περιγραφή

camera

The Vision Sensor to record with: DOWNWARD_CAMERA or FORWARD_CAMERA.

# Press button 7 to end recording
def end_recording():
    drone.camera.stop_recording(FORWARD_CAMERA)
    drone.land()

controller.button7.pressed(end_recording)

# Record a video as you fly around
controller.screen.show_camera(FORWARD_CAMERA)
drone.take_off(climb_to=500)
drone.camera.start_recording(FORWARD_CAMERA)
while True:
    # Move with controller
    drone.move_with_vectors(
        forward=controller.axis4.position(),
        rightward=controller.axis3.position(),
        upward=controller.axis1.position(),
        rotation=controller.axis2.position()
    )
    wait(5, MSEC)

stop_recording#

stop_recording stops the recording of the specified Vision Sensor.

Για πληροφορίες σχετικά με την προβολή και ανάκτηση εγγραφών, μεταβείτε εδώ.

Χρήση:

drone.camera.stop_recording(camera)

Παράμετροι

Περιγραφή

camera

The Vision Sensor to stop recording with: DOWNWARD_CAMERA or FORWARD_CAMERA.

# Press button 7 to end recording
def end_recording():
    drone.camera.stop_recording(FORWARD_CAMERA)
    drone.land()

controller.button7.pressed(end_recording)

# Record a video as you fly around
controller.screen.show_camera(FORWARD_CAMERA)
drone.take_off(climb_to=500)
drone.camera.start_recording(FORWARD_CAMERA)
while True:
    # Move with controller
    drone.move_with_vectors(
        forward=controller.axis4.position(),
        rightward=controller.axis3.position(),
        upward=controller.axis1.position(),
        rotation=controller.axis2.position()
    )
    wait(5, MSEC)

capture_image#

capture_image takes a picture with the specified Vision Sensor.

Για πληροφορίες σχετικά με την προβολή και ανάκτηση εικόνων που έχουν ληφθεί, μεταβείτε εδώ.

Χρήση:

drone.camera.capture_image(camera)

Παράμετροι

Περιγραφή

camera

The Vision Sensor to take a picture with: DOWNWARD_CAMERA or FORWARD_CAMERA.

# Press button 7 to take pictures
def take_picture():
    drone.camera.capture_image(FORWARD_CAMERA)

controller.button7.pressed(take_picture)

# Take pictures while you control the drone
controller.screen.show_camera(FORWARD_CAMERA)
drone.take_off(climb_to=500)
while True:
    # Move with controller
    drone.move_with_vectors(
        forward=controller.axis4.position(),
        rightward=controller.axis3.position(),
        upward=controller.axis1.position(),
        rotation=controller.axis2.position()
    )
    wait(5, MSEC)

Μεταλλάκτες#

show_camera#

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

Χρήση:

controller.screen.show_camera(camera)

Παράμετροι

Περιγραφή

camera

The Vision Sensor feed to display: DOWNWARD_CAMERA or FORWARD_CAMERA.

# Switch camera feeds after 3 seconds
controller.screen.show_camera(DOWNWARD_CAMERA)
wait(3, SECONDS)
controller.screen.show_camera(FORWARD_CAMERA)

hide_camera#

hide_camera hides the specified Vision Sensor’s feed.

Χρήση:

controller.screen.hide_camera()

Παράμετροι

Περιγραφή

Αυτή η μέθοδος δεν έχει παραμέτρους.

# Hide camera feed after 3 seconds
controller.screen.show_camera(FORWARD_CAMERA)
wait(3, SECONDS)
controller.screen.hide_camera()

set_overlay_reticle#

set_overlay_reticle enables or disables the overlay reticle. A reticle is a visual marker, like a crosshair, that appears in the camera’s view to help with aiming or aligning objects.

By default, the reticle overlay is set to True at the start of a project, only on the downward Vision Sensor.

Usage:
controller.screen.set_overlay_reticle(state)

Παράμετροι

Περιγραφή

state

The state of the overlay reticle: True enables the overlay reticle. False disables the overlay reticle.

# Hide the reticle when not aligning to a landing area
controller.screen.show_camera(DOWNWARD_CAMERA)
drone.take_off(climb_to=500)
controller.screen.set_overlay_reticle(False)
while True:
    # Move with controller
    drone.move_with_vectors(
        forward=controller.axis4.position(),
        rightward=controller.axis3.position(),
        upward=controller.axis1.position(),
        rotation=controller.axis2.position()
    )
    wait(5, MSEC)

set_overlay_telemetry#

set_overlay_telemetry enables or disables the visibility of the drone’s telemetry data on the controller’s screen. Telemetry is live data from the drone while it is flying or running a project.

By default, the telemetry data overlay is set to True at the start of a project.

Usage:
controller.screen.set_overlay_telemetry(state)

Παράμετροι

Περιγραφή

state

The state of the telemetry data: True enables viewing telemetry data on the screen. False disables viewing telemetry data on the screen.

# Clear the camera video for better visibility
controller.screen.show_camera(FORWARD_CAMERA)
drone.take_off(climb_to=500)
controller.screen.set_overlay_telemetry(False)
while True:
    # Move with controller
    drone.move_with_vectors(
        forward=controller.axis4.position(),
        rightward=controller.axis3.position(),
        upward=controller.axis1.position(),
        rotation=controller.axis2.position()
    )
    wait(5, MSEC)

Αποκτητές#

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.

Χρήση:

drone.camera.is_recording(camera)

Παράμετροι

Περιγραφή

camera

The Vision Sensor to check recording status of: DOWNWARD_CAMERA or FORWARD_CAMERA.

# Use button 7 to start and stop recording
def toggle_recording():
    if drone.camera.is_recording(FORWARD_CAMERA):
        drone.camera.stop_recording(FORWARD_CAMERA)
    else:
        drone.camera.start_recording(FORWARD_CAMERA)

controller.button7.pressed(toggle_recording)

# Make video recordings while you control the drone
controller.screen.show_camera(FORWARD_CAMERA)
drone.take_off(climb_to=500)
while True:
    # Move with controller
    drone.move_with_vectors(
        forward=controller.axis4.position(),
        rightward=controller.axis3.position(),
        upward=controller.axis1.position(),
        rotation=controller.axis2.position()
    )
    wait(5, MSEC)

get_recording_time#

get_recording_time returns the amount of time a specific Vision Sensor has been recording for as a decimal (float) in seconds.

Χρήση:

drone.camera.get_recording_time(camera)

Παράμετροι

Περιγραφή

camera

The Vision Sensor to check recording time of: DOWNWARD_CAMERA or FORWARD_CAMERA.

# Record a video for 10 seconds
controller.screen.show_camera(FORWARD_CAMERA)
drone.camera.start_recording(FORWARD_CAMERA)
drone.take_off(climb_to=500)
while not (drone.camera.get_recording_time(FORWARD_CAMERA)) >= 10:
    wait(5, MSEC)
drone.camera.stop_recording(FORWARD_CAMERA)