Click here to Skip to main content
15,881,455 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
object tracking in a video by using C# programming

What I have tried:

//// Background Subtraction
            using (CvCapture capture = CvCapture.FromFile("C:\\opencv\\Movie\\2nd view 6th senario uncompressed.avi"))
            //using (CvCapture sourceSrc = CvCapture.FromFile("C:\\opencv\\Movie\\2nd view 6th senario uncompressed.avi"))

            using (IplImage img = capture.QueryFrame())
            using (BackgroundSubtractorMOG mog = new BackgroundSubtractorMOG())
          //  using (BackgroundSubtractorMOG2 mog2 = new BackgroundSubtractorMOG2())
            // using (BackgroundSubtractorGMG gmg = new BackgroundSubtractorGMG())


            using (CvWindow windowSrc = new CvWindow("src"))
            using (CvWindow windowDst = new CvWindow("dst"))
            {
                CvBlobs blobs = new CvBlobs();
                var frame2 = new Mat();


                IplImage imgFrame;
                IplImage imgIplFg;
                IplImage imgIplFgDst;

                CvRect[] square = new CvRect[2000];
                int j = 0;

foreach (var item in blobs)
                        {// new
                            Console.WriteLine("{0} | Centroid:{1} Area:{2}", item.Key, item.Value.Centroid, item.Value.Area);

                            imgFrame.DrawRect(item.Value.Rect, CvColor.Red);

                            square[j] = item.Value.Rect;
                            j++;
                            int count = 0;
                            //            // new code
                            //            // To show 2 point sequences
                            //            // using the array to put the images to the matrix 
                            CvPoint[] points = new CvPoint[50];
                            for (int i = 0; i < 50; i++)

 windowDst.Image = imgFg.ToIplImage();
                            windowDst.Image = imgIplFgDst;

                            Cv.WaitKey(50);

                        }
                    }

            }
            //// ******************

        }
    }
Posted
Updated 18-Dec-22 23:43pm
v3
Comments
OriginalGriff 13-Dec-22 1:59am    
Answer updated.

1 solution

While we are more than willing to help those that are stuck, that doesn't mean that we are here to do it all for you! We can't do all the work, you are either getting paid for this, or it's part of your grades and it wouldn't be at all fair for us to do it all for you.

So we need you to do the work, and we will help you when you get stuck. That doesn't mean we will give you a step by step solution you can hand in!
Start by explaining where you are at the moment, and what the next step in the process is. Then tell us what you have tried to get that next step working, and what happened when you did.

If you are having problems getting started at all, then this may help: How to Write Code to Solve a Problem, A Beginner's Guide[^]

[edit]
Your revised version with "code" does nothing - not even compile.
"=" is an assignment operator, not a comparison - that would be "==".
Even if you fix that and it compiles, it will still do nothing because a variable cannot be two different values at the same time.

Throwing rubbish together in the hope we will do all the "heavy lifting" of image tracking isn't going to get you anywhere - all it will do is annoy those you want help from.
[/edit]
 
Share this answer
 
v2

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