private void DetectorSec(int deger) { Kamera camera = kameraKutusu1.Camera; if (camera != null) { camera.Lock(); switch (deger) { case 0: md = null; camera.MDetector = md; break; case 1: //md = new TwoFramesDifferenceMotionDetector(true); TwoFramesDifferenceMotionDetector TwoFrameTH = new TwoFramesDifferenceMotionDetector(true, noise); TwoFrameTH.DifferenceThreshold = trackBar1.Value; //label4.Text = TwoFrameTH.MotionLevel.ToString(); camera.MDetector = TwoFrameTH; break; case 2: //md = new BackgroundModelingHighPrecisionMotionDetector(true); BackgroundModelingHighPrecisionMotionDetector BgHighTH = new BackgroundModelingHighPrecisionMotionDetector(true, noise); BgHighTH.DifferenceThreshold = trackBar1.Value; //label4.Text = BgHighTH.MotionLevel.ToString(); camera.MDetector = BgHighTH; break; case 3: //md = new BackgroundModelingLowPrecisionMotionDetector(true); BackgroundModelingLowPrecisionMotionDetector BgLowTH = new BackgroundModelingLowPrecisionMotionDetector(true); BgLowTH.DifferenceThreshold = trackBar1.Value; //label4.Text = BgLowTH.MotionLevel.ToString(); camera.MDetector = BgLowTH; break; case 4: //md = new CountingMotionDetector(true); CountingMotionDetector CountTH = new CountingMotionDetector(true); CountTH.DifferenceThreshold = trackBar1.Value; //CountTH.FramesPerBackgroundUpdate = 50; camera.MDetector = CountTH; //camera.IsRunning break; } //camera.MDetector = md; camera.UnLock(); } }
private void OpenVideo(IVideoSource iv) { // this.Cursor = Cursors.WaitCursor; try { CloseVideo(); Kamera camera = new Kamera(iv, md); Kamera camera2 = new Kamera(iv, mdetector); camera.YeniFrame += new EventHandler(Kamera_YeniFrame); camera.Start(); kameraKutusu1.Camera = camera; ivideo = iv; } catch { } }
private void CloseVideo() { try { Kamera camera = kameraKutusu1.Camera; if (camera != null) { kameraKutusu1.Camera = null; Application.DoEvents(); camera.Stop(); camera = null; if (mdetector != null) { mdetector.Reset(); } ivideo = null; } } catch { } }