我是一个初学者,正在学习编程一种叫Tello的无人机。我正试着用它拍摄一张照片。在
在手册中,没有使用无人机拍摄图像的选项。这里只提到了录像。如何用无人机用Python代码捕捉图像?在
以下是tello.py文件的代码:# This code is adopted from https://learn.droneblocks.io/p/tello-drone-programming-with-python/
# Import the necessary modules
import socket
import threading
import time
class Tello():
def __init__(self):
# IP and port of Tello
self.tello_address = ('192.168.10.1', 8889)
# IP and port of local computer
self.local_address = ('', 9000)
# Create a UDP connection that we'll send the command to
self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
# Bind to the local address and port
self.sock.bind(self.local_address)
# Create and start a listening thread that runs in the background
# This utilizes our receive functions and will continuously monitor for incoming messages
self.receiveThread = threading.Thread(target=self.receive)
self.receiveThread.daemon = True
self.receiveThread.start()
# Send the message to Tello and allow for a delay in seconds
def send(self, message, delay):
# Try to send the message otherwise print the exception
try:
self.sock.sendto(message.encode(), self.tello_address)
print("Sending message: " + message)
except Exception as e:
print("Error sending: " + str(e))
# Delay for a user-defined period of time
time.sleep(delay)
# Receive the message from Tello
def receive(self):
# Continuously loop and listen for incoming messages
while True:
# Try to receive the message otherwise print the exception
try:
response, ip_address = self.sock.recvfrom(128)
print("Received message: " + response.decode(encoding='utf-8'))
except Exception as e:
# If there's an error close the socket and break out of the loop
self.sock.close()
print("Error receiving: " + str(e))
break
以下是flight1.py文件的代码:
^{pr2}$
我该怎么用无人机捕捉图像?在