Added new gestures and detection parameters tuning

Esse commit está contido em:
Nikita Kiselov
2021-03-10 17:30:44 +02:00
commit b417ce0584
4 arquivos alterados com 27 adições e 12 exclusões
+2 -1
Ver Arquivo
@@ -1,6 +1,7 @@
device = 0
width = 960
height = 540
min_detection_confidence = 0.5
min_detection_confidence = 0.7
min_tracking_confidence = 0.5
buffer_len = 5
is_keyboard = True
+19 -8
Ver Arquivo
@@ -1,5 +1,6 @@
from djitellopy import Tello
class TelloGestureController:
def __init__(self, tello: Tello):
self.tello = tello
@@ -16,23 +17,33 @@ class TelloGestureController:
print("GESTURE", gesture_id)
if not self._is_landing:
if gesture_id == 0:
if gesture_id == 0: # Forward
self.forw_back_velocity = 30
elif gesture_id == 1:
elif gesture_id == 1: # STOP
self.forw_back_velocity = self.up_down_velocity = \
self.left_right_velocity = self.yaw_velocity = 0
if gesture_id == 5: # Back
self.forw_back_velocity = -30
elif gesture_id == 2:
self.forw_back_velocity = 0
elif gesture_id == 3:
elif gesture_id == 2: # UP
self.up_down_velocity = 25
elif gesture_id == 4: # DOWN
self.up_down_velocity = -25
elif gesture_id == 3: # LAND
self._is_landing = True
self.forw_back_velocity = self.up_down_velocity = \
self.left_right_velocity = self.yaw_velocity = 0
self.tello.land()
elif gesture_id == 6: # LEFT
self.left_right_velocity = 20
elif gesture_id == 7: # RIGHT
self.left_right_velocity = -20
elif gesture_id == -1:
self.forw_back_velocity = self.up_down_velocity = \
self.left_right_velocity = self.yaw_velocity = 0
self.tello.send_rc_control(self.left_right_velocity, self.forw_back_velocity,
self.up_down_velocity, self.yaw_velocity)
+5 -2
Ver Arquivo
@@ -29,6 +29,9 @@ def get_args():
parser.add("--min_tracking_confidence",
help='min_tracking_confidence',
type=float)
parser.add("--buffer_len",
help='Length of gesture buffer',
type=int)
args = parser.parse_args()
@@ -64,7 +67,7 @@ def main():
# Take-off drone
# tello.takeoff()
tello.takeoff()
cap = tello.get_frame_read()
@@ -74,7 +77,7 @@ def main():
gesture_detector = GestureRecognition(args.use_static_image_mode, args.min_detection_confidence,
args.min_tracking_confidence)
gesture_buffer = GestureBuffer(buffer_len=5)
gesture_buffer = GestureBuffer(buffer_len=args.buffer_len)
def tello_control(key, keyboard_controller, gesture_controller):
global gesture_buffer
@@ -1,7 +1,7 @@
Forward
Stop
Up
OK
Land
Down
Back
Left
1 Forward
2 Stop
3 Up
4 OK Land
5 Down
6 Back
7 Left