示例#1
0
        /// <summary>
        ///
        /// </summary>
        public override void Dispose()
        {
            base.Dispose();

            ForeBrush?.Dispose();
            BackgroundBrush?.Dispose();
        }
示例#2
0
 private void description_ForeColorChanged(object sender, EventArgs e)
 {
     if (ForeBrush != null)
     {
         ForeBrush.Dispose();
     }
     ForeBrush = CreateBrush(Description.ForeColor);
 }
示例#3
0
        public override void Dispose()
        {
            base.Dispose();

            if (ForeBrush != null)
            {
                ForeBrush.Dispose();
            }
        }
示例#4
0
        public override void Dispose()
        {
            base.Dispose();

            if (ForeBrush != null)
            {
                ForeBrush.Dispose();
            }
            if (BackgroundBrush != null)
            {
                BackgroundBrush.Dispose();
            }
        }
示例#5
0
        public void Dispose()
        {
            if (_disposing)
            {
                return;
            }


            _disposing = true;
            lock (_sync)
            {
                ClearMotionZones();
                ForeBrush.Dispose();
                BackBrush.Dispose();
                DrawFont.Dispose();
                if (_framerates != null)
                {
                    _framerates.Clear();
                }

                if (Mask != null)
                {
                    Mask.Dispose();
                    Mask = null;
                }
                Alarm           = null;
                NewFrame        = null;
                PlayingFinished = null;
                Plugin          = null;

                VideoSource = null;

                if (MotionDetector != null)
                {
                    try
                    {
                        MotionDetector.Reset();
                    }
                    catch (Exception ex)
                    {
                        if (ErrorHandler != null)
                        {
                            ErrorHandler(ex.Message);
                        }
                    }
                    MotionDetector = null;
                }
            }
        }
示例#6
0
        protected virtual void Dispose(bool disposing)
        {
            if (_disposed)
            {
                return;
            }



            ClearMotionZones();
            Detect          = null;
            NewFrame        = null;
            PlayingFinished = null;
            Plugin          = null;

            ForeBrush?.Dispose();
            BackBrush?.Dispose();
            DrawFont?.Dispose();
            _framerates?.Clear();

            Mask?.Dispose();
            Mask = null;

            VideoSource?.Dispose();
            VideoSource = null;


            try
            {
                MotionDetector?.Reset();
            }
            catch (Exception ex)
            {
                ErrorHandler?.Invoke(ex.Message);
            }
            MotionDetector = null;

            _disposed = true;
        }
示例#7
0
文件: Camera.cs 项目: zmaples/iSpy
        private void VideoNewFrame(object sender, NewFrameEventArgs e)
        {
            var nf = NewFrame;
            var f  = e.Frame;

            if (_requestedToStop || nf == null || f == null)
            {
                return;
            }


            if (_lastframeEvent > DateTime.MinValue)
            {
                if ((Helper.Now < _nextFrameTarget))
                {
                    return;
                }
                CalculateFramerates();
            }

            _lastframeEvent = Helper.Now;

            if (_updateResources)
            {
                _updateResources = false;
                DrawFont.Dispose();
                DrawFont = null;
                ForeBrush.Dispose();
                ForeBrush = null;
                BackBrush.Dispose();
                BackBrush = null;
                SetMaskImage();
                RotateFlipType rft;
                if (Enum.TryParse(CW.Camobject.rotateMode, out rft))
                {
                    RotateFlipType = rft;
                }
                else
                {
                    RotateFlipType = RotateFlipType.RotateNoneFlipNone;
                }
            }


            Bitmap bmOrig  = null;
            bool   bMotion = false;

            lock (_sync)
            {
                try
                {
                    bmOrig = ResizeBmOrig(f);

                    if (RotateFlipType != RotateFlipType.RotateNoneFlipNone)
                    {
                        bmOrig.RotateFlip(RotateFlipType);
                    }

                    _width  = bmOrig.Width;
                    _height = bmOrig.Height;

                    if (ZPoint == Point.Empty)
                    {
                        ZPoint = new Point(bmOrig.Width / 2, bmOrig.Height / 2);
                    }

                    if (CW.NeedMotionZones)
                    {
                        CW.NeedMotionZones = !SetMotionZones(CW.Camobject.detector.motionzones);
                    }

                    if (Mask != null)
                    {
                        ApplyMask(bmOrig);
                    }

                    if (CW.Camobject.alerts.active && Plugin != null && Alarm != null)
                    {
                        bmOrig = RunPlugin(bmOrig);
                    }

                    var bmd = bmOrig.LockBits(new Rectangle(0, 0, bmOrig.Width, bmOrig.Height), ImageLockMode.ReadWrite, bmOrig.PixelFormat);

                    //this converts the image into a windows displayable image so do it regardless
                    using (var lfu = new UnmanagedImage(bmd))
                    {
                        if (_motionDetector != null)
                        {
                            bMotion = ApplyMotionDetector(lfu);
                        }
                        else
                        {
                            MotionDetected = false;
                        }

                        if (CW.Camobject.settings.FishEyeCorrect)
                        {
                            _feCorrect.Correct(lfu, CW.Camobject.settings.FishEyeFocalLengthPX,
                                               CW.Camobject.settings.FishEyeLimit, CW.Camobject.settings.FishEyeScale, ZPoint.X,
                                               ZPoint.Y);
                        }

                        if (ZFactor > 1)
                        {
                            var f1 = new ResizeNearestNeighbor(lfu.Width, lfu.Height);
                            var f2 = new Crop(ViewRectangle);
                            try
                            {
                                using (var imgTemp = f2.Apply(lfu))
                                {
                                    f1.Apply(imgTemp, lfu);
                                }
                            }
                            catch (Exception ex)
                            {
                                ErrorHandler?.Invoke(ex.Message);
                            }
                        }
                    }
                    bmOrig.UnlockBits(bmd);
                    PiP(bmOrig);
                    AddTimestamp(bmOrig);
                }
                catch (UnsupportedImageFormatException ex)
                {
                    CW.VideoSourceErrorState   = true;
                    CW.VideoSourceErrorMessage = ex.Message;

                    bmOrig?.Dispose();

                    return;
                }
                catch (Exception ex)
                {
                    bmOrig?.Dispose();

                    ErrorHandler?.Invoke(ex.Message);

                    return;
                }


                if (MotionDetector != null && !CW.Calibrating && MotionDetector.MotionProcessingAlgorithm is BlobCountingObjectsProcessing && !CW.PTZNavigate && CW.Camobject.settings.ptzautotrack)
                {
                    try
                    {
                        ProcessAutoTracking();
                    }
                    catch (Exception ex)
                    {
                        ErrorHandler?.Invoke(ex.Message);
                    }
                }
            }

            if (!_requestedToStop)
            {
                nf.Invoke(this, new NewFrameEventArgs(bmOrig));
            }
            if (bMotion)
            {
                TriggerDetect(this);
            }
        }