/// <summary> /// Opens a video file. /// </summary> /// <param name="path"></param> public void Open(string path) { CVCapture newCapture = new CVCapture(path); if (Opening != null) { OpeningEventArgs oea = new OpeningEventArgs(); oea.CurrentCapture = capture; oea.NewCapture = newCapture; oea.Cancel = false; Opening(this, oea); if (oea.Cancel) { newCapture.Dispose(); return; } } videoTimer.Enabled = false; capture = newCapture; videoTimer.Interval = 1000 / capture.FramesPerSecond; }
private void videoPlayer_Opening(VideoPlayer sender, OpeningEventArgs args) { if (bgFrame != null) bgFrame.Dispose(); // create accumulator image when a new video is opened. bgAccum = new double[args.NewCapture.Height, args.NewCapture.Width]; for (int row = 0; row < args.NewCapture.Height; ++row) for (int col = 0; col < args.NewCapture.Width; ++col) bgAccum[row, col] = -1.0; bgFrame = args.NewCapture.CreateCompatibleImage(); }