Exemplo n.º 1
0
        private void SetupCapture()
        {
            if (_capture != null)
            {
                _capture.Dispose();
            }

            var request = new CaptureRequest
            {
                Device        = CaptureDevice.Usb
                , CameraIndex = (int)spinEditCameraIndex.Value
            };

            request.Config = HarvestFormCaptureConfig();

            if (radFile.Checked)
            {
                request.File = _videoFileSource;
            }

            //var captureDevice = CaptureDevice.Pi;
            if (EnvironmentService.IsUnix)
            {
                request.Device = CaptureDevice.Pi;
            }

            CapturePi.DoMatMagic("CreateCapture");

            _capture = CaptureFactory.GetCapture(request);

            AssignCaptureToConsumers(_capture);
            SetupFramerateTracking(_capture);

            tabControlMain_SelectedIndexChanged(null, null);
        }
Exemplo n.º 2
0
        private static ICaptureGrab BuildCaptureGrabber(CaptureConfig config = null)
        {
            var request = new CaptureRequest {
                Device = CaptureDevice.Usb
            };

            if (EnvironmentService.IsUnix)
            {
                request.Device = CaptureDevice.Pi;
            }

            if (config == null)
            {
                // Default capture
                request.Config = new CaptureConfig {
                    Resolution = new Resolution(160, 120), Framerate = 50, Monochrome = false
                };
            }

            var capture      = CaptureFactory.GetCapture(request);
            var actualConfig = capture.GetCaptureProperties();

            Log.Info($"Created capture: {actualConfig}");

            SafetyCheckRoi(_consoleOptions, actualConfig);
            return(capture);
        }
Exemplo n.º 3
0
        private void MainForm_Load(object sender, EventArgs e)
        {
            var captureDevice = CaptureDevice.Usb;

            //var captureDevice = CaptureDevice.Pi;
            if (Environment.OSVersion.Platform == PlatformID.Unix)
            {
                captureDevice = CaptureDevice.Pi;
            }
            _capture = CaptureFactory.GetCapture(captureDevice);
            //_capture = new CaptureFile(@"D:\Data\Documents\Pictures\2014\20140531_SwimmingLessons\MVI_8742.MOV");

            SetupCameraConsumers(_capture);
            SetupFramerateTracking(_capture);

//            SetCaptureProperties(); //access violation with logitech
        }
Exemplo n.º 4
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();
        }