logo

为什么识别矩形的例程会把圆也识别为矩形呢?

2019-05-12 21:28
K
dx1g

为什么识别矩形的例程会把圆也识别为矩形呢?

2019-05-13 08:48
I
网红小智智 星瞳科技

请提供一下和图片代码。

2019-05-14 12:22
K
dx1g

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565) # grayscale is faster (160x120 max on OpenMV-M7)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)
clock = time.clock()

while(True):
    clock.tick()
    img = sensor.snapshot()

    # 下面的`threshold`应设置为足够高的值,以滤除在图像中检测到的具有
    # 低边缘幅度的噪声矩形。最适用与背景形成鲜明对比的矩形。

    for r in img.find_rects(threshold = 10000):
        img.draw_rectangle(r.rect(), color = (255, 0, 0))
        for p in r.corners(): img.draw_circle(p[0], p[1], 5, color = (0, 255, 0))
        print(r)
4fbc9c26-5dce-42c5-ba4c-9fd3a09b1b91.png
K
dx1g
ff53541d-befc-4758-a994-b56bbf9c75fc.png
2019-05-16 19:29
D
xsyz

你可以把threshold调高一点试试,识别到的矩形的强度肯定是大于圆的