Ejemplo n.º 1
0
        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();
            }
        }
Ejemplo n.º 2
0
        protected override void OnPaint(System.Windows.Forms.PaintEventArgs e)
        {
            if ((needSizeUpdate) || (firstFrame))
            {
                needSizeUpdate = false;
            }
            Monitor.Enter(this);

            Graphics  ge = e.Graphics;
            Rectangle rc = this.ClientRectangle;
            Pen       p  = new Pen(Color.Black, 1);

            ge.DrawRectangle(p, rc.X, rc.Y, rc.Width - 1, rc.Height - 1);
            count++;
            //   lbl.Text = count.ToString();

            Label lbl = new Label();

            if (camera != null)
            {
                try
                {
                    camera.Lock();

                    if ((camera.SonFrame != null) && (camera.SonFrameHata == null))
                    {
                        ge.DrawImage(camera.SonFrame, rc.X + 1, rc.Y + 1, rc.Width - 2, rc.Height - 2);
                    }

                    else
                    {
                        Font       dr     = new Font("Arial", 12);
                        SolidBrush drbush = new SolidBrush(Color.White);
                        ge.DrawString((camera.SonFrameHata == null) ? "Baðlantý Saðlanýyor" : camera.SonFrameHata, dr, drbush, new Point(5, 5));

                        dr.Dispose();
                        drbush.Dispose();
                    }
                }
                //catch (Exception)
                //{

                //}
                catch (ThreadAbortException) { Thread.ResetAbort(); }
                finally
                {
                    camera.UnLock();
                }
            }


            p.Dispose();
            Monitor.Exit(this);
            base.OnPaint(e);
        }