Click here to Skip to main content
15,911,315 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Bitmap image = (Bitmap)pictureBox4.Image;
// create instance of blob counter
BlobCounter blobCounter = new BlobCounter();
blobCounter.FilterBlobs = true;
blobCounter.MinHeight = 5;
blobCounter.MinWidth = 5;
//process the dilated image
blobCounter.ProcessImage(image);
// get info about detected objects
Blob[] blobs = blobCounter.GetObjectsInformation();

// create a graphics object to draw on the image and a pen
Graphics g = Graphics.FromImage(image );
Pen Redpen = new Pen(Color.Red, 2);

SimpleShapeChecker shapechecker= new SimpleShapeChecker ();

//check in image and draw around the object found as rectangle
for(int i=0,n=blobs.Length ;i<n;i++)>
{
List<intpoint> edgepoints = blobCounter.GetBlobsEdgePoints(blobs [i ]);
List <intpoint> cornerpoints;
if (shapechecker.IsQuadrilateral(edgepoints, out cornerpoints ))
{
if (shapechecker.CheckPolygonSubType (cornerpoints ) == PolygonSubType.Rectangle)
{
g.DrawPolygon (Redpen, cornerpoints.ToArray ());
}

}
}
Redpen.Dispose();
g.Dispose();
Posted

try as below, use System.Drawing.Point
C#
for(int i=0,n=blobs.Length ;i<n;i++)>
{
	List<intpoint> edgepoints = blobCounter.GetBlobsEdgePoints(blobs [i ]);
	List<intpoint> cornerpoints;
	if (shapechecker.IsQuadrilateral(edgepoints, out cornerpoints ))
	{
		if (shapechecker.CheckPolygonSubType (cornerpoints ) == PolygonSubType.Rectangle)
		{
			g.DrawPolygon (Redpen, cornerpoints.Select(p => new System.Drawing.Point(p.X, p.Y)).ToArray());
		}
	}
}
 
Share this answer
 
v2
I have tried all possible solutions available on google...like usin linq...which dint work , then about the code to be added like for conversion from system.point to aforge, ad one more thing i do not get the ToPointsArray method as well ...as in it does not exist ....am I missing out on any library or reference....please help....I'm sure its a small thing I'm missing out on. Sorry for the trouble but I'm new to using Aforge.Net .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900