用列表轮廓形状匹配轮廓

2024-09-30 00:25:40 发布

您现在位置:Python中文网/ 问答频道 /正文

我创建了下面的程序来更正答案表。你知道吗

https://gist.github.com/andreemidio/d2cdf3d301fd8df1677e9a315ff845f0

我能画出轮廓,识别填充物,我需要匹配信息。你知道吗

每行返回我30个矩形轮廓,其中填充的是确定的。我现在需要知道这些充满的肺泡在这个阵列中的位置。所以我返回问题答案和所选选项。 我认为信息匹配的问题就在代码的这一部分。你知道吗

posicaoRespostas = np.empty(0,int)

for (q, i) in enumerate(np.arange(0, len(questionCnts), 30)):


cnts = contours.sort_contours(questionCnts[i:i+30])[0]

for (l ,k )in enumerate(cnts):
    (x, y, w, h) = cv2.boundingRect(k)
    if (w >= 20 and h >= 20) and (w <= 25  and h <= 25) and ar >= 0.7 and ar <= 1.3:
        box = [(x//5)*5, y]
    #print(x, y)

    posicaoRespostas = np.append(posicaoRespostas,(l))

    cv2.rectangle(bolhas, (x, y), (x+w, y+h), (0, 0, 255), 1) #desenho para visualização

我曾经读过阿德里安罗斯布鲁克的这篇文章

https://www.pyimagesearch.com/2016/10/03/bubble-sheet-multiple-choice-scanner-and-test-grader-using-omr-python-and-opencv/

原件

Imagem Original

尝试

Image processada


Tags: and答案inhttpscom信息fornp

热门问题