コード例 #1
0
        public void ExtractFeatures()
        {
            var featureExtraction = new FeatureExtraction();

            featureExtraction.ExtractFeatures(); //Insert
            //featureExtraction.ExtractWordBigramFeatures(); //Update
        }
コード例 #2
0
 //method that runs for every capturing
 public void OnCaptured(CaptureResult captureResult)
 {
     try
     {
         // Check capture quality and throw an error if bad.
         if (!fp.CheckCaptureResult(captureResult))
         {
             return;
         }
         else
         {
             //convert to a valid finger print first
             DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
             if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
             {
                 throw new Exception(resultConversion.ResultCode.ToString());
             }
             else
             {
                 //if it succesfully convert then display for user to see
                 // Create bitmap - this part display the captured on screen
                 foreach (Fid.Fiv fiv in captureResult.Data.Views)
                 {
                     SendMessage(Action.SendBitmap, fp.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                 }
                 firstFinger = resultConversion.Data;
             }
         }
     }
     catch (Exception ex)
     {
         // Send error message, then close form
         SendMessage(Action.SendMessage, "Error:  " + ex.Message);
     }
 }
コード例 #3
0
        //Gathers the required counts for the features and performs feature selection
        private FeaturesStatistics selectFeatures(List <Document> dataset, int numberOfFeatures = 30)
        {
            FeatureExtraction featureExtractor = new FeatureExtraction();

            //the FeatureStatistica object contains statistics about all the features found in the documents
            FeaturesStatistics statistics = featureExtractor.extractFeatureStatistics(dataset);

            //we pass this information to the feature selection algorithm and we get a list with the selected features
            Dictionary <String, Double> selectedFeatures = featureExtractor.select(statistics, numberOfFeatures);


            Dictionary <String, Dictionary <String, int> > newfeatureCategoryJointCount = new Dictionary <string, Dictionary <string, int> >();

            //clip from the stats all the features that are not selected
            foreach (var arr in statistics.featureCategoryJointCount)
            {
                if (selectedFeatures.ContainsKey(arr.Key))
                {
                    newfeatureCategoryJointCount.Add(arr.Key, arr.Value);
                }
            }

            statistics.featureCategoryJointCount = newfeatureCategoryJointCount;
            return(statistics);
        }
コード例 #4
0
        private IEnumerable <Fmd> CaptureAndExtractFmd()
        {
            while (!objVariables.reset)
            {
                DataResult <Fmd> resultConversion;

                try
                {
                    if (objVariables.count >= 8)
                    {
                        MessageBox.Show("El registro no se completó, vuelve a intentarlo.",
                                        "Aviso",
                                        MessageBoxButtons.OK,
                                        MessageBoxIcon.Exclamation,
                                        MessageBoxDefaultButton.Button1);

                        objVariables.count = 0;
                        break;
                    }

                    Fid fid = null;

                    if (objVariables.currentReader == null)
                    {
                        objVariables.currentReader = objDevice.IndexDevice();
                        objDevice.InitializeDevice(ref objVariables.currentReader);
                    }

                    if (!CaptureFinger(ref fid))
                    {
                        //break;
                    }

                    if (fid == null)
                    {
                        continue;
                    }

                    objVariables.count++;

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

                    objPrincipal.txtSalida.Dispatcher.BeginInvoke(new Action(delegate()
                    {
                        objPrincipal.txtSalida.AppendText("\nLa huella se ha capturado. Captura Numero: " + objVariables.count);
                    }));

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

                yield return(resultConversion.Data);
            }
        }
コード例 #5
0
        public static void ExtractClusteringFeatures()
        {
            LoggedConsole.WriteLine("feature extraction process...");
            var inputDir  = @"D:\Mahnoosh\Liz\Least_Bittern\";
            var resultDir = Path.Combine(inputDir, "FeatureLearning");

            //var trainSetPath = Path.Combine(inputDir, "TrainSet");
            var testSetPath   = Path.Combine(inputDir, "TestSet\\one_min_recordings");
            var configPath    = @"D:\Mahnoosh\Liz\Least_Bittern\FeatureLearningConfig.yml";
            var centroidsPath = Path.Combine(resultDir, "ClusterCentroids0.csv");

            var configFile = configPath.ToFileInfo();

            if (configFile == null)
            {
                throw new FileNotFoundException("No config file argument provided");
            }
            else if (!configFile.Exists)
            {
                throw new ArgumentException($"Config file {configFile.FullName} not found");
            }

            var configuration = ConfigFile.Deserialize <FeatureLearningSettings>(configFile);

            List <double[][]> centroids = new List <double[][]>();

            centroids.Add(Csv.ReadMatrixFromCsv <double>(centroidsPath.ToFileInfo(), TwoDimensionalArray.None).ToJagged());
            FeatureExtraction.UnsupervisedFeatureExtraction(configuration, centroids, testSetPath, resultDir);
            LoggedConsole.WriteLine("Done...");
        }
コード例 #6
0
ファイル: NaiveBayes.cs プロジェクト: waliul-cse/NBayesDotNet
        /// <summary>
        /// Gathers the required counts for the features and performs feature selection
        /// on the above counts. It returns a FeatureStats object that is later used
        /// for calculating the probabilities of the model.
        /// </summary>
        /// <param name="dataset"> </param>
        /// <returns>  </returns>
        private FeatureStats selectFeatures(IList <Document> dataset)
        {
            FeatureExtraction featureExtractor = new FeatureExtraction();

            //the FeatureStats object contains statistics about all the features found in the documents
            FeatureStats stats = featureExtractor.extractFeatureStats(dataset); //extract the stats of the dataset

            //we pass this information to the feature selection algorithm and we get a list with the selected features
            IDictionary <string, double?> selectedFeatures = featureExtractor.chisquare(stats, chisquareCriticalValue);

            //clip from the stats all the features that are not selected
            IEnumerator <KeyValuePair <string, IDictionary <string, int> > > it = stats.featureCategoryJointCount.GetEnumerator();

            while (it.MoveNext())
            {
                string feature = it.Current.Key;

                if (selectedFeatures.ContainsKey(feature) == false)
                {
                    //if the feature is not in the selectedFeatures list remove it
                    it.Current.Value.Remove(feature);
                }
            }

            return(stats);
        }
コード例 #7
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);
            }
        }
コード例 #8
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);
            }
        }
コード例 #9
0
        protected FeatureSet ExtractFeatures(Sample sample, DataPurpose purpose)
        {
            var extractor = new FeatureExtraction();
            var feedback  = CaptureFeedback.None;
            var features  = new FeatureSet();

            extractor.CreateFeatureSet(sample, purpose, ref feedback, ref features);

            return((feedback == CaptureFeedback.Good) ? features : null);
        }
コード例 #10
0
        /// <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, oHelper.Mensaje2);

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

                if (count == 0)
                {
                    firstFinger = resultConversion.Data;

                    OperadorEncontrado = funciones.CompararHuella(firstFinger, secondFinger);

                    if (OperadorEncontrado.IdOperador != 0)
                    {
                        SendMessage(Action.SendMessage, "Huella coincide con operador " + OperadorEncontrado.Nombre + " y su status es " + OperadorEncontrado.Status);
                        SendMessage(Action.SendMessage, oHelper.Mensaje1);
                    }

                    else
                    {
                        SendMessage(Action.SendMessage, oHelper.Mensaje5);
                        SendMessage(Action.SendMessage, oHelper.Mensaje1);
                    }

                    count = 0;
                }
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, oHelper.Error + ex.Message);
            }

            ///si el lector es desconectado con la ventana de verification abierta, mandamos a cerrarla automaticamente
            ///para llamar al evento Verification_Closed y que se cargue el load del main para que salga el mensajeBox de lector
            ///desconectado (Reintentar/Salir)
            if (captureResult.ResultCode == Constants.ResultCode.DP_DEVICE_FAILURE)
            {
                Thread t = new Thread(cerrar);
                t.Start();
            }
        }
コード例 #11
0
        /// <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;
                }

                count++;

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

                SendMessage(Action.SendMessage, "A finger was captured.  \r\nCount:  " + (count));

                if (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(resultConversion.ResultCode.ToString());
                }

                preenrollmentFmds.Add(resultConversion.Data);

                if (count >= 4)
                {
                    DataResult <Fmd> resultEnrollment = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preenrollmentFmds);

                    if (resultEnrollment.ResultCode == Constants.ResultCode.DP_SUCCESS)
                    {
                        SendMessage(Action.SendMessage, "An enrollment FMD was successfully created.");
                        SendMessage(Action.SendMessage, "Place a finger on the reader.");
                        preenrollmentFmds.Clear();
                        count = 0;
                        return;
                    }
                    else if (resultEnrollment.ResultCode == Constants.ResultCode.DP_ENROLLMENT_INVALID_SET)
                    {
                        SendMessage(Action.SendMessage, "Enrollment was unsuccessful.  Please try again.");
                        SendMessage(Action.SendMessage, "Place a finger on the reader.");
                        preenrollmentFmds.Clear();
                        count = 0;
                        return;
                    }
                }

                SendMessage(Action.SendMessage, "Now place the same finger on the reader.");
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, "Error:  " + ex.Message);
            }
        }
コード例 #12
0
        public void OnCaptured(CaptureResult captureResult)
        {
            this.picBoxToCap     = picBoxFingerPrint;
            this.fingerToCapture = 0;
            count++;
            lblCount.Invoke(new Action(() => { lblCount.Text = count.ToString(); }));
            DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);

            if (captureResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
            {
                if (CurrentReader != null)
                {
                    CurrentReader.Dispose();
                    CurrentReader = null;
                }

                MessageBox.Show("Error:  " + captureResult.ResultCode);
            }
            if (captureResult.Data != null)
            {
                foreach (Fid.Fiv fiv in captureResult.Data.Views)
                {
                    picBoxFingerPrint.Image    = CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height);
                    picBoxFingerPrint.SizeMode = PictureBoxSizeMode.Zoom;
                }
            }
            preenrollmentFmds.Add(resultConversion.Data);
            if (count >= 4)
            {
                resultEnrollment = Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preenrollmentFmds);

                TempFingerPrint = Fmd.SerializeXml(resultConversion.Data);

                resultEnrollment = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.ANSI, preenrollmentFmds);

                if (resultEnrollment.ResultCode == Constants.ResultCode.DP_SUCCESS)
                {
                    FileStream fs = new System.IO.FileStream(@"..\..\Pictures\right.bmp", FileMode.Open, FileAccess.Read);
                    picRigithWrong.Invoke(new Action(() => { picRigithWrong.Image = Image.FromStream(fs); }));
                    picRigithWrong.SizeMode = PictureBoxSizeMode.Zoom;
                    //preenrollmentFmds.Clear();
                    //count = 0;
                    MessageBox.Show("An enrollment was successfully created.");
                    return;
                }
                else if (resultEnrollment.ResultCode == Constants.ResultCode.DP_ENROLLMENT_INVALID_SET)
                {
                    MessageBox.Show("Enrollment was unsuccessful.  Please try again.");
                    preenrollmentFmds.Clear();
                    count = 0;
                    return;
                }
            }
        }
コード例 #13
0
        static void Main(string[] args)
        {
            var repositorio = new DigitalRepositorio();
            var biometrias  = repositorio.RecuperarPagina(1, 8000);

            Console.WriteLine($"{biometrias.Count()} biometrias recuperadas...");

            foreach (var biometria in biometrias)
            {
                var teste = FeatureExtraction.CreateFmdFromRaw(biometria.TemplateISO, 1, 1, 1, 1, 1, Constants.Formats.Fmd.ISO);
            }
        }
コード例 #14
0
ファイル: DeviceControlDP.cs プロジェクト: sfcheewill/Blm
 public FingerTemplate Extract(FingerImage image)
 {
     if (image is FingerImageDP)
     {
         var fingerImage = image as FingerImageDP;
         DataResult <Fmd> resultConversion = FeatureExtraction.CreateFmdFromFid(fingerImage.fid, Constants.Formats.Fmd.ANSI);
         if (resultConversion.ResultCode == Constants.ResultCode.DP_SUCCESS)
         {
             return(new TemplateDP(resultConversion.Data));
         }
     }
     return(null);
 }
コード例 #15
0
        /// <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.");

                IDs.Clear();

                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());
                }

                SendMessage(Action.SendMessage, "Please wait while searching is done in background.");

                anyFinger = resultConversion.Data;
                Fmd[] fmdsArray = fmds.ToArray();

                foreach (Fmd fmd in fmdsArray)
                {
                    CompareResult compareResult = Comparison.Compare(anyFinger, 0, fmd, 0);
                    if (compareResult.Score < (PROBABILITY_ONE / 100000))
                    {
                        IDs.Add(fmdsDic[fmd]);
                    }
                }
                SendMessage(Action.SendMessage, IDs.Count.ToString() + " Finger Print(s) Matched.");
                SendMessage(Action.SendMessage, "Click the button below to show results or place thumb to search again.");

                if (IDs.Count > 0)
                {
                    SendMessage(Action.ShowMatchedEntry, "");
                }
                else
                {
                    SendMessage(Action.HideMatchedEntry, "");
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error in Identification: " + ex.Message);
            }
        }
コード例 #16
0
        public void Extract_Tests()
        {
            var featureExtraction = new FeatureExtraction();

            var validValues = "Button Fly,Button-End,D Ring,Double D Ring,Drawstring,Elastic,Flat Solid Buckle,Hook & Eye,J-Clip,Pull On,Round Classic Ring,Self Tie,Snap On,Snaps,Square Classic Ring,Velcro,Zipper";
            //Scenario 1: exact match
            var source1   = "Double D Ring";
            var scenario1 = featureExtraction.Extract(source1, validValues);

            Assert.AreEqual("Double D Ring", scenario1);
            //Scenario 2: source contains list of valid values
            // 2.1 source contains single matching
            // 2.2 source contains multiple matching
            // 2.2 source contains multiple matching but get only one
            // 2.3 source contains multiple matching but get only one
            // with assistance of keyword
            var source21   = "Versace Collection D Ring woven leather tote bag with golden hardware. Flat top handles with hanging logo medallion, 5.5\" drop. Removable chain shoulder strap, 18.5\" drop. Flap top with logo plaque; snap closure. Interior, cotton lining; one zip and two slip pockets. Metal feet protect bottom of bag. 10.5\"H x 14\"W x 4.5\"D; weighs 13 oz. Imported.";
            var scenario21 = featureExtraction.Extract(source21, validValues);

            Assert.AreEqual("D Ring", scenario21);
            var source221 =
                "Versace Collection D Ring woven leather tote bag with golden hardware. Flat top handles with hanging logo medallion, 5.5\" drop. Removable chain shoulder strap, 18.5\" drop. Flap top with logo plaque; snap closure. Interior, cotton lining; one zip and two slip pockets. Metal feet protect bottom of bag. 10.5\"H x 14\"W x 4.5\"D; weighs 13 oz. Imported. Elastic";
            var scenario221 = featureExtraction.Extract(source221, validValues,
                                                        3, 0);

            Assert.AreEqual("D Ring/Elastic", scenario221);

            var scenario222 = featureExtraction.Extract(source221, validValues,
                                                        3, 1);

            Assert.AreEqual("D Ring", scenario222);

            //var scenario223 = featureExtraction.Extract(source221, validValues,
            //    3, 1, "/", "closure");
            //Assert.AreEqual("Snaps", scenario223);

            //Scenario 3:

            //Scenario 4: similarity checks
            // return multiple result
            var source4   = "Versace Collection woven D Rin leather tote bag with golden hardware. Flat top handles with hanging logo medallion, 5.5\" drop. Removable chain shoulder strap, 18.5\" drop. Flap top with logo plaque; snap closure. Interior, cotton lining; one zip and two slip pockets. Metal feet protect bottom of bag. 10.5\"H x 14\"W x 4.5\"D; weighs 13 oz. Imported.";
            var scenario4 = featureExtraction.Extract(source4, validValues, 1, 0);

            var source41   = "Versace Collection woven Elasti leather tote bag with golden hardware. Flat top handles with hanging logo medallion, 5.5\" drop. Removable chain shoulder strap, 18.5\" drop. Flap top with logo plaque; snap closure. Interior, cotton lining; one zip and two slip pockets. Metal feet protect bottom of bag. 10.5\"H x 14\"W x 4.5\"D; weighs 13 oz. Imported.";
            var scenario41 = featureExtraction.Extract(source41, validValues, 1, 1);


            //var source = "Versace Collection D Ring woven leather tote bag with golden hardware. Flat top handles with hanging logo medallion, 5.5\" drop. Removable chain shoulder strap, 18.5\" drop. Flap top with logo plaque; snap closure. Interior, cotton lining; one zip and two slip pockets. Metal feet protect bottom of bag. 10.5\"H x 14\"W x 4.5\"D; weighs 13 oz. Imported.";

            //var s = new FeatureExtraction().Extract(source,validValues,3);
        }
コード例 #17
0
        protected FeatureSet ExtractFeatures(Sample Sample, DataPurpose Purpose)
        {
            FeatureExtraction Extractor = new FeatureExtraction();
            CaptureFeedback   feedback  = CaptureFeedback.None;
            FeatureSet        features  = new FeatureSet();

            Extractor.CreateFeatureSet(Sample, Purpose, ref feedback, ref features);
            if (feedback == CaptureFeedback.Good)
            {
                return(features);
            }

            return(null);
        }
コード例 #18
0
        private async void Identify(object Huella = null)
        {
            try
            {
                if (FingerPrintData == null)
                {
                    return;
                }

                Error           = "Verificando huella...";
                IniciaAnimacion = true;
                Thread.Sleep(5000);
                var Service = new BiometricoServiceClient();

                var CompareResult = Service.CompararHuellaImputado(new ComparationRequest {
                    BIOMETRICO = FeatureExtraction.CreateFmdFromFid(FingerPrintData, Constants.Formats.Fmd.ANSI).Data.Bytes, ID_TIPO_BIOMETRICO = DD_Dedo.HasValue ? DD_Dedo.Value : enumTipoBiometrico.INDICE_DERECHO, ID_TIPO_FORMATO = enumTipoFormato.FMTO_DP
                });

                if (CompareResult.Identify)
                {
                    var result      = CompareResult.Result[0];
                    var NombreLogin = await StaticSourcesViewModel.CargarDatosAsync(() => new cImputado().GetData().Where(w => w.ID_ANIO == result.ID_ANIO && w.ID_CENTRO == result.ID_CENTRO && w.ID_IMPUTADO == result.ID_IMPUTADO).FirstOrDefault());

                    var nombreComparar = NombreLogin.NOMBRE.Trim() + " " + NombreLogin.PATERNO.Trim() + " " + NombreLogin.MATERNO.Trim();
                    //cambiar el proceso para que traiga el username y de ahi sacar el resto de los datos.
                    if (_usuario.NombreCompleto != nombreComparar)
                    {
                        Error = "El capturista no pertenece a esta sesion";
                    }
                    else
                    {
                        Error = "Su huella ha sido autenticada con exito";

                        OnProgress.Start();
                        Autenticado = true;
                    }
                }
                else
                {
                    Error = "Esta huella no esta registrada en el sistema";
                }
                IniciaAnimacion = false;
                FingerPrintData = null;
            }
            catch (Exception ex)
            {
                Error           = "Ocurrió un error al verficar la huella";
                IniciaAnimacion = false;
            }
        }
コード例 #19
0
ファイル: FingerPrintScanner.cs プロジェクト: vmware14/qrcode
        public static FeatureSet ExtractFeatures(Sample sample, DataPurpose datapurpose)
        {
            FeatureExtraction extractor = new FeatureExtraction();
            CaptureFeedback   feedback  = CaptureFeedback.None;
            FeatureSet        feature   = new FeatureSet();

            extractor.CreateFeatureSet(sample, datapurpose, ref feedback, ref feature);
            if (feedback == CaptureFeedback.Good)
            {
                return(feature);
            }
            else
            {
                return(null);
            }
        }
コード例 #20
0
ファイル: ReceiveLSL.cs プロジェクト: shldn/mdons
 // Use this for initialization
 void Start()
 {
     //EPOC..
     buffer    = new Buffer();
     fe        = new FeatureExtraction();
     sample    = new float[Buffer.CH];
     gyroXmean = new float[gyroIndexMax];
     gyroYmean = new float[gyroIndexMax];
     gyroIndex = 0;
     gyroTag   = false;
     gyroX     = gyroY = 0;
     rotationX = rotationY = 0;
     // create stream info and outlet
     //dispText.text = "initial";
     ReceivingFromLSL.Start();
     RetrivingFromBuffer.Start();
 }
コード例 #21
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);
            }
        }
コード例 #22
0
ファイル: Enroll.cs プロジェクト: jesman09/UareU-C-Sharp
        void reader_On_Captured(CaptureResult capResult)
        {
            if (capResult.Quality == Constants.CaptureQuality.DP_QUALITY_GOOD)
            {
                count++;
                DataResult <Fmd> fmd = FeatureExtraction.CreateFmdFromFid(capResult.Data, Constants.Formats.Fmd.DP_PRE_REGISTRATION);

                // Get view bytes to create bitmap.
                foreach (Fid.Fiv fiv in capResult.Data.Views)
                {
                    //Ask user to press finger to get fingerprint
                    UpdateEnrollMessage("Click save button to save fingerprint", HelperFunctions.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
                    break;
                }

                //preEnrollmentFmd.Add(fmd.Data);
                //enrollmentFmd = DPUruNet.Enrollment.CreateEnrollmentFmd(Constants.Formats.Fmd.DP_REGISTRATION, preEnrollmentFmd);

                ////if (enrollmentFmd.ResultCode == Constants.ResultCode.DP_SUCCESS)
                //{
                //    if (fingerindex == 0)
                //    {
                //        fmd1 = enrollmentFmd;
                //        fingerindex++;
                //        count = 0;
                //        preEnrollmentFmd.Clear();
                //        UpdateEnrollMessage("Please swipe 2nd finger", null);
                //    }
                //    else if (fingerindex == 1)
                //    {
                //        fmd2 = enrollmentFmd;
                //        preEnrollmentFmd.Clear();
                //        UpdateEnrollMessage("User " + userIDTb.Text.ToString() + " Successfully Enrolled!", null);
                //        string userid = userIDTb.Text.ToString();
                //        HelperFunctions.updateFMDUserIDList(fmd1.Data, fmd2.Data, userid);

                //        if (!CheckIfUserExists())
                //        {
                //            SaveEnrolledFmd(userIDTb.Text.ToString(), Fmd.SerializeXml(fmd1.Data), Fmd.SerializeXml(fmd2.Data));
                //        }

                //    }

                // }
            }
        }
コード例 #23
0
        /// <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 (resultConversion.ResultCode != Constants.ResultCode.DP_SUCCESS)
                {
                    _sender.Reset = true;
                    throw new Exception(resultConversion.ResultCode.ToString());
                }

                if (count == 0)
                {
                    firstFinger = resultConversion.Data;
                    count      += 1;
                    SendMessage(Action.SendMessage, "Now place the same or a different finger on the reader.");
                }
                else if (count == 1)
                {
                    secondFinger = resultConversion.Data;
                    CompareResult compareResult = Comparison.Compare(firstFinger, 0, secondFinger, 0);
                    if (compareResult.ResultCode != Constants.ResultCode.DP_SUCCESS)
                    {
                        _sender.Reset = true;
                        throw new Exception(compareResult.ResultCode.ToString());
                    }

                    SendMessage(Action.SendMessage, "Comparison resulted in a dissimilarity score of " + compareResult.Score.ToString() + (compareResult.Score < (PROBABILITY_ONE / 100000) ? " (fingerprints matched)" : " (fingerprints did not match)"));
                    SendMessage(Action.SendMessage, "Place a finger on the reader.");
                    count = 0;
                }
            }
            catch (Exception ex)
            {
                // Send error message, then close form
                SendMessage(Action.SendMessage, "Error:  " + ex.Message);
            }
        }
コード例 #24
0
        /// <summary>
        /// Create FMD from samples
        /// </summary>
        /// <param name="fid"></param>
        /// <returns></returns>
        private IEnumerable <Fmd> CreateFMD(string folderPath)
        {
            //Convert the fingerprint samples to raw byte[]
            //Create FMD of the fingerprint samples from Raw
            foreach (string file in Directory.EnumerateFiles(folderPath, "*.bmp"))
            {
                Image img = Image.FromFile(file);

                //DataResult<Fmd> data = Importer.ImportFmd(imageToByteArray(img), Constants.Formats.Fmd.ISO, Constants.Formats.Fmd.ISO);
                //yield return data.Data;

                DataResult <Fmd> fmd = FeatureExtraction.CreateFmdFromRaw(ConvertToRaw(img), 0, 0, img.Width, img.Height,
                                                                          (int)img.HorizontalResolution, Constants.Formats.Fmd.ISO);

                yield return(fmd.Data);
            }
        }
コード例 #25
0
        private IEnumerable <Fmd> CaptureAndExtractFmd()
        {
            while (!reset)
            {
                DataResult <Fmd> resultConversion;

                try
                {
                    if (count >= 8)
                    {
                        SendMessage("Enrollment was unsuccessful.  Please try again.");
                        count = 0;
                        break;
                    }

                    Fid fid = null;
                    if (!_sender.CaptureFinger(ref fid))
                    {
                        break;
                    }

                    if (fid == null)
                    {
                        continue;
                    }

                    count++;

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

                    SendMessage("A finger was captured.  \r\nCount:  " + (count));

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

                yield return(resultConversion.Data);
            }
        }
コード例 #26
0
        private async void Identify(object Huella = null)
        {
            try
            {
                if (FingerPrintData == null)
                {
                    return;
                }

                Error = "Iniciando sesión...";
                var Service = new BiometricoServiceClient();

                var CompareResult = Service.CompararHuellaImputado(new ComparationRequest {
                    BIOMETRICO = FeatureExtraction.CreateFmdFromFid(FingerPrintData, Constants.Formats.Fmd.ANSI).Data.Bytes, ID_TIPO_BIOMETRICO = DD_Dedo.HasValue ? DD_Dedo.Value : BiometricoServiceReference.enumTipoBiometrico.INDICE_DERECHO, ID_TIPO_FORMATO = enumTipoFormato.FMTO_DP
                });

                if (CompareResult.Identify)
                {
                    var result      = CompareResult.Result[0];
                    var NombreLogin = await StaticSourcesViewModel.CargarDatosAsync(() => new cImputado().GetData().Where(w => w.ID_ANIO == result.ID_ANIO && w.ID_CENTRO == result.ID_CENTRO && w.ID_IMPUTADO == result.ID_IMPUTADO).FirstOrDefault());

                    User.NombreCompleto = NombreLogin.NOMBRE.Trim() + " " + NombreLogin.PATERNO.Trim() + " " + NombreLogin.MATERNO.Trim();
                    //cambiar el proceso para que traiga el username y de ahi sacar el resto de los datos.
                    if (User.NombreCompleto == "ANGEL EMILIO AREVALO MARQUEZ")
                    {
                        User.Username = "******";
                    }
                    else
                    {
                        User.Username = "******";
                    }
                    OnProgress.Start();
                }
                else
                {
                    Error = "El usuario o la contraseña son incorrectos";
                }

                FingerPrintData = null;
            }
            catch
            {
                Error = "Ocurrió un error al iniciar sesión";
            }
        }
コード例 #27
0
        private static bool RunJob(string jobCode)
        {
            var result = false;

            switch (jobCode)
            {
            case "FE":
                Console.WriteLine(string.Format("[{0}] {1} is starting...", DateTime.Now, _jobList[jobCode]));

                var stopWatch = new Stopwatch();
                stopWatch.Start();

                try
                {
                    var featureExtraction = new FeatureExtraction();
                    featureExtraction.ExtractFeatures();

                    stopWatch.Stop();
                    var ts          = stopWatch.Elapsed;
                    var elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

                    Console.WriteLine(string.Format("[{0}] {1} has finished, in {2}.", DateTime.Now, _jobList[jobCode], elapsedTime));

                    result = true;
                }
                catch (Exception ex)
                {
                    stopWatch.Stop();
                    var ts          = stopWatch.Elapsed;
                    var elapsedTime = string.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);

                    Console.WriteLine(string.Format("[{0}] {1} has stopped, in {2}, with error: \n{3}", DateTime.Now, _jobList[jobCode], elapsedTime, ex.ToString()));

                    result = false;
                }

                Console.WriteLine();
                break;
            }

            return(result);
        }
コード例 #28
0
        private async Task BroadcastAggregate(Reference <DataAggregate> aggregate, OrchestratorTwin twin)
        {
            List <Task> messages = new List <Task>();

            foreach (Routing item in Enum.GetValues(typeof(Routing)))
            {
                if (twin.RoutingMode.HasFlag(item))
                {
                    switch (item)
                    {
                    case Routing.VisualizeFeature:
                        messages.Add(Visualization.PublishAsync(new GraphData()
                        {
                            CorrelationID = "Feature",
                            Values        = aggregate.Message.Values
                        }
                                                                ));
                        break;

                    case Routing.FeatureExtraction:
                        messages.Add(FeatureExtraction.PublishAsync(new DataAggregate()
                        {
                            CorrelationID = "Feature",
                            Values        = aggregate.Message.Values
                        }));
                        break;

                    default:
                        continue;
                    }
                }
            }

            if (messages.Count > 0)
            {
                await Task.WhenAll(messages);
            }
        }
コード例 #29
0
 /// <summary>
 /// Handler for when a fingerprint is captured.
 /// </summary>
 /// <param name="captureResult">contains info and data on the fingerprint capture</param>
 public void OnCaptured(CaptureResult captureResult)
 {
     try
     {
         // Check capture quality and throw an error if bad.
         if (!Clases.HuellaDigital.CheckCaptureResult(captureResult))
         {
             return;
         }
         // Create bitmap
         foreach (Fid.Fiv fiv in captureResult.Data.Views)
         {
             SendMessage(Action.SendBitmap, Clases.HuellaDigital.CreateBitmap(fiv.RawImage, fiv.Width, fiv.Height));
         }
         //Guardamos el FMD de la huella
         res = FeatureExtraction.CreateFmdFromFid(captureResult.Data, Constants.Formats.Fmd.ANSI);
     }
     catch (Exception ex)
     {
         // Send error message, then close form
         SendMessage(Action.SendMessage, "Error:  " + ex.Message);
     }
 }
コード例 #30
0
        public void Execute(Arguments arguments)
        {
            LoggedConsole.WriteLine("feature learning process...");

            var inputDir     = @"D:\Mahnoosh\Liz\Least_Bittern\";
            var inputPath    = Path.Combine(inputDir, "TrainSet\\one_min_recordings");
            var trainSetPath = Path.Combine(inputDir, "TrainSet\\train_data");

            // var testSetPath = Path.Combine(inputDir, "TestSet");
            var configPath = @"D:\Mahnoosh\Liz\Least_Bittern\FeatureLearningConfig.yml";
            var resultDir  = Path.Combine(inputDir, "FeatureLearning");

            Directory.CreateDirectory(resultDir);

            // var outputMelImagePath = Path.Combine(resultDir, "MelScaleSpectrogram.png");
            // var outputNormMelImagePath = Path.Combine(resultDir, "NormalizedMelScaleSpectrogram.png");
            // var outputNoiseReducedMelImagePath = Path.Combine(resultDir, "NoiseReducedMelSpectrogram.png");
            // var outputReSpecImagePath = Path.Combine(resultDir, "ReconstrcutedSpectrogram.png");
            // var outputClusterImagePath = Path.Combine(resultDir, "Clusters.bmp");

            // +++++++++++++++++++++++++++++++++++++++++++++++++patch sampling from 1-min recordings

            var configFile = configPath.ToFileInfo();

            if (configFile == null)
            {
                throw new FileNotFoundException("No config file argument provided");
            }
            else if (!configFile.Exists)
            {
                throw new ArgumentException($"Config file {configFile.FullName} not found");
            }

            var configuration = ConfigFile.Deserialize <FeatureLearningSettings>(configFile);
            int patchWidth    =
                (configuration.MaxFreqBin - configuration.MinFreqBin + 1) / configuration.NumFreqBand;

            var clusteringOutputList = FeatureLearning.UnsupervisedFeatureLearning(configuration, inputPath);

            List <double[][]> allBandsCentroids = new List <double[][]>();

            for (int i = 0; i < clusteringOutputList.Count; i++)
            {
                var clusteringOutput = clusteringOutputList[i];

                // writing centroids to a csv file
                // note that Csv.WriteToCsv can't write data types like dictionary<int, double[]> (problems with arrays)
                // I converted the dictionary values to a matrix and used the Csv.WriteMatrixToCsv
                // it might be a better way to do this
                string pathToClusterCsvFile = Path.Combine(resultDir, "ClusterCentroids" + i.ToString() + ".csv");
                var    clusterCentroids     = clusteringOutput.ClusterIdCentroid.Values.ToArray();
                Csv.WriteMatrixToCsv(pathToClusterCsvFile.ToFileInfo(), clusterCentroids.ToMatrix());

                // sorting clusters based on size and output it to a csv file
                Dictionary <int, double> clusterIdSize = clusteringOutput.ClusterIdSize;
                int[] sortOrder = KmeansClustering.SortClustersBasedOnSize(clusterIdSize);

                // Write cluster ID and size to a CSV file
                string pathToClusterSizeCsvFile = Path.Combine(resultDir, "ClusterSize" + i.ToString() + ".csv");
                Csv.WriteToCsv(pathToClusterSizeCsvFile.ToFileInfo(), clusterIdSize);

                // Draw cluster image directly from clustering output
                List <KeyValuePair <int, double[]> > list = clusteringOutput.ClusterIdCentroid.ToList();
                double[][] centroids = new double[list.Count][];

                for (int j = 0; j < list.Count; j++)
                {
                    centroids[j] = list[j].Value;
                }

                allBandsCentroids.Add(centroids);

                List <double[, ]> allCentroids = new List <double[, ]>();
                for (int k = 0; k < centroids.Length; k++)
                {
                    // convert each centroid to a matrix in order of cluster ID
                    // double[,] cent = PatchSampling.ArrayToMatrixByColumn(centroids[i], patchWidth, patchHeight);
                    // OR: in order of cluster size
                    double[,] cent = MatrixTools.ArrayToMatrixByColumn(centroids[sortOrder[k]], patchWidth, configuration.PatchHeight);

                    // normalize each centroid
                    double[,] normCent = DataTools.normalise(cent);

                    // add a row of zero to each centroid
                    double[,] cent2 = PatchSampling.AddRow(normCent);

                    allCentroids.Add(cent2);
                }

                // concatenate all centroids
                double[,] mergedCentroidMatrix = PatchSampling.ListOf2DArrayToOne2DArray(allCentroids);

                // Draw clusters
                var clusterImage = ImageTools.DrawMatrixWithoutNormalisation(mergedCentroidMatrix);
                clusterImage.RotateFlip(RotateFlipType.Rotate270FlipNone);
                var outputClusteringImage = Path.Combine(resultDir, "ClustersWithGrid" + i.ToString() + ".bmp");
                clusterImage.Save(outputClusteringImage);
            }

            // extracting features
            FeatureExtraction.UnsupervisedFeatureExtraction(configuration, allBandsCentroids, trainSetPath, resultDir);
            LoggedConsole.WriteLine("Done...");
        }