Exemplo n.º 1
0
        public CustomerImageDto AddImageToCustomer(int[] pixels, int customerID, int width, int height)
        {
            Customer      customer = _repository.Load <Customer>(customerID);
            CustomerImage image    = new CustomerImage();

            var face = ImageProcessingUtils.DetectAndTrimFace(pixels, new Size(width, height), new Size(80, 80), HaarCascadeLocation);

            if (face == null)
            {
                return(null);
            }

            var equalized = ImageProcessingUtils.EqualizeHist(face);

            image.Customer = customer;

            image.Data = equalized.Bytes;
            image.Date = DateTime.Now;


            using (TransactionScope scope = new TransactionScope())
            {
                _repository.Save <CustomerImage>(image);
                scope.Complete();
            }

            return(new CustomerImageDto()
            {
                Id = image.Id, Data = equalized.Bytes
            });
        }
Exemplo n.º 2
0
        public String RecognizeCustomer(int[] pixels, int width, int height)
        {
            var face = ImageProcessingUtils.DetectAndTrimFace(pixels, new Size(width, height), new Size(80, 80), HaarCascadeLocation);

            //if no or more than one face was presented in the picture
            if (face == null)
            {
                return(null);
            }

            var equalized  = ImageProcessingUtils.EqualizeHist(face);
            var recognizer = CreateRecognizer(0.001, EIGEN_DISTANCE_THRESHOLD);

            if (recognizer == null)
            {
                return(null);
            }

            return(recognizer.Recognize(equalized));
        }