/// <summary> /// Factory method - Builds Image Processing Unit and all relevant components /// </summary> /// <param name="dispatcher">Dispatcher used to present frames in GUI relevant thread</param> /// <param name="screen">Canvas to draw frames on</param> /// <returns>ImageProcessPack with all components</returns> public static ImageProcessPack Create(Dispatcher dispatcher, System.Windows.Controls.Canvas screen) { if (!_isCreated) { IsDemoMode = Configuration.Attributes.GetValue <bool>(Configuration.Names.KEY_IS_DEMO_MODE); //Frame/Demo streamer FramePublisher framePublisher; if (!IsDemoMode) { framePublisher = new FrameStreamer(); } else { framePublisher = new DemoStreamer(); } FrameUiMonitor uiMonitor = new FrameUiMonitor(framePublisher, dispatcher, screen); //Initialize Marks double widthRate = screen.Width / framePublisher.FrameWidth; double heightRate = screen.Height / framePublisher.FrameHeight; Marks.Initialize(dispatcher, screen, widthRate, heightRate); //Image/Demo processing unit ImagingProcess imagingProcess; if (!IsDemoMode) { imagingProcess = new FrameProcessingUnit(framePublisher); } else { imagingProcess = new DemoProcessingUnit(framePublisher); } return(new ImageProcessPack(framePublisher, uiMonitor, imagingProcess)); } return(null); }