Пример #1
0
        static bool ReadBiometric()
        {
            //Give some time in order to Load the whole configuration
            System.Threading.Thread.Sleep(1000);


            BiometricFacade biometricFacade = reader.GetBiometricFacade();

            try
            {
                biometricFacade.ReadBiometricInfoTemplates();
                BIT firstBit         = biometricFacade.FirstBit;
                BIT secondBit        = biometricFacade.SecondBit;
                int refDataQualifier = firstBit.ReferenceDataQualifier;

                Console.WriteLine("Please place your \"{0}\" over the biometric sensor:", GetFingerIndexType(firstBit.FingerIndex).Name);

                try
                {
                    SensorDevice sensor = new SagemSensorDevice();
                    // SensorDevice sensor = new DermalogSensorDevice
                    FingerIndexType fingerIndex = FingerIndexType.LEFT_INDEX_TYPE;
                    FTP_Image       image       = sensor.CaptureImage(firstBit.FingerIndex);
                    BiometricFacade bio         = reader.GetBiometricFacade();
                    FTP_Template    template    = bio.ConvertImage(image, FormatType.ISO_19794_CS.Format);

                    if (image == null || image.Pixels == null)
                    {
                        return(false);
                    }


                    bool result = biometricFacade.MatchOnCard(firstBit, template);
                    //bool result = biometricFacade.MatchOffCard(firstBit, template);

                    //int result = biometricFacade.ReadFingerprints();

                    Console.WriteLine("Is Valid? {0}", result);
                }
                catch (MiddlewareException ex)
                {
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Sensor Error: {0}", ex.Message);
                    Console.ResetColor();
                }
            }
            catch (MiddlewareException ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("Biometric error: {0}", ex.Message);
                Console.ResetColor();
            }

            return(false);
        }