private void CloseVideoSource()
        {
            this.Cursor = Cursors.WaitCursor;

            videoSourcePlayer.SignalToStop();

            for (int i = 0; (i < 50) && (videoSourcePlayer.IsRunning); i++)
            {
                Thread.Sleep(100);
            }
            if (videoSourcePlayer.IsRunning)
            {
                videoSourcePlayer.Stop();
            }

            timer.Stop();
            alarmTimer.Stop();

            _motionHistory.Clear();

            if (_detector != null)
            {
                _detector.Reset();
            }

            videoSourcePlayer.BorderColor = Color.Black;
            this.Cursor = Cursors.Default;
        }
예제 #2
0
        // Close current video source
        private void CloseVideoSource( )
        {
            // set busy cursor
            this.Cursor = Cursors.WaitCursor;

            // stop current video source
            videoSourcePlayer.SignalToStop( );

            // wait 2 seconds until camera stops
            for (int i = 0; (i < 50) && (videoSourcePlayer.IsRunning); i++)
            {
                Thread.Sleep(100);
            }
            if (videoSourcePlayer.IsRunning)
            {
                videoSourcePlayer.Stop( );
            }

            // stop timers
            timer.Stop( );
            alarmTimer.Stop( );

            motionHistory.Clear( );

            // reset motion detector
            if (detector != null)
            {
                detector.Reset( );
            }

            videoSourcePlayer.BorderColor = Color.Black;
            this.Cursor = Cursors.Default;
        }
예제 #3
0
        // Close current video source
        private void CloseVideoSource()
        {
            foreach (KeyValuePair <VideoSourcePlayer, string> vp in players)
            {
                // set busy cursor
                this.Cursor = Cursors.WaitCursor;

                // stop current video source
                vp.Key.SignalToStop();

                // wait 2 seconds until camera stops
                for (int i = 0; (i < 50) && (vp.Key.IsRunning); i++)
                {
                    Thread.Sleep(100);
                }
                if (vp.Key.IsRunning)
                {
                    vp.Key.Stop();
                }

                // reset motion detector
                if (detector != null)
                {
                    detector.Reset();
                }

                vp.Key.BorderColor = Color.Black;
                this.Cursor        = Cursors.Default;
            }
        }
예제 #4
0
        private void CloseVideoSource()
        {
            if (!bOpsStopped)
            {
                videoPlayer.SignalToStop();

                if (videoPlayer.IsRunning)
                {
                    videoPlayer.WaitForStop();
                    Thread.Sleep(150);
                    videoPlayer.Stop();
                }

                if (motionDetector != null)
                {
                    motionDetector.Reset();
                }

                bOpsStopped = true;

                this.lblInfotext.Text.ToUpper();
                this.lblInfotext.Text = "You can safely exit the App now.";
                this.lblInfotext.Text.ToLower();
            }
        }
예제 #5
0
 public void Reset()
 {
     motionDetector.Reset();
     while (motionLevels.Count > 0)
     {
         motionLevels.Take();
     }
 }
 protected override void PostServoSettle()
 {
     IsServoInMotion = true;
     _screen.WriteLine("Servo moved, waiting {0:F}ms for motion settle", _timerUntilMotionSettled.Interval);
     _motionDetector.Reset();
     _timeToZeroMotion = new Stopwatch();
     _timeToZeroMotion.Start();
     _timerUntilMotionSettled.Start();
 }
예제 #7
0
 public void ResetDetector()
 {
     detector.Reset();
     process.Reset();
     startProcess = false;
     count        = 0;
     LR           = 0;
     RL           = 0;
     startProcess = true;
 }
예제 #8
0
 private void selectedPortableDevice_CaptureCompleted(object sender, EventArgs e)
 {
     if (!IsVisible)
     {
         return;
     }
     _detector.Reset();
     _photoCapturedTime = DateTime.Now;
     IsBusy             = false;
     _timer.Start();
     StartLiveView();
 }
예제 #9
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;
                }
            }
        }
예제 #10
0
 //---按钮被单击事件
 private void startBtn_Click(object sender, EventArgs e)
 {
     try
     {
         if (startBtn.Text == "开始")
         {
             ///--
             startBtn.Text = "停止";
             if (rbH.Checked)
             {
                 cam.VideoResolution = cam.VideoCapabilities[0];
             }
             else if (rbM.Checked)
             {
                 cam.VideoResolution = cam.VideoCapabilities[1];
             }
             else
             {
                 cam.VideoResolution = cam.VideoCapabilities[2];
             }
             ///---启动摄像头
             cam.Start();
             timer1.Start();
             if (detector != null)
             {
                 detector.Reset();
             }
             detected          = false;
             detectedCount     = 0;
             btnRecord.Enabled = true;
         }
         else
         {
             ///--设置按钮提示字样
             startBtn.Text = "开始";
             ///--停止摄像头捕获图像
             cam.Stop();
             timer1.Stop();
             btnRecord.Enabled = false;
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
예제 #11
0
 private void CloseVideoSource()
 {
     if (_motionDetector != null)
     {
         _motionDetector.Reset();
     }
     if (_videoSource == null)
     {
         return;
     }
     if (!_videoSource.IsRunning)
     {
         return;
     }
     _videoSource.SignalToStop();
     _videoSource = null;
 }
예제 #12
0
        public void CloseVideoSource()
        {
            Variaveis.Principal().Cursor = System.Windows.Input.Cursors.Wait;
            if (asyncVideoSource != null)
            {
                //
                asyncVideoSource.NewFrame -= AsyncVideoSource_NewFrame;
                asyncVideoSource.SignalToStop();
                if (asyncVideoSource.IsRunning == true)
                {
                    var esperawindow = new Esperawindow();
                    esperawindow.Owner = Variaveis.Principal();
                    esperawindow.ShowDialog();
                }
                for (int i = 0; (i < 50) && (asyncVideoSource.IsRunning == true); i++)
                {
                    if (asyncVideoSource.IsRunning != true)
                    {
                        break;
                    }


                    if (asyncVideoSource.IsRunning == true)
                    {
                        MessageBox.Show("OK");
                    }
                }
                if (asyncVideoSource.IsRunning == true)
                {
                    asyncVideoSource.Stop();
                }

                if (detector != null)
                {
                    detector.Reset();
                }
            }

            Variaveis.Principal().Cursor = System.Windows.Input.Cursors.Arrow;
        }
예제 #13
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;
        }
        //void LPR_processingPlateFinished(object sender, SimpleLPR2.Candidate results)
        //{
        //    processNextFrame = false;
        //}

        public void resetMotionDetector()
        {
            motionDetector.Reset();
        }
예제 #15
0
        // On new frame
        private void video_NewFrame(object sender, NewFrameEventArgs e)
        {
            try
            {
                // lock
                Monitor.Enter(this);

                // dispose old frame
                if (pubFrame != null)
                {
                    pubFrame.Dispose();
                }


                //lastFrame = (Bitmap)e.Frame.Clone();
                pubFrame = (Bitmap)e.Frame.Clone();


                ////*************************************
                ////pre-process bitmap for area detection
                ////*************************************

                //Bitmap areaDetectionPreparedImage;

                //if (areaOffAtMotionTriggered && !areaOffAtMotionReset)
                //{
                //    motionDetecotor.Reset();
                //    areaOffAtMotionReset = true;
                //}

                //if (areaDetection && !areaOffAtMotionTriggered)
                //{
                //    areaDetectionPreparedImage = selectArea(pubFrame, AreaDetectionWithin, RectWidth, RectHeight, RectX, RectY);

                //    if (exposeArea)
                //    {
                //        pubFrame = areaDetectionPreparedImage;
                //    }
                //}
                //else
                //{
                //    areaDetectionPreparedImage = pubFrame;
                //}


                ////*************************************
                ////pre-process bitmap for area detection
                ////*************************************

                if (_detectionOn)
                {
                    if ((calibrating && cam == CameraRig.trainCam) || (alarmActive && alert))
                    {
                        // apply motion detector
                        if (motionDetector != null)
                        {
                            //*************************************
                            //pre-process bitmap for area detection
                            //*************************************

                            Bitmap areaDetectionPreparedImage;

                            if (areaOffAtMotionTriggered && !areaOffAtMotionReset)
                            {
                                motionDetector.Reset();
                                areaOffAtMotionReset = true;
                            }

                            if (areaDetection && !areaOffAtMotionTriggered)
                            {
                                areaDetectionPreparedImage = selectArea(pubFrame, AreaDetectionWithin, RectWidth, RectHeight, RectX, RectY);

                                if (exposeArea)
                                {
                                    pubFrame = areaDetectionPreparedImage;
                                }
                            }
                            else
                            {
                                areaDetectionPreparedImage = pubFrame;
                            }


                            //*************************************
                            //pre-process bitmap for area detection
                            //*************************************



                            motionDetector.ProcessFrame(areaDetectionPreparedImage);


                            MotionLevelArgs a = new MotionLevelArgs();
                            CamIdArgs       b = new CamIdArgs();
                            a.lvl      = motionDetector.MotionDetectionAlgorithm.MotionLevel;
                            a.alarmLvl = movementVal;
                            b.cam      = cam;
                            b.name     = name;
                            motionLevelEvent(null, a, b);

                            // check motion level
                            if (calibrating && cam == CameraRig.trainCam)
                            {
                                bubble.train(motionDetector.MotionDetectionAlgorithm.MotionLevel);
                            }
                            else
                            {
                                if (alarmActive &&
                                    alert &&
                                    motionDetector.MotionDetectionAlgorithm.MotionLevel >= movementVal &&
                                    motionAlarm != null)
                                {
                                    CamIdArgs c = new CamIdArgs();
                                    c.cam  = cam;
                                    c.name = name;
                                    LevelArgs l = new LevelArgs();
                                    l.lvl = Convert.ToInt32(100 * motionDetector.MotionDetectionAlgorithm.MotionLevel);

                                    motionAlarm(null, c, l);
                                }
                                else
                                {
                                    certifiedTriggeredByNonSpike = false;
                                    triggeredBySpike             = false;
                                }
                            }

                            //System.Diagnostics.Debug.Print(triggeredBySpike.ToString());
                        }
                    }
                }//if (_detectionOn)



                // image dimension
                width  = pubFrame.Width;
                height = pubFrame.Height;

                //#ref5617
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                // unlock
                Monitor.Exit(this);
            }

            // notify client
            if (NewFrame != null)
            {
                NewFrame(this, new EventArgs());
            }
        }
예제 #16
0
        // On new frame
        private void video_NewFrame(object sender, NewFrameEventArgs e)
        {
            try
            {
                // lock
                Monitor.Enter(this);

                // dispose old frame
                if (pubFrame != null)
                {
                    pubFrame.Dispose();
                }


                //lastFrame = (Bitmap)e.Frame.Clone();

                try
                {
                    pubFrame = (Bitmap)e.Frame.Clone();
                    //#ToDo
                    if (frameRateTrack)
                    {
                        frames.addFrame();
                    }
                    //purge outside of this on a semi-regular basis
                    //framesDtCount.purge(100);
                    //framesDt.Add(DateTime.Now);
                }
                catch (Exception)
                {
                    pubFrame = (Bitmap)Properties.Resources.imagenotavailable.Clone();
                }



                if (_detectionOn)
                {
                    if ((calibrating && camNo == CameraRig.TrainCam) || (alarmActive && alert))
                    {
                        // apply motion detector
                        if (motionDetector != null)
                        {
                            //*************************************
                            //pre-process bitmap for area detection
                            //*************************************

                            Bitmap areaDetectionPreparedImage;

                            if (areaOffAtMotionTriggered && !areaOffAtMotionReset)
                            {
                                motionDetector.Reset();
                                areaOffAtMotionReset = true;
                            }

                            if (areaDetection && !areaOffAtMotionTriggered)
                            {
                                areaDetectionPreparedImage = selectArea(pubFrame, AreaDetectionWithin, RectWidth, RectHeight, RectX, RectY);

                                if (exposeArea)
                                {
                                    pubFrame = areaDetectionPreparedImage;
                                }
                            }
                            else
                            {
                                areaDetectionPreparedImage = pubFrame;
                            }


                            //*************************************
                            //pre-process bitmap for area detection
                            //*************************************



                            motionDetector.ProcessFrame(areaDetectionPreparedImage);


                            MotionLevelArgs a = new MotionLevelArgs();
                            CamIdArgs       b = new CamIdArgs();
                            a.lvl      = motionDetector.MotionDetectionAlgorithm.MotionLevel;
                            a.alarmLvl = movementVal;
                            b.cam      = camNo;
                            b.name     = name;
                            motionLevelEvent(null, a, b);

                            // check motion level
                            if (calibrating && camNo == CameraRig.TrainCam)
                            {
                                bubble.train(motionDetector.MotionDetectionAlgorithm.MotionLevel);
                            }
                            else
                            {
                                if (alarmActive &&
                                    alert &&
                                    motionDetector.MotionDetectionAlgorithm.MotionLevel >= movementVal &&
                                    motionAlarm != null)
                                {
                                    CamIdArgs c = new CamIdArgs();
                                    c.cam  = camNo;
                                    c.name = name;
                                    LevelArgs l = new LevelArgs();
                                    l.lvl = Convert.ToInt32(100 * motionDetector.MotionDetectionAlgorithm.MotionLevel);

                                    motionAlarm(null, c, l);
                                }
                                else
                                {
                                    certifiedTriggeredByNonSpike = false;
                                    triggeredBySpike             = false;
                                }
                            }
                        }
                    }
                }//if (_detectionOn)



                // image dimension
                width  = pubFrame.Width;
                height = pubFrame.Height;

                //#ref5617
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
            }
            finally
            {
                // unlock
                Monitor.Exit(this);
            }

            // notify client
            if (NewFrame != null)
            {
                NewFrame(this, new EventArgs());
            }
        }