public void TestBlobTracking() { Capture capture = new Capture(); ImageViewer viewer = new ImageViewer(); BlobTrackerAutoParam<Gray> param = new BlobTrackerAutoParam<Gray>(); //param.BlobDetector = new BlobDetector(Emgu.CV.CvEnum.BLOB_DETECTOR_TYPE.CC); param.FGDetector = new FGDetector<Gray>(Emgu.CV.CvEnum.FORGROUND_DETECTOR_TYPE.FGD); //param.BlobTracker = new BlobTracker(Emgu.CV.CvEnum.BLOBTRACKER_TYPE.CCMSPF); param.FGTrainFrames = 10; BlobTrackerAuto<Gray> tracker = new BlobTrackerAuto<Gray>(param); MCvFont font = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_SIMPLEX, 1.0, 1.0); Application.Idle += new EventHandler(delegate(object sender, EventArgs e) { tracker.Process(capture.QuerySmallFrame().PyrUp().Convert<Gray, Byte>()); Image<Gray, Byte> img = tracker.ForgroundMask; //viewer.Image = tracker.GetForgroundMask(); foreach (MCvBlob blob in tracker) { img.Draw(Rectangle.Round(blob), new Gray(255.0), 2); img.Draw(blob.ID.ToString(), ref font, Point.Round(blob.Center), new Gray(255.0)); } viewer.Image = img; }); viewer.ShowDialog(); }