91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 3KB
    文件類型: .py
    金幣: 2
    下載: 2 次
    發布日期: 2021-06-18
  • 語言: Python
  • 標簽: openmv??同時識別??

資源簡介

停車 識別三種顏色 通過串口 發送給arduino 進行處理。。利用的是色塊的橫坐標 大小比較 從而將三種顏色 排列組合 到達排序效果 針對工程訓練大賽 openmv 顏色識別 共享此代碼 歡迎學習

資源截圖

代碼片段和文件信息

import?sensor?image?time?pyb
red_threshold?=?(47?68?55?103?25?63)?#?red_thresholds
green_threshold??=?(82?58?-15?-99?-49?31)?#?green_thresholds
blue_threshold??=?(28?81?-52?81?-29?-87)#?blue_thresholds

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time?=?2000)
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)#水平翻轉
clock?=?time.clock()
uart?=?pyb.UART(1?9600?timeout_char?=?100)
#?只有比“pixel_threshold”多的像素和多于“area_threshold”的區域才被
#?下面的“find_blobs”返回。?如果更改相機分辨率,
#?請更改“pixels_threshold”和“area_threshold”。?“merge?=?True”合并圖像中所有重疊的色塊。
r=0
g=0
b=0
k=1
c=2
d=0
while(True):
????clock.tick()
????c?=?uart.readchar()-48

????if?c==1?:
????????while(c==1):
????????????img?=?sensor.snapshot().lens_corr(1.8)
????????????for?blob?in?img.find_blobs([red_threshold]?pixels_threshold=800?area_threshold=800):
????????????????img.draw_rectangle(blob.rect())
????????????????img.draw_cross(blob.cx()?blob.cy())
????????????????r=blob.cx()
????????????#print(“1111111111111“)
????????????#print(r)
????????????for?blob?in?img.find_blobs([green_threshold]?pixels_threshold=200?area_th

評論

共有 條評論