public User RecognizeFace(Image<Gray, byte> face)
        {
            using (var context = new FaceRecognitionContext())
            {
                var faces = new List<Image<Gray, byte>>();
                var ids = new List<string>();

                foreach (var user in context.Users)
                {
                    var reconogizedFace = new Image<Gray, byte>(user.Face.GetBitmap());
                    var id = user.Id.ToString(CultureInfo.InvariantCulture);

                    faces.Add(reconogizedFace);
                    ids.Add(id);
                }

                if (ids.Any())
                {
                    var termCrit = new MCvTermCriteria(ids.Count(), 0.001);
                    var recognizedFaces = new EigenObjectRecognizer(faces.ToArray(), ids.ToArray(), 2500, ref termCrit);

                    var label = recognizedFaces.Recognize(face);

                    if (!String.IsNullOrEmpty(label))
                    {
                        var id = int.Parse(label);
                        return context.Users.SingleOrDefault(x => x.Id == id);        
                    }

                    
                }

                return null;
            }
        }
        public void SaveNewDetectedFace(string name, Image<Gray, byte> detectedFace)
        {
            using (var context = new FaceRecognitionContext())
            {
                byte[] pixelData;
                using(var ms = new MemoryStream())
        {
            detectedFace.Bitmap.Save(ms, ImageFormat.Bmp);
            pixelData = ms.ToArray();
        }
                
                var recognizedFace = new RecognizedFace
                                         {
                                             Height = detectedFace.Height,
                                             Width = detectedFace.Width,
                                             PixelData = pixelData
                                         };
                var user = new User
                               {
                                   Face = recognizedFace,
                                   NickName = name
                               };

                context.Users.Add(user);
                context.SaveChanges();
            }
        }