資源簡(jiǎn)介
使用openmv識(shí)別紅綠藍(lán)物塊顏色,黑色和白色也有簡(jiǎn)易識(shí)別。并且可以計(jì)算出顏色物塊的距離。
代碼片段和文件信息
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?藍(lán)色閾值
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)#垂直翻轉(zhuǎn)
#sensor.set_hmirror(True)#水平翻轉(zhuǎn)
r_led?=?LED(1)
b_led?=?LED(3)
clock?=?time.clock()
uart?=?UART(3?115200)?#打開串口
uart.init(115200?bits=8?parity=None?stop=1)?#位寬度參數(shù)bits=8,奇偶校驗(yàn)參數(shù)parity=None停止位參數(shù)stop=1
#?只有比“pixel_threshold”多的像素和多于“area_threshol
評(píng)論
共有 條評(píng)論