// Close current file public void closeInputSource() { if (cameraWindow != null && cameraWindow.camera != null) { pause(); cameraWindow.camera = null; _inputType = TInputType.NONE; } }
private void menuFileOpenFile_Click(object sender, EventArgs e) { openFileDialog.FileName = ""; openFileDialog.Filter = "Picture Files (*.bmp,*.gif,*.jpeg,*.jp?,*.png,*.emf,*.exif,*.ico,*.tiff,*.wmf)|*.bmp;*.gif;*.jpeg;*.jp?;*.png;*.emf;*.exif;*.ico;*.tiff;*.wmf"; openFileDialog.Filter += "|Video Files (*.avi)|*.avi"; DialogResult result = openFileDialog.ShowDialog(); if (result == DialogResult.Cancel) { return; } try { TInputType type = TInputType.UNKNOWN; reset(); if (openFileDialog.FilterIndex == 1) { type = TInputType.IMAGE; statusInputType.Text = "Image"; buttonPlay.Enabled = false; buttonPause.Enabled = false; buttonStop.Enabled = false; buttonGoToFirst.Enabled = false; buttonBackward.Enabled = false; buttonForward.Enabled = false; buttonGoToLast.Enabled = false; } else if (openFileDialog.FilterIndex == 2) { type = TInputType.VIDEO; statusInputType.Text = "Video"; buttonPlay_Click(null, null); buttonGoToFirst.Enabled = true; buttonBackward.Enabled = true; buttonForward.Enabled = true; buttonGoToLast.Enabled = true; } _asmEngine.resetModel(); _inputSource.openInputSource(openFileDialog.FileName, type, true); _inputSource.setFps(_isLimit, _fpsLimit); videoProgress.Minimum = 0; videoProgress.Maximum = _inputSource.length; videoProgress.Value = 0; }catch (Exception exc) { MessageBox.Show(exc.Message); statusInputType.Text = "NONE"; } }
// Open video source public bool openInputSource(string identifier, TInputType type, bool isAutoPlay) { IVideoSource source; switch (type) { case TInputType.IMAGE: source = new ImageSource(); break; case TInputType.VIDEO: source = new VideoFileSource(); break; case TInputType.DEVICE: source = new CaptureDevice(); break; default: return(false); } source.VideoSource = identifier; // close previous file closeInputSource(); // create camera CCamera camera = new CCamera(source); // attach camera to camera window _cameraWindow.postRenderingEvent = postRenderingEvent; _cameraWindow.camera = camera; _cameraWindow.camera.preRenderingEvent = preRenderingEvent; _inputType = type; if (isAutoPlay) { play(); } else { //getFirstFrame(); } // reset statistics _statIndex = _statReady = 0; return(true); }