資源簡介
到物塊位置時,openmv接受到arduino發送信號,獲取顏色標識,然后識別下一個,識別三次后得到物塊顏色順序,發送給arduino,到二維碼時識別出二維碼發送給arduino
代碼片段和文件信息
import?sensor?image?time
import?json
from?pyb?import?UART
red_threshold?=?(17?43?14?57?3?39)
green_threshold?=?(30?55?-49?-13?5?44)
blue_threshold?=?(21?48?-26?10?-36?5)
red_color_code?=?1
green_color_code?=?2
blue_color_code?=?4
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(10)
sensor.set_auto_whitebal(False)
sensor.skip_frames(30)
sensor.set_auto_gain(False)
clock?=?time.clock()
uart?=?UART(3?115200)
count?=?0
cmd?=?‘‘
while(True):
????clock.tick()
????img?=?sensor.snapshot()
????img.lens_corr(1.8)
????if?uart.any():
??????tmp_data?=?uart.readline()
??????print(tmp_data)
??????if?tmp_data?==?b‘qr\r\n‘:
???????zhi?=?0
???????while(zhi==0):
????????img?=?sensor.snapshot()
????????img.lens_corr(1.8)
????????for?code?in?img.find_qrcodes():
?????????zhi?=?code.payload()
?????????uart.write(zhi+‘\n‘)
?????????print(‘you?send:‘zhi)
- 上一篇:PyQt4中文教程chm版
- 下一篇:劍指offer 66編程題Python
評論
共有 條評論