要求是要加条件,进行判断如果环境改变,输出形状,如果形状被遮挡,输出颜色
N
na3m
@na3m
0
声望
28
楼层
755
资料浏览
0
粉丝
0
关注
na3m 发布的帖子
-
在形状被遮挡后识别颜色,环境改变后识别颜色怎么解决
import sensor, image, time, math # 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 = [(0, 20, -18, 127, -8, 22), # generic_red_thresholds -> index is 0 so code == (1 << 0) (0, 60, -18, -48, 22, 127), (0, 50, 2, 127, 2, 127)] # generic_green_thresholds -> index is 1 so code == (1 << 1) # Codes are or'ed together when "merge=True" for "find_blobs". #roi=(20,20,20,20) sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.HQQVGA) 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() # Only blobs that with more pixels than "pixel_threshold" and more area than "area_threshold" are # returned by "find_blobs" below. Change "pixels_threshold" and "area_threshold" if you change the # camera resolution. "merge=True" must be set to merge overlapping color blobs for color codes. def yanse(): for blob in img.find_blobs(thresholds, pixels_threshold=100, area_threshold=100, merge=True): if blob.code() == 1: # r/g code == (1 << 1) | (1 << 0) print("红色") ys=0 elif blob.code() == 2: # r/g code == (1 << 1) | (1 << 0) print("绿色") ys=1 elif blob.code() == 4: # r/g code == (1 << 1) | (1 << 0) print("黑色") ys=2 else: print("无色") while(True): clock.tick() img = sensor.snapshot() for r in img.find_rects(threshold = 1000): img.draw_rectangle(r.rect(), color = (255, 0, 0)) roi1=r.rect() yanse() print("矩形") jx=1 print("FPS %f" % clock.fps()) for c in img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,r_min = 2, r_max = 100, r_step = 2): img.draw_circle(c.x(), c.y(), c.r(), color = (255, 0, 0)) roi1=(c.x(), c.y(), c.r()) yanse() print("圆形") yx=2
-
实现多个二维码同时识别定位怎么更改,求指教
import sensor, image, time from pyb import UART import json black_threshold = (0, 20, -18, 127, -8, 22) #black green_threshold = (0, 70, -128, -28, 22, 127) #green red_threshold = (0, 50, -128, 127, 12, 127) #red thresholds = (0,0,50,50) QRCode_1="www.xt.com"; QRCode_2="www.gym.com"; QRCode_3="www.gyt.com"; QRCode_4="www.jgz.com"; QRCode_5="www.njs.com"; qr = 0 a = 1 sensor.reset() sensor.set_pixformat(sensor.RGB565) sensor.set_framesize(sensor.QQVGA) 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() uart = UART(3, 115200) #识别二维码 while(a): clock.tick() img = sensor.snapshot() img.lens_corr(1.8) # 1.8的强度参数对于2.8mm镜头来说是不错的。 for code in img.find_qrcodes(): img.draw_rectangle(code.rect(), color = (255, 0, 0)) if code.payload() == QRCode_1 : qr=1; elif code.payload() == QRCode_2 : qr=2; elif code.payload() == QRCode_3 : qr=3; elif code.payload() == QRCode_4 : qr=4; else : qr=5; print("二维码",code) print(qr) output_str="%d,%d,%d,%d,%d" % (code.x(), code.y(),code.w(),code.h(),qr) uart.write(output_str+'\r\n')
-
RE: 相似度阈值如何写 比如识别颜色阈值小于0.3识别颜色 识别颜色阈值小于0.6识别形状
@kidswong999 如何调 老师要求是遮挡一下形状可以通过颜色识别定位,改变光线条件可以通过形状定位
-
RE: 相似度阈值如何写 比如识别颜色阈值小于0.3识别颜色 识别颜色阈值小于0.6识别形状
@kidswong999 就是先识别颜色如果因为光线的原因或遮挡颜色达不到自己定义的阈值然后识别形状 怎么解决!
-
相似度阈值如何写 比如识别颜色阈值小于0.3识别颜色 识别颜色阈值小于0.6识别形状
相似度阈值如何写 比如识别颜色阈值小于0.3识别颜色 识别颜色阈值小于0.6识别形状