กล้อง#

การแนะนำ#

โดรน VEX AIR มีเซ็นเซอร์ตรวจจับภาพสองตัวที่ทำหน้าที่เป็นกล้องในตัว—ตัวหนึ่งอยู่ด้านหน้าและอีกตัวอยู่ด้านล่าง สามารถบันทึกทั้งภาพนิ่งและวิดีโอระหว่างการบินได้ ใน VEXcode AIR คำว่า “camera” จะหมายถึงเซ็นเซอร์ตรวจจับภาพตัวใดตัวหนึ่งเสมอ ตัวอย่างเช่น ในคำสั่งเช่น drone.camera.start_recording(FORWARD_CAMERA), camera หมายถึงเซ็นเซอร์ตรวจจับภาพ และ FORWARD_CAMERA เลือกเซ็นเซอร์ที่อยู่ด้านหน้า

ในการถ่ายโอนวิดีโอและภาพนิ่งจากตัวควบคุมโดรน VEX AIR ให้เชื่อมต่อตัวควบคุมเข้ากับคอมพิวเตอร์ของคุณ ตัวควบคุมจะปรากฏเป็นอุปกรณ์จัดเก็บข้อมูลขนาดใหญ่ (คล้ายกับไดรฟ์ USB) ทำให้คุณสามารถคัดลอกไฟล์ได้โดยตรง หลังจากเสร็จสิ้นโครงการแล้ว ให้รอประมาณหนึ่งนาทีเพื่อให้ตัวควบคุมดาวน์โหลดภาพหรือวิดีโอจากโดรนเสร็จสมบูรณ์ก่อนที่จะพยายามคัดลอกไฟล์เหล่านั้น

ด้านล่างนี้คือรายการวิธีการทั้งหมดที่มีให้เลือกใช้:

การกระทำ

  • start_recording – บันทึกวิดีโอจากเซ็นเซอร์ตรวจจับภาพ

  • stop_recording – หยุดการบันทึกจากเซ็นเซอร์ตรวจจับภาพ

  • capture_image – จับภาพจากเซ็นเซอร์ตรวจจับภาพ

ตัวปรับแต่ง

  • show_camera – แสดงเซ็นเซอร์ตรวจจับภาพที่เลือกไว้บนตัวควบคุมโดรน VEX AIR

  • hide_camera – ซ่อนฟีดเซ็นเซอร์ภาพบนตัวควบคุม

  • set_overlay_reticle – แสดงหรือซ่อนเส้นเล็งแบบซ้อนทับ

  • set_overlay_telemetry – แสดงหรือซ่อนข้อมูล telemetry

ผู้รับ

  • is_recording – คืนค่าว่าเซ็นเซอร์วิชั่นกำลังบันทึกอยู่หรือไม่

  • get_recording_time – ส่งคืนเวลาที่ใช้ในการบันทึก

การกระทำ#

start_recording#

start_recording เริ่มการบันทึกด้วยเซ็นเซอร์ตรวจจับภาพที่ระบุ

สำหรับข้อมูลเกี่ยวกับการดูและเรียกดูบันทึก ไปที่นี่

วิธีใช้:

drone.camera.start_recording(camera)

พารามิเตอร์

คำอธิบาย

camera

เซ็นเซอร์ตรวจจับภาพที่จะบันทึกด้วย: DOWNWARD_CAMERA หรือ 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 หยุดการบันทึกของเซ็นเซอร์ตรวจจับภาพที่ระบุ

สำหรับข้อมูลเกี่ยวกับการดูและเรียกดูบันทึก ไปที่นี่

วิธีใช้:

drone.camera.stop_recording(camera)

พารามิเตอร์

คำอธิบาย

camera

เซ็นเซอร์ตรวจจับภาพเพื่อหยุดการบันทึกด้วย: DOWNWARD_CAMERA หรือ 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 ถ่ายภาพด้วยเซ็นเซอร์ตรวจจับภาพที่ระบุ

สำหรับข้อมูลเกี่ยวกับการดูและเรียกค้นภาพที่บันทึกไว้ ไปที่นี่

วิธีใช้:

drone.camera.capture_image(camera)

พารามิเตอร์

คำอธิบาย

camera

เซ็นเซอร์ตรวจจับภาพสำหรับถ่ายภาพ: DOWNWARD_CAMERA หรือ 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 ตั้งค่าโหมดหน้าจอปัจจุบันเป็นฟีดเซ็นเซอร์ภาพที่ระบุ

วิธีใช้:

controller.screen.show_camera(camera)

พารามิเตอร์

คำอธิบาย

camera

ฟีดเซ็นเซอร์ตรวจจับภาพที่จะแสดง: DOWNWARD_CAMERA หรือ 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 ซ่อนภาพจากเซ็นเซอร์ตรวจจับภาพที่ระบุ

วิธีใช้:

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 เปิดหรือปิดใช้งานเส้นเล็งแบบซ้อนทับ เส้นเล็งคือเครื่องหมายภาพ เช่น กากบาท ที่ปรากฏในมุมมองของกล้องเพื่อช่วยในการเล็งหรือจัดแนววัตถุ

โดยค่าเริ่มต้น การซ้อนทับเส้นเล็งจะถูกตั้งค่าเป็น True เมื่อเริ่มต้นโครงการ เฉพาะบนเซ็นเซอร์ตรวจจับภาพด้านล่างเท่านั้น

Usage:
controller.screen.set_overlay_reticle(state)

พารามิเตอร์

คำอธิบาย

state

สถานะของเป้าเล็งแบบซ้อนทับ: True เปิดใช้งานเป้าเล็งแบบซ้อนทับ False ปิดใช้งานเป้าเล็งแบบซ้อนทับ

# 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 จะเปิดหรือปิดการแสดงข้อมูล telemetry ของโดรนบนหน้าจอควบคุม ข้อมูล telemetry คือข้อมูลแบบเรียลไทม์จากโดรนขณะบินหรือขณะปฏิบัติงาน

โดยค่าเริ่มต้น การซ้อนทับข้อมูล telemetry จะถูกตั้งค่าเป็น True เมื่อเริ่มต้นโครงการ

Usage:
controller.screen.set_overlay_telemetry(state)

พารามิเตอร์

คำอธิบาย

state

สถานะของข้อมูลการวัดระยะทาง: True เปิดใช้งานการแสดงข้อมูลการวัดระยะทางบนหน้าจอ False ปิดใช้งานการแสดงข้อมูลการวัดระยะทางบนหน้าจอ

# 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 ส่งคืนค่าบูลีนที่ระบุว่าเซ็นเซอร์ตรวจจับภาพที่ระบุ กำลังบันทึกอยู่หรือไม่

  • True – เซ็นเซอร์ตรวจจับภาพที่ระบุ กำลังบันทึกอยู่

  • False – เซ็นเซอร์ตรวจจับภาพที่ระบุไม่ได้ทำการบันทึก

วิธีใช้:

drone.camera.is_recording(camera)

พารามิเตอร์

คำอธิบาย

camera

เซ็นเซอร์ตรวจจับภาพเพื่อตรวจสอบสถานะการบันทึกของ: DOWNWARD_CAMERA หรือ 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 ส่งคืนระยะเวลาที่เซ็นเซอร์ตรวจจับภาพเฉพาะตัวหนึ่งบันทึกเป็นทศนิยม (float) ในหน่วยวินาที

วิธีใช้:

drone.camera.get_recording_time(camera)

พารามิเตอร์

คำอธิบาย

camera

เซ็นเซอร์ตรวจจับภาพเพื่อตรวจสอบเวลาบันทึกของ: DOWNWARD_CAMERA หรือ 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)