|
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- using CvEnum = Emgu.CV.CvEnum;
- using Emgu.CV.Structure;
- using Emgu.CV;
- using Emgu.CV.UI;
- using Emgu.CV.VideoSurveillance;
- namespace testEmg
- {
- public partial class Form1 : Form
- {
- public Image<Bgr, Byte> mImage1;
- public Capture mCapture;
- private int count;
- private BlobTrackerAuto mbta;
- public Form1()
- {
- InitializeComponent();
- }
- private void button3_Click(object sender, EventArgs e)
- {
- OpenFileDialog dlg = new OpenFileDialog();
- string filter = "avi file(*.avi)|*.avi|wmv file(*.wmv)|*.wmv";
- dlg.Filter = filter;
- //
- if (DialogResult.OK != dlg.ShowDialog())
- {
- return;
- }
- //
- mCapture = new Capture(dlg.FileName);
- //
- ForgroundDetector fgd = new ForgroundDetector(Emgu.CV.CvEnum.FORGROUND_DETECTOR_TYPE.FGD);
- BlobDetector bd = new BlobDetector(Emgu.CV.CvEnum.BLOB_DETECTOR_TYPE.CC);
- BlobTracker bt = new BlobTracker(Emgu.CV.CvEnum.BLOBTRACKER_TYPE.CC);
- BlobTrackerAutoParam btap = new BlobTrackerAutoParam();
- btap.ForgroundDetector = fgd;
- btap.BlobDetector = bd;
- btap.BlobTracker = bt;
- btap.FGTrainFrames = 5;
- btap.BTPP = null;
- btap.UsePPData = 0;
- mbta = new BlobTrackerAuto(btap);
- //
- Application.Idle+=delegate(Object o,EventArgs w)
- {
- mImage1 = mCapture.QueryFrame();
- if (mImage1 == null)
- {
- return;
- }
- mbta.Process(mImage1); // geterror here
- Console.WriteLine("blob Count:{0}", mbta.Count);
- imageBox1.Image = mImage1;
- };
-
- }
- }
- }
复制代码 |
|