xxxx18一60岁hd中国/日韩女同互慰一区二区/西西人体扒开双腿无遮挡/日韩欧美黄色一级片 - 色护士精品影院www

  • 大小: 6KB
    文件類型: .py
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2024-01-27
  • 語(yǔ)言: Python
  • 標(biāo)簽: OpenMV??例程??

資源簡(jiǎn)介

OpenMV識(shí)別交通燈例程,僅需根據(jù)環(huán)境修改交通燈紅、綠、黃顏色閾值即可,思路清晰,識(shí)別率高。

資源截圖

代碼片段和文件信息

#?Untitled?-?By:?CZK?-?周五?5月?10?2019


import?sensor?imagetimelcd?pyb
from?pyb?import?UARTTimerLED
#
red_threshold_01?=?(60?88?23?63?6?-25)
green_threshold_01?=?(85?98?-90?1?4?-63)
yellow_threshold_01?=?(64?99?-23?18?14?66)
#


sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)#320*240
sensor.set_framesize(sensor.VGA)
sensor.set_windowing((240?240))


#sensor.snapshot().save(“/snapshot-%d.jpg“?%?pyb.rng())?#?Save?Pic.

sensor.skip_frames()
sensor.set_auto_whitebal(False)??????#關(guān)閉白平衡
sensor.set_auto_gain(False)??????????#關(guān)閉自動(dòng)增益
clock?=?time.clock()
lcd.init()???????????????????????????#Initialize?the?lcd?screen.
uart?=?UART(31152008None1)???????#創(chuàng)建串口對(duì)象

data?=?[]

LED_Red?=?LED(1)
LED_Green?=?LED(2)
LED_Blue?=?LED(3)
BLUE_LED_PIN?=?3

def?expand_roi(roi):
????#?set?for?QQVGA?160*120
????extra?=?5
????win_size?=?(640?480)
????(x?y?width?height)?=?roi
????new_roi?=?[x-extra?y-extra?width+2*extra?height+2*extra]

????if?new_roi[0]?????????new_roi[0]?=?0
????if?new_roi[1]?????????new_roi[1]?=?0
????if?new_roi[2]?>?win_size[0]:
????????new_roi[2]?=?win_size[0]
????if?new_roi[3]?>?win_size[1]:
????????new_roi[3]?=?win_size[1]

????return?tuple(new_roi)
sensor.skip_frames(time?=?2000)?#?Give?the?user?time?to?get?ready.

tim?=?Timer(4freq=1)??????????????#?create?a?timer?object?using?timer?4
#tim.callback(tick)
tim.deinit()




while(True):
????img?=?sensor.snapshot()
????clock.tick()?#?Track?elapsed?milliseconds?between?snapshots().
????blobs_red?=?img.find_blobs([red_threshold_01]?area_threshold=150)
????blobs_green?=?img.find_blobs([green_threshold_01]?area_threshold=150)
????blobs_yellow?=?img.find_blobs([yellow_threshold_01]?area_threshold=150)


????if?blobs_yellow:
????#如果找到了目標(biāo)顏色
????????#print(blobs)
????????#print(“黃燈“)
????????numjtdy?=?numjtdy+1
????????for?blob?in?blobs_yellow:
????????#迭代找到的目標(biāo)顏色區(qū)域
????????????is_circle?=?False
????????????max_circle?=?None
????????????max_radius?=?-1

????????????new_roi?=?expand_roi(blob.rect())

????????????for?c?in?img.find_circles(threshold?=?2000?x_margin?=?20?y_margin?=?20?r_margin?=?10?roi=new_roi):
????????????????is_circle?=?True
????????????????#?img.draw_circle(c.x()?c.y()?c.r()?color?=?(255?255?255))
????????????????if?c.r()?>?max_radius:
????????????????????max_radius?=?c.r()
????????????????????max_circle?=?c
????????????if?is_circle:
????????????????#?如果有對(duì)應(yīng)顏色的圓形?標(biāo)記外框
????????????????#?Draw?a?rect?around?the?blob.
????????????????img.draw_rectangle(new_roi)?#?rect
????????????????img.draw_rectangle(blob.rect())?#?rect
????????????????#用矩形標(biāo)記出目標(biāo)顏色區(qū)域
????????????????img.draw_cross(blob[5]?blob[6])?#?cx?cy
??????

評(píng)論

共有 條評(píng)論