カメラ#
導入#
VEX AIRドローンには、機体前面と底面にそれぞれ1つずつ、搭載カメラとして機能する2つのビジョンセンサーが搭載されています。これらは飛行中に画像と動画の両方を撮影できます。VEXcode AIRでは、「カメラ」という単語は常にこれらのビジョンセンサーのいずれかを指します。たとえば、 drone.camera.start_recording(FORWARD_CAMERA)ようなコマンドでは、 camera はビジョンセンサーを指し、 FORWARD_CAMERA は前面のセンサーを選択します。
VEX AIRドローンコントローラーからビデオ録画や画像を転送するには、コントローラーをコンピューターに接続します。コントローラーはマスストレージデバイス(USBドライブと同様)として認識され、ファイルを直接コピーできるようになります。プロジェクト終了後、コントローラーがドローンから画像や録画のダウンロードを完了するまで約1分待ってから、コピーを試みてください。
以下に、利用可能なメソッドの一覧を示します。
アクション
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 は、指定されたビジョンセンサーを使用して録画を開始します。
録画の視聴と取得に関する情報については、こちらをご覧ください。
使用法:
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 は、指定されたビジョンセンサーの録画を停止します。
録画の視聴と取得に関する情報については、こちらをご覧ください。
使用法:
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 に設定されます。
Usage:
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 に設定されます。
Usage:
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)