python tello_Tello-Edu无人机:如何用Python代码捕捉图像

我是一个初学者,正在学习编程一种叫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}$

我该怎么用无人机捕捉图像?在

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值