public void ReadVideo(string fileName) { Init(); _videoProcessType = true; if (!File.Exists(fileName)) { throw new FileNotFoundException("Archivo no encontrado.", fileName); } var videoReader = new VideoReader(fileName); var frame = videoReader.ReadVideoFrame(); NumeroImagenActual++; TotalImagenes = (int)videoReader.FrameCount; _facialEmotionRecognition = new FacialEmotionRecognition(frame); while (frame != null && !_stop) { if (!_pause) { frame = videoReader.ReadVideoFrame(); NumeroImagenActual++; if (frame == null) { continue; } ProcessImage(frame); } } videoReader.Close(); }
public void ReadImages(string path) { Init(); _videoProcessType = false; //var path = @"C:\Users\Newton\Desktop\CK\cohn-kanade\S010\006"; var files = Directory.GetFiles(path); if (files.Count() == 0) { throw new ArgumentException("Directorio no contiene imágenes."); } TotalImagenes = files.Count(); var frame = (Bitmap)Image.FromFile(files.First()); NumeroImagenActual++; _facialEmotionRecognition = new FacialEmotionRecognition(frame); foreach (var file in files.Skip(1)) { if (_stop) { break; } while (_pause) { Thread.Sleep(100); } frame = (Bitmap)Image.FromFile(file); NumeroImagenActual++; ProcessImage(frame); } }