private static void ReadVideo() { // Opens MP4 file (ffmpeg is probably needed) var capture = new VideoCapture("Videos/cube_003.avi"); int sleepTime = (int)Math.Round(1000 / capture.Fps); using (var window = new Window("capture")) { using (var image = new Mat()) // Frame image buffer { // When the movie playback reaches end, Mat.data becomes NULL. while (true) { capture.Read(image); // same as cvQueryFrame if (image.Empty()) { break; } src = ImageUtil.GetCopy(image); grey = image.CvtColor(ColorConversionCodes.BGR2GRAY); tresh = GetTresh(); //window.ShowImage(tresh); var corners = FaceDetector.GetFaceCorners(src, tresh, window); if (corners != null && !corners.Rotated) { var face = FaceExtractor.Extract(src, corners); if (FaceUniquenessDetector.IsUnique(face)) { var bitmap = OpenCvSharp.Extensions.BitmapConverter.ToBitmap(face); bitmap.Save("Results\\face" + Guid.NewGuid() + ".png", ImageFormat.Png); var colors = ColorsExtractor.Extract(face); var t = colors.GetColor("0-2"); } } var k = Cv2.WaitKey(sleepTime); if (k == 27) { break; } } } } }
private static void Init() { tresh = GetTresh(); Cv2.ImShow("dst", tresh); FaceDetector.GetFaceCorners(src, tresh); }