相機#
介紹#
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– 顯示或隱藏遙測資料。
吸氣劑
is_recording– 返回視覺感應器是否正在錄製。get_recording_time– 傳回錄製所花費的時間。
行動#
start_recording#
start_recording 使用指定的視覺感應器開始錄製。
For information about viewing and retrieving recordings, go here.
用法:
drone.camera.start_recording(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 停止指定視覺感測器的錄製。
For information about viewing and retrieving recordings, go here.
用法:
drone.camera.stop_recording(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)
參數 |
描述 |
|---|---|
|
視覺感應器用於拍照: |
# 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)
參數 |
描述 |
|---|---|
|
要顯示的視覺感測器訊號: |
# 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 ,僅在向下視覺感測器上。
用法:
controller.screen.set_overlay_reticle(state)
參數 |
描述 |
|---|---|
|
疊加準星的狀態: |
# 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 啟用或停用無人機遙測資料在控制器螢幕上的顯示。遙測數據是指無人機飛行或執行專案時即時採集的數據。
預設情況下,遙測資料疊加層在專案開始時設定為 True。
用法:
controller.screen.set_overlay_telemetry(state)
參數 |
描述 |
|---|---|
|
遙測資料狀態: |
# 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)
參數 |
描述 |
|---|---|
|
視覺感測器檢查以下錄影狀態: |
# 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)
參數 |
描述 |
|---|---|
|
視覺感測器檢查錄影時間: |
# 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)