资源简介
使用openmv识别红绿蓝物块颜色,黑色和白色也有简易识别。并且可以计算出颜色物块的距离。
代码片段和文件信息
import sensor image time pyblcd
from pyb import UART
from pyb import LED
red_threshold = (3481978873) # red_thresholds 红色阈值
green_threshold = (2550-4040560) # green_thresholds 绿色阈值
blue_threshold = (42 72 -60 16 -26 -67)# blue_thresholds 蓝色阈值
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 3000)
sensor.set_auto_gain(False) # must be turned off for color tracking
sensor.set_auto_whitebal(False) # must be turned off for color tracking
#sensor.set_vflip(True)#垂直翻转
#sensor.set_hmirror(True)#水平翻转
r_led = LED(1)
b_led = LED(3)
clock = time.clock()
uart = UART(3 115200) #打开串口
uart.init(115200 bits=8 parity=None stop=1) #位宽度参数bits=8,奇偶校验参数parity=None停止位参数stop=1
# 只有比“pixel_threshold”多的像素和多于“area_threshol
评论
共有 条评论