private void timer1_Tick(object sender, EventArgs e) { vidFrame++; if (vidFrame >= video.GetCaptureProperty(CapProp.FrameCount)) { timer1.Enabled = false; } else { var frame = video.QueryFrame(); Image <Bgr, byte> image = frame.ToImage <Bgr, byte>(); if (typs == 0) { imageBox1.Image = image; } else if (background != null && typs == 1) { imageBox1.Image = logic.diffusal(image, background); } else if (typs == 2) { var foregroundMask = image.Convert <Gray, byte>().CopyBlank(); backgrSubstr.Apply(image.Convert <Gray, byte>(), foregroundMask); var filtrMask = logic.FilterMask(foregroundMask, image); imageBox1.Image = filtrMask; } } }