private void OnImageDone(object o, Gst.GLib.SignalArgs args)
        {
            pipeline.SetState (Gst.State.Null);

            Emgu.CV.Image <Bgr, byte> sourceImage =
            new Emgu.CV.Image<Bgr, byte> ("snapshot.png");

            // Image conversion
            ImageProcessor processor = new ImageProcessor (sourceImage);

            // Face detection
            var detector = new FaceDetector ("/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml",
            processor.NormalizedImage);

            Image<Gray, byte> grayFace = processor.GrayscaleImage;

            System.Drawing.Rectangle rect = new System.Drawing.Rectangle ();
            if (detector.processImage (grayFace, out rect)) {
                Title = "Face found";
                Photo = grayFace.GetSubRect(rect);
                //PreviewResult();
            } else {
                Title = "Face not found";
            }
        }
Exemple #2
0
        private void OnImageDone(object o, Gst.GLib.SignalArgs args)
        {
            Emgu.CV.Image <Bgr, byte> sourceImage =
            new Emgu.CV.Image<Bgr, byte> ("snapshot.png");

            // Image conversion
            ImageProcessor processor = new ImageProcessor (sourceImage);

            // Face detection
            var detector = new FaceDetector ("/usr/local/share/OpenCV/haarcascades/haarcascade_frontalface_alt2.xml",
            processor.NormalizedImage);

            Image<Gray, byte> drawedFace = processor.GrayscaleImage;

            System.Drawing.Rectangle rect = new System.Drawing.Rectangle();
            if (detector.processImage (drawedFace, out rect)) {
                Title = "Лицо найдено. Данные отправляются на сервер";
                var binding = new BasicHttpBinding ();
                var address = new EndpointAddress ("http://" + entryHost.Text + ":" + entryPort.Text);
                client = new CommandClient (binding, address);
                Console.WriteLine (client.authenticate (UserInfoManager.SerializeImage (processor.NormalizedImage.GetSubRect(rect).Clone())));
            //	Console.WriteLine (client.executeCommand ("dmesg", ""));

            } else {
                Title = "В видоискателе нет лица";
                authButton.Sensitive = true;
            }
            /*
            using (Image<Bgr, byte> img = new Image<Bgr, byte>(400, 200, new Bgr(255, 0, 0))) {
            MCvFont f = new MCvFont(Emgu.CV.CvEnum.FONT.CV_FONT_HERSHEY_COMPLEX, 1.0, 1.0);
            Emgu.CV.CvInvoke.cvNamedWindow("w1");
            CvInvoke.cvShowImage("w1", img.Ptr);
            CvInvoke.cvWaitKey (0);
            //Destory the window
            CvInvoke.cvDestroyWindow("w1");
            } */
        }