-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject_detect.py
More file actions
27 lines (27 loc) · 937 Bytes
/
object_detect.py
File metadata and controls
27 lines (27 loc) · 937 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import cv2
import matplotlib.pyplot as plt
import cvlib as cv
from cvlib.object_detection import draw_bbox
from djitellopy import Tello
import numpy as np
tello = Tello()
tello.connect()
tello.streamon()
def get_resized_frame(w=640,h=480):
return cv2.resize(tello.get_frame_read().frame,(w,h))
while True:
img = get_resized_frame()
bbox, label, conf = cv.detect_common_objects(img)
output_image = draw_bbox(img, bbox, label, conf)
bat = "Battery: {}%".format(tello.get_battery())
cv2.putText(output_image, bat, (5, 480-5),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
temp = "Temperature: {}%C".format(tello.get_temperature())
cv2.putText(output_image, temp, (5, 480-25),
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 0, 255), 2)
cv2.imshow("Image", output_image)
if cv2.waitKey(1) & 0xFF == ord('q'):
cv2.destroyAllWindows()
break
tello.streamoff()
cv2.destroyAllWindows()