Exemple #1
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 #2
0
        private void Start()
        {
            CloseVideoSource();
            ButtonImage = Application.Current.Resources["StopImage"] as BitmapImage;
            // le détecteur de mouvement
            _motionDetector = new MotionDetector(
                new TwoFramesDifferenceDetector
            {
                DifferenceThreshold = 15,
                SuppressNoise       = true
            },
                new BlobCountingObjectsProcessing
            {
                HighlightColor         = Color.Red,
                HighlightMotionRegions = true,
                MinObjectsHeight       = 10,
                MinObjectsWidth        = 10
            });

            _videoSource           = new VideoCaptureDevice(SelectedDevice.MonikerString);
            _videoSource.NewFrame += OnNewFrameReceived;
            _videoSource.Start();
            Information      = "Capture démarrée";
            _timer.IsEnabled = true;
        }
Exemple #3
0
        static void Main()
        {
            _path = Path.GetTempPath();
            Console.WriteLine("Motion Detector");
            Console.WriteLine("Detects motion in the integrated laptop webcam");
            Console.WriteLine("Threshold level: " + _motionAlarmLevel);
            _motionDetector = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionAreaHighlighting());
            if (new FilterInfoCollection(FilterCategory.VideoInputDevice).Count > 0)
            {
                _path += "motions";

                if (!Directory.Exists(_path))
                {
                    Directory.CreateDirectory(_path);
                }
                else
                {
                    var dir = new DirectoryInfo(_path);
                    foreach (var fi in dir.GetFiles())
                    {
                        fi.Delete();
                    }
                }

                var videoDevice        = new FilterInfoCollection(FilterCategory.VideoInputDevice)[0];
                var videoCaptureDevice = new VideoCaptureDevice(videoDevice.MonikerString);
                var videoSourcePlayer  = new AForge.Controls.VideoSourcePlayer();
                videoSourcePlayer.NewFrame   += VideoSourcePlayer_NewFrame;
                videoSourcePlayer.VideoSource = new AsyncVideoSource(videoCaptureDevice);
                videoSourcePlayer.Start();
            }
        }
        private void MotionDetectionControl_Load(object sender, EventArgs e)
        {
            _motionDetector = new MotionDetector();
            SetUIFromSubtractorConfig();

            ddlBiggestTargeting.SelectedText = BiggestMotionType.Area.ToString();
        }
Exemple #5
0
        private void MotionForm_Shown(object sender, EventArgs e)
        {
            AppendLog("程序已加载...");
            try
            {
                AppendLog("正在读取摄像头设备列表...");
                //初始化摄像头设备
                VideoDevicesList = new FilterInfoCollection(FilterCategory.VideoInputDevice);
                AppendLog("使用默认摄像头设备...");
                //使用默认设备
                VideoSource = new VideoCaptureDevice(VideoDevicesList[0].MonikerString);
                //绑定事件
                AppendLog("注册警报事件");
                VideoSource.NewFrame += new NewFrameEventHandler(Alert);
                AppendLog("正在启动摄像头...");
                //启动摄像头
                VideoSource.Start();
            }
            catch (Exception ex)
            {
                AppendLog("无法连接或启动摄像头,程序即将退出...\n{0}", ex.Message);
                MessageBox.Show(string.Format("无法连接摄像头:\n{0}", ex.Message));
                Application.Exit();
            }
            AppendLog("设备初始化完成!开始监视...");

            //运动监视
            LunchDetector = new MotionDetector(motionDetector, motionProcessing);
            AppendLog("运行监视创建完成...");
            AppendLog("————————————");
        }
Exemple #6
0
 public Handbell(MotionControllerManager.MotionControllerManager manager, int index)
 {
     _manager                 = manager;
     _button1Pressed          = false;
     _button1Down             = false;
     _button2Pressed          = false;
     _button2Down             = false;
     _button3Pressed          = false;
     _button3Down             = false;
     _button4Pressed          = false;
     _button4Down             = false;
     _handstroke              = true;
     _backstroke              = false;
     _handstrokeStrike        = false;
     _backstrokeStrike        = false;
     _handstrokeStrikePending = false;
     _backstrokeStrikePending = false;
     _lasttick                = 0;
     _axis = 2;             //Z-axis
     if (index < _manager.Count)
     {
         _controller       = index;
         _handbell         = index;
         _motionController = _manager.getDetector(_controller);
         _enabled          = true;
     }
     else
     {
         _enabled    = false;
         _controller = -1;
     }
 }
Exemple #7
0
        public static void LoadCameras()
        {
            UseMotionDetection = Config.Load().Webcams.UseMotionDetection;
            BlobCountingObjectsProcessing motionProcessor = new BlobCountingObjectsProcessing();

            detector = new MotionDetector(
                new SimpleBackgroundModelingDetector(),
                motionProcessor);

            Cameras      = new ConcurrentDictionary <string, Camera>();
            CameraFrames = new ConcurrentDictionary <string, byte[]>();
            var videoDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);

            if (videoDevices.Count == 0)
            {
                return;
            }
            foreach (FilterInfo device in videoDevices)
            {
                var cameraId = Guid.NewGuid().ToString("N").ToUpper();
                var camera   = new Camera
                {
                    Id       = cameraId,
                    Name     = device.Name,
                    Moniker  = device.MonikerString,
                    Physical = new VideoCaptureDevice(device.MonikerString)
                };
                camera.Physical.NewFrame += (sender, e) => HandleFrame(sender, e, cameraId);
                Cameras.TryAdd(cameraId, camera);
            }
            Console.WriteLine($"{Cameras.Count} cameras loaded");
        }
Exemple #8
0
        // Startup

        private void Form1_Load(object sender, System.EventArgs e)
        {
            motdet = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionAreaHighlighting());
            try
            {
                serialPort1.PortName = "com3";
                serialPort1.BaudRate = 9600;
                serialPort1.Open();
            }
            catch
            {
                MessageBox.Show("Make Sure arduino is pluged in if it is reset device and try again");
            }
            webcam = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo VideoCaptureDevice in webcam)
            {
                comboBox1.Items.Add(VideoCaptureDevice.Name);
            }
            comboBox1.SelectedIndex = 0;

            cam           = new VideoCaptureDevice(webcam[comboBox1.SelectedIndex].MonikerString);
            cam2          = new VideoCaptureDevice(webcam[comboBox1.SelectedIndex].MonikerString);
            cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
            videoSourcePlayer1.VideoSource = cam2;
            cam.Stop();
            cam2.Stop();
            cam.Start();
            byte pos = Convert.ToByte(textBox1.Text);

            serialPort1.Write(new byte[] { pos }, 0, 1);
        }
        public void Should_TurnOn_IfMotionDetected()
        {
            var testController = new TestController();
            var adapter        = new TestMotionDetectorAdapter();
            var motionDetector = new MotionDetector(
                "Test",
                adapter,
                testController.GetInstance <ISchedulerService>(),
                testController.GetInstance <ISettingsService>());

            var automation = new TurnOnAndOffAutomation(
                "Test",
                testController.GetInstance <IDateTimeService>(),
                testController.GetInstance <ISchedulerService>(),
                testController.GetInstance <ISettingsService>(),
                testController.GetInstance <IDaylightService>());

            var output = new Lamp("Test", new TestLampAdapter());

            Assert.AreEqual(true, output.GetState().Has(PowerState.Off));

            automation.WithTrigger(motionDetector);
            automation.WithTarget(output);

            adapter.Invoke();

            Assert.AreEqual(true, output.GetState().Has(PowerState.On));
        }
        public void Should_NotTurnOn_IfMotionDetected_AndTimeRangeConditionIs_NotFulfilled()
        {
            var testController = new TestController();

            testController.SetTime(TimeSpan.Parse("18:00:00"));
            var adapter        = new TestMotionDetectorAdapter();
            var motionDetector = new MotionDetector(
                "Test",
                adapter,
                testController.GetInstance <ISchedulerService>(),
                testController.GetInstance <ISettingsService>());

            var automation = new TurnOnAndOffAutomation(
                "Test",
                testController.GetInstance <IDateTimeService>(),
                testController.GetInstance <ISchedulerService>(),
                testController.GetInstance <ISettingsService>(),
                testController.GetInstance <IDaylightService>());

            var output = new Lamp("Test", new TestLampAdapter());

            Assert.AreEqual(true, output.GetState().Has(PowerState.Off));

            automation.WithTurnOnWithinTimeRange(() => TimeSpan.Parse("10:00:00"), () => TimeSpan.Parse("15:00:00"));
            automation.WithTrigger(motionDetector);
            automation.WithTarget(output);

            adapter.Invoke();

            Assert.AreEqual(true, output.GetState().Has(PowerState.Off));
        }
        public FMain()
        {
            InitializeComponent();

            motiondetector = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionAreaHighlighting());
            fic            = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo item in fic)
            {
                cbDevices.Items.Add(item.Name);
            }
            if (cbDevices.Items.Count > 0)
            {
                cbDevices.SelectedIndex = 0;
            }
            else
            {
                btnCaptureVideoStart.Enabled = false;
                btnArreterCapture.Enabled    = false;
            }

            timerVideo = new Timer();
            timerVideo.Stop();
            timerVideo.Interval = 1000;
            timerVideo.Tick    += timerVideo_tick;

            timerCamera = new Timer();
            timerCamera.Stop();
            timerCamera.Interval = 1000;
            timerCamera.Tick    += timerCamera_tick;
        }
Exemple #12
0
 public Camera(IVideoSource source, MotionDetector detector)
 {
     //VideoSource = new AsyncVideoSource(source, false);
     VideoSource           = source;
     _motionDetector       = detector;
     VideoSource.NewFrame += VideoNewFrame;
 }
Exemple #13
0
        /// <summary>
        ///   Initializes a new instance of the <see cref="ProcessingData" /> class.
        /// </summary>
        public ProcessingData()
        {
            //this.ColorThreshold = new ObservableCollection<int>();
            //this.BlobMinDiameter = new ObservableCollection<double>();
            //this.BlobMaxDiameter = new ObservableCollection<double>();

            this.colorAndCropFilter = new ColorAndCropFilterRgb();
            this.cropFilter         = new CropFilterRgb();
            this.histogrammFilter   = new Histogram();
            this.segmentator        = new HistogramMinMaxSegmentator();

            this.TargetColor.CollectionChanged       += this.TargetColorCollectionChanged;
            this.CurrentBlobCenter.CollectionChanged += this.BlobCollectionChanged;
            this.DetectedBlob.CollectionChanged      += this.BlobCollectionChanged;
            this.ColorThreshold.CollectionChanged    += this.HlslParamsCollectionChanged;
            this.BlobMinDiameter.CollectionChanged   += this.HlslParamsCollectionChanged;
            this.BlobMaxDiameter.CollectionChanged   += this.HlslParamsCollectionChanged;
            var motionDetector  = new TwoFramesDifferenceDetectorSpecial();
            var motionProcessor = new MotionAreaHighlightingSpecial();

            this.detector = new MotionDetector(motionDetector, motionProcessor);
            this.MotionThreshold.CollectionChanged  += this.MotionDetectionParameterCollectionChanged;
            this.SuppressNoise.CollectionChanged    += this.MotionDetectionParameterCollectionChanged;
            this.PositiveContrast.CollectionChanged += this.MotionDetectionParameterCollectionChanged;

            this.PropertyChanged += this.ProcessingDataPropertyChanged;
        }
        private void DeteMov_Load(object sender, EventArgs e)
        {
            // Inicializa variables de detenctor.
            Detector01 = new MotionDetector(new CustomFrameDifferenceDetector(), new BlobCountingObjectsProcessing());
            Detector02 = new MotionDetector(new CustomFrameDifferenceDetector(), new GridMotionAreaProcessing());
            Detector03 = new MotionDetector(new CustomFrameDifferenceDetector(), new MotionAreaHighlighting());
            Detector04 = new MotionDetector(new CustomFrameDifferenceDetector(), new MotionBorderHighlighting());

            Detector05 = new MotionDetector(new SimpleBackgroundModelingDetector(), new BlobCountingObjectsProcessing());
            Detector06 = new MotionDetector(new SimpleBackgroundModelingDetector(), new GridMotionAreaProcessing());
            Detector07 = new MotionDetector(new SimpleBackgroundModelingDetector(), new MotionAreaHighlighting());
            Detector08 = new MotionDetector(new SimpleBackgroundModelingDetector(), new MotionBorderHighlighting());

            Detector09 = new MotionDetector(new TwoFramesDifferenceDetector(), new BlobCountingObjectsProcessing());
            Detector10 = new MotionDetector(new TwoFramesDifferenceDetector(), new GridMotionAreaProcessing());
            Detector11 = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionAreaHighlighting());
            Detector12 = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionBorderHighlighting());;

            NivelDetenccion = 0;
            // Lista los dispositivos de entrada de vídeo.
            Dispositivos = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            // Dispositivo tiene un array, con todos los dispositivos disponibles.
            foreach (FilterInfo i in Dispositivos)
            {
                cbCamara.Items.Add(i.Name);
            }
            cbCamara.SelectedIndex = 0;

            DispositivosColor = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            foreach (FilterInfo x in DispositivosColor)
            {
                cbCamaraColor.Items.Add(x.Name);
            }
            cbCamaraColor.SelectedIndex = 0;
        }
Exemple #15
0
        public MotionDebugPanel(CamInterface source, MotionDetector motionDetect)
        {
            cam = source;
            md  = motionDetect;
            InitializeComponent();

            cam.NewFrame += new NewFrameEventHandler(cam_NewFrame);
        }
        public void InitCamera(int deviceIndex, int resolutionIndex)
        {
            camera = new VideoCaptureDevice(videoDeviceCollection[deviceIndex].MonikerString);

            detector = new MotionDetector(new SimpleBackgroundModelingDetector(), new MotionAreaHighlighting());

            camera.VideoResolution = camera.VideoCapabilities[resolutionIndex];
        }
 public ScreenWriter(IProcessor processor, ILogger logger, MotionDetector motionDetector)
 {
     _processor = processor;
     _logger    = logger;
     _path      = @"C:\OutOfRulesDir";
     _recording = false;
     _detector  = motionDetector;
 }
 public frmSideCamera()
 {
     InitializeComponent();
     getCamera();
     descriptor.SetSVMDetector(HOGDescriptor.GetDefaultPeopleDetector());
     motionDetector = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionAreaHighlighting());
     fgDetector     = new BackgroundSubtractorMOG2();
 }
        MotionSensor()
        {
            var detectionAlgorithm  = new TwoFramesDifferenceDetector(true);
            var processingAlgorithm = new MotionAreaHighlighting();

            motionDetector = new MotionDetector(detectionAlgorithm, processingAlgorithm);

            motionLevels = new BlockingCollection <Motion>(new ConcurrentQueue <Motion>());
        }
Exemple #20
0
 public Camera(VideoCaptureDevice source, MotionDetector detector, string _name)
 {
     ipCamera              = false;
     cameraName            = _name;
     pubFrame              = null;
     this.videoSource      = source;
     this.motionDetector   = detector;
     videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
 }
 public MainWindow()
 {
     InitializeComponent();
     detector         = new MotionDetector(new SimpleBackgroundModelingDetector(), new MotionAreaHighlighting());
     this.DataContext = this;
     GetSelectableDevices();
     GetVideoResolution();
     this.Closing += MainWindow_Closing;
 }
Exemple #22
0
 public Camera(MJPEGStream source, MotionDetector detector, string _name)
 {
     ipCamera              = true;
     cameraName            = _name;
     pubFrame              = null;
     this.videoSource      = source;
     this.motionDetector   = detector;
     videoSource.NewFrame += new NewFrameEventHandler(video_NewFrame);
 }
        public SpeedMeasurer()
        {
            blobCounter = new BlobCountingObjectsProcessing(50, 50, false);
            blobCounter.HighlightColor = Color.FromArgb(0, 255, 0);
            SimpleBackgroundModelingDetector bmd = new SimpleBackgroundModelingDetector(true, true);

            bmd.FramesPerBackgroundUpdate = 1;
            detector = new MotionDetector(bmd, blobCounter);
        }
Exemple #24
0
        public MotionDetect(int webcamID)
        {
            VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice);
            FinalVideo          = new VideoCaptureDevice(VideoCaptureDevices[webcamID].MonikerString);
            var motionProcessor = new MotionAreaHighlighting();

            Detector             = new MotionDetector(new TwoFramesDifferenceDetector(), motionProcessor);
            FinalVideo.NewFrame += FinalVideo_NewFrame;
        }
Exemple #25
0
        private void CompleteImageComarision(string actualImageContainer, string actualImage, string referenceImage, string referenceImageContainer)
        {
            var df             = new BlobStorageService();
            var motionDetector = new MotionDetector();

            motionDetector.ProcessFrame(df.ReadImageContent(referenceImage, referenceImageContainer));
            var result = new ImageComparisionResult();

            result.UploadImageAfterProcess(motionDetector.ProcessFrame(df.ReadImageContent(actualImage, actualImageContainer)), actualImageContainer, actualImage);
        }
Exemple #26
0
        public VideoCaptureDevice ActivarCam()
        {
            FuenteDeVideo = new VideoCaptureDevice(MonikeCam);

            //Inicializar variable de detector
            Detector = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionBorderHighlighting());
            Activo   = true;

            return(FuenteDeVideo);
        }
Exemple #27
0
 private void button10_Click(object sender, EventArgs e)
 {
     newVideo.SignalToStop();
     newVideo.WaitForStop();
     pictureBox1.Image        = null;
     newVideo                 = new VideoCaptureDevice(filterDevices[comboBox1.SelectedIndex].MonikerString);
     newVideo.NewFrame       += VideoCaptureDevice_NewFrame;
     newVideo.VideoResolution = newVideo.VideoCapabilities[index];
     motionDetector           = new MotionDetector(new SimpleBackgroundModelingDetector(), new MotionAreaHighlighting());
     newVideo.Start();
 }
 public void ChangeResolution(int resolutionIndex)
 {
     if (camera.IsRunning)
     {
         camera.SignalToStop();
         camera.WaitForStop();
         camera.VideoResolution = camera.VideoCapabilities[resolutionIndex];
         detector = new MotionDetector(new SimpleBackgroundModelingDetector(), new MotionAreaHighlighting());
         camera.Start();
     }
 }
Exemple #29
0
        //detect if there is motion in frames
        private Bitmap DetectMotion(MotionDetector motionDetector, Bitmap videoFrame)
        {
            Bitmap frames = null;

            // process new video frame and check motion level
            if (motionDetector.ProcessFrame(videoFrame) > 0.02)
            {
                frames = videoFrame;
            }
            return(frames);
        }
Exemple #30
0
 private void Form1_Load(object sender, EventArgs e)
 {
     Detector       = new MotionDetector(new TwoFramesDifferenceDetector(), new MotionBorderHighlighting());
     NivelDeteccion = 0;
     Dispositivos   = new FilterInfoCollection(FilterCategory.VideoInputDevice);
     foreach (FilterInfo x in Dispositivos)
     {
         comboBox1.Items.Add(x.Name);
     }
     comboBox1.SelectedIndex = 0;
 }
        public Camera()
        {
            Detector = new MotionDetector();
            BitmapSourceProvider = new BitmapSourceProvider();
            Connector = new MediaConnector();
            VadFilter = new VADFilter { Enabled = false, ActivationLevel = 40 };
            Snapshot = new SnapshotHandler();

            VadFilter.VoiceDetected += VadFilterVoiceDetected;
            Duration = 10;
        }
        public CameraConfigurationItem(string cameraId, VideoViewerWF videoViewer)
        {
            this.videoViewer = videoViewer;
            this.id = cameraId;
              provider = new DrawingImageProvider();
              connector = new MediaConnector();
              detector = new MotionDetector();
              videoResizer = new VideoResizer();
            detector.PixelIntensitySensitivy = Settings.PixelIntensitySensitivity; //0-255
            detector.PixelAmountSensitivy = Settings.PixelAmountSensitivity; //0-10

            videoViewer.SetImageProvider(provider);
        }
        private void MotionDetectionControl_Load(object sender, EventArgs e)
        {
            _motionDetector = new MotionDetector();
            SetUIFromSubtractorConfig();

            ddlBiggestTargeting.SelectedText = BiggestMotionType.Area.ToString();
        }