logo

请问怎样提高这段代码的识别准确性,现在识别不太稳定,会乱入其他类型

2023-07-07 10:29
Z
iv2r
import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565) # 灰度更快
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()
sensor.set_auto_gain(False) # 颜色跟踪必须关闭自动增益
sensor.set_auto_whitebal(False) # 颜色跟踪必须关闭白平衡

threshold_B=[(0, 15, 0, 40, -80, -20)]
#threshold_B=[(34, 58, -5, 46, -128, -14)]
thresholds_R=[(30, 100, 15, 127, 15, 127)]

while(True):
    clock.tick()
    img = sensor.snapshot().lens_corr(1.8)
    if img.find_blobs(threshold_B, pixels_threshold=100, area_threshold=100, merge=True): #找蓝色色块
        if img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,r_min = 2, r_max = 100, r_step = 2):#圆形
            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))
                print("蓝色")
                
        else:
 
            print("蓝色假")
    if img.find_blobs(thresholds_R, pixels_threshold=100, area_threshold=100, merge=True): #找红色色块
        if img.find_circles(threshold = 3500, x_margin = 10, y_margin = 10, r_margin = 10,r_min = 2, r_max = 100, r_step = 2):#圆形
            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))

                print("红色假")
        else:

            print("红色")
    print("FPS %f" % clock.fps())
a735d172-8faf-4702-ab49-ead4588a4ad5.png
2023-07-07 10:35
Z
iv2r
f78c2a8c-8a12-4dc1-aa67-48001a2cd374.png
Z
iv2r
be24d2b8-bc3c-45a6-879a-39630a031d81.png
2023-07-07 11:08
Z
iv2r

@iv2r 就是 想消抖 让它稳定点 有没有什么办法

2023-07-07 16:49
I
网红小智智 星瞳科技

https://book.openmv.cc/image/blob_circle.html