Forum to discuss AForge.NET Framework, its features, API, how-tos, etc.
by rogercorrea » Mon May 30, 2011 3:21 am
Hi,
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.
Thanks!
- Attachments
-

- Problem area. Three squares. One with filled.
- Untitled.jpg (11.08 KiB) Viewed 1031 times
-
rogercorrea
-
- Posts: 8
- Joined: Mon May 30, 2011 3:14 am
by andrew.kirillov » Wed Jun 01, 2011 12:59 pm
Hello,
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.
-

andrew.kirillov
- Site Admin, AForge.NET Developer
-
- Posts: 2571
- Joined: Fri Jan 23, 2009 9:12 am
- Location: UK
by rogercorrea » Wed Jun 01, 2011 11:41 pm
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?
- Attachments
-

- Tela_GED.png (2.71 KiB) Viewed 1012 times
-
rogercorrea
-
- Posts: 8
- Joined: Mon May 30, 2011 3:14 am
by andrew.kirillov » Thu Jun 02, 2011 6:30 am
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.
-

andrew.kirillov
- Site Admin, AForge.NET Developer
-
- Posts: 2571
- Joined: Fri Jan 23, 2009 9:12 am
- Location: UK
by cesarsouza » Fri Jun 10, 2011 11:48 pm
rogercorrea wrote: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?
Hi Roger, 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, César
-
cesarsouza
-
- Posts: 63
- Joined: Fri Apr 10, 2009 3:41 pm
by andrew.kirillov » Sat Jun 11, 2011 2:23 pm
cesarsouza wrote: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 )
True. Fixed.
-

andrew.kirillov
- Site Admin, AForge.NET Developer
-
- Posts: 2571
- Joined: Fri Jan 23, 2009 9:12 am
- Location: UK
by rogercorrea » Wed Jun 15, 2011 1:50 am
Hi! 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.
-
rogercorrea
-
- Posts: 8
- Joined: Mon May 30, 2011 3:14 am
by andrew.kirillov » Wed Jun 15, 2011 8:59 am
rogercorrea wrote:I was in doubt about what the optimal value to consider this appointment.
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.
-

andrew.kirillov
- Site Admin, AForge.NET Developer
-
- Posts: 2571
- Joined: Fri Jan 23, 2009 9:12 am
- Location: UK
by rogercorrea » Wed Jun 15, 2011 11:37 am
There is a more accurate way of detecting at least I was no black pixels inside the square?
-
rogercorrea
-
- Posts: 8
- Joined: Mon May 30, 2011 3:14 am
by andrew.kirillov » Wed Jun 15, 2011 12:01 pm
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.
-

andrew.kirillov
- Site Admin, AForge.NET Developer
-
- Posts: 2571
- Joined: Fri Jan 23, 2009 9:12 am
- Location: UK
Return to AForge.NET Framework
|

|