3
I created the program below, to make the correction of tests.
https://gist.github.com/andreemidio/d2cdf3d301fd8df1677e9a315ff845f0
I was able to outline, identify the fillers, I need to match the information.
Each line returns me 30 rectangular outlines, of which the filled ones are identified. now I need to know the position of these filled alveoli inside this array.So I return the answer of the question and the selected option
The result for visualization is this
I believe that the question of the match of information lies in that part of the code.
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
Has a picture of the answer card filled whole randomly?
– danieltakeshi
Not yet, because I’m not even able to make the identification, the second part is to do with random answers. This template is there, because I know exactly where the answers are and it is easier to validate the output.
– Andre Emidio
Yes, the photos in the post, are the ones I use. From the second image of the mural, I arrive at the first image, in this case, has been processed and removed the contours I need.
– Andre Emidio
To find the position of these outlines after findcontour, see this function of Opencv. Where it is possible to check the coordinates of the contours found. But your program is irreproducible, I suggest creating a [mcve]
– danieltakeshi
And you use the function
findcontour
with the Bubbles library, but I think the Hough Circles would be more appropriate. Where the output of this function would already give you the coordinates of all the circles of the answer book. If the circle was filled correctly, I suggest using morphological transforms to "disappear" with the circles without padding and using Hough Circles to locate the fill of the answers.– danieltakeshi
I’m making the change now, I was doing a separate test to see how the Hough Circles behaves in the image, currently I’m with detection error 10 outlines not found.
– Andre Emidio
But I still have the question, how it was to trace the information, whether the question 1: A, is really marked ??
– Andre Emidio
You already have the circle coordinate, so you can check if this region of interest (ROI) has how many non-white pixels, if it is a number of pixels greater than the amount of the highest letter (A,B,C,D,E), you know that this position is marked. Then with the position you know the question number and which alternative is ticked.
– danieltakeshi
Okay, I’ll try what you said, I put the code in a reset. https://github.com/andreemidio/omr2
– Andre Emidio