myzn 发布的帖子
-
我想要通过别人给我发送信息,更换目标,但是摄像头为什么会卡
-
我用openmv与感光模块通信,但在接收数据等我时候总是出现UnicodeError的问题
-- coding: utf-8 --
import sensor, image, time, pyb, json
from pyb import UART
from pyb import Pin
yellow_threshold = (60 ,83 , -9, 46, 31, 72)
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000 )
sensor.set_auto_whitebal(False)
sensor.set_auto_whitebal(False)
#关闭白平衡。白平衡是默认开启的,在颜色识别中,需要关闭白平衡。
uart = UART(3, 9600, timeout_char=1000)
uart = UART(3,9600)clock = time.clock()
while(True):
clock.tick()
#FH = 0x55
#str='%d'%(FH)
uart.write('U')
if uart.any():
a=uart.readline().decode().strip()#首先是一个字节串,加入decode变为字符串,strip删掉回车和换行
print(a)
m = a[2:7]
print(m)
#n=int(m)
# if n>=00000 and n<00130:
# yellow_threshold = (39 ,72 , -11, 11, -46, -34)
# print(1)
#if n>=00130 and n<00200:
# yellow_threshold = (19 ,68 , -9, 12, -40, -13)
# print(2)
#if n>=00450 and n<00650:
# yellow_threshold = (60 ,23 , -9, 46, 31, 72)
# print(3)
#if n>=00650 and n<00850:
# yellow_threshold = (0 ,0 , -11, 3, -33, -23)
# print(4)
#if n>=00850 and n<01050:
# yellow_threshold = (60 ,23 , -9, 46, 31, 72)
# print(5)
#if n>=01050 and n<01250:
# yellow_threshold = (60 ,23 , -9, 46, 31, 72)
# print(6)
#if n>=01250 and n<01450:
# yellow_threshold = (60 ,23 , -9, 46, 31, 72)
# print(7)
#if n>=01450 and n<01650:
# yellow_threshold = (60 ,23 , -9, 46, 31, 72)
# print(8)
#if n>=01650 and n<01850:
# yellow_threshold = (60 ,23 , -9, 46, 31, 72)
# print(9)
#if n>=01850 and n<02000:
# yellow_threshold = (60 ,23 , -9, 46, 31, 72)
# print(10)img = sensor.snapshot().lens_corr(1.9) blob= img.find_blobs([yellow_threshold])#寻找黄色最大的色块 if blob: #如果找到了目标颜色 for b in blob: img.draw_rectangle(b[0:4]) # rect img.draw_cross(b[5], b[6]) # cx, cy这是我的代码