Beispiel #1
0
        private void tmMonitorTick_Tick(object sender, EventArgs e)
        {
            prevCapture.Dispose();
            prevCapture    = currentCapture;
            currentCapture = new SigmaDeltaStruct(captureRect.Width, captureRect.Height);

            using (Graphics g = Graphics.FromImage(currentCapture.BitmapData.Bitmap))
            {
                g.CopyFromScreen(captureRect.X, captureRect.Y,
                                 0, 0,
                                 currentCapture.BitmapData.Bitmap.Size,
                                 CopyPixelOperation.SourceCopy);
            }
            SigmaDeltaTick();

            pbRegionView.Image      = currentCapture.BitmapData.Bitmap;
            pbMotionDetection.Image = motionEstimator.Bitmap;

            lblCurrentLevel.Text = Math.Round(rmse * 100.0).ToString() + "%";

            if (rmse >= (tbAlarmThreshold.Value / 100.0))
            {
                if (!isAlarmActive)
                {
                    ToggleAlarm();
                }
            }
            else
            {
                if (isAlarmActive)
                {
                    ToggleAlarm();
                }
            }
        }
 public SigmaDeltaStruct(SigmaDeltaStruct sds)
 {
     BitmapData        = (DirectBitmap)sds.BitmapData.Clone();
     FirstBgEstimator  = new short[sds.BitmapData.Width * sds.BitmapData.Height];
     SecondBgEstimator = new short[sds.BitmapData.Width * sds.BitmapData.Height];
     sds.FirstBgEstimator.CopyTo(FirstBgEstimator, 0);
     sds.SecondBgEstimator.CopyTo(SecondBgEstimator, 0);
     Disposed = false;
 }
Beispiel #3
0
        private void updateCaptureBitmaps()
        {
            if (prevCapture != null)
            {
                prevCapture.Dispose();
            }

            if (currentCapture != null)
            {
                currentCapture.Dispose();
            }

            if (motionEstimator != null)
            {
                motionEstimator.Dispose();
            }

            if (bgEstimator != null)
            {
                bgEstimator.Dispose();
            }

            prevCapture     = new SigmaDeltaStruct(captureRect.Width, captureRect.Height);
            currentCapture  = new SigmaDeltaStruct(captureRect.Width, captureRect.Height);
            motionEstimator = new DirectBitmap(captureRect.Width, captureRect.Height);
            bgEstimator     = new DirectBitmap(captureRect.Width, captureRect.Height);


            using (Graphics g = Graphics.FromImage(currentCapture.BitmapData.Bitmap))
            {
                g.CopyFromScreen(captureRect.X, captureRect.Y,
                                 0, 0,
                                 currentCapture.BitmapData.Bitmap.Size,
                                 CopyPixelOperation.SourceCopy);
            }

            using (Graphics g = Graphics.FromImage(prevCapture.BitmapData.Bitmap))
            {
                g.CopyFromScreen(captureRect.X, captureRect.Y,
                                 0, 0,
                                 prevCapture.BitmapData.Bitmap.Size,
                                 CopyPixelOperation.SourceCopy);
            }

            prevCapture.PopulateEstimators();
            currentCapture.PopulateEstimators();
            bgEstimator.SeedWith8bppGrayscale(currentCapture.FirstBgEstimator);
        }