First Version (#1)
Co-authored-by: Anujith Muraleedharan <140189296+AnujithM@users.noreply.github.com>
This commit is contained in:
31
example_exercises/5_take_a_picture.py
Executable file
31
example_exercises/5_take_a_picture.py
Executable file
@@ -0,0 +1,31 @@
|
||||
import os
|
||||
import cv2
|
||||
import time
|
||||
import numpy as np
|
||||
from tello_sim.tello_sim_client import TelloSimClient
|
||||
|
||||
# Initialize and connect
|
||||
tello = TelloSimClient()
|
||||
tello.connect()
|
||||
tello.streamon()
|
||||
|
||||
# Takeoff
|
||||
tello.takeoff()
|
||||
time.sleep(5) # Let drone stabilize after takeoff
|
||||
|
||||
# Get frame object
|
||||
frame_read = tello.get_frame_read()
|
||||
|
||||
tello.streamoff()
|
||||
|
||||
# Prepare directory to save
|
||||
script_dir = os.path.dirname(__file__)
|
||||
artifact_folder_path = os.path.join(script_dir, "../../artifacts/images")
|
||||
os.makedirs(artifact_folder_path, exist_ok=True)
|
||||
|
||||
# Save the frame
|
||||
save_path = os.path.join(artifact_folder_path, "picture.png")
|
||||
cv2.imwrite(save_path, np.array(frame_read.frame))
|
||||
|
||||
# Land
|
||||
tello.land()
|
||||
Reference in New Issue
Block a user