hehemouse / aforge

Automatically exported from code.google.com/p/aforge
Other
0 stars 0 forks source link

Blob Detection problem with certain aspect ratio rectangles. #160

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Download the attached images.  There are two sets of images in which I 
performed corner detection using the code in (2).

2.

            // create instance of blob counter
            BlobCounter blobCounter = new BlobCounter();

            //Eliminate noisy pixels from our blob search.
            blobCounter.FilterBlobs = true;
            blobCounter.MinHeight = 6;
            blobCounter.MinWidth = 22;
            blobCounter.MaxHeight = 15;

            // process input image
            blobCounter.ProcessImage(placeHolder);
            // get information about detected objects
            Blob[] blobs = blobCounter.GetObjectsInformation();

            // create Graphics object to draw on the image and a pen
            Graphics g = Graphics.FromImage(placeHolder);
            Pen bluePen = new Pen(Color.Blue, 2);
            // check each object and draw circle around objects, which
            // are recognized as circles
            double[] blobAdjustedSize = new double[blobs.Length];
            for (int i = 0, n = blobs.Length; i < n; i++)
            {
                List<IntPoint> edgePoints = blobCounter.GetBlobsEdgePoints(blobs[i]);
                List<IntPoint> corners = PointsCloud.FindQuadrilateralCorners(edgePoints);

                g.DrawPolygon(bluePen, ToPointsArray(corners));

            }

3. Compare the two sets of pre and post blob detection images provided. Observe 
that otherwise identical draw style/color rectangles fail to be detected once 
their width:height reaches approximately 11:1 ratio.

What is the expected output? What do you see instead?
Only 3 out of 4 of their corners are detected.  This means the rectangles are 
detected as triangles even though the fourth undetected corner is really no 
different than the three that were properly detected.

What version of the product are you using?
2.1.4.0

Please provide any additional information below.
This issue can actually be worked around in part by using the Bounding 
Rectangle for the blobs because we are searching for rectangles and we get the 
first three points correctly.  However, as mentioned by Andrew in the forums 
(http://www.aforgenet.com/forum/viewtopic.php?f=2&t=1745), the 
FindQuadrilateralCorners() function is not working properly in this situation.

Original issue reported on code.google.com by mkort...@gmail.com on 10 Oct 2010 at 9:31

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I think by highlighting the individual EdgePoint and Corner Point pixels it 
makes the problem much more clear (corners are too close to each other and 
FindQuadrileteralCorners() doesn't like it).

Original comment by mkort...@gmail.com on 10 Oct 2010 at 10:38

Attachments:

GoogleCodeExporter commented 9 years ago
In case my above comment wasn't clear, the following highlighting code was used:

                foreach (IntPoint point in edgePoints)
                {
                    g.DrawRectangle(greenPen, point.X, point.Y, 1, 1);
                }

                foreach (IntPoint point in corners)
                {
                  g.DrawRectangle(redPen, point.X, point.Y, 1, 1);
                }

Original comment by mkort...@gmail.com on 10 Oct 2010 at 10:42

GoogleCodeExporter commented 9 years ago
Okay after looking at PointsCloud.cs it is clear that the line 381 is setting 
too high a distortion limit:

double distortionLimit = 0.1 * ( cloudSize.X + cloudSize.Y ) / 2;

If I set distortionLimit to a lower value, detection works fine.  

If I do:

double distortionLimit = 0.06 * ( cloudSize.X + cloudSize.Y ) / 2;

Then I get the attached pictures.

Is it not possible to overload this function with a custom distortionLimit 
parameter?

This is actually an excellent discovery for me because it also eliminates a 
problem with smaller health bars getting too close to each other and being 
recorded as a trapezoid.

Original comment by mkort...@gmail.com on 10 Oct 2010 at 11:24

Attachments:

GoogleCodeExporter commented 9 years ago

Original comment by andrew.k...@gmail.com on 7 Jan 2011 at 3:01

GoogleCodeExporter commented 9 years ago
1) Fixing the issue of detecting flat rectangles with high aspect ratio between 
adjacent sides.
2) Adding PointsCloud.QuadrilateralRelativeDistortionLimit static property, so 
user could tweak distortion limit if he understands what he does.

The original issue described in the ticket is fixed by the first change, so 
there is no need for using QuadrilateralRelativeDistortionLimit. However this 
property was still added to give more control to users.

Committed in revision 1368. Will be released in version 2.1.5.

Original comment by andrew.k...@gmail.com on 7 Jan 2011 at 4:09

GoogleCodeExporter commented 9 years ago

Original comment by andrew.k...@gmail.com on 12 Jan 2011 at 11:43