AForge.NET

  :: AForge.NET Framework :: Articles :: Forums ::

multiple color tracking

The forum is to discuss topics related to different areas of image processing and computer vision.

multiple color tracking

Postby parsa.engz » Fri Oct 28, 2016 3:04 pm

Hello,
using Aforge I filtered out two colors and was tracking them in real time. Sometimes with different lighting conditions the software shows several rectangles.
How I can choose the largest one?
here is the part of the code

BlobCounter blobCounter = new BlobCounter();
blobCounter.FilterBlobs = true;
blobCounter.MinWidth = 10;
blobCounter.MinHeight = 10;
blobCounter.ProcessImage(grayscaledBitmap);
blobCounter.FilterBlobs = true; //I have added
blobCounter.ObjectsOrder = ObjectsOrder.Size; //I have added

Rectangle[] rects = blobCounter.GetObjectsRectangles();

for (int i = 0; rects.Length > i; i++)
{
//if (i < 2)
//{
Rectangle objectRect = rects[i];
Graphics g = Graphics.FromImage(resultImage);
using (System.Drawing.Pen pen = new System.Drawing.Pen(Color.FromArgb(252, 3, 26), 2))
{
g.DrawRectangle(pen, objectRect);

}

int objectX = objectRect.X + (objectRect.Width / 2);
int objectY = objectRect.Y + (objectRect.Height / 2);

obj_position = objectX + "," + objectY;


Console.WriteLine(i + " " + obj_position);


g.Dispose();
//}

}

Thanks
Attachments
colorTracking.JPG
colorTracking.JPG (30.72 KiB) Viewed 9031 times
parsa.engz
 
Posts: 7
Joined: Fri Sep 30, 2016 1:36 pm

Re: multiple color tracking

Postby andrew.kirillov » Sun Oct 30, 2016 10:19 am

Hello,

Blob counter provides filtering and sorting by size. Should help.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK

Re: multiple color tracking

Postby parsa.engz » Tue Feb 07, 2017 1:53 pm

Thanks for your reply.

I have detected 2 colored objects and tracked them in real time. My question is how can I retrieve the RGB values of the detected object in the "rect" in order to label the objects. I would like to label for example the blue object as BLUE and the red object as RED. How can I do that?

thank you.
Parsa
parsa.engz
 
Posts: 7
Joined: Fri Sep 30, 2016 1:36 pm

Re: multiple color tracking

Postby andrew.kirillov » Tue Feb 07, 2017 3:59 pm

Blob.ColorMean may help.
With best regards,
Andrew


Interested in supporting AForge.NET Framework?
User avatar
andrew.kirillov
Site Admin, AForge.NET Developer
 
Posts: 3453
Joined: Fri Jan 23, 2009 9:12 am
Location: UK




Return to Image Processing and Computer Vision