コード例 #1
0
 public Identification(Person person, double confidence, IdentifyResult identifyResult, DetectedFace face)
 {
     Person         = person;
     IdentifyResult = identifyResult;
     Face           = face;
     Confidence     = confidence;
 }
コード例 #2
0
        public async Task <ActionResult> Emotions()
        {
            var personGroupId = Request["PersonGroupId"];
            var model         = new IdentifyFacesModel();

            var groups = await FaceClient.ListPersonGroupsAsync();

            model.PersonGroups = groups.Select(g => new SelectListItem
            {
                Value = g.PersonGroupId,
                Text  = g.Name
            }).ToList();

            if (Request.HttpMethod == "GET")
            {
                return(View(model));
            }

            Face[]           faces   = new Face[] { };
            Guid[]           faceIds = new Guid[] { };
            IdentifyResult[] results = new IdentifyResult[] { };

            await RunOperationOnImage(async stream =>
            {
                var emotionsType = new[] { FaceAttributeType.Emotion };
                faces            = await FaceClient.DetectAsync(stream, returnFaceAttributes: emotionsType);
                faceIds          = faces.Select(f => f.FaceId).ToArray();

                if (faceIds.Length > 0)
                {
                    results = await FaceClient.IdentifyAsync(personGroupId, faceIds);
                }
            });

            if (faceIds.Length == 0)
            {
                model.Error = "No faces detected";
                return(View(model));
            }

            foreach (var result in results)
            {
                var identifiedFace = new IdentifiedFace();
                identifiedFace.Face = faces.FirstOrDefault(f => f.FaceId == result.FaceId);

                foreach (var candidate in result.Candidates)
                {
                    var person = await FaceClient.GetPersonAsync(personGroupId, candidate.PersonId);

                    identifiedFace.PersonCandidates.Add(person.PersonId, person.Name);
                }

                model.IdentifiedFaces.Add(identifiedFace);
                identifiedFace.Color = Settings.ImageSquareColors[model.IdentifiedFaces.Count];
            }

            model.ImageDump = GetInlineImageWithIdentifiedFaces(model.IdentifiedFaces);

            return(View(model));
        }
コード例 #3
0
ファイル: Identification.cs プロジェクト: dlineros/finger
        /// <summary>
        /// Handler for when a fingerprint is captured.
        /// </summary>
        /// <param name="captureResult">contains info and data on the fingerprint capture</param>
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                // Check capture quality and throw an error if bad.
                if (!_sender.CheckCaptureResult(captureResult))
                {
                    return;
                }

                SendMessage(Action.SendMessage, "A finger was captured.");

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                if (count == 0)
                {
                    rightIndex = resultConversion.Data;
                    count     += 1;
                    SendMessage(Action.SendMessage, "Now place your right thumb on the reader.");
                }
                else if (count == 1)
                {
                    rightThumb = resultConversion.Data;
                    count     += 1;
                    SendMessage(Action.SendMessage, "Now place any finger on the reader.");
                }
                else if (count == 2)
                {
                    anyFinger = resultConversion.Data;
                    Fmd[] fmds = new Fmd[2];
                    fmds[0] = rightIndex;
                    fmds[1] = rightThumb;

                    // See the SDK documentation for an explanation on threshold scores.
                    int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                    IdentifyResult identifyResult = Comparison.Identify(anyFinger, 0, fmds, thresholdScore, 2);
                    if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        _sender.Reset = true;
                        throw new Exception(identifyResult.ResultCode.ToString());
                    }

                    SendMessage(Action.SendMessage, "Identification resulted in the following number of matches: " + identifyResult.Indexes.Length.ToString());
                    SendMessage(Action.SendMessage, "Place your right index finger on the reader.");
                    count = 0;
                }
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, "Error:  " + ex.Message);
            }
        }
コード例 #4
0
 public Identification(string name, double confidence, IdentifyResult identifyResult, DetectedFace face)
 {
     Person         = new Person();
     Person.Name    = name;
     IdentifyResult = identifyResult;
     Face           = face;
     Confidence     = confidence;
 }
コード例 #5
0
        private void OnCaptured(CaptureResult captureResult)
        {
            bool existio = false;

            try
            {
                if (!Clases.HuellaDigital.CheckCaptureResult(captureResult))
                {
                    return;
                }

                ////Creamos el bitmap para el PictureBox
                //foreach (Fid.Fiv fiv in captureResult.Data.Views)
                //{
                //    SendMessage(Action.SendBitmap, Clases.HuellaDigital.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                //}

                //Guardamos la variable de la huella
                res = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    Clases.HuellaDigital.Reset = true;
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                Fmd[] fmds = new Fmd[2];

                foreach (int k in Clases.HuellaDigital.Fmds.Keys)
                {
                    fmds[0] = Clases.HuellaDigital.Fmds[k];
                    int probabilidad = DPFJ_PROBABILITY_ONE * 1 / 100000;

                    IdentifyResult ideRes = Comparison.Identify(res.Data, 0, fmds, probabilidad, Clases.HuellaDigital.Fmds.Count + 1);

                    if (ideRes.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        Clases.HuellaDigital.Reset = true;
                        throw new Exception(ideRes.ResultCode.ToString());
                    }
                    if (ideRes.Indexes.Length > 0)
                    {
                        SendMessage(Action.SendOK, k.ToString());
                        existio = true;
                        break;
                    }
                }
                if (!existio)
                {
                    SendMessage(Action.SendMessage, "La huella no coincide con alguna del registro\n");
                }
            }
            catch (Exception ex)
            {
                //Mostramos un MessageBox con el mensaje de error
                SendMessage(Action.SendMessage, ex.Message);
            }
        }
        private string ExtractCandidates(IdentifyResult person)
        {
            string candidateString = $"Possible candidates for {person.FaceId}:\n";
            var    candidates      = person.Candidates;

            foreach (var candidate in candidates)
            {
                candidateString += "> " + candidate.PersonId + " with confidence " + candidate.Confidence + "\n";
            }

            return(candidateString);
        }
コード例 #7
0
        public async Task <List <FullPersonDto> > RecognizeFullPersonsAsync(Face[] faces, string imagePath)
        {
            var selectedFaces = faces.Take(10).ToList();

            List <FullPersonDto>   persons           = new List <FullPersonDto>();
            IList <IdentifyResult> identifyResults   = new List <IdentifyResult>();
            IEnumerable <Person>   recognizedPersons = new List <Person>();

            try
            {
                identifyResults = (await _faceServiceClient.IdentifyAsync(Global.OxfordPersonGroupId, selectedFaces.Select(f => f.FaceId).ToArray())).ToList();
                IList <Guid> candidatesId = identifyResults.Where(i => i.Candidates.Any()).Select(i => i.Candidates[0].PersonId).ToList();
                recognizedPersons = _unit.PersonRepository.GetPersonsByCandidateIds(candidatesId);
            }
            catch (FaceAPIException e)
            {
                LogManager.GetLogger(GetType()).Info("Error during recognition", e);
            }

            foreach (Face face in selectedFaces)
            {
                Person         person         = null;
                IdentifyResult identifyResult = identifyResults.FirstOrDefault(i => i.FaceId == face.FaceId);

                if (identifyResult != null && identifyResult.Candidates.Any())
                {
                    person = recognizedPersons.FirstOrDefault(p => p.PersonApiId == identifyResult.Candidates[0].PersonId);
                }

                EmotionScores emotionTask = await ProcessRecognitionItemPicture(imagePath, face);

                persons.Add(new FullPersonDto
                {
                    PersonId  = face.FaceId,
                    FirstName = person.FirstName,
                    Age       = face.FaceAttributes.Age,
                    Gender    = face.FaceAttributes.Gender,
                    Beard     = face.FaceAttributes.FacialHair.Beard,
                    Glasses   = face.FaceAttributes.Glasses,
                    Mustache  = face.FaceAttributes.FacialHair.Moustache,
                    Anger     = emotionTask.Anger,
                    Contempt  = emotionTask.Contempt,
                    Disgust   = emotionTask.Disgust,
                    Fear      = emotionTask.Fear,
                    Happiness = emotionTask.Happiness,
                    Neutral   = emotionTask.Neutral,
                    Sadness   = emotionTask.Sadness,
                    Surprise  = emotionTask.Surprise
                });
            }

            return(persons);
        }
コード例 #8
0
        void reader_On_Captured(CaptureResult capResult)
        {
            if (capResult.Quality == Constants.CaptureQuality.DP_QUALITY_GOOD)
            {
                DataResult <Fmd> fmdResult = FeatureExtraction.CreateFmdFromFid(capResult.Data, Constants.Formats.Fmd.DP_VERIFICATION);
                //If successfully extracted fmd then assign fmd
                if (fmdResult.ResultCode == Constants.ResultCode.DP_SUCCESS)
                {
                    fmd = fmdResult.Data;
                    // Get view bytes to create bitmap.
                    foreach (Fid.Fiv fiv in capResult.Data.Views)
                    {
                        UpdateVerifyMessage("Fingerprint Captured", CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                        break;
                    }
                }
                else
                {
                    UpdateVerifyMessage("Could not successfully create a verification FMD", null);
                }

                //Perform indentification of fmd of captured sample against enrolledFmdList
                IdentifyResult vResult = Comparison.Identify(fmd, 0, enrolledFmdList, 21474, 5);

                //If number of matches returned by IdentificationResult are greater than 0 then user is authorized
                if (vResult.ResultCode == Constants.ResultCode.DP_SUCCESS)
                {
                    if (vResult.Indexes.Length > 0)
                    {
                        UpdateVerifyMessage("User Authorized", null);
                    }
                    else
                    {
                        UpdateVerifyMessage("User Unauthorized", null);
                    }
                }
                else
                {
                    UpdateVerifyMessage("Error occured on verfication.", null);
                }
            }
            else
            {
                UpdateVerifyMessage("Please swipe finger again", null);
            }
        }
コード例 #9
0
        public async Task <IEnumerable <FaceDetectionResult> > DetectFacesAsync(ImageRequest request)
        {
            try
            {
                // .NET の FaceAPI を呼ぶためのクラスを生成
                var client = new FaceServiceClient(subscriptionKey: Secrets.CongnitiveServiceFaceApiKey, apiRoot: Consts.CognitiveServiceFaceApiEndPoint);

                // DetectAsync で、画像のどこに顔があって、その顔は何歳か、という情報を取得している
                var results = await client.DetectAsync(imageStream : new MemoryStream(request.Image), returnFaceAttributes : new[]
                {
                    FaceAttributeType.Age,
                });

                var personListId = await this.PersonListIdRepository.GetIdAsync();

                // 取得した顔が誰の顔かを認識している
                var identifyResults = (await client.IdentifyAsync(personListId, results.Select(x => x.FaceId).ToArray()))
                                      .ToDictionary(x => x.FaceId);

                var l = new List <FaceDetectionResult>();
                foreach (var r in results)
                {
                    IdentifyResult identifyResult = null;
                    identifyResults.TryGetValue(r.FaceId, out identifyResult);
                    var faceDetectionResult = new FaceDetectionResult
                    {
                        FaceId    = identifyResult?.Candidates.FirstOrDefault()?.PersonId.ToString() ?? new Guid().ToString(),
                        Age       = (int)r.FaceAttributes.Age,
                        Rectangle = new BusinessObjects.FaceRectangle
                        {
                            Top    = r.FaceRectangle.Top,
                            Left   = r.FaceRectangle.Left,
                            Width  = r.FaceRectangle.Width,
                            Height = r.FaceRectangle.Height,
                        }
                    };
                    l.Add(faceDetectionResult);
                }
                return(l);
            }
            catch (FaceAPIException)
            {
                return(Enumerable.Empty <FaceDetectionResult>());
            }
        }
コード例 #10
0
        private DetectedPerson GetPersonFromResult(IdentifyResult result, List <Person> persons)
        {
            if (result.Candidates.Count == 0)
            {
                return(null);
            }
            IdentifyCandidate candidate = result.Candidates
                                          .OrderByDescending(c => c.Confidence)
                                          .First();

            Person person = persons.FirstOrDefault(p => p.PersonId == candidate.PersonId);

            return(person == null ? null : new DetectedPerson()
            {
                Name = person.Name,
                Confidence = candidate.Confidence,
            });
        }
        private bool isFingerprintDataExist(Fmd fingerprint)
        {
            // See the SDK documentation for an explanation on threshold scores.
            int            thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;
            IdentifyResult identifyResult = Comparison.Identify(fingerprint, 0, adminsFingerprintData.ToArray(), thresholdScore, adminsFingerprintData.Count);

            if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                throw new Exception(identifyResult.ResultCode.ToString());
            }

            if (identifyResult.Indexes.Length > 0)
            {
                return(true);
            }

            return(false);
        }
コード例 #12
0
        //async void AssociatedObject_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        //{
        //    MapView mapView = sender as MapView;
        //    var screenPoint = e.GetPosition(mapView);

        //    // Convert the screen point to a point in map coordinates
        //    var mapPoint = mapView.ScreenToLocation(screenPoint);

        //    // get the FeatureLayer
        //    FeatureLayer featureLayer = mapView.Map.Layers[1] as FeatureLayer;
        //    // Get the FeatureTable from the FeatureLayer.
        //    Esri.ArcGISRuntime.Data.FeatureTable featureTable = featureLayer.FeatureTable;

        //    // Translate the MapPoint into Microsoft Point object.
        //    System.Windows.Point windowsPoint = mapView.LocationToScreen(mapPoint);
        //    // get the Row IDs of the features that are hit
        //    long[] featureLayerRowIDs = await featureLayer.HitTestAsync(mapView, windowsPoint);

        //    if (featureLayerRowIDs.Length == 1)
        //    {

        //        // Cause the features in the FeatureLayer to highlight (cyan) in the Map.
        //        featureLayer.SelectFeatures(featureLayerRowIDs);

        //        // Perform a Query on the FeatureLayer.FeatureTable using the ObjectID of the feature tapped/clicked on in the map. Actually it is a List of ObjectID values
        //        // but since we are trying for an Identify type of operation we really only have one ObjectID in the list.
        //        IEnumerable<GeodatabaseFeature> geoDatabaseFeature = (IEnumerable<GeodatabaseFeature>)await featureTable.QueryAsync(featureLayerRowIDs);

        //        foreach (Esri.ArcGISRuntime.Data.GeodatabaseFeature oneGeoDatabaseFeature in geoDatabaseFeature)
        //        {
        //            // Get the desired Field attribute values from the GeodatabaseFeature.
        //            System.Collections.Generic.IDictionary<string, object> attributes = oneGeoDatabaseFeature.Attributes;

        //            object postID = attributes["POST_ID"];

        //            // Construct a StringBuilder to hold the text from the Field attributes.
        //            System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder();
        //            stringBuilder.AppendLine("POST ID: " + postID.ToString());

        //            Messenger.Default.Send<NotificationMessage>(new NotificationMessage(stringBuilder.ToString()));
        //        }
        //    }
        //}

        async void AssociatedObject_MouseUp(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            MapView mapView     = sender as MapView;
            var     screenPoint = e.GetPosition(mapView);

            // Convert the screen point to a point in map coordinates
            var mapPoint = mapView.ScreenToLocation(screenPoint);

            // Create a new IdentifyTask pointing to the map service to identify (USA)
            var uri          = new Uri("http://sampleserver6.arcgisonline.com/arcgis/rest/services/USA/MapServer");
            var identifyTask = new IdentifyTask(uri);

            // Create variables to store identify parameter information
            //--current map extent (Envelope)
            var extent = mapView.Extent;
            //--tolerance, in pixels, for finding features
            var tolerance = 7;
            //--current height, in pixels, of the map control
            var height = (int)mapView.ActualHeight;
            //--current width, in pixels, of the map control
            var width = (int)mapView.ActualWidth;

            // Create a new IdentifyParameter; pass the variables above to the constructor
            var identifyParams = new Esri.ArcGISRuntime.Tasks.Query.IdentifyParameters(mapPoint, extent, tolerance, height, width);

            // Identify only the top most visible layer in the service
            identifyParams.LayerOption = LayerOption.Top;

            // Set the spatial reference to match with the map's
            identifyParams.SpatialReference = mapView.SpatialReference;

            // Execute the task and await the result
            IdentifyResult idResult = await identifyTask.ExecuteAsync(identifyParams);

            // See if a result was returned
            if (idResult != null && idResult.Results.Count > 0)
            {
                // Get the feature for the first result
                var topLayerFeature = idResult.Results[0].Feature as Graphic;

                // do something
            }
        }
コード例 #13
0
ファイル: ResultDetail.cs プロジェクト: Volador17/OilCute
        private void ShowIdGrid(IdentifyResult result, int num, int numOfId)
        {
            this.gridId.Rows.Clear();
            this.gridId.Visible  = true;
            this.gridFit.Visible = false;
            this.gridPLS.Visible = false;
            this.gridItg.Visible = false;
            if (result == null || result.Items.Length == 0)
            {
                return;
            }

            result = IdentifyModel.GetPredictValue(result, num, numOfId);
            int k = 1;

            foreach (var r in result.Items)
            {
                if (k > num)
                {
                    break;
                }
                var cell = new DataGridViewRowHeaderCell()
                {
                    Value = k.ToString()
                };
                var row = new MyDataIdRow()
                {
                    Item       = r,
                    HeaderCell = cell
                };
                row.CreateCells(this.gridId, r.Spec.UUID, r.TQ.ToString("F4"), r.SQ.ToString("F4"),
                                r.Result);
                this.gridId.Rows.Add(row);
                k++;
            }
        }
コード例 #14
0
        /// <summary>
        /// Open a reader and capture three fingers to identify with.
        /// </summary>
        private void IdentifyThread()
        {
            Constants.ResultCode result = Constants.ResultCode.DP_DEVICE_FAILURE;

            result = Sender.CurrentReader.Open(Constants.CapturePriority.DP_PRIORITY_COOPERATIVE);

            if (result != Constants.ResultCode.DP_SUCCESS)
            {
                MessageBox.Show("Error:  " + result);
                if (Sender.CurrentReader != null)
                {
                    Sender.CurrentReader.Dispose();
                    Sender.CurrentReader = null;
                }
                return;
            }

            Fmd fmd1 = null;
            Fmd fmd2 = null;
            Fmd fmd3 = null;

            SendMessage("Place your right index finger on the reader.");

            var count = 0;

            while (!reset)
            {
                Fid fid = null;

                if (!Sender.CaptureFinger(ref fid))
                {
                    break;
                }

                if (fid == null)
                {
                    continue;
                }

                SendMessage("A finger was captured.");

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(fid, Constants.Formats.Fmd.ANSI);

                if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    break;
                }

                if (count == 0)
                {
                    fmd1   = resultConversion.Data;
                    count += 1;
                    SendMessage("Now place your right thumb on the reader.");
                }
                else if (count == 1)
                {
                    fmd2   = resultConversion.Data;
                    count += 1;
                    SendMessage("Now place any finger on the reader.");
                }
                else if (count == 2)
                {
                    fmd3 = resultConversion.Data;
                    Fmd[] fmds = new Fmd[2];
                    fmds[0] = fmd1;
                    fmds[1] = fmd2;

                    // See the SDK documentation for an explanation on threshold scores.
                    int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                    IdentifyResult identifyResult = Comparison.Identify(fmd3, 0, fmds, thresholdScore, 2);

                    if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        break;
                    }

                    SendMessage("Identification resulted in the following number of matches: " + identifyResult.Indexes.Length.ToString());
                    SendMessage("Place your right index finger on the reader.");
                    count = 0;
                }
            }

            if (Sender.CurrentReader != null)
            {
                Sender.CurrentReader.Dispose();
            }
        }
コード例 #15
0
        /// <summary>
        /// Asynchronously recognize persons from oxford and database and return
        /// recognition results
        /// </summary>
        public async Task <List <RecognitionItem> > RecognizePersonsAsync(Face[] faces, string imagePath)
        {
            List <RecognitionItem> results = new List <RecognitionItem>();

            // Selects max 10 faces to make identification ordered by the size of rectangle of faces
            var selectedFaces = faces.Take(10).ToList();

            // Makes identification from microsoft oxford
            IList <IdentifyResult> identifyResults   = new List <IdentifyResult>();
            IEnumerable <Person>   recognizedPersons = new List <Person>();

            try
            {
                identifyResults = (await _faceServiceClient.IdentifyAsync(Global.OxfordPersonGroupId, selectedFaces.Select(f => f.FaceId).ToArray())).ToList();
                // Extracts guids of found candidates
                IList <Guid> candidatesId = identifyResults.Where(i => i.Candidates.Any()).Select(i => i.Candidates[0].PersonId).ToList();
                // Gets candidates' information in database
                recognizedPersons = _unit.PersonRepository.GetPersonsByCandidateIds(candidatesId);
            }
            catch (FaceAPIException e)
            {
                var persons = await _faceServiceClient.GetPersonsAsync(Global.OxfordPersonGroupId);

                LogManager.GetLogger(GetType()).Info("Error during recognition", e);
                if (persons.Any())
                {
                    return(results);
                }
            }

            int imageCounter = 0;

            foreach (Face face in selectedFaces)
            {
                Person person = null;

                // Gets identification result which match with current face
                IdentifyResult identifyResult = identifyResults.FirstOrDefault(i => i.FaceId == face.FaceId);
                double         confidence     = 1;

                if (identifyResult != null && identifyResult.Candidates.Any())
                {
                    person     = recognizedPersons.FirstOrDefault(p => p.PersonApiId == identifyResult.Candidates[0].PersonId);
                    confidence = identifyResult.Candidates[0].Confidence;
                }

                imageCounter++;

                results.Add(new RecognitionItem
                {
                    Face              = face,
                    Person            = person,
                    ImageUrl          = imagePath,
                    ImageCounter      = imageCounter,
                    Confidence        = confidence,
                    DateOfRecognition = DateTime.UtcNow,
                });
            }

            return(results);
        }
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                if (!fingerprintReader.CheckCaptureResult(captureResult))
                {
                    return;
                }
                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    fingerprintReader.CurrentReader.Reset();
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                // See the SDK documentation for an explanation on threshold scores.
                int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                if (isAdminLogin)
                {
                    IdentifyResult identifyResult = Comparison.Identify(resultConversion.Data, 0, AdminFingerPrints.ToArray(), thresholdScore, AdminFingerPrints.Count);
                    if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        throw new Exception(identifyResult.ResultCode.ToString());
                    }

                    if (identifyResult.Indexes.Length > 0)
                    {
                        fingerprintReader.CancelCaptureAndCloseReader(this.OnCaptured);
                        Application.Current.Dispatcher.Invoke((Action) delegate
                        {
                            AdminDashboard adminDashboard = new AdminDashboard();
                            adminDashboard.CurrentAdminId = AdminId.ElementAt(identifyResult.Indexes[0][0]);
                            adminDashboard.Show();
                            fingerprintReader.CurrentReader.Dispose();
                            fingerprintReader.CurrentReader = null;
                            this.Close();
                        });
                    }
                }
                else
                {
                    IdentifyResult identifyResult = Comparison.Identify(resultConversion.Data, 0, StudenFingerPrints.ToArray(), thresholdScore, StudenFingerPrints.Count);
                    if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        throw new Exception(identifyResult.ResultCode.ToString());
                    }

                    if (identifyResult.Indexes.Length > 0)
                    {
                        fingerprintReader.CancelCaptureAndCloseReader(this.OnCaptured);
                        Application.Current.Dispatcher.Invoke((Action) delegate
                        {
                            StudentDashboard studentDash = new StudentDashboard(StudentId.ElementAt(identifyResult.Indexes[0][0]).ToString(), database);
                            studentDash.Show();
                            fingerprintReader.CurrentReader.Dispose();
                            fingerprintReader.CurrentReader = null;
                            this.Close();
                        });
                    }
                }
            }
            catch (Exception)
            {
                Application.Current.Dispatcher.Invoke((Action) delegate
                {
                    ErrorHeader1.Text     = "Fingerprint device error";
                    ErrorContent1.Text    = "Error while capturing the fingerprint.";
                    DialogMessage1.IsOpen = true;
                });
            }
        }
コード例 #17
0
ファイル: MainWindow.xaml.cs プロジェクト: vjaindmi/exit0
        /// <summary> Function which submits a frame to the Face API. </summary>
        /// <param name="frame"> The video frame to submit. </param>
        /// <returns> A <see cref="Task{LiveCameraResult}"/> representing the asynchronous API call,
        ///     and containing the faces returned by the API. </returns>
        private async Task <LiveCameraResult> FacesAnalysisFunction(VideoFrame frame)
        {
            // Encode image.
            var jpg = frame.Image.ToMemoryStream(".jpg", s_jpegParams);
            // Submit image to API.
            var attrs = new List <FaceAttributeType> {
                FaceAttributeType.Age,
                FaceAttributeType.Gender, FaceAttributeType.HeadPose
            };

            try
            {
                Face[] faces = await _faceClient.DetectAsync(jpg, returnFaceAttributes : attrs);

                if (faces.Count() == 1)
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        InformationText.Visibility = Visibility.Visible;
                        InformationText.Text       = "One face detected. Identification in progress....";
                    });


                    _grabber.StopProcessingAsync();

                    //Hide the live stream
                    this.Dispatcher.Invoke(() =>
                    {
                        LeftImage.Visibility  = Visibility.Collapsed;
                        RightImage.Visibility = Visibility.Collapsed;
                    });

                    Guid[]           guids          = faces.Select(ff => ff.FaceId).ToArray();
                    IdentifyResult[] identifyResult = new IdentifyResult[] { };

                    await Task.Delay(2000);

                    identifyResult = await _faceClient.IdentifyAsync(GroupName, guids);

                    if (identifyResult.Any())
                    {
                        if (identifyResult.FirstOrDefault().Candidates.FirstOrDefault() != null)
                        {
                            if (identifyResult.FirstOrDefault().Candidates.FirstOrDefault().Confidence >= 0.5)
                            {
                                //TextToSpeech();
                                this.Dispatcher.Invoke(() =>
                                {
                                    InformationText.Visibility = Visibility.Visible;
                                    InformationText.Text       = listOfNames.ContainsKey(identifyResult.FirstOrDefault().Candidates.FirstOrDefault().PersonId.ToString()) ? "Face Identified !! Welcome, " +
                                                                 listOfNames[identifyResult.FirstOrDefault().Candidates.FirstOrDefault().PersonId.ToString()].UserName : "";
                                });
                                await Task.Delay(5000);

                                string target = "https://dminc.zoom.us/j/" + listOfNames[identifyResult.FirstOrDefault().Candidates.FirstOrDefault().PersonId.ToString()].ZoomId;
                                Process.Start(target);
                            }
                        }
                        else
                        {
                            this.Dispatcher.Invoke(() =>
                            {
                                InformationText.Visibility = Visibility.Visible;
                                InformationText.Text       = "Oops!! Your face could not be identified !! :(";
                            });
                        }
                    }
                }
                else if (faces.Count() > 1)
                {
                    //More than two faces detected
                    return(null);
                }
                else
                {
                    this.Dispatcher.Invoke(() =>
                    {
                        InformationText.Visibility = Visibility.Visible;
                        InformationText.Text       = "Oops!! Your face could not be identified !! :(";
                    });
                }

                return(new LiveCameraResult {
                    Faces = faces
                });
            }
            catch (Exception ex)
            {
                MessageArea.Text = ex.Message.ToString();
                return(null);
            }
            finally
            {
                _grabber.StopProcessingAsync();
            }
        }
コード例 #18
0
        private void identificationControl_OnIdentify(DPCtlUruNet.IdentificationControl IdentificationControl, IdentifyResult IdentificationResult)
        {
            if (IdentificationResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                if (IdentificationResult.Indexes == null)
                {
                    if (IdentificationResult.ResultCode == Constants.ResultCode.DP_INVALID_PARAMETER)
                    {
                        MessageBox.Show("Warning: Fake finger was detected.");
                    }
                    else if (IdentificationResult.ResultCode == Constants.ResultCode.DP_NO_DATA)
                    {
                        MessageBox.Show("Warning: No finger was detected.");
                    }
                    else
                    {
                        if (_sender.CurrentReader != null)
                        {
                            _sender.CurrentReader.Dispose();
                            _sender.CurrentReader = null;
                        }
                    }
                }
                else
                {
                    if (_sender.CurrentReader != null)
                    {
                        _sender.CurrentReader.Dispose();
                        _sender.CurrentReader = null;
                    }

                    MessageBox.Show("Error:  " + IdentificationResult.ResultCode);
                }
            }
            else
            {
                _sender.CurrentReader = IdentificationControl.Reader;
                txtMessage.Text       = txtMessage.Text + "OnIdentify:  " + (IdentificationResult.Indexes.Length.Equals(0) ? "No " : "One or more ") + "matches.  Try another finger.\r\n\r\n";
            }

            txtMessage.SelectionStart = txtMessage.TextLength;
            txtMessage.ScrollToCaret();
        }
コード例 #19
0
ファイル: IdentifyGridView.cs プロジェクト: Volador17/OilCute
        private void AddResult(IdentifyResult r, int num, int numOfId)
        {
            if (!this._inited)
            {
                this.Init();
            }
            if (r == null || num < 1)
            {
                return;
            }
            this._results.Add(r);
            if (!this._compShow)
            {
                var names = r.Components.Select(c => c.Name).ToArray();
                for (int i = 0; i < names.Length; i++)
                {
                    if (i < this._dColnum - 4 && this.Columns.Count > (4 + i))
                    {
                        this.Columns[4 + i].HeaderText = names[i];
                    }
                    else
                    {
                        this.Columns.Add(new DataGridViewTextBoxColumn()
                        {
                            Width      = 60,
                            HeaderText = names[i],
                            ReadOnly   = true,
                        });
                    }
                }
                this._compShow = true;
            }

            var rtmp = IdentifyModel.GetPredictValue(r, num, numOfId);

            var objs = new List <object>();

            objs.Add(rtmp.Spec.Name);
            objs.Add("");
            objs.Add("");
            objs.Add(rtmp.IsId);
            foreach (var c in rtmp.Components)
            {
                objs.Add(double.IsNaN(c.ActualValue) ? "" : c.ActualValue.ToString(string.Format("F{0}", c.Eps)));
            }
            TreeGridNode node;

            if (this.Nodes.Count <= (this._results.Count - 1) * 3)
            {
                node = this.Nodes.Add(objs.ToArray());
            }
            else
            {
                node = this.Nodes[(this._results.Count - 1) * 3];
                for (int i = 0; i < objs.Count; i++)
                {
                    if (node.Cells.Count > i)
                    {
                        node.Cells[i].Value = objs[i];
                    }
                }
            }
            for (int i = 0; i < num; i++)
            {
                if (rtmp.Items.Length > i)
                {
                    var row = new nodeRow(rtmp.Items[i]);
                    node.Nodes.Add(row);
                    row.Cells[0].Value = rtmp.Items[i].Spec.Name;
                    row.Cells[1].Value = rtmp.Items[i].TQ.ToString("F4");
                    row.Cells[2].Value = rtmp.Items[i].SQ.ToString("F4");
                    row.Cells[3].Value = rtmp.Items[i].Result ? "Yes" : "No";
                    var cidx = 4;
                    foreach (var c in rtmp.Items[i].Spec.Components)
                    {
                        row.Cells[cidx].Value = double.IsNaN(c.ActualValue) ? "" : c.ActualValue.ToString(string.Format("F{0}", c.Eps));
                        cidx++;
                    }
                }
            }

            //预测值
            objs = new List <object>();
            objs.Add("预测值");
            objs.Add("");
            objs.Add("");
            objs.Add("");
            foreach (var c in rtmp.Components)
            {
                objs.Add(double.IsNaN(c.PredictedValue) ? "" : c.PredictedValue.ToString(string.Format("F{0}", c.Eps)));
            }

            if (this.Nodes.Count <= (this._results.Count - 1) * 3 + 1)
            {
                this.Nodes.Add(objs.ToArray());
            }
            else
            {
                var tn = this.Nodes[(this._results.Count - 1) * 3 + 1];
                for (int i = 0; i < objs.Count; i++)
                {
                    if (tn.Cells.Count > i)
                    {
                        tn.Cells[i].Value = objs[i];
                    }
                }
            }

            //偏差
            objs = new List <object>();
            objs.Add("偏差");
            objs.Add("");
            objs.Add("");
            objs.Add("");
            if (rtmp.Components != null && rtmp.Components.Count > 0)
            {
                foreach (var c in rtmp.Components)
                {
                    objs.Add(double.IsNaN(c.Error) ? "" : c.Error.ToString(string.Format("F{0}", c.Eps)));
                }
            }
            if (this.Nodes.Count <= (this._results.Count - 1) * 3 + 2)
            {
                this.Nodes.Add(objs.ToArray());
            }
            else
            {
                var tn = this.Nodes[(this._results.Count - 1) * 3 + 2];
                for (int i = 0; i < objs.Count; i++)
                {
                    if (tn.Cells.Count > i)
                    {
                        tn.Cells[i].Value = objs[i];
                    }
                }
            }
        }
コード例 #20
0
        private void OnCaptured(CaptureResult result)
        {
            frmEncontrarDispositivo n = new frmEncontrarDispositivo();
            //if (n.conectado==false)
            //{
            //    DialogResult dialogoerror = globales.MessageBoxError("Ocurrio un error, no se detecta dispositivo", "Verificar", globales.menuPrincipal);
            //    return;
            //    dispo.Text = "DISPOSITIVO NO CONECTADO";
            //}

            DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(result.Data, Constants.Formats.Fmd.ANSI);

            if (result.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                //throw new Exception(result.ResultCode.ToString());
            }


            Fmd capturado = resultConversion.Data;

            try
            {
                string hexa = ByteArrayToString(capturado.Bytes);
            }
            catch
            {
                CheckForIllegalCrossThreadCalls = false;
                dispo.Text = "DISPOSITIVO NO CONECTADO";
                return;
            }

            //    string query = $"select jpp,num,huella from nominas_catalogos.maestro where huella is not null order by jpp,num";
            string query = "select jpp,num,huella from nominas_catalogos.maestro where huella is not null  and huella <>'' order by jpp,num";
            List <Dictionary <string, object> > resultado = globales.consulta(query);

            if (resultado.Count <= 0)
            {
                return;
            }


            string caaaa = Fmd.SerializeXml(capturado);
            Fmd    dese  = Fmd.DeserializeXml(caaaa);

            bool encontrado = true;

            foreach (Dictionary <string, object> item in resultado)
            {
                string      xmlStr = Convert.ToString(item["huella"]);
                XmlDocument xml    = new XmlDocument();
                xml.LoadXml(xmlStr);
                Fmd   fmd  = Fmd.DeserializeXml(xmlStr);
                Fmd[] fmds = new Fmd[1];
                fmds[0] = fmd;
                // fmds[1] = capturado;


                int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;

                CompareResult  resultadoAux   = Comparison.Compare(capturado, 0, fmd, 0);
                IdentifyResult identifyResult = Comparison.Identify(capturado, 0, fmds, thresholdScore, 2);

                if (resultadoAux.Score == 0)
                {
                    realizarMensaje(tipo_mensaje.success, $"{item["jpp"]} encontrado");


                    query     = $"select * from nominas_catalogos.maestro where huella is not null and jpp = '{item["jpp"]}' and num = {item["num"]} order by jpp,num";
                    resultado = globales.consulta(query);
                    if (resultado.Count != 0)
                    {
                        huellita = true;
                        rellenar(resultado[0]);
                    }
                    encontrado = true;
                    break;
                }
                else
                {
                    encontrado = false;
                }

                if (resultadoAux.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    realizarMensaje(tipo_mensaje.exclamation, "UPS, NO SE ENCUENTRA LA HUELLA EN LA BASE");
                    encontrado = true;
                    return;
                }
            }

            if (!encontrado)
            {
                realizarMensaje(tipo_mensaje.exclamation, "UPS, NO SE ENCUENTRA LA HUELLA EN LA BASE");
            }
        }
コード例 #21
0
 public IdentifyFaceResponse(IdentifyResult identifyResult)
 {
     _identifyResult = identifyResult;
 }
コード例 #22
0
        public async Task <ActionResult> Attributes()
        {
            var personGroupId = Request["PersonGroupId"];
            var model         = new IdentifyFacesModel();

            var groups = await FaceClient.ListPersonGroupsAsync();

            model.PersonGroups = groups.Select(g => new SelectListItem
            {
                Value = g.PersonGroupId,
                Text  = g.Name
            }).ToList();
            model.PersonGroups.Insert(0, new SelectListItem {
                Text = "", Value = ""
            });

            if (Request.HttpMethod == "GET")
            {
                return(View(model));
            }

            Face[]           faces   = new Face[] { };
            Guid[]           faceIds = new Guid[] { };
            IdentifyResult[] results = new IdentifyResult[] { };
            var faceAttributeTypes   = new[] {
                FaceAttributeType.Accessories, FaceAttributeType.Age, FaceAttributeType.Blur,
                FaceAttributeType.Exposure, FaceAttributeType.FacialHair, FaceAttributeType.Gender,
                FaceAttributeType.Glasses, FaceAttributeType.Hair, FaceAttributeType.HeadPose,
                FaceAttributeType.Makeup, FaceAttributeType.Noise, FaceAttributeType.Occlusion,
                FaceAttributeType.Smile
            };

            await RunOperationOnImage(async stream =>
            {
                faces   = await FaceClient.DetectAsync(stream, returnFaceAttributes: faceAttributeTypes);
                faceIds = faces.Select(f => f.FaceId).ToArray();

                if (faceIds.Length > 0 && !string.IsNullOrEmpty(personGroupId))
                {
                    results = await FaceClient.IdentifyAsync(personGroupId, faceIds);
                }
            });

            if (faceIds.Length == 0)
            {
                model.Error = "No faces detected";
                return(View(model));
            }

            if (!string.IsNullOrEmpty(personGroupId))
            {
                foreach (var result in results)
                {
                    var identifiedFace = new IdentifiedFace();
                    identifiedFace.Face = faces.FirstOrDefault(f => f.FaceId == result.FaceId);

                    foreach (var candidate in result.Candidates)
                    {
                        var person = await FaceClient.GetPersonAsync(personGroupId, candidate.PersonId);

                        identifiedFace.PersonCandidates.Add(person.PersonId, person.Name);
                    }

                    identifiedFace.Color = Settings.ImageSquareColors[model.IdentifiedFaces.Count];
                    model.IdentifiedFaces.Add(identifiedFace);
                }
            }
            else
            {
                foreach (var face in faces)
                {
                    var identifiedFace = new IdentifiedFace {
                        Face = face
                    };
                    model.IdentifiedFaces.Add(identifiedFace);

                    identifiedFace.Color = Settings.ImageSquareColors[model.IdentifiedFaces.Count];
                }
            }

            model.ImageDump = GetInlineImageWithIdentifiedFaces(model.IdentifiedFaces);

            return(View(model));
        }
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                if (!fingerprintReader.CheckCaptureResult(captureResult))
                {
                    return;
                }

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    fingerprintReader.CurrentReader.Reset();
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        richTextBox.Document.Blocks.Clear();
                        richTextBox.AppendText("\nError\nPlease try again.\nPlace your finger on the device.");
                    });
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                if (isFingerprintDataExist(resultConversion.Data))
                {
                    firstFinger  = null;
                    secondFinger = null;
                    MessageBox.Show("It seems that there's slightly the same fingerprint data as yours.\n\nPlease use your other fingers.", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        richTextBox.Document.Blocks.Clear();
                        richTextBox.AppendText("\nPlace any finger on the device.");
                    });
                }
                else
                {
                    if (firstFinger == null)
                    {
                        firstFinger = resultConversion.Data;
                        Application.Current.Dispatcher.Invoke((Action) delegate
                        {
                            richTextBox.Document.Blocks.Clear();
                            richTextBox.AppendText("\nFinger was captured\nNow Place the same finger on the device.");
                        });
                    }
                    else
                    {
                        if (secondFinger == null)
                        {
                            secondFinger = resultConversion.Data;
                            Fmd[] fmds = new Fmd[1];
                            fmds[0] = firstFinger;

                            // See the SDK documentation for an explanation on threshold scores.
                            int            thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;
                            IdentifyResult identifyResult = Comparison.Identify(secondFinger, 0, fmds, thresholdScore, 1);
                            if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                            {
                                throw new Exception(identifyResult.ResultCode.ToString());
                            }

                            if (identifyResult.Indexes.Length <= 0)
                            {
                                Application.Current.Dispatcher.Invoke((Action) delegate
                                {
                                    richTextBox.Document.Blocks.Clear();
                                    richTextBox.AppendText("\nFailed, first finger and second finger not matched.\nPlease try again, place any finger on the device.");
                                    firstFinger  = null;
                                    secondFinger = null;
                                });
                            }
                            else
                            {
                                Application.Current.Dispatcher.Invoke((Action) delegate
                                {
                                    richTextBox.Document.Blocks.Clear();
                                    richTextBox.AppendText("\nSuccess, please submit your registration now.");
                                    btn_submit.IsEnabled = true;
                                });
                                fingerprintReader.CancelCaptureAndCloseReader(this.OnCaptured);
                            }
                        }
                    }
                }
            } catch (Exception ex)
            {
                MessageBox.Show("Error while capturing the fingerprint.\nPlease try again later." + ex, "Error Fingerprint", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Dispatcher.Invoke((Action) delegate
                {
                    fingerprintReader.CurrentReader.Dispose();
                    fingerprintReader.CurrentReader = null;
                    this.Close();
                });
            }
        }
コード例 #24
0
        public async Task <ActionResult> Identify()
        {
            var personGroupId = Request["PersonGroupId"];
            var model         = new IdentifyFacesModel();

            var groups = await FaceClient.ListPersonGroupsAsync();

            model.PersonGroups = groups.Select(g => new SelectListItem
            {
                Value = g.PersonGroupId,
                Text  = g.Name
            }).ToList();

            if (Request.HttpMethod == "GET")
            {
                return(View(model));
            }

            try
            {
                Face[]           faces   = new Face[] { };
                Guid[]           faceIds = new Guid[] { };
                IdentifyResult[] results = new IdentifyResult[] { };

                await RunOperationOnImage(async stream =>
                {
                    faces   = await FaceClient.DetectAsync(stream);
                    faceIds = faces.Select(f => f.FaceId).ToArray();

                    if (faceIds.Count() > 0)
                    {
                        results = await FaceClient.IdentifyAsync(personGroupId, faceIds);
                    }
                });

                if (faceIds.Length == 0)
                {
                    model.Error = "No faces detected";
                    //return View("ConfirmationPage", model);
                }

                foreach (var result in results)
                {
                    var identifiedFace = new IdentifiedFace();
                    identifiedFace.Face = faces.FirstOrDefault(f => f.FaceId == result.FaceId);

                    foreach (var candidate in result.Candidates)
                    {
                        await RunOperationOnImage(async stream =>
                        {
                            var person = await FaceClient.GetPersonAsync(personGroupId, candidate.PersonId);
                            identifiedFace.PersonCandidates.Add(person.PersonId, person.Name);
                        });

                        // var person = await FaceClient.GetPersonAsync(personGroupId, candidate.PersonId);
                        // identifiedFace.PersonCandidates.Add(person.PersonId, person.Name);
                    }

                    identifiedFace.Color = Settings.ImageSquareColors[model.IdentifiedFaces.Count];

                    model.IdentifiedFaces.Add(identifiedFace);
                }
            }
            catch {
                model.Error = "No faces detected, Please try again";
            }
            model.ImageDump = GetInlineImageWithFaces(model.IdentifiedFaces.Select(x => x.Face));
            TempData.Add("MyTempData", model);
            return(RedirectToAction("ConfirmationPage"));
        }
コード例 #25
0
 public IdentifyUserResult(bool userDetected, IdentifyResult identifyResult)
 {
     UserDetected   = userDetected;
     IdentifyResult = identifyResult;
 }
コード例 #26
0
ファイル: IdentifyDlg.cs プロジェクト: jacsa/prison-mis
        void reader_On_Captured(CaptureResult result)
        {
            if (result.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                MessageBox.Show("Capture failed.");
                return;
            }

            Fid fid = result.Data;

            //Display captured image
            if (this.InvokeRequired)
            {
                this.BeginInvoke(new Function(delegate
                {
                    pbImage.Image = new Bitmap(Fid2Bitmap.CreateBitmap(result.Data.Views[0].Bytes, fid.Views[0].Width, fid.Views[0].Height), pbImage.Size);
                }));
            }

            //Extract pre-registration features
            DataResult <Fmd> fmdResult = FeatureExtraction.CreateFmdFromFid(result.Data, Constants.Formats.Fmd.DP_VERIFICATION);

            if (fmdResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                MessageBox.Show("Error extracting features from image.  Please try again");
                return;
            }
            else
            {
                fmd = fmdResult.Data;
            }

            // Lets identify the print

            // Perform indentification of fmd of captured sample against enrolledFmds for userid
            IdentifyResult iResult1 = Comparison.Identify(fmd, 0, HelperFunctions.GetAllFmd1s, 21474, 1);

            // If Identify was successful
            if (iResult1.ResultCode == Constants.ResultCode.DP_SUCCESS)
            {
                //If number of matches were greater than 0
                if (iResult1.Indexes.Length == 1)
                {
                    string[] usernames  = HelperFunctions.GetAllPrisonerIds;
                    string   prisonerId = usernames[iResult1.Indexes[0][0]];

                    string ip = (_serverIP == "(local)" ? "localhost" : _serverIP);

                    string url = string.Format("http://{0}/PMIS/Prisoner/Details?PrisonerId={1}", ip, prisonerId);

                    //if(browser == null)
                    //    browser = new WebBrowser();

                    //browser.Navigate(url, "_prs");
                    //browser.Document.Window.Open(url, "_prs", null, true);

                    //window.Open(url, "_prs", null, true);
                    System.Diagnostics.Process.Start(url);
                }
                else if (iResult1.Indexes.Length > 1)
                {
                    string ids = "";

                    string[] usernames = HelperFunctions.GetAllPrisonerIds;

                    for (int i = 0; i < iResult1.Indexes.Length; i++)
                    {
                        ids += usernames[iResult1.Indexes[i][0]] + ", ";
                    }

                    MessageBox.Show("Error: Multiple matches found. Prisoner IDs : {0}", ids);
                }
                else
                {
                    MessageBox.Show("Prisoner NOT found! Try again or enroll prisoner!");
                }
            }
            else
            {
                MessageBox.Show("Error : " + iResult1.ResultCode.ToString());
            }

            pbImage.Image = null;
        }
コード例 #27
0
        private void OnCaptured(CaptureResult captureResult)
        {
            try
            {
                if (!fingerprint.CheckCaptureResult(captureResult))
                {
                    return;
                }

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    fingerprint.CurrentReader.Reset();
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        TxtBlock_FingerprintMessage.Text = "Error. Please try again. Place your finger on the device.";
                    });
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                if (studentInfo.Firstfinger == null)
                {
                    studentInfo.Firstfinger = resultConversion.Data;
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        TxtBlock_FingerprintMessage.Text = "Finger was captured. Now Place the same finger on the device.";
                    });
                }
                else
                {
                    if (studentInfo.Lastfinger == null)
                    {
                        studentInfo.Lastfinger = resultConversion.Data;
                        Fmd[] fmds = new Fmd[1];
                        fmds[0] = studentInfo.Firstfinger;

                        // See the SDK documentation for an explanation on threshold scores.
                        int            thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;
                        IdentifyResult identifyResult = Comparison.Identify(studentInfo.Lastfinger, 0, fmds, thresholdScore, 1);
                        if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                        {
                            throw new Exception(identifyResult.ResultCode.ToString());
                        }

                        if (identifyResult.Indexes.Length <= 0)
                        {
                            Application.Current.Dispatcher.Invoke((Action) delegate
                            {
                                TxtBlock_FingerprintMessage.Text = "Failed, first finger and second finger not matched. Please try again, place any finger on the device.";
                                studentInfo.Firstfinger          = null;
                                studentInfo.Lastfinger           = null;
                            });
                        }
                        else
                        {
                            Application.Current.Dispatcher.Invoke((Action) delegate
                            {
                                SaveStudentToDatabase();
                                TxtBlock_FingerprintMessage.Text = "Success, your fingerprint data was saved. Please click the next button to finish.";
                                Btn_ProceedLast.IsEnabled        = true;
                                fingerprint.CancelCaptureAndCloseReader(this.OnCaptured);
                            });
                        }
                    }
                }
            } catch (Exception ex)
            {
                MessageBox.Show("Error while capturing the fingerprint.\nPlease try again later." + ex, "Error Fingerprint", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Dispatcher.Invoke((Action) delegate
                {
                    fingerprint.CurrentReader.Dispose();
                    fingerprint.CurrentReader = null;
                    this.Close();
                });
            }
        }
コード例 #28
0
        private async void Verification_OnIdentify(IdentificationControl IdentificationControl, IdentifyResult IdentificationResult)
        {
            if (IdentificationResult.Indexes != null && IdentificationResult.Indexes.Count() > 0)
            {
                await Task.Delay(6000);

                var ab = new absen {
                    PengaturanId = 1, PegawaiId = Pegawai.Id, Tanggal = DateTime.Now, JamMasuk = DateTime.Now.TimeOfDay
                };
                var absenCollection = ResourcesBase.GetMainWindowViewModel().AbsenCollection;
                absenCollection.OnChangeSource += AbsenCollection_OnChangeSource;
                absenCollection.Add(ab);


                this.Close();
            }
        }
コード例 #29
0
        private void OnCaptured(CaptureResult captureResult)
        {
            Application.Current.Dispatcher.Invoke((Action) delegate
            {
                Snackbar_Recorded.IsActive = false;
            });
            try
            {
                if (!fingerprintReader.CheckCaptureResult(captureResult))
                {
                    return;
                }

                DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
                if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    fingerprintReader.CurrentReader.Reset();
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        Snackbar_Recorded.IsActive = true;
                        SnackBar_Message.Text      = "Sorry, please try again.";
                    });
                    throw new Exception(captureResult.ResultCode.ToString());
                }

                // See the SDK documentation for an explanation on threshold scores.
                int            thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 100000;
                IdentifyResult identifyResult = Comparison.Identify(resultConversion.Data, 0, studentFmds.ToArray(), thresholdScore, studentFmds.Count);
                if (identifyResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    throw new Exception(identifyResult.ResultCode.ToString());
                }

                if (identifyResult.Indexes.Length > 0)
                {
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        string findStudentId = studentIds.ElementAt(identifyResult.Indexes[0][0]);
                        UpdateStudentInformation(findStudentId);
                        if (IsAttendedAlready(findStudentId))
                        {
                            SnackBar_Message.Text      = "Your attendance is already recorded.";
                            Snackbar_Recorded.IsActive = true;
                        }
                        else
                        {
                            if (SaveAttendancetoDatabase(findStudentId))
                            {
                                SnackBar_Message.Text      = "Successful, your attendance is recorded.";
                                Snackbar_Recorded.IsActive = true;
                                AttendedIds.AddFirst(findStudentId);
                            }
                            else
                            {
                                SnackBar_Message.Text      = "Sorry, that doesn't work. Please try again.";
                                Snackbar_Recorded.IsActive = true;
                            }
                        }
                    });
                }
                else
                {
                    Application.Current.Dispatcher.Invoke((Action) delegate
                    {
                        TxtBox_StudentID.Clear();
                        TxtBox_Name.Clear();
                        TxtBox_Course.Clear();
                        TxtBox_Year.Clear();
                        SnackBar_Message.Text      = "Sorry, that doesn't work. Please try again.";
                        Snackbar_Recorded.IsActive = true;
                    });
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error while capturing the fingerprint.\nPlease try again later." + ex, "Error Fingerprint", MessageBoxButton.OK, MessageBoxImage.Error);
                Application.Current.Dispatcher.Invoke((Action) delegate
                {
                    this.Close();
                });
            }
        }