Hi everyone I'm done with tracking multiple objects based on color
but I want to fill the distance between its previous x,y and its current position but i don't know to do it
****I'm a beginner and learning so don't make fun of my code
What I have tried:
public void findObject(Bitmap image)
{
blobCounter.MinWidth = blobCounter.MinHeight = 10;
blobCounter.MaxWidth = blobCounter.MaxHeight = 40;
blobCounter.FilterBlobs = true;
blobCounter.ObjectsOrder = ObjectsOrder.XY;
objectsData = image.LockBits(new Rectangle(0, 0, image.Width, image.Height), ImageLockMode.ReadWrite, image.PixelFormat);
grayScaleFilter = new Grayscale(0.2125, 0.7154, 0.0721);
UnmanagedImage grayImage = grayScaleFilter.Apply(new UnmanagedImage(objectsData));
image.UnlockBits(objectsData);
blobCounter.ProcessImage(image);
rects = blobCounter.GetObjectsRectangles();
Blob[] blobs = blobCounter.GetObjectsInformation();
pictureBox2.Image = image;
PointF inp = new PointF(ix, iy);
for (int i = 0; i < rects.Length; i++)
{
Rectangle objectRectangle = rects[i];
objCount = i;
Graphics g = pictureBox1.CreateGraphics();
Graphics f = pictureBox1.CreateGraphics();
Graphics s = pictureBox1.CreateGraphics();
int objectX = objectRectangle.X;
int objectY = objectRectangle.Y;
ix = objectX;
iy = objectY;
objectsXY[i, 0] = objectX;
objectsXY[i, 1] = objectY;
Pen penx = new Pen(Color.Red);
System.Drawing.Point[] points =
{
new System.Drawing.Point(objectX,objectY),
new System.Drawing.Point(objectsXY[i,0],objectsXY[i, 1]),
};
using (Pen pen = new Pen(Color.FromArgb(2, 227, 252), 2))
{
g.DrawRectangle(pen, objectRectangle);
g.DrawString((i + 1).ToString(), new Font("Arial", 15), Brushes.Yellow, objectRectangle);
f.FillEllipse(Brushes.Black, objectRectangle.X, objectRectangle.Y, 5, 5);
}
}