1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

Telloドローンからの受信画像をPCでWindow表示されないときは、key = cv2.waitKey(1) & 0xffを忘れていないか要確認

Posted at

ハマりどころ

この一行を削除すると、画像が受信できなくなる。

key = cv2.waitKey(1) & 0xff

__msg = input("")__で、キーボード入力を受け取る場合も、上記の行は、残さないといけない。

実行画面

Terminal
from djitellopy import Tello
import cv2, math, time

tello = Tello()
tello.connect()

tello.streamon()
frame_read = tello.get_frame_read()

# tello.takeoff()

while True:
    # In reality you want to display frames in a seperate thread. Otherwise
    #  they will freeze while the drone moves.
    img = frame_read.frame
    cv2.imshow("drone", img)
    
    #次の行(key = cv2.・・・)を削除すると、画像が受信できなくなる。
    key = cv2.waitKey(1) & 0xff
    msg = ""
    msg = input("Tello1号機に送る指示コマンドを入力してください。:  ")
    print("操作コマンド : {0} が入力されました。".format(msg))
    if msg == "i":
        tello.takeoff()
    elif msg == "w":
        tello.move_forward(30)
    elif msg == "s":
        tello.move_back(30)
    elif msg == "a":
        tello.move_left(30)
    elif msg == "d":
        tello.move_right(30)
    elif msg == "e":
        tello.rotate_clockwise(30)
    elif msg == "q":
        tello.rotate_counter_clockwise(30)
    elif msg == "r":
        tello.move_up(30)
    elif msg == "f":
        tello.move_down(30)
    elif msg == "g":
        tello.land()
    

tello.land()

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?