private void timer_Tick(object sender, EventArgs e) { timer.Enabled = false; m_IntegrationDetectionController.RunMeasurements(); }
public void Run() { if (!m_Arguments.TryGetValue("f", out m_VideoFileName)) { Console.Error.WriteLine("-f must be specified"); return; } if (!File.Exists(m_VideoFileName)) { Console.Error.WriteLine(string.Format("File '{0}' cannot be found.", m_VideoFileName)); return; } if (".pixdet".Equals(Path.GetExtension(m_VideoFileName), StringComparison.InvariantCultureIgnoreCase)) { var pixdet = new PixDetFile(m_VideoFileName, FileAccess.Read); m_ExpectedFit = pixdet.GetStoredIntegrationFit(); m_PixelImageProvider = pixdet; } else { m_ExpectedFit = null; var videoPlayer = new AutomationVideoPlayer(); if (!videoPlayer.OpenVideo(m_VideoFileName)) { Console.Error.WriteLine(string.Format("Cannot open file '{0}'.", m_VideoFileName)); return; } m_PixelImageProvider = videoPlayer; } string sfStr; m_StartFrameNo = 0; if (!m_Arguments.TryGetValue("sf", out sfStr) || !int.TryParse(sfStr, out m_StartFrameNo)) { m_StartFrameNo = m_PixelImageProvider.FirstFrame; } string pixFile; m_RecordPixelFile = false; if (m_Arguments.TryGetValue("pix", out pixFile)) { if (!Path.IsPathRooted(pixFile)) { pixFile = Path.GetFullPath(@".\" + pixFile); } var dirName = Path.GetDirectoryName(pixFile); if (!Directory.Exists(dirName)) { Console.Error.WriteLine(string.Format("Recording directory '{0}' does not exist", dirName)); return; } m_RecordFileName = pixFile; m_RecordPixelFile = true; m_PixDetFile = new PixDetFile(m_RecordFileName, FileAccess.Write); m_PixDetFile.WriteHeader(m_VideoFileName, m_StartFrameNo); } m_Controller = new IntegrationDetectionController(m_PixelImageProvider, m_StartFrameNo); m_Controller.OnPotentialIntegration += OnPotentialIntegration; m_Controller.OnFramePixels += m_Controller_OnFramePixels; m_Controller.RunMeasurements(); m_RunFinished.WaitOne(); }