Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.
I'm having a problem to detect marked boxes (OMR) using Aforge.
In one of the squares (which was marked by the user) as there is a line crossing within the same algorithm interprets it as a triangle and not as the square with more padding.
Someone can tell me what I can do to improve?
Attached below the image with the problem.
If you use Blob Counter (don't forget to invert your picture first), then you will find individual boxes. When you get those and extract their images, you may analyze them further. Empty boxes should have pixels only on borders of the extracted image. But boxes with some marks will have pixels inside as well.
Hi Andrew. Thank you for response.
To give you an idea about my problem as shown in the figure above post, I'm using the example ShapeChecker that comes along with AForge and he can not find the last square returning a triangle as shown in the figure attached.
Any ideas on what I can do to solve this problem?
I would try to search for black objects in your images, instead of white. In other words I would invert the image and try to go from there. Obviously shape checker will not help you in this case as well, since your checked box will not become square on the inverted image. But it will allow you to find any box (checked or unchecked) as a single blob and then further analyze it.
If the Shape Checker can not return one of the options as a square, it means this option is the one which was marked. What happens if you use this information to try to decide whether a box is checked or not? You can also combine this with some logic to check if pixels inside the box are marked as Andrew suggested.
By the way Andrew, I believe there is a small typo in the docs for the Simple Shape Checker (http://www.aforgenet.com/framework/docs ... c3d4a7.htm) where it reads:
maxDitance = max( minAcceptableDistortion, relativeDistortionLimit * ( width + height ) / 2 )
All the best,
Thanks for the answers from you!
I was able to detect whether the square of the marking or not. I used the properties MinAcceptableDistortion, RelativeDistortionLimit and AngleError and could return the same integer. However now I have the problem in time to detect whether it is satisfied in relation to others. I'm using the same property and Fullness 0.29920442753372534 returns the value for the square that is marked. I was in doubt about what the optimal value to consider this appointment. Can anyone help me?
PS: Andrew, I followed your suggestion and reversed the image.
You can try to find more or less optimal value experimentally - trial and errors. Or better try statistical approach - collect some reasonable amount of checked and unchecked boxes (lets say 100) and just see what are the min/max/mean values of Fullness for checked and unchecked box. Those value should help to make decision about setting threshold.
Hardly possible to get what you just said ...
The Fullness property may not be accurate for such type of a task. I am not sure why you chose it ... As I mentioned before you need to check if there are black pixels (or white on the inverted image) inside of the box, not on edges. So you may need to leave small gap for the box itself and check what are the pixel values inside.