public CatLitterBoxTwitterSender WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null) throw new ArgumentNullException(nameof(motionDetector));

            motionDetector.StateChanged += RestartTimer;
            return this;
        }
Exemple #2
0
 public Camera(IVideoSource source, IMotionDetector detector)
 {
     this.videoSource              = source;
     this.motionDetecotor          = detector;
     videoSource.NewFrame         += new NewFrameEventHandler(video_NewFrame);
     videoSource.VideoSourceError += new VideoSourceErrorEventHandler(video_VideoSourceError);
 }
Exemple #3
0
        public MotionDetector GetDefaultMotionDetector()
        {
            IMotionDetector motionDetector = null;
            MotionDetector  detector       = null;

            process = new CountingObjectsProcessing();
            //AForge.Vision.Motion.IMotionDetector detector = null;
            //AForge.Vision.Motion.IMotionProcessing processor = null;
            // AForge.Vision.Motion.MotionDetector motionDetector = null;
            process.MinObjectsHeight = minHeight;
            process.MinObjectsWidth  = minWidth;
            //process.blobCounter.ObjectsOrder = ObjectsOrder.None;

            motionDetector = new SimpleBackgroundModelingDetector()
            {
                DifferenceThreshold = 50,                //ilosc roznicy pomiedzy pikselami
                //FramesPerBackgroundUpdate = 10000,
                MillisecondsPerBackgroundUpdate = 60000, //po tylu milisekundach restartowane jest tlo
                SuppressNoise = true
            };

            detector = new MotionDetector(motionDetector, process);

            return(detector);
        }
Exemple #4
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="imagingData">Common Use Imaging Data</param>
 /// <param name="preprocessor">Image Preprocessor Unit [Default is nu will be created]</param>
 /// <param name="motionInspector">Motion Detection Unit [Default is nu will be created]</param>
 public Tracker(IImageData imagingData, IImagePreparation preprocessor = null, IMotionDetector motionInspector = null)
 {
     ComputerVisionMonitors = new Dictionary<eComputerVisionMonitor, IComputerVisionMonitor>();
     ImagingData = imagingData;
     MotionInspector = motionInspector ?? new MotionDetector(ImagingData);
     PreProcessor = preprocessor ?? new ImagePreProcessor();
 }
Exemple #5
0
 public Camera(VideoCaptureDevice source, IMotionDetector detector)
 {
     lastFrame             = null;
     this.videoSource      = source;
     this.motionDetecotor  = detector;
     videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
 }
        protected override void OnMotionDetected(IMotionDetector motionDetector)
        {
            JsonObject data = CreateDataPackage(motionDetector.Id, EventType.MotionDetected);
            data.SetNamedValue("kind", JsonValue.CreateStringValue("detected"));

            Task.Run(() => SendToAzureEventHubAsync(data));
        }
Exemple #7
0
 public Camera( IVideoSource source, IMotionDetector detector )
 {
     this.videoSource = source;
     this.motionDetecotor = detector;
     videoSource.NewFrame += new NewFrameEventHandler( video_NewFrame );
     videoSource.VideoSourceError += new VideoSourceErrorEventHandler( video_VideoSourceError );
 }
        protected override void OnMotionDetected(IMotionDetector motionDetector)
        {
            JsonObject data = CreateDataPackage(motionDetector.Id, EventType.MotionDetected);

            data.SetNamedValue("kind", JsonValue.CreateStringValue("detected"));

            Task.Run(() => SendToAzureEventHubAsync(data));
        }
Exemple #9
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="imagingData">Common imaging data for all Image Processing Unit</param>
 /// <param name="streamer">Frame Streamer used to check if we received new frames</param>
 /// <param name="preprocessor">Image Preparation unit [default is null - will be created]</param>
 /// <param name="motionInspector">Motion Detection unit [default is null - will be created</param>
 public BallTracker(IImageData imagingData, FramePublisher streamer, IImagePreparation preprocessor = null, IMotionDetector motionInspector = null)
     : base(imagingData, preprocessor, motionInspector)
 {
     _streamer = streamer;
     CannyThreshold = DEFAULT_CANNY_THRESHOLD;
     CircleAccumulator = DEFAULT_CIRCLE_ACCUMULATOR_THRESHOLD;
     InverseRatio = DEFAULT_INVERSE_RATIO;
 }
Exemple #10
0
        public Kamera(IVideoSource ivideo, IMotionDetector mdetector)
        {
            this.ivideo    = ivideo;
            this.mdetector = mdetector;

            ivideo.NewFrame         += new NewFrameEventHandler(Kamera_YeniFrame);
            ivideo.VideoSourceError += new VideoSourceErrorEventHandler(Kamera_VideoError);
        }
        public MotionDetector(IEventAggregator eventAggregator, int workMode)
        {
            if (eventAggregator == null) throw new ArgumentNullException("eventAggregator");
            _eventAggregator = eventAggregator;

            _eventAggregator.SwitchMotionDetector += delegate { this.SwitchMotionDetector(); };
            _currentMotionDetector = workMode == 1 ? _nullMotionDetector : _motionDetector;
        }
        public BathroomFanAutomation WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null) throw new ArgumentNullException(nameof(motionDetector));

            motionDetector.GetMotionDetectedTrigger().Triggered += TurnOn;
            motionDetector.GetDetectionCompletedTrigger().Triggered += StartTimeout;

            return this;
        }
        public CatLitterBoxTwitterSender WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null)
            {
                throw new ArgumentNullException(nameof(motionDetector));
            }

            motionDetector.StateChanged += RestartTimer;
            return(this);
        }
 public void SwitchMotionDetector()
 {
     if (CurrentMotionDetector == _nullMotionDetector)
     {
         CurrentMotionDetector = _motionDetector;
     }
     else
     {
         CurrentMotionDetector = _nullMotionDetector;
     }
 }
        public AutomaticTurnOnAndOffAutomation WithTrigger(IMotionDetector motionDetector, params IParameter[] parameters)
        {
            if (motionDetector == null) throw new ArgumentNullException(nameof(motionDetector));
            if (parameters == null) throw new ArgumentNullException(nameof(parameters));

            motionDetector.MotionDetected += (s, e) => Trigger();
            motionDetector.DetectionCompleted += (s, e) => StartTimeout();
            motionDetector.IsEnabledChanged += CancelTimeoutIfMotionDetectorDeactivated;
            
            return this;
        }
        public MotionDetector(IEventAggregator eventAggregator, int workMode)
        {
            if (eventAggregator == null)
            {
                throw new ArgumentNullException("eventAggregator");
            }
            _eventAggregator = eventAggregator;

            _eventAggregator.SwitchMotionDetector += delegate { this.SwitchMotionDetector(); };
            _currentMotionDetector = workMode == 1 ? _nullMotionDetector : _motionDetector;
        }
        public BathroomFanAutomation WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null)
            {
                throw new ArgumentNullException(nameof(motionDetector));
            }

            motionDetector.GetMotionDetectedTrigger().Triggered     += TurnOn;
            motionDetector.GetDetectionCompletedTrigger().Triggered += StartTimeout;

            return(this);
        }
        public BathroomFanAutomation WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null)
            {
                throw new ArgumentNullException(nameof(motionDetector));
            }

            motionDetector.MotionDetectedTrigger.Triggered           += (_, __) => TurnOnSlow();
            motionDetector.MotionDetectionCompletedTrigger.Triggered += (_, __) => StartTimeout();

            return(this);
        }
Exemple #19
0
        public BathroomFanAutomation WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null)
            {
                throw new ArgumentNullException(nameof(motionDetector));
            }

            _messageBroker.CreateTrigger <MotionDetectedEvent>(motionDetector.Id).Attach(TurnOnSlow);
            _messageBroker.CreateTrigger <MotionDetectionCompletedEvent>(motionDetector.Id).Attach(StartTimeout);

            return(this);
        }
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            // Defer task instance in order to keep this task running
            deferral = taskInstance.GetDeferral();
            taskInstance.Canceled += TaskInstanceCanceled;

            motionDetector = new PassiveInfraredMotionDetector(26, 500);
            motionDetector.Initialize();

            themeNotification = new SeinfeldThemeNotification();

            motionDetector.MotionDetected += MotionDetectorMotionDetectedAsync;
        }
        public TurnOnAndOffAutomation WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null)
            {
                throw new ArgumentNullException(nameof(motionDetector));
            }

            motionDetector.MotionDetectedTrigger.Attach(ExecuteAutoTrigger);
            motionDetector.MotionDetectionCompletedTrigger.Attach(StartTimeout);

            _settingsService.CreateSettingsMonitor <MotionDetectorSettings>(motionDetector, CancelTimeoutIfMotionDetectorDeactivated);

            return(this);
        }
Exemple #22
0
        public TurnOnAndOffAutomation WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null)
            {
                throw new ArgumentNullException(nameof(motionDetector));
            }

            motionDetector.GetMotionDetectedTrigger().Attach(Trigger);
            motionDetector.GetDetectionCompletedTrigger().Attach(StartTimeout);

            motionDetector.Settings.ValueChanged += CancelTimeoutIfMotionDetectorDeactivated;

            return(this);
        }
Exemple #23
0
        public static MotionDetector GetDefaultMotionDetector()
        {
            IMotionDetector   detector       = null;
            IMotionProcessing processor      = null;
            MotionDetector    motionDetector = null;

            //detector = new AForge.Vision.Motion.TwoFramesDifferenceDetector()
            //{
            //    DifferenceThreshold = 15,
            //    SuppressNoise = true
            //};

            //detector = new AForge.Vision.Motion.CustomFrameDifferenceDetector()
            //{
            //    DifferenceThreshold = 55,
            //    KeepObjectsEdges = true,
            //    SuppressNoise = true
            //};

            detector = new SimpleBackgroundModelingDetector()
            {
                DifferenceThreshold             = 10,
                FramesPerBackgroundUpdate       = 10,
                KeepObjectsEdges                = true,
                MillisecondsPerBackgroundUpdate = 0,
                SuppressNoise = true
            };

            //processor = new AForge.Vision.Motion.GridMotionAreaProcessing()
            //{
            //    HighlightColor = System.Drawing.Color.Red,
            //    HighlightMotionGrid = true,
            //    GridWidth = 100,
            //    GridHeight = 100,
            //    MotionAmountToHighlight = 10F
            //};

            processor = new BlobCountingObjectsProcessing()
            {
                HighlightColor         = System.Drawing.Color.Red,
                HighlightMotionRegions = true,
                MinObjectsHeight       = 200,
                MinObjectsWidth        = 200
            };

            motionDetector = new MotionDetector(detector, processor);

            return(motionDetector);
        }
Exemple #24
0
        private void CancelTimeoutIfMotionDetectorDeactivated(IMotionDetector motionDetector, SettingValueChangedEventArgs eventArgs)
        {
            if (eventArgs.SettingName != "IsEnabled")
            {
                return;
            }

            if (!motionDetector.Settings.IsEnabled)
            {
                lock (_syncRoot)
                {
                    _turnOffTimeout?.Cancel();
                }
            }
        }
        public void Run(IBackgroundTaskInstance taskInstance)
        {
            // Defer task instance in order to keep this task running
            deferral = taskInstance.GetDeferral();
            taskInstance.Canceled += TaskInstanceCanceled;

            motionDetector = new PassiveInfraredMotionDetector(26, 500);
            motionDetector.Initialize();

            lightsNotification = new HueLightsNotification("[Your app key goes here]");
            lightsNotification.InitializeAsync()
            .Wait();

            motionDetector.MotionDetected += MotionDetectorMotionDetectedAsync;
        }
Exemple #26
0
    // Set motion detector
    private void SetMotionDetector(IMotionDetector detector)
    {
      this.detector = detector;

      // set motion detector to camera
      Camera camera = cameraWindow1.Camera;

      if (camera != null)
      {
        camera.Lock();
        camera.MotionDetector = detector;
        // reset statistics
        statIndex = statReady = 0;
        camera.Unlock();
      }
    }
        private void SetupDemo()
        {
            // Get the area from the controller.
            IArea area = this.GetArea(Room.ExampleRoom);

            // Get the single motion detector from the controller.
            IMotionDetector motionDetector        = GetComponent <IMotionDetector>();
            ITrigger        motionDetectedTrigger = motionDetector.GetMotionDetectedTrigger();

            // Get the single temperature and humidity sensor from the controller.
            ITemperatureSensor temperatureSensor = GetComponent <ITemperatureSensor>();
            IHumiditySensor    humiditySensor    = GetComponent <IHumiditySensor>();

            // Get the button with the specified ID from the area (not globally).
            IButton  button        = area.GetButton(ExampleRoom.Button1);
            ITrigger buttonTrigger = button.GetPressedShortlyTrigger();

            // Get a test lamp from the area (not globally).
            ILamp lamp2 = area.GetLamp(ExampleRoom.Lamp2);
            ILamp lamp3 = area.GetLamp(ExampleRoom.Lamp3);

            // Integrate the twitter client if the configuration file is available.
            TwitterClient twitterClient;

            if (TwitterClientFactory.TryCreateFromDefaultConfigurationFile(out twitterClient))
            {
                RegisterService(new TwitterClient());

                IAction tweetAction = twitterClient.GetTweetAction($"Someone is here ({DateTime.Now})... @chkratky");

                motionDetectedTrigger.Attach(tweetAction);
                buttonTrigger.Attach(tweetAction);
            }

            // An automation is "Fulfilled" per default.
            ////var automation = new Automation(new AutomationId("DemoAutomation"))
            ////    .WithTrigger(motionDetectedTrigger)
            ////    .WithActionIfConditionsFulfilled(lamp3.GetTurnOnAction())
            ////    .WithCondition(ConditionRelation.And, new ComponentIsInStateCondition(lamp2, BinaryStateId.Off))
            ////    .WithCondition(ConditionRelation.And, new NumericValueSensorHasValueGreaterThanCondition(humiditySensor, 80));

            //AddAutomation(automation);

            SetupTelegramBot();

            new PersonalAgentToApiDispatcher(this).ExposeToApi(ApiController);
        }
Exemple #28
0
        private void SetMotionDetectionAlgorithm(IMotionDetector detectionAlgorithm)
        {
            lock (sync_context)
            {
                motionHistory.Clear();

                detector.MotionDetectionAlgorithm = detectionAlgorithm;

                if (detectionAlgorithm is TwoFramesDifferenceDetector)
                {
                    if (detector.MotionProcessingAlgorithm is MotionBorderHighlighting)
                    {
                        SetMotionProcessingAlgorithm(new MotionAreaHighlighting());
                    }
                }
            }
        }
Exemple #29
0
        private void SetMotionDetectionAlgorithm(IMotionDetector detectionAlgorithm)
        {
            lock (this)
            {
                motionDetector.MotionDetectionAlgorithm = detectionAlgorithm;

                if (detectionAlgorithm is TwoFramesDifferenceDetector)
                {
                    if ((motionDetector.MotionProcessingAlgorithm is MotionBorderHighlighting) ||
                        (motionDetector.MotionProcessingAlgorithm is BlobCountingObjectsProcessing))
                    {
                        motionProcessingType = 1;
                        SetMotionProcessingAlgorithm(new MotionAreaHighlighting());
                    }
                }
            }
        }
        private void SetMotionDetectionAlgorithm(IMotionDetector detectionAlgorithm)
        {
            lock (this)
            {
                _detector.MotionDetectionAlgorithm = detectionAlgorithm;
                _motionHistory.Clear();

                if (detectionAlgorithm is TwoFramesDifferenceDetector)
                {
                    if (
                        (_detector.MotionProcessingAlgorithm is MotionBorderHighlighting) ||
                        (_detector.MotionProcessingAlgorithm is BlobCountingObjectsProcessing))
                    {
                        SetMotionProcessingAlgorithm(new MotionAreaHighlighting());
                    }
                }
            }
        }
        public MainWindowViewModel()
        {
            VideoDevices = new ObservableCollection <FilterInfo>();
            GetVideoDevices();
            IsDesktopSource       = true;
            StartSourceCommand    = new RelayCommand(StartCamera);
            StopSourceCommand     = new RelayCommand(StopCamera);
            StartRecordingCommand = new RelayCommand(StartRecording);
            StopRecordingCommand  = new RelayCommand(StopRecording);
            SaveSnapshotCommand   = new RelayCommand(SaveSnapshot);
            IpCameraUrl           = "http://88.53.197.250/axis-cgi/mjpg/video.cgi?resolution=320×240";
            _motionProcessing     = new BlobCountingObjectsProcessing(true);
            _motionDetector       = new SimpleBackgroundModelingDetector(true);

            _detector = new MotionDetector(
                _motionDetector,
                _motionProcessing);
        }
Exemple #32
0
        /// <summary>
        /// should be called by any function that changes the detectorType
        /// to load the correct Detector and start it.
        /// </summary>
        private void loadDetectorType()
        {
            switch (detectorType)
            {
            case DetectorType.None:
                detector = null;
                break;

            case DetectorType.Basic:
                detector = new MotionDetector1();
                break;

            case DetectorType.Outline:
                detector = new MotionDetector2();
                break;

            case DetectorType.Block:
                detector = new MotionDetector3();
                break;

            case DetectorType.FastBlock:
                detector = new MotionDetector3Optimized();
                break;

            case DetectorType.Box:
                detector = new MotionDetector4();
                break;
            }

            // enable/disable motion alarm
            if (detector != null)
            {
                detector.MotionLevelCalculation = EnableAlert;
            }

            // set motion detector to camera
            if (camera != null)
            {
                camera.Lock();
                camera.MotionDetector = detector;

                camera.Unlock();
            }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MotionDetector"/> class.
 /// </summary>
 /// 
 /// <param name="detector">Motion detection algorithm to apply to each video frame.</param>
 /// 
 public MotionDetector( IMotionDetector detector ) : this( detector, null ) { }
        public void createMotionDetector()
        {
            switch (detectionSensitivity)
            {
                case DETECTIONSENSITIVITY.LOW:
                {
                    sensitivityFactor = 0.15;
                    break;
                }
                case DETECTIONSENSITIVITY.MEDIUM:
                {
                    sensitivityFactor = 0.1;
                    break;
                }
                case DETECTIONSENSITIVITY.HIGH:
                {
                    sensitivityFactor = 0.01;
                    break;
                }
            }

            switch (detectionMethod)
            {
                case MOTION.MOTION_AREA_HIGHLIGHTING:
                {
                    motionProcessor = new MotionAreaHighlighting();
                    break;
                }
                case MOTION.MOTION_GRID_AREA_HIGHLIGHTING:
                {
                    motionProcessor = new GridMotionAreaProcessing(5, 5);
                    break;
                }
                case MOTION.MOTION_BORDER_HIGHLIGHTING:
                {
                    motionProcessor = new MotionBorderHighlighting();
                    break;
                }
                case MOTION.MOTION_BLOB_COUNTER:
                        {
                            motionProcessor = new BlobCountingObjectsProcessing();
                            break;
                        }
            }

            switch (detecionSpeed)
            {
                case DETECTIONSPEED.FAST:
                {
                    skipFrame = 3;
                    break;
                }
                case DETECTIONSPEED.MEDIUM:
                {
                    skipFrame = 2;
                    break;
                }
                case DETECTIONSPEED.SLOW:
                {
                    skipFrame = 1;
                    break;
                }
            }

            if (detectionType == DETECTIONTYPE.TWO_FRAMES_DIFFERENCE)
                detector = new TwoFramesDifferenceDetector(true);
            else
                detector = new SimpleBackgroundModelingDetector(true, true);

            motionDetector = new MotionDetector(detector, motionProcessor);

            motionDetector.MotionZones = detectionArea;
        }
 // Select detector 3 - optimized
 private void detector3OptimizedMotionItem_Click(object sender, System.EventArgs e)
 {
     detector     = new MotionDetector3Optimized();
     detectorType = 4;
     SetMotionDetector();
 }
        public TurnOnAndOffAutomation WithTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null) throw new ArgumentNullException(nameof(motionDetector));

            motionDetector.GetMotionDetectedTrigger().Attach(ExecuteAutoTrigger);
            motionDetector.GetDetectionCompletedTrigger().Attach(StartTimeout);

            motionDetector.Settings.ValueChanged += (s, e) => CancelTimeoutIfMotionDetectorDeactivated(motionDetector, e);

            return this;
        }
        public void createMotionDetector()
        {
            switch (detectionSensitivity)
            {
            case DETECTIONSENSITIVITY.LOW:
            {
                sensitivityFactor = 0.15;
                break;
            }

            case DETECTIONSENSITIVITY.MEDIUM:
            {
                sensitivityFactor = 0.1;
                break;
            }

            case DETECTIONSENSITIVITY.HIGH:
            {
                sensitivityFactor = 0.01;
                break;
            }
            }

            switch (detectionMethod)
            {
            case MOTION.MOTION_AREA_HIGHLIGHTING:
            {
                motionProcessor = new MotionAreaHighlighting();
                break;
            }

            case MOTION.MOTION_GRID_AREA_HIGHLIGHTING:
            {
                motionProcessor = new GridMotionAreaProcessing(5, 5);
                break;
            }

            case MOTION.MOTION_BORDER_HIGHLIGHTING:
            {
                motionProcessor = new MotionBorderHighlighting();
                break;
            }

            case MOTION.MOTION_BLOB_COUNTER:
            {
                motionProcessor = new BlobCountingObjectsProcessing();
                break;
            }
            }

            switch (detecionSpeed)
            {
            case DETECTIONSPEED.FAST:
            {
                skipFrame = 3;
                break;
            }

            case DETECTIONSPEED.MEDIUM:
            {
                skipFrame = 2;
                break;
            }

            case DETECTIONSPEED.SLOW:
            {
                skipFrame = 1;
                break;
            }
            }

            if (detectionType == DETECTIONTYPE.TWO_FRAMES_DIFFERENCE)
            {
                detector = new TwoFramesDifferenceDetector(true);
            }
            else
            {
                detector = new SimpleBackgroundModelingDetector(true, true);
            }


            motionDetector = new MotionDetector(detector, motionProcessor);

            motionDetector.MotionZones = detectionArea;
        }
Exemple #38
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MotionDetector"/> class.
 /// </summary>
 /// 
 /// <param name="detector">Motion detection algorithm to apply to each video frame.</param>
 /// <param name="processor">Motion processing algorithm to apply to each video frame after
 /// motion detection is done.</param>
 /// 
 public MotionDetector( IMotionDetector detector, IMotionProcessing processor )
 {
     _detector  = detector;
     _processor = processor;
 }
Exemple #39
0
 private void button30_Click(object sender, EventArgs e)
 {
     detector = new MotionDetector4();
     detectorType = 5;
     SetMotionDetector();
 }
Exemple #40
0
        // Set motion detector
        private void SetMotionDetector(IMotionDetector detector)
        {
            this.detector = detector;

              // set motion detector to camera
              Camera camera = cameraWindow1.Camera;

              if (camera != null)
              {
            camera.Lock();
            camera.MotionDetector = detector;
            // reset statistics
            statIndex = statReady = 0;
            camera.Unlock();
              }
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="MotionDetector"/> class.
 /// </summary>
 /// 
 /// <param name="detector">Motion detection algorithm to apply to each video frame.</param>
 /// <param name="processor">Motion processing algorithm to apply to each video frame after
 /// motion detection is done.</param>
 /// 
 public MotionDetector( IMotionDetector detector, IMotionProcessing processor )
 {
     this.detector  = detector;
     this.processor = processor;
 }
 // Remove any motion detectors
 private void noneMotionItem_Click(object sender, System.EventArgs e)
 {
     detector     = null;
     detectorType = 0;
     SetMotionDetector();
 }
        public Automation WithMotionDetectionCompletedTrigger(IMotionDetector motionDetector)
        {
            if (motionDetector == null) throw new ArgumentNullException(nameof(motionDetector));

            motionDetector.DetectionCompleted += (s, e) => Trigger();
            return this;
        }
Exemple #44
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MotionDetector"/> class.
 /// </summary>
 ///
 /// <param name="detector">Motion detection algorithm to apply to each video frame.</param>
 ///
 public MotionDetector(IMotionDetector detector) : this(detector, null)
 {
 }
Exemple #45
0
 public Camera(IVideoSource source, IMotionDetector detector)
 {
     this.mVideoSource = source;
     this.mMotionDetecotor = detector;
     mVideoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
 }
Exemple #46
0
 // Remove any motion detectors
 private void noneMotionItem_Click( object sender, System.EventArgs e )
 {
     detector = null;
     detectorType = 0;
     SetMotionDetector( );
 }
Exemple #47
0
 // Select detector 3 - optimized
 private void detector3OptimizedMotionItem_Click( object sender, System.EventArgs e )
 {
     detector = new MotionDetector3Optimized( );
     detectorType = 4;
     SetMotionDetector( );
 }
Exemple #48
0
 // Select detector 4
 private void detector4MotionItem_Click( object sender, System.EventArgs e )
 {
     detector = new MotionDetector4( );
     detectorType = 5;
     SetMotionDetector( );
 }
 // Select detector 3
 private void detector3MotionItem_Click(object sender, System.EventArgs e)
 {
     detector     = new MotionDetector3();
     detectorType = 3;
     SetMotionDetector();
 }
 public void SwitchMotionDetector()
 {
     if (CurrentMotionDetector == _nullMotionDetector)
     {
         CurrentMotionDetector = _motionDetector;
     }
     else
     {
         CurrentMotionDetector = _nullMotionDetector;
     }
 }
Exemple #51
0
        // Set new motion detection algorithm
        private void SetMotionDetectionAlgorithm( IMotionDetector detectionAlgorithm )
        {
            lock ( this )
            {
                detector.MotionDetectionAlgorithm = detectionAlgorithm;
                motionHistory.Clear( );

                if ( detectionAlgorithm is TwoFramesDifferenceDetector )
                {
                    if (
                        ( detector.MotionProcessingAlgorithm is MotionBorderHighlighting ) ||
                        ( detector.MotionProcessingAlgorithm is BlobCountingObjectsProcessing ) )
                    {
                        motionProcessingType = 1;
                        SetMotionProcessingAlgorithm( new MotionAreaHighlighting( ) );
                    }
                }
            }
        }
 protected virtual void OnMotionDetected(IMotionDetector motionDetector)
 {
 }
Exemple #53
0
 /// <summary>
 /// Initializes a new instance of the <see cref="MotionDetector"/> class.
 /// </summary>
 ///
 /// <param name="detector">Motion detection algorithm to apply to each video frame.</param>
 /// <param name="processor">Motion processing algorithm to apply to each video frame after
 /// motion detection is done.</param>
 ///
 public MotionDetector(IMotionDetector detector, IMotionProcessing processor)
 {
     this.detector  = detector;
     this.processor = processor;
 }
Exemple #54
0
 private void button25_Click(object sender, EventArgs e)
 {
     detector = null;
     detectorType = 0;
     SetMotionDetector();
 }
        private void CancelTimeoutIfMotionDetectorDeactivated(IMotionDetector motionDetector, SettingValueChangedEventArgs eventArgs)
        {
            if (eventArgs.SettingName != "IsEnabled")
            {
                return;
            }

            if (!motionDetector.Settings.IsEnabled)
            {
                lock (_syncRoot)
                {
                    _turnOffTimeout?.Cancel();
                }
            }
        }
Exemple #56
0
 private void button29_Click(object sender, EventArgs e)
 {
     detector = new MotionDetector3Optimized();
     detectorType = 4;
     SetMotionDetector();
 }