Ejemplo n.º 1
0
        private void btnStartStop_Click(object sender, EventArgs e)
        {
            if (_capture == null)
            {
                SetupCapture();
            }
            if (_capture != null)
            {
                if (CameraCaptureInProgress)
                {
                    //stop the capture
                    btnStartStop.Text = "Start Capture";
                    _capture.Dispose();
                    _capture = null;
                }
                else
                {
                    btnStartStop.Text = "Stop";
                    _capture.Start();
                    toolStripLabelSettings.Text = _capture.GetCaptureProperties().ToString();
                }

                CameraCaptureInProgress = !CameraCaptureInProgress;
            }
        }
Ejemplo n.º 2
0
        public CameraBasedPanTiltRunner(
            IPanTiltMechanism panTiltMech
            , ICaptureGrab captureGrabber
            , IController<CameraPanTiltProcessOutput> controller
            , IScreen screen)
            : base(panTiltMech)
        {
            _controller = controller;

            Screen = screen;

            FpsTracker = new FpsTracker();
            FpsTracker.ReportEveryNthFrame = 2;
            FpsTracker.ReportFrames = s => Screen.WriteLine(s);

            CameraCapture = captureGrabber;
            CameraCapture.ImageGrabbed += InternalImageGrabbedHandler;

            CaptureConfig = captureGrabber.GetCaptureProperties();
        }
Ejemplo n.º 3
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();
        }