/// <summary> /// Enables the input of the webcam /// </summary> public static bool EnableWebcam(string cameraUrl = null) { IVideoSource capture; try { if (cameraUrl == null) { capture = new VideoCaptureDevice( new FilterInfoCollection(FilterCategory.VideoInputDevice)[0].MonikerString); } else //assumes that it's a MJPEG stream, it's forms so whatever { capture = new MJPEGStream(cameraUrl); } source = new ProcessableVideoSource(capture); } catch (Exception e) { Console.WriteLine(e); MessageBox.Show(Messages.cameraNotFound); return(false); } processor = new FaceProcessor(source); processor.Start(); source.NewFrame += GetFrame; source.Start(); return(true); }
public async Task <(string url, string id)> AddStreamAsync(ProcessableVideoSource source) { var server = new MJPEGServer(source, start: true); streamServers[source] = server; await Processor.AddSourceAsync(source); return(server.Url, source.Id.ToString()); }
public MJPEGServer(ProcessableVideoSource source, int port = 0, bool start = false) { this.source = source; listener = new TcpListener(IPAddress.Any, port >= 0 ? port : 0); if (start) { Start(); } }
public void RemoveStream(ProcessableVideoSource source, bool removeFromProcessor = false) { if (streamServers.TryRemove(source, out var server)) { server.Stop(); } if (removeFromProcessor) { Processor.RemoveSource(source); } }
public static void RemoveStream(ProcessableVideoSource source) { streamServers.TryRemove(source, out var server); server.Stop(); Processor.RemoveSource(source); }