Kamera#

Ievads#

VEX AIR dronam ir divi redzes sensori, kas kalpo kā iebūvētās kameras — viens priekšpusē un viens apakšā. Tie lidojuma laikā var uzņemt gan attēlus, gan video. VEXcode AIR valodā vārds “camera” vienmēr attiecas uz vienu no šiem redzes sensoriem. Piemēram, komandā drone.camera.start_recording(FORWARD_CAMERA), camera attiecas uz redzes sensoriem, un FORWARD_CAMERA atlasa priekšējo sensoru.

Lai pārsūtītu videoierakstus un attēlus no VEX AIR drona kontroliera, pievienojiet kontrolieri datoram. Tas tiks parādīts kā lielapjoma atmiņas ierīce (līdzīga USB diskam), kas ļaus jums tieši kopēt failus. Pēc projekta pabeigšanas pagaidiet apmēram minūti, līdz kontrolieris pabeidz attēlu vai ierakstu lejupielādi no drona, pirms mēģināt tos kopēt.

Zemāk ir visu pieejamo metožu saraksts:

Darbības

Mutatori

Geters

Darbības#

start_recording#

start_recording sāk ierakstīšanu ar norādīto redzes sensoru.

For information about viewing and retrieving recordings, go here.

Lietojums:

drone.camera.start_recording(camera)

Parametri

Apraksts

camera

Redzes sensors ierakstīšanai ar: DOWNWARD_CAMERA vai 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 aptur norādītā redzes sensora ierakstīšanu.

For information about viewing and retrieving recordings, go here.

Lietojums:

drone.camera.stop_recording(camera)

Parametri

Apraksts

camera

Redzes sensors pārtrauc ierakstīšanu ar: DOWNWARD_CAMERA vai 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 uzņem attēlu ar norādīto redzes sensoru.

Lai iegūtu informāciju par uzņemto attēlu apskati un atgūšanu, skatiet šeit.

Lietojums:

drone.camera.capture_image(camera)

Parametri

Apraksts

camera

Redzes sensors attēla uzņemšanai ar: DOWNWARD_CAMERA vai 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)

Mutatori#

show_camera#

show_camera iestata pašreizējo ekrāna režīmu uz norādīto redzes sensora plūsmu.

Lietojums:

controller.screen.show_camera(camera)

Parametri

Apraksts

camera

Redzes sensora plūsmai jāparādās: DOWNWARD_CAMERA vai 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 paslēpj norādītā redzes sensora plūsmu.

Lietojums:

controller.screen.hide_camera()

Parametri

Apraksts

Šai metodei nav parametru.

# 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 iespējo vai atspējo pārklājuma tīkliņu. Tīkliņs ir vizuāls marķieris, līdzīgs krustveida krustojumam, kas parādās kameras skatā, lai palīdzētu mērķēt vai izlīdzināt objektus.

Pēc noklusējuma tīkliņa pārklājums projekta sākumā ir iestatīts uz True , tikai uz lejupvērstā redzes sensora.

Usage:
controller.screen.set_overlay_reticle(state)

Parametri

Apraksts

state

Pārklājošā tīkliņa stāvoklis: True iespējo pārklājošo tīkliņu. False atspējo pārklājošo tīkliņu.

# 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 iespējo vai atspējo drona telemetrijas datu redzamību kontroliera ekrānā. Telemetrija ir tiešie dati no drona, kamēr tas lido vai darbojas ar projektu.

Pēc noklusējuma telemetrijas datu pārklājums projekta sākumā ir iestatīts uz True.

Usage:
controller.screen.set_overlay_telemetry(state)

Parametri

Apraksts

state

Telemetrijas datu stāvoklis: True iespējo telemetrijas datu skatīšanu ekrānā. False atspējo telemetrijas datu skatīšanu ekrānā.

# 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)

Getteri#

is_recording#

is_recording atgriež Būla vērtību, kas norāda, vai norādītais redzes sensors pašlaik veic ierakstīšanu.

  • True – norādītais redzes sensors veic ierakstīšanu.

  • False – Norādītais redzes sensors neveic ierakstu.

Lietojums:

drone.camera.is_recording(camera)

Parametri

Apraksts

camera

Redzes sensors pārbauda ierakstīšanas statusu: DOWNWARD_CAMERA vai 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 atgriež laika daudzumu, ko konkrēts redzes sensors ir veicis ierakstīšanu, decimālskaitļa (float) veidā sekundēs.

Lietojums:

drone.camera.get_recording_time(camera)

Parametri

Apraksts

camera

Redzes sensors pārbauda ierakstīšanas laiku: DOWNWARD_CAMERA vai 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)