欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136

標題: 工程訓練賽 用openmv識別二維碼與顏色 [打印本頁]

作者: SUPER111111    時間: 2019-10-21 18:15
標題: 工程訓練賽 用openmv識別二維碼與顏色
import sensor, image, time,json
from pyb import UART

i= 1
# Color Tracking Thresholds (L Min, L Max, A Min, A Max, B Min, B Max)
# The below thresholds track in general red/green things. You may wish to tune them...
thresholds = [(7, 41, 13, 37, -63, -21), #yellow generic_red_thresholds -> index is 0 so code == (1 << 0)
              (55, 79, -39, 0, 8, 27),
              (35, 55, 21, 84, 26, 69)] #blue generic_green_thresholds -> index is 1 so code == (1 << 1)
# 當“find_blobs”的“merge = True”時,code代碼被組合在一起。

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
clock = time.clock()

# 只有比“pixel_threshold”多的像素和多于“area_threshold”的區域才被
# 下面的“find_blobs”返回。 如果更改相機分辨率,
# 請更改“pixels_threshold”和“area_threshold”。 “merge = True”合并圖像中所有重疊的色塊。
uart =UART(3,115200)

while(True):
    clock.tick()
    img = sensor.snapshot()
    if i==1:
         img.lens_corr(1.8) # strength of 1.8 is good for the 2.8mm lens.
         for code in img.find_qrcodes():
            print(code)
            output_str="{%d}" code
            uart.write(output_str+'\r\n')
            print('send:',output_str)
            i=1
    else:
        for blob in img.find_blobs(thresholds,pixels_threshold =50):
            if blob.code() == 1: # r/g code == (1 << 1) | (1 << 0)
                img.draw_rectangle(blob.rect())
                img.draw_cross(blob.cx(), blob.cy())
                output_str="{1}"
                uart.write(output_str+'\r\n')
                print('send:',output_str)
            if blob.code() == 2: # r/g code == (1 << 1) | (1 << 0)
                img.draw_rectangle(blob.rect())
                img.draw_cross(blob.cx(), blob.cy())
                output_str="{2}"
                uart.write(output_str+'\r\n')
                print('send:',output_str)
                #print(2)
            if blob.code() == 4: # r/g code == (1 << 1) | (1 << 0)
                img.draw_rectangle(blob.rect())
                img.draw_cross(blob.cx(), blob.cy())
                output_str="{3}"
                uart.write(output_str+'\r\n')
                print('send:',output_str)
                #print(3)


作者: 2337907856    時間: 2020-12-20 17:00
復制到open mv的IDE中為什么會有錯誤呢




歡迎光臨 (http://www.raoushi.com/bbs/) Powered by Discuz! X3.1