ZForge.Motion.Controls.Camera.video_NewFrame C# (CSharp) Метод

video_NewFrame() приватный Метод

private video_NewFrame ( object sender, NewFrameEventArgs e ) : void
sender object
e AForge.Video.NewFrameEventArgs
Результат void
        private void video_NewFrame(object sender, NewFrameEventArgs e)
        {
            try
            {
                bool motion = false;
                lock (this)
                {
                    // dispose old frame
                    if (mLastFrame != null)
                    {
                        mLastFrame.Dispose();
                    }
                    mLastFrame = new Bitmap(e.Frame);
                    if (this.Mirror)
                    {
                        mLastFrame.RotateFlip(RotateFlipType.RotateNoneFlipX);
                    }
                    if (this.Flip)
                    {
                        mLastFrame.RotateFlip(RotateFlipType.RotateNoneFlipY);
                    }

                    // apply motion detector
                    if (mMotionDetecotor != null)
                    {
                        mMotionDetecotor.ProcessFrame(mLastFrame);
                        if (mMotionDetecotor is ICountingMotionDetector)
                        {
                            ICountingMotionDetector m = mMotionDetecotor as ICountingMotionDetector;
                            motion = (m.ObjectsCount > 0);
                        }
                        else
                        {
                            motion = (mMotionDetecotor.MotionLevel > 0.005);
                        }
                    }

                    // image dimension
                    mImageWidth = mLastFrame.Width;
                    mImageHeight = mLastFrame.Height;
                }

                if (this.Alarm != null)
                {
                    if ((motion && this.DetectMode == DETECTMODE.MOTION) || (motion == false && this.DetectMode == DETECTMODE.STILLNESS))
                    {
                        Alarm(this, new EventArgs());
                    }
                }
            }
            catch (Exception)
            {
            }
            // notify client
            if (NewFrame != null)
                NewFrame(this, new NewFrameEventArgs(null));
        }