Searching of quadrilateral/triangle corners.

Namespace:  AForge.Imaging
Assembly:  AForge.Imaging (in AForge.Imaging.dll) Version: 2.2.5.0 (2.2.5.0)

Syntax

C#
public class QuadrilateralFinder

Remarks

The class searches for quadrilateral's/triangle's corners on the specified image. It first collects edge points of the object and then uses FindQuadrilateralCorners(IEnumerable<(Of <(IntPoint>)>)) to find corners the quadrilateral/triangle.

Note:The class treats all black pixels as background (none-object) and all none-black pixels as object.

The class processes grayscale 8 bpp and color 24/32 bpp images.

Sample usage:

CopyC#
// get corners of the quadrilateral
QuadrilateralFinder qf = new QuadrilateralFinder( );
List<IntPoint> corners = qf.ProcessImage( image );

// lock image to draw on it with AForge.NET's methods
// (or draw directly on image without locking if it is unmanaged image)
BitmapData data = image.LockBits( new Rectangle( 0, 0, image.Width, image.Height ),
    ImageLockMode.ReadWrite, image.PixelFormat );

Drawing.Polygon( data, corners, Color.Red );
for ( int i = 0; i < corners.Count; i++ )
{
    Drawing.FillRectangle( data,
        new Rectangle( corners[i].X - 2, corners[i].Y - 2, 5, 5 ),
        Color.FromArgb( i * 32 + 127 + 32, i * 64, i * 64 ) );
}

image.UnlockBits( data );

Source image:

Result image:

Inheritance Hierarchy

System..::.Object
  AForge.Imaging..::.QuadrilateralFinder

See Also