openmv第一次调试
2018-09-19 20:14:51
import sensor, image, time
import car
import json
import time
from pyb import UART
from pid import PID sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.RGB565) # use RGB565.
sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
sensor.skip_frames(30) # Let new settings take affect.
sensor.set_auto_whitebal(False) # 追踪颜色需要关闭白平衡
sensor.set_auto_gain(False)#扫码需要关闭自动增益
clock = time.clock() # Tracks FPS.
red_threshold = (13, 49, 18, 61, 6, 47) #红色阈值
size_threshold = 2000
x_pid = PID(p=0.5, i=1, imax=100)
h_pid = PID(p=0.05, i=0.1, imax=50)
uart = UART(3, 115200)
ma_flag = 0
ma = []
'''
#串口通信:
测试json数据 {(1,22),(-3,33),(22222,0),(9999,12),(0,0)}
data=[]
data_out = json.dumps(set(data))
uart.write(data_out +'\n')
uart.write("Hello World!\r")
'''
######################
'''
#扫码反馈信息
img.lens_corr(1.8) # 缩小视野
for code in img.find_qrcodes():
print(code) '''
def find_ma():
global ma_flag
if ma_flag :
print("已完成扫码。")
else :
ma = img.find_qrcodes()
if ma:
print("发现二维码即将停车进行扫码")
saoma()
ma_flag = 1
else:
print("正在寻找二维码。。。") def saoma():
img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens.
for code in img.find_qrcodes():
print(code) def find_max(blobs):
max_size=0
for blob in blobs:
if blob[2]*blob[3] > max_size:
max_blob=blob
max_size = blob[2]*blob[3]
return max_blob while(True):
clock.tick() # Track elapsed milliseconds between snapshots().
img = sensor.snapshot()
find_ma() '''
blobs = img.find_blobs([red_threshold])
if blobs:
max_blob = find_max(blobs)
x_error = max_blob[5]-img.width()/2
h_error = max_blob[2]*max_blob[3]-size_threshold
# print("x error: ", x_error)
print("测试与arduino通信")
###下面代码为测试与arduino通信发送坐标####
data=[]
for b in blobs:
# Draw a rect around the blob.
img.draw_rectangle(b[0:4]) # rect
img.draw_cross(b[5], b[6]) # cx, cy
data.append((b.cx(),b.cy()))
data_out = json.dumps(set(data))
uart.write(data_out +'\n')
###################################
img.draw_rectangle(max_blob[0:4]) # rect
img.draw_cross(max_blob[5], max_blob[6]) # cx, cy
x_output=x_pid.get_pid(x_error,1)
h_output=h_pid.get_pid(h_error,1)
print("h_output",h_output)
car.run(-h_output-x_output,-h_output+x_output)
else:
car.run(10,-10) #旋转寻找小球
'''
openmv第一次调试的更多相关文章
- HearthBuddy 第一次调试
HearthBuddy https://www.jiligame.com/70639.html 解压缩包,打开hearthbuddy.exe直接运行就可以:不用替换mono.dll直接可用:不需要校验 ...
- Cocos2d-x第一次调试出现的问题
1.无法打开包括文件:“CCStdC.h“ http://blog.csdn.net/jbboy/article/details/9773087 2.无法打开文件“libcocos2d.lib” 用v ...
- xamarin.forms uwp app部署到手机移动设备进行测试,真机调试(device portal方式部署)
最近学习xamarin.刚好 手上有一个lumia 930.所以试一试把uwp app部署到手机上,并真机调试一把. 目前环境: 1.开发pc电脑是win10,版本1607.加入了insider,所以 ...
- 移动端 h5调试技巧
一 安卓 一 chrome 1.安卓手机安装chrome浏览器,手机打开开发者模式,用usb线链接电脑,并且允许调试. 2.电脑chrome地址栏输入 chrome://inspect 进入后点击 i ...
- Xcode 7如何 免费 真机调试iOS应用
运行Xcode后,点击菜单中的Preferences…进入Accounts标签,这里选择添加Apple ID: 在弹出的对话框中登入你的Apple ID,没有的话去注册一个就是了,登录成功后会看到下面 ...
- Xcode 7如何免费真机调试iOS应用
Xcode 7如何免费真机调试iOS应用的简单方式: 运行Xcode后,点击菜单中的Preferences…进入Accounts标签,这里选择添加Apple ID:在弹出的对话框中登入你的Apple ...
- 通过IIS调试ASP.NET项目
当我们使用Visual Studio调试的时候,通常我们会选择VS自带的ASP.NET Developerment Server(也是默认选项),当第一次调试的时候(按F5或Ctrl+F5不调试直接打 ...
- 使用IIS配合VS调试
当我们使用Visual Studio调试(Debug)的时候,通常我们会选择VS自带的ASP.NET Developerment Server(也是默认选项),当第一次调试的时候(按F5或Ctrl+F ...
- 【转】Xcode 7 真机调试详细步骤
原文网址:http://www.jianshu.com/p/fa5f90b61ad6 文/ldjhust(简书作者)原文链接:http://www.jianshu.com/p/fa5f90b61ad6 ...
随机推荐
- wampserver64安装时出现计算机缺少MCVR110.DLL无法安装等
在安装wamp完成后运行出现上述问题,是因为wamp版本与DLL不对称.下面给出 wamp64位下载地址 http://www.onlinedown.net/soft/118187.htm vcred ...
- js简易美丽的提示框
<span style="font-size:14px;">function showTips(txt, time, status) { var htmlCon = ' ...
- 每天复习Shell—ls
ls命令是linux下最经常使用的命令.ls命令就是list的缩写缺省下ls用来打印出当前文件夹的清单假设ls指定其它文件夹那么就会显示指定文件夹里的文件及文件夹清单. 通过ls 命令不仅能够查 ...
- MSMQ消息队列的安装、启用
最近研究消息队列,先从微软自带的MSMQ开始,百度如何安装,方式如下: 控制面板---程序和功能--启用和关闭windows功能--Microsoft Message Queue(MSMQ)服务器 默 ...
- ALLOWED_HOSTS = ['*']
https://docs.djangoproject.com/en/1.10/ref/settings/#std:setting-ALLOWED_HOSTS https://stackoverflow ...
- TCP Operational Overview and the TCP Finite State Machine (FSM) http://tcpipguide.com/free/t_TCPOperationalOverviewandtheTCPFiniteStateMachineF.htm
http://tcpipguide.com/free/t_TCPOperationalOverviewandtheTCPFiniteStateMachineF.htm http://tcpipgu ...
- YTU 2959: 代码填充--雨昕学矩阵
2959: 代码填充--雨昕学矩阵 时间限制: 1 Sec 内存限制: 128 MB 提交: 112 解决: 50 题目描述 雨昕开始学矩阵了.矩阵数乘规则:一个数k乘一个矩阵A还是一个矩阵,行数 ...
- AutoIT: 开发界面结合GUI automation和Watir Automation
可以应用AutoIT开发出界面,从而把AutoIT对GUI的自动化测试与Watir对web的自动化测结合在一起.以下代码是我学习GUI界面开发的实例代码.1. 当点击Watir_Test_Button ...
- .NET获取汉字首字母
/// <summary> /// 获取汉字首字母(可包含多个汉字) /// </summary> /// <param name="strText" ...
- 使用Jquery动态加入对象的集合属性,提交集合属性到表单
1.设置模型,引入构造函数,初始化集合 public class Person { public Person() //引入构造函数,初始化集合.如果未设置构造函数,集合会出现错误. { Skills ...