First Version (#1)
Co-authored-by: Anujith Muraleedharan <140189296+AnujithM@users.noreply.github.com>
This commit is contained in:
32
example_exercises/4_camera_sanity_check.py
Executable file
32
example_exercises/4_camera_sanity_check.py
Executable file
@@ -0,0 +1,32 @@
|
||||
from tello_sim.tello_sim_client import TelloSimClient
|
||||
import cv2
|
||||
|
||||
# Create a Tello instance
|
||||
tello = TelloSimClient()
|
||||
# Desired window size
|
||||
WINDOW_WIDTH = 640
|
||||
WINDOW_HEIGHT = 360
|
||||
# Connect to Tello
|
||||
tello.connect()
|
||||
|
||||
tello.streamon()
|
||||
|
||||
# Create a normal, resizable window
|
||||
cv2.namedWindow("frame", cv2.WINDOW_NORMAL)
|
||||
cv2.resizeWindow("frame", WINDOW_WIDTH, WINDOW_HEIGHT)
|
||||
|
||||
try:
|
||||
while True:
|
||||
img = tello.get_frame_read().frame
|
||||
if img is not None:
|
||||
img_bgr = cv2.cvtColor(img, cv2.COLOR_RGB2BGR)
|
||||
# Resize the image to fit the window size
|
||||
img_resized = cv2.resize(img_bgr, (WINDOW_WIDTH, WINDOW_HEIGHT), interpolation=cv2.INTER_AREA)
|
||||
cv2.imshow("frame", img_resized)
|
||||
if cv2.waitKey(1) == ord('q'):
|
||||
break
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
finally:
|
||||
print("fin")
|
||||
cv2.destroyAllWindows()
|
||||
Reference in New Issue
Block a user