private FileInfo GetSettingsFileInfo()
        {
            var appData  = ExecutionEnvironment.GetApplicationMetadata();
            var fileName = Path.Combine(appData.ExeFolder, "colordetectsettings.xml");

            return(new FileInfo(fileName));
        }
        protected FileInfo GetFileInfo(string filename83)
        {
            var appData           = ExecutionEnvironment.GetApplicationMetadata();
            var settingsFilename  = Path.Combine(appData.ExeFolder, filename83);
            var colorSettingsFile = new FileInfo(settingsFilename);

            return(colorSettingsFile);
        }
Example #3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            var appData = ExecutionEnvironment.GetApplicationMetadata();

            Log.Info(appData);

            SetupCameraConsumers();
            radCamera.Checked           = true;
            cmbResolution.SelectedIndex = 1;
        }
Example #4
0
        protected void Application_Start()
        {
            Log.Info("-------------------------------------------------------------------------------------------------------");
            var appdata = ExecutionEnvironment.GetApplicationMetadata();

            Log.Info("{0}", appdata.GetLogStartupMessage());

            ComposeAutofac();

            AreaRegistration.RegisterAllAreas();

            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);
        }
Example #5
0
        private void ReadColorSettings()
        {
            var appData           = ExecutionEnvironment.GetApplicationMetadata();
            var settingsFilename  = Path.Combine(appData.ExeFolder, "colordetectsettings.xml");
            var colorSettingsFile = new FileInfo(settingsFilename);

            if (colorSettingsFile.Exists)
            {
                ColourSettings = Kelvin <ColourDetectSettings> .FromXmlFile(settingsFilename);

                Log.Info(m => m("Color detection settings found: {0}", ColourSettings));
            }
            else
            {
                Log.Info(m => m("No color detection settings found at '{0}'", settingsFilename));
            }
        }
Example #6
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            Log.Info("-------------------------------------------------------------------------------------------------------");
            var appdata = ExecutionEnvironment.GetApplicationMetadata();

            Log.Info(appdata.ToString());

            Game.Instance.GetViewPortClients = () => new ViewPortHubClientsProxy();
            Game.Instance.GetGamepadClients  = () => new GamepadHubClientsProxy();
            Game.Instance.Init();

            ModelBinders.Binders.Add(typeof(Point), new PointModelBinder());
        }
Example #7
0
        static void Main(string[] args)
        {
            var appData = ExecutionEnvironment.GetApplicationMetadata();

            Log.Info(appData);

            var options = new ConsoleOptions(args);

            if (options.ShowHelp)
            {
                Console.WriteLine("Options:");
                options.OptionSet.WriteOptionDescriptions(Console.Out);
                return;
            }

            ICaptureGrab capture = null;

            if (options.Mode != Mode.simple)
            {
                var captureDevice = CaptureDevice.Usb;
                if (Environment.OSVersion.Platform == PlatformID.Unix)
                {
                    captureDevice = CaptureDevice.Pi;
                }
                capture = CaptureFactory.GetCapture(captureDevice);
                var captureProperties = capture.GetCaptureProperties();
                Log.Info(m => m("Capture properties: {0}", captureProperties));

                SafetyCheckRoi(options, captureProperties);
            }

            IRunner runner;

            Log.Info(options);
            switch (options.Mode)
            {
            case Mode.simple: runner = new SimpleCv();
                break;

            case Mode.colourdetect:
                var colorDetector = new ColorDetectRunner(capture);
                if (options.HasColourSettings)
                {
                    colorDetector.Settings = options.ColourSettings;
                }
                runner = colorDetector;
                break;

            case Mode.haar:

                var relativePath    = string.Format(@"haarcascades{0}haarcascade_frontalface_default.xml", Path.DirectorySeparatorChar);
                var cascadeFilename = Path.Combine(appData.ExeFolder, relativePath);
                var cascadeContent  = File.ReadAllText(cascadeFilename);
                runner = new CascadeRunner(capture, cascadeContent);
                break;


            case Mode.servosort:
                runner = new ServoSorter(capture, options);
                break;

            default:
                throw KrakenException.Create("Option mode {0} needs wiring up", options.Mode);
            }

            runner.Run();
        }
Example #8
0
        static void Main(string[] args)
        {
            var appData = ExecutionEnvironment.GetApplicationMetadata();

            Log.Info(appData);

            _consoleOptions = new ConsoleOptions(args);

            if (_consoleOptions.ShowHelp)
            {
                Console.WriteLine("Options:");
                _consoleOptions.OptionSet.WriteOptionDescriptions(Console.Out);
                return;
            }

            CapturePi.DoMatMagic("CreateCapture");

            var noCaptureGrabs = new[] { Mode.simple, Mode.pantiltjoy, Mode.ipReport };
            var i2cRequired    = new[] { Mode.pantiltface, Mode.pantiltjoy, Mode.pantiltcolour, Mode.pantiltmultimode };

            ICaptureGrab capture = null;

            if (!noCaptureGrabs.Contains(_consoleOptions.Mode))
            {
                var config = CaptureConfig.Parse(_consoleOptions.CaptureConfig);
                capture = BuildCaptureGrabber(config);
                Log.Info($"Requested capture {capture.RequestedConfig}");
            }

            IPanTiltMechanism panTiltMech = null;
            IScreen           screen      = null;

            if (i2cRequired.Contains(_consoleOptions.Mode))
            {
                var pwmDeviceFactory = new Pca9685DeviceFactory();
                var pwmDevice        = pwmDeviceFactory.GetDevice(_consoleOptions.UseFakeDevice);
                panTiltMech = new PanTiltMechanism(pwmDevice);
                screen      = new ConsoleScreen();
                screen.Clear();
            }
            else
            {
                Log.Info("Pan Tilt is not required");
            }

            IRunner runner;

            Log.Info(_consoleOptions);
            switch (_consoleOptions.Mode)
            {
            case Mode.noop:
                var noopRunner = new NoopRunner(capture);
                noopRunner.ReportFramesPerSecond = true;
                runner = noopRunner;
                break;

            case Mode.simple: runner = new SimpleCv();
                break;

            case Mode.colourdetect:
                var colorDetector = new ColorDetectRunner(capture);
                if (_consoleOptions.HasColourSettings)
                {
                    colorDetector.Settings = _consoleOptions.ColourSettings;
                }
                runner = colorDetector;
                break;

            case Mode.haar:
                var relativePath    = $@"haarcascades{Path.DirectorySeparatorChar}haarcascade_frontalface_default.xml";
                var cascadeFilename = Path.Combine(appData.ExeFolder, relativePath);
                var cascadeContent  = File.ReadAllText(cascadeFilename);
                runner = new CascadeRunner(capture, cascadeContent);
                break;

            case Mode.servosort:
                runner = new ServoSorter(capture, _consoleOptions);
                break;

            case Mode.pantiltjoy:
                var joyController = new JoystickPanTiltController(panTiltMech);
                runner = new TimerRunner(joyController, screen);
                break;

            case Mode.pantiltface:
                var controllerF = new FaceTrackingPanTiltController(panTiltMech, capture.RequestedConfig);
                runner = new CameraBasedPanTiltRunner(panTiltMech, capture, controllerF, screen);
                break;

            case Mode.pantiltmultimode:
                var cameraHubProxy = new CameraHubProxy();
                cameraHubProxy.Connect();
                var remoteScreen     = new RemoteConsoleScreen(cameraHubProxy);
                var piServerClient   = new BsonPostImageTransmitter();
                var imageTransmitter = new RemoteImageSender(piServerClient, cameraHubProxy);

                cameraHubProxy.SettingsChanged += (sender, s) =>
                {
                    remoteScreen.Enabled     = s.EnableConsoleTransmit;
                    imageTransmitter.Enabled = s.EnableImageTransmit;
                };

                var controllerMultimode = new MultimodePanTiltController(panTiltMech, capture.RequestedConfig, remoteScreen, cameraHubProxy, imageTransmitter);

                var cameraBasedRunner = new CameraBasedPanTiltRunner(panTiltMech, capture, controllerMultimode, screen);
                runner = cameraBasedRunner;

                cameraHubProxy.UpdateCapture += (s, e) =>
                {
                    remoteScreen.WriteLine($"Changing capture settings to {e}");
                    var newGrabber = BuildCaptureGrabber(e);
                    cameraBasedRunner.UpdateCaptureGrabber(newGrabber);
                };
                break;

            case Mode.pantiltcolour:
                var controllerC = new ColourTrackingPanTiltController(panTiltMech, capture.RequestedConfig);
                if (_consoleOptions.HasColourSettings)
                {
                    controllerC.Settings = _consoleOptions.ColourSettings;
                }
                else
                {
                    throw KrakenException.Create("Colour settings not found");
                }
                runner = new CameraBasedPanTiltRunner(panTiltMech, capture, controllerC, screen);
                break;

            case Mode.ipReport:
                var hub = new CameraHubProxy();
                runner = new IpReporter(hub);
                break;

            default:
                throw KrakenException.Create("Option mode {0} needs wiring up", _consoleOptions.Mode);
            }

            runner.Run();
        }
Example #9
0
        public ActionResult Index()
        {
            ViewBag.AppData = ExecutionEnvironment.GetApplicationMetadata();

            return(View());
        }