private void InitProcessor()
        {
            tbxFile.Text = openFileDialog1.FileName;
            Processor = new VideoProcessor(tbxFile.Text);
            btnStart.Enabled = true;
            btnSetParameters.Enabled = true;
            frmProcessedImg = new ImageForm();
            frmProcessedImg.Text = @"Processed Image";
            frmProcessedImg.Owner = this;
            frmOpticalFlowImg = new ImageForm();
            frmOpticalFlowImg.Text = @"Optical Flow Vectors";
            frmOpticalFlowImg.Owner = this;

            Processor.ImageProcessed = image =>
            {
                if (!frmProcessedImg.IsDisposed)
                {
                    frmProcessedImg.Invoke(new MethodInvoker(() =>
                      {
                          frmProcessedImg.imageBox1.Image = image;
                          frmProcessedImg.Size = new Size(image.Size.Width + 50, image.Size.Height + 50);
                      }));
                }
            };

            Processor.OpticalFlowVectorsProcessed = image =>
            {
                if (cbxComputeFlowImage.Checked && !frmOpticalFlowImg.IsDisposed)
                {
                    frmOpticalFlowImg.Invoke(new MethodInvoker(() =>
                    {
                        frmOpticalFlowImg.imageBox1.Image = image;
                        frmOpticalFlowImg.Size = new Size(image.Size.Width + 50, image.Size.Height + 50);
                    }));
                }
            };
        }
 private void btnStop_Click(object sender, EventArgs e)
 {
     btnStop.Enabled = false;
     btnSetParameters.Enabled = false;
     btnPauseCont.Enabled = false;
     Processor.StopCapture();
     btnStart.Enabled = true;
     Processor.Dispose();
     Processor = null;
 }