logo

对上传的图片分别选取了四个ROI识别其中的矩形,但只能识别到左上角的矩形,其他区域识别不到是什么原因?

2023-05-30 00:24
K
cyvf
# Find Rects Example
#
# 这个例子展示了如何使用april标签代码中的四元检测代码在图像中找到矩形。 四元检测算法以非常稳健的方式检测矩形,并且比基于Hough变换的方法好得多。 例如,即使镜头失真导致这些矩形看起来弯曲,它仍然可以检测到矩形。 圆角矩形是没有问题的!
# (但是,这个代码也会检测小半径的圆)...

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565) # 灰度更快(160x120 max on OpenMV-M7)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time = 2000)
clock = time.clock()

while(True):
    clock.tick()
    img = sensor.snapshot().lens_corr(strength = 1.8, zoom = 1.0)
    # 下面的`threshold`应设置为足够高的值,以滤除在图像中检测到的具有
    # 低边缘幅度的噪声矩形。最适用与背景形成鲜明对比的矩形。

    for r1 in img.find_rects(roi = (0,0,100,100),threshold = 1000):
        img.draw_rectangle(r1.rect(), color = (255, 0, 0))
        print("1")
        print(r1.rect())
    for r2 in img.find_rects(roi = (400,0,240,200),threshold = 1000):
        img.draw_rectangle(r2.rect(), color = (255, 0, 0))
        print("2")
        print(r2.rect())
    for r3 in img.find_rects(roi = (0,350,100,100),threshold = 1000):
        img.draw_rectangle(r3.rect(), color = (255, 0, 0))   
        print("3")
        print(r3.rect())
    for r4 in img.find_rects(roi = (300,350,340,100),threshold = 1000):
        img.draw_rectangle(r4.rect(), color = (255, 0, 0))
        print("4")
        print(r4.rect())
34eec5a8-1594-419c-a192-ebe840a3f52f.jpg
2023-05-31 19:35
I
网红小智智 星瞳科技

我感觉是固件有计算错误,已经提交issue

https://github.com/openmv/openmv/issues/1854