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

標(biāo)題: 關(guān)于OPNEMV的視覺識(shí)別系統(tǒng) [打印本頁]

作者: 公長拜拜    時(shí)間: 2018-6-19 13:49
標(biāo)題: 關(guān)于OPNEMV的視覺識(shí)別系統(tǒng)

作者: 公長拜拜    時(shí)間: 2018-6-19 13:49
標(biāo)題: 關(guān)于OPNEMV的視覺識(shí)別系統(tǒng)
相機(jī)采用openmv硬件相機(jī),能夠識(shí)別顏色,并將RGB值返回,或是找到固定RGB值的圖像區(qū)域范圍

程序如下://語言 :python 編程

import sensor, image, pyb, os, time

sensor.reset() # Initialize the camera sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # or sensor.GRAYSCALE
sensor.set_framesize(sensor.QQVGA) # or sensor.QQVGA (or others)
sensor.skip_frames(time = 2000) # Let new settings take affect.
sensor.set_auto_whitebal(True) # Turn off white balance.
clock = time.clock() # Tracks FPS.
min_degree = 0
max_degree = 179
#獲取正確樣本圖片
if not "temp" in os.listdir():os.mkdir("temp")#創(chuàng)建文件夾temp
print("3秒后錄制正確樣本")
kernel_size = 1 # kernel width = (size*2)+1, kernel height = (size*2)+1
kernel = [-1, -1, -1,\
          -1, +3, -1,\
          -1, -1, -1]
sensor.skip_frames(time= 3000)
sensor.snapshot().save("temp/bg.bmp")
print("正確樣本保存結(jié)束")

while(True):
    clock.tick()
    print("請(qǐng)放置好被檢測(cè)樣本")
    time.sleep(3)
    print("開始檢測(cè)")
    img = sensor.snapshot()


    img.difference("temp/bg.bmp")
    thresholds=(240,255)
    img.find_blobs([thresholds], pixels_threshold=100, area_threshold=100, merge=True);
    for l in img.find_lines(threshold = 1000, theta_margin = 25, rho_margin = 25):
           if (min_degree <= l.theta()) and (l.theta() <= max_degree):
               img.draw_line(l.line(), color = (255, 0, 0))

               print(l)
//下面是一些重要函數(shù)用法
image.find_template(template, threshold, roi=Auto, step=2, search=image.SEARCH_EX)
Tries to find the first location in the image where template matches using Normalized Cross Correlation. Returns a bounding box tuple (x, y, w, h) for the matching location otherwise None.

template is a small image object that is matched against this image object. Note that both images must be grayscale.

threshold is floating point number (0.0-1.0) where a higher threshold prevents false positives while lowering the detection rate while a lower threshold does the opposite.

roi is the region-of-interest rectangle (x, y, w, h) to search in.

step is the number of pixels to skip past while looking for the template. Skipping pixels considerably speeds the algorithm up. This only affects the algorithm in SERACH_EX mode.

search can be either image.SEARCH_DS or image.SEARCH_EX. image.SEARCH_DS searches for the template using as faster algorithm than image.SEARCH_EX but may not find the template if it’s near the edges of the image. image.SEARCH_EX does an exhaustive search for the image but can be much slower than image.SEARCH_DS.

Note

roi, step, and search are keyword arguments which must be explicitly invoked in the function call by writing roi=, step=, or search=.


作者: 公長拜拜    時(shí)間: 2018-6-19 13:49
主要代碼,以及一個(gè)例程




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