public frmIntegrationDetection(IntegrationDetectionController integrationDetectionController, VideoController videoController, bool allowPixDetExport = false) { InitializeComponent(); m_IntegrationDetectionController = integrationDetectionController; m_VideoController = videoController; m_IntegrationDetectionController.OnPotentialIntegration += DisplayFoundIntegration; m_IntegrationDetectionController.OnFrameData += OnFrameData; m_IntegrationDetectionController.OnBeginProgress += m_IntegrationDetectionController_OnBeginProgress; m_IntegrationDetectionController.OnProgress += m_IntegrationDetectionController_OnProgress; m_AllowPixDetExport = allowPixDetExport; if (m_AllowPixDetExport) { m_IntegrationDetectionController.OnFramePixels += m_IntegrationDetectionController_OnFramePixels; } picFrameSpectrum.Image = new Bitmap(picFrameSpectrum.Width, picFrameSpectrum.Height); picSigmas.Image = new Bitmap(picSigmas.Width, picSigmas.Height); pnlResult.Visible = false; pnlResult.SendToBack(); btnCorrectInterlaced.Visible = videoController != null && videoController.FramePlayer.Video is ReInterlacingVideoStream; }
public void Dispose() { var disp = m_PixelImageProvider as IDisposable; if (disp != null) { disp.Dispose(); } if (m_Controller != null) { m_Controller.OnFramePixels -= m_Controller_OnFramePixels; m_Controller.OnPotentialIntegration -= OnPotentialIntegration; m_Controller.Dispose(); m_Controller = null; } }
private void btnDetectIntegration_Click(object sender, EventArgs e) { var intDetController = new IntegrationDetectionController(m_VideoController, m_VideoController.CurrentFrameIndex); using (var frm = new frmIntegrationDetection(intDetController, m_VideoController)) { frm.StartPosition = FormStartPosition.CenterParent; DialogResult res = frm.ShowDialog(this); if (res == DialogResult.OK) { if (frm.IntegratedFrames != null) { m_VideoAstrometry.MovingToFirstIntegratedFrame(); cbxInstDelayMode.SelectedIndex = 0; // Set delay type to automatic nudIntegratedFrames.SetNUDValue(frm.IntegratedFrames.Interval); m_VideoController.MoveToFrame(frm.IntegratedFrames.StartingAtFrame); SyncTimeStampControlWithExpectedFrameTime(); btnDetectIntegration.Enabled = false; } } else if (res == DialogResult.Cancel) { if ((MovementExpectation)cbxExpectedMotion.SelectedIndex != MovementExpectation.Slow) { MessageBox.Show( this, "When measuring fast moving objects it is absolutely essential to move the video to the first frame of an integration interval " + "before starting the measurements. Press 'Cancel' now and ensure that you have manually positioned to the first frame of the next " + "integration interval before you continue.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } }
private void btnIntegrationDetection_Click(object sender, EventArgs e) { nudNumFramesToBin.BackColor = SystemColors.Window; nudReferenceFrame.BackColor = SystemColors.Window; var provider = new LCFileImagePixelProvider(LCFile); var intDetController = new IntegrationDetectionController(provider, (int)LCFile.Header.MinFrame); using (var frm = new frmIntegrationDetection(intDetController, null)) { frm.StartPosition = FormStartPosition.CenterParent; if (frm.ShowDialog(this) == DialogResult.OK && frm.IntegratedFrames != null) { nudNumFramesToBin.Value = frm.IntegratedFrames.Interval; nudReferenceFrame.Value = frm.IntegratedFrames.StartingAtFrame; nudNumFramesToBin.BackColor = Color.Honeydew; nudReferenceFrame.BackColor = Color.Honeydew; } } }
private void btnDetectIntegrationRate_Click(object sender, EventArgs e) { var intDetController = new IntegrationDetectionController(m_VideoController, (int)nudFirstFrame.Value); using (var frm = new frmIntegrationDetection(intDetController, m_VideoController)) { frm.StartPosition = FormStartPosition.CenterParent; DialogResult res = frm.ShowDialog(this); if (res == DialogResult.OK) { if (frm.IntegratedFrames != null) { nudIntegratedFrames.SetNUDValue(frm.IntegratedFrames.Interval); nudStartingAtFrame.SetNUDValue(frm.IntegratedFrames.StartingAtFrame); m_State = AavConfigState.ReadyToConvert; var reinterlacedStream = m_VideoController.FramePlayer.Video as ReInterlacingVideoStream; if (reinterlacedStream != null && (reinterlacedStream.Mode == ReInterlaceMode.ShiftOneField || reinterlacedStream.Mode == ReInterlaceMode.SwapFields)) { rbFirstFieldBottom.Checked = true; } UpdateControlState(); return; } } } if (m_VideoController.ShowMessageBox( "This must be an integrated video with consistent and known integration rate in order to convert it to AAV.\r\n\r\nTo enter manually the 'Starting At' frame and the 'Integration' rate press OK.\r\n\r\nPlease note that Tangra will not try to validate the values you entered.", "Tangra", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2) == DialogResult.OK) { m_ManualIntegrationConfig = true; m_State = AavConfigState.ManualIntegrationRateEntry; UpdateControlState(); } }
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(); }