예제 #1
0
        /// <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);
        }
예제 #2
0
        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());
        }
예제 #3
0
        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();
            }
        }
예제 #4
0
 public void RemoveStream(ProcessableVideoSource source, bool removeFromProcessor = false)
 {
     if (streamServers.TryRemove(source, out var server))
     {
         server.Stop();
     }
     if (removeFromProcessor)
     {
         Processor.RemoveSource(source);
     }
 }
예제 #5
0
 public static void RemoveStream(ProcessableVideoSource source)
 {
     streamServers.TryRemove(source, out var server);
     server.Stop();
     Processor.RemoveSource(source);
 }