Пример #1
0
 private void drawLevel(object sender, MotionLevelArgs a, CamIdArgs b)
 {
     if (b.cam == CameraRig.ConfigCam)
     {
         double sensitivity = (double)Convert.ToInt32(txtMov.Text);
         LevelControlBox.levelDraw(Convert.ToInt32(a.lvl * 100), sensitivity);
     }
 }
Пример #2
0
        // On new frame
        private void video_NewFrameOLD(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();


                if (_detectionOn)
                {
                    // 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);
                            }
                        }
                    }
                }//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());
            }
        }
Пример #3
0
        private void drawLevel(object sender, MotionLevelArgs a, CamIdArgs b)
        {
            if (b.cam == CameraRig.drawCam)
            {

                double sensitivity = (double)Convert.ToInt32(txtMov.Text);
                levelDraw(Convert.ToInt32(a.lvl * 100), sensitivity);

            }
        }
Пример #4
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());
            }
        }
Пример #5
0
        // On new frame
        private void video_NewFrameOLD(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();

                if (_detectionOn)
                {

                    // apply motion detector
                    if (motionDetecotor != null)
                    {

                        //*************************************
                        //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
                        //*************************************

                        motionDetecotor.ProcessFrame(areaDetectionPreparedImage);

                        MotionLevelArgs a = new MotionLevelArgs();
                        CamIdArgs b = new CamIdArgs();
                        a.lvl = motionDetecotor.MotionDetectionAlgorithm.MotionLevel;
                        b.cam = cam;
                        motionLevelEvent(null, a, b);

                        // check motion level
                        if (calibrating && cam == CameraRig.trainCam)
                        {
                            bubble.train(motionDetecotor.MotionDetectionAlgorithm.MotionLevel);
                        }
                        else
                        {
                            if (alarmActive && alert && motionDetecotor.MotionDetectionAlgorithm.MotionLevel >= movementVal && motionAlarm != null)
                            {

                                CamIdArgs c = new CamIdArgs();
                                c.cam = cam;
                                LevelArgs l = new LevelArgs();
                                l.lvl = Convert.ToInt32(100 * motionDetecotor.MotionDetectionAlgorithm.MotionLevel);

                                motionAlarm(null, c, l);

                            }
                        }
                    }

                }//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());
            }
        }
Пример #6
0
        // On new frame
        private void video_NewFrame(object sender, NewFrameEventArgs e)
        {
            try
            {
                // lock
                Monitor.Enter(this);

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


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


                // apply motion detector
                if (motionDetecotor != null)
                {
                    motionDetecotor.ProcessFrame(ref lastFrame);


                    MotionLevelArgs a = new MotionLevelArgs();
                    CamIdArgs       b = new CamIdArgs();
                    a.lvl = motionDetecotor.MotionLevel;
                    b.cam = cam;
                    motionLevelEvent(null, a, b);


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

                            motionAlarm(null, c, l);
                        }
                    }
                }

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

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

            // notify client
            if (NewFrame != null)
            {
                NewFrame(this, new EventArgs());
            }
        }
Пример #7
0
 public static void motionEvent(object sender, MotionLevelArgs a, CamIdArgs b)
 {
     levelLine(a, b);
     RecordMotionStats(a, b);
 }
Пример #8
0
        public static void levelLine(MotionLevelArgs a, CamIdArgs b)
        {
            if (b.cam == CameraRig.activeCam)
            {
                motionLevel = Convert.ToInt32((int)Math.Floor(a.lvl * 100));

                if (motionLevelChanged != null && motionLevel != motionLevelprevious)
                {

                    motionLevelprevious = motionLevel;
                    motionLevelChanged(null, new EventArgs());

                }
            }
        }
Пример #9
0
 public static void RecordMotionStats(MotionLevelArgs a, CamIdArgs b)
 {
     statistics.add(b.cam, Convert.ToInt32((int)Math.Floor(a.lvl * 100)), time.millisecondsSinceStart(), bubble.profileInUse);
 }