Ejemplo n.º 1
0
        public VideoInterpreter(string pathToVideoSource, string pathToXmlFile, Dispatcher dispatcher)
        {
            //sets variables that are not passed
            this.showWindow = false;
            numCarsInLot    = 0;
            steady          = 0;
            oldNumCarsInLot = 0;
            fps             = 60;
            frameWidth      = 1920;
            frameHeight     = 1080;
            didStart        = false;
            didStop         = false;
            didEnter        = false;
            frCt            = 0;

            CarDidEnter = null;
            CarDidLeave = null;

            this.pathToVideoSource = pathToVideoSource;
            this.dispatcher        = dispatcher;

            //sets up video stream pull
            vCapture = new Emgu.CV.VideoCapture(pathToVideoSource);
            if (fps > 0)
            {
                vCapture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.Fps, fps);
            }
            vCapture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameWidth, frameWidth);
            vCapture.SetCaptureProperty(Emgu.CV.CvEnum.CapProp.FrameHeight, frameHeight);
            casc = new Emgu.CV.CascadeClassifier(pathToXmlFile);
        }
Ejemplo n.º 2
0
 public void EmguCvCaptureVideoStream(string url, Action <Emgu.CV.Mat> action)
 {
     using Emgu.CV.VideoCapture capture = new Emgu.CV.VideoCapture(url, Emgu.CV.VideoCapture.API.Any);
     if (capture.IsOpened == false)
     {
         return;
     }
     using Emgu.CV.Mat frame = capture.QueryFrame();
     while (_stopPlay == false)
     {
         if (capture.Read(frame)) //capture.Retrieve(frame)// 无法继续读取
         {
             if (!frame.IsEmpty)
             {
                 action?.Invoke(frame);
             }
         }
     }
     frame.Dispose();
     capture.Dispose();
 }