public FaceSearchFacade(Damany.Imaging.Processors.MotionDetector motionDetector,
            Damany.Imaging.Processors.PortraitFinder portraitFinder,
            IEnumerable<Damany.Imaging.Common.IFacePostFilter> facePostFilters,
            FaceComparer faceComparer,
            IEventAggregator eventAggregator)
        {
            _motionDetector = motionDetector;
            _portraitFinder = portraitFinder;
            _facePostFilters = facePostFilters;
            _eventAggregator = eventAggregator;
            _faceComparer = faceComparer;

            MotionQueueSize = 10;

            Rectangle rectangle = GetRoi();

            _portraitFinder.ROI = rectangle;
        }
        public static FaceSearchController CreateNewController(IFrameStream source)
        {
            PortraitFinder finder = new PortraitFinder();

            MotionDetector motionDetector = new MotionDetector();
            motionDetector.MotionFrameCaptured += finder.HandleMotionFrame;

            Damany.Util.PersistentWorker retriever = CreateDriver(source, motionDetector);

            var controller = new FaceSearchController()
            {
                Worker = retriever,
                PortraitFinder = finder,
                MotionDetector = motionDetector
            };

            return controller;
        }
        public FaceSearchFacade(Damany.Imaging.Processors.MotionDetector motionDetector,
                                Damany.Imaging.Processors.PortraitFinder portraitFinder,
                                IEnumerable <Damany.Imaging.Common.IFacePostFilter> facePostFilters,
                                FaceComparer faceComparer,
                                IEventAggregator eventAggregator)
        {
            _motionDetector  = motionDetector;
            _portraitFinder  = portraitFinder;
            _facePostFilters = facePostFilters;
            _eventAggregator = eventAggregator;
            _faceComparer    = faceComparer;

            MotionQueueSize = 10;

            Rectangle rectangle = GetRoi();

            _portraitFinder.ROI = rectangle;
        }
        public static FaceSearchController CreateNewController(IFrameStream source)
        {
            PortraitFinder finder = new PortraitFinder();

            MotionDetector motionDetector = new MotionDetector();

            motionDetector.MotionFrameCaptured += finder.HandleMotionFrame;

            Damany.Util.PersistentWorker retriever = CreateDriver(source, motionDetector);

            var controller = new FaceSearchController()
            {
                Worker         = retriever,
                PortraitFinder = finder,
                MotionDetector = motionDetector
            };

            return(controller);
        }
        private static Damany.Util.PersistentWorker CreateDriver(IFrameStream source, MotionDetector motionDetector)
        {
            var retriever = new Damany.Util.PersistentWorker();
            retriever.OnWorkItemIsDone += item =>
            {
                Console.Write("\r");
                Frame f = item as Frame;
                Console.Write(f.ToString());
            };

            retriever.DoWork = delegate
            {
                var frame = source.RetrieveFrame();
                retriever.ReportWorkItem(frame);
                motionDetector.DetectMotion(frame);
            };

            retriever.OnExceptionRetry = delegate { source.Connect(); };
            return retriever;
        }
        private static Damany.Util.PersistentWorker CreateDriver(IFrameStream source, MotionDetector motionDetector)
        {
            var retriever = new Damany.Util.PersistentWorker();

            retriever.OnWorkItemIsDone += item =>
            {
                Console.Write("\r");
                Frame f = item as Frame;
                Console.Write(f.ToString());
            };

            retriever.DoWork = delegate
            {
                var frame = source.RetrieveFrame();
                retriever.ReportWorkItem(frame);
                motionDetector.DetectMotion(frame);
            };

            retriever.OnExceptionRetry = delegate { source.Connect(); };
            return(retriever);
        }