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); }
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); }
public static CaptureFactory getInstance() { if (instance == null) { instance = new CaptureFactory(); } return instance; }
private void ConfigureCaptureSession() { if (!LayoutConfiguration.ShowsCameraItem) { return; } _captureSession = CaptureFactory.Create(GetCameraCell, Delegate, CaptureSettings.CameraMode); _captureSession.Prepare( GetCaptureVideoOrientation(UIApplication.SharedApplication.StatusBarOrientation)); _cameraCollectionViewCellDelegate = new CameraCollectionViewCellDelegate(GetCameraCell, _captureSession, CaptureSettings); }
protected MaxReason GetCaptures( Match match, int groupNumber, Func <string, bool>?predicate, List <Capture> captures) { int maxMatchesInFile = MaxMatchesInFile; int maxTotalMatches = MaxTotalMatches; int count = 0; if (maxMatchesInFile > 0) { if (maxTotalMatches > 0) { maxTotalMatches -= Telemetry.MatchCount; count = Math.Min(maxMatchesInFile, maxTotalMatches); } else { count = maxMatchesInFile; } } else if (maxTotalMatches > 0) { maxTotalMatches -= Telemetry.MatchCount; count = maxTotalMatches; } Debug.Assert(count >= 0, count.ToString()); MaxReason maxReason = CaptureFactory.GetCaptures( ref captures, match, groupNumber, count, predicate, CancellationToken); if ((maxReason == MaxReason.CountEqualsMax || maxReason == MaxReason.CountExceedsMax) && maxTotalMatches > 0 && (maxMatchesInFile == 0 || maxTotalMatches <= maxMatchesInFile)) { TerminationReason = FileSystem.TerminationReason.MaxReached; } return(maxReason); }
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 }
public Form1() { InitializeComponent(); // JPEG http://pasteldth.dyndns.org/cgi-bin/net_jpeg.cgi?ch=2 // MJPEG http://64.122.208.241:8000/axis-cgi/mjpg/video.cgi?resolution=320x240 var captureFactory = new CaptureFactory(); captureFactory.CaptureType = Enums.StreamType.Jpeg; capture = captureFactory.Create(); capture.NewFrame += capture_NewFrame; var config = new CaptureConfigs(); config.Source = @"http://pasteldth.dyndns.org/cgi-bin/net_jpeg.cgi?ch=2"; config.Username = "******"; config.Password = "******"; config.FrameInterval = 0; capture.Configs = config; }
/// <summary> /// This method starts capture process for microphone and loopback. /// </summary> /// <param name="socketUri">websocket uri of the audio gateway</param> /// <param name="conversationId">the conversation identifier</param> /// <param name="debugMode">enable or disable the debug mode</param> /// <returns></returns> #pragma warning restore CA1303 // Do not pass literals as localized parameters static async Task StartCaptureAsync(Uri socketUri, string conversationId, bool debugMode) { loopback = new CaptureFactory() { SocketUri = socketUri, DeviceType = DeviceType.Loopback, ConversationId = conversationId }; await loopback.InitializeAsync(debugMode).ConfigureAwait(false); microphone = new CaptureFactory() { SocketUri = socketUri, DeviceType = DeviceType.Microphone, ConversationId = conversationId }; await microphone.InitializeAsync(debugMode).ConfigureAwait(false); loopback.StartRecording(); microphone.StartRecording(); captureStopped = false; }
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(); }
private List <TextSpan> GetFilteredSpans(List <Capture> groups, CancellationToken cancellationToken) { ImmutableArray <TextSpan> .Builder?allSpans = null; foreach (Capture group in groups) { foreach (Filter filter in SpellcheckState.Filters) { Match?match = filter.Match(group.Value); if (match != null) { var captures = new List <Capture>(); MaxReason _ = CaptureFactory.GetCaptures( ref captures, match, filter.GroupNumber, count: 0, filter.Predicate, cancellationToken); if (allSpans == null) { allSpans = ImmutableArray.CreateBuilder <TextSpan>(); } foreach (Capture capture in captures) { allSpans.Add(new TextSpan(capture.Index, capture.Length)); } } } } if (allSpans == null) { return(new List <TextSpan>()); } allSpans.Sort((x, y) => { int diff = x.Start.CompareTo(y.Start); return((diff != 0) ? diff : -x.Length.CompareTo(y.Length)); }); TextSpan span = allSpans[0]; var spans = new List <TextSpan>() { span }; for (int i = 1; i < allSpans.Count; i++) { TextSpan span2 = allSpans[i]; if (span.Start == span2.Start) { continue; } if (span2.Start <= span.End + 1) { span = TextSpan.FromBounds(span.Start, span2.End); spans[^ 1] = span;