Пример #1
0
        public ILabel Get(IIdentifier id)
        {
            string filePath = _clientsPath + @"\$" + id.IdentifingCode.ToString() + @".txt";
            string name;

            using (TextReader tr = new StreamReader(filePath))
            {
                name = tr.ReadLine();
            }
            Label response = new Label(name, id);

            for (int photoCounter = 0; photoCounter < _numOfPhotoes; photoCounter++)
            {
                string    currrentPath = _imagesPath + @"\" + photoCounter.ToString() + "$" + id.IdentifingCode.ToString() + ".bmp";
                FaceImage currentImage = new FaceImage(new Bitmap(currrentPath))
                {
                    Id = id
                };
                response.AddImage(currentImage);
            }
            return(response);
        }
Пример #2
0
        public async Task <WisTResponse> RegisterAsync(RegistrationInfo userInfo)
        {
            WisTResponse response                = WisTResponse.Registered;
            var          rootPath                = _hostingEnvironemnt.ContentRootPath;
            var          detectConfig            = _configuration["FaceClassifierPath"];
            var          recognizeConfig         = _configuration["TransistRateCoefficient"];
            var          transistRateCoefficient = double.Parse(recognizeConfig, new NumberFormatInfo {
                NumberDecimalSeparator = "."
            });
            var pathToHaar = Path.Combine(rootPath, detectConfig);

            var images = new List <FaceImage>();
            var login  = new Label(userInfo.Login);

            try
            {
                using (var memoryStream = new MemoryStream())
                {
                    foreach (var onePhoto in userInfo.Photoes)
                    {
                        await onePhoto.CopyToAsync(memoryStream);

                        var image = new Bitmap(Image.FromStream(memoryStream));
                        login.AddImage(new FaceImage(image, pathToHaar));
                    }
                }
                _labelRepo.Add(login);
            }
            catch (UndetectedFaceException)
            {
                response = WisTResponse.NotDetectedFace;
                return(response);
            }


            //       _imgRepo.Add(images);

            return(response);
        }