Hi, im new here and i was wondering if anyone could help me with some code. I want to do blobtraking, so i found some Aforge source codes that work just fine i bitmaps, but can not manage to make it right on my project.
http://www.aforgenet.com/articles/shape_checker/
So i start from the example CLEyeWinFormTest code of codelaboratories, and i am tyring to add _form.ProccesImage(bmpGraph); on the CreateBitmap(w,h) method but picturebox1 go to black even though i created another picturebox to process the other image…
I think the program might get stucked on a line, but i don’t manage to see it.
here’s the new code:
public void ProcessImage(Bitmap bitmap)
{
BitmapData bitmapData = bitmap.LockBits(
new Rectangle(0, 0, bitmap.Width, bitmap.Height),
ImageLockMode.ReadWrite, bitmap.PixelFormat);
// step 1 - turn background to black
ColorFiltering colorFilter = new ColorFiltering();
colorFilter.Red = new IntRange(0, 64);
colorFilter.Green = new IntRange(0, 64);
colorFilter.Blue = new IntRange(0, 64);
colorFilter.FillOutsideRange = false;
//colorFilter.ApplyInPlace(bitmapData);
BlobCounter blobCounter = new BlobCounter();
blobCounter.FilterBlobs = true;
blobCounter.MinHeight = 5;
blobCounter.MinWidth = 5;
blobCounter.ProcessImage(bitmapData);
Blob[] blobs = blobCounter.GetObjectsInformation();
bitmap.UnlockBits(bitmapData);
// locate objects using blob counter
// create Graphics object to draw on the image and a pen
Graphics g = Graphics.FromImage(bitmap);
Pen redPen = new Pen(Color.Red, 2);
SimpleShapeChecker shapeChecker = new SimpleShapeChecker();
// check each object and draw circle around objects, which
// are recognized as circles
for (int i = 0, n = blobs.Length; i < n; i++)
{
List
DoublePoint center;
double radius;
if (shapeChecker.IsCircle(edgePoints, out center, out radius))
{
g.DrawEllipse(redPen,
(int)(center.X - radius),
(int)(center.Y - radius),
(int)(radius * 2),
(int)(radius * 2));
}
}
redPen.Dispose();
g.Dispose();
pictureBox2.Image = bitmap;
}