Example #1
0
        private void GetBiometricDisplay(FingerprintTemplate tptQuery, IntPtr rawImage, int width, int height, int res, IntPtr hdc, ref IntPtr handle, int matchContext)
        {
            IntPtr zero = IntPtr.Zero;

            try
            {
                zero = Marshal.AllocHGlobal(tptQuery.Size);
                Marshal.Copy(tptQuery.Buffer, 0, zero, tptQuery.Size);
                int errorCode = 0;
                try
                {
                    errorCode = GrFingerprintProxy.GrBiometricDisplay(zero, rawImage, width, height, res, hdc, ref handle, matchContext);
                }
                catch (AccessViolationException exception)
                {
                    FingerprintException exception2 = new FingerprintException(-113, exception);
                    throw exception2;
                }
                FingerprintException.CheckError(errorCode);
            }
            catch (OutOfMemoryException exception3)
            {
                throw new FingerprintException(-7, exception3);
            }
            finally
            {
                Marshal.FreeHGlobal(zero);
            }
        }
Example #2
0
        public void ConvertTemplate(FingerprintTemplate tpt, [Out] FingerprintTemplate newTpt, int context, GrTemplateFormat format)
        {
            IntPtr zero = IntPtr.Zero;
            IntPtr ptr2 = IntPtr.Zero;

            try
            {
                zero = Marshal.AllocHGlobal(tpt.Size);
                Marshal.Copy(tpt.Buffer, 0, zero, tpt.Size);
                ptr2 = Marshal.AllocHGlobal(0x2710);
                int newTptSize = 0x2710;
                this.ConvertTemplate(zero, ptr2, ref newTptSize, context, (int)format);
                ptr2   = Marshal.ReAllocHGlobal(ptr2, (IntPtr)newTptSize);
                newTpt = new FingerprintTemplate(ptr2, newTptSize);
            }
            catch (OutOfMemoryException exception)
            {
                throw new FingerprintException(-7, exception);
            }
            catch (NullReferenceException exception2)
            {
                throw new FingerprintException(-5, exception2);
            }
            catch (ArgumentException exception3)
            {
                throw new FingerprintException(-5, exception3);
            }
            finally
            {
                Marshal.FreeHGlobal(zero);
                Marshal.FreeHGlobal(ptr2);
            }
        }
        void Matching(FingerprintTemplate probe, FingerprintTemplate candidate)
        {
            double score = new FingerprintMatcher(probe)
                           .Match(candidate);

            Assert.Greater(score, 40);
        }
Example #4
0
        public int Verify(FingerprintTemplate queryTemplate, FingerprintTemplate referenceTemplate, out int verifyScore, int context)
        {
            int    num;
            IntPtr zero        = IntPtr.Zero;
            IntPtr destination = IntPtr.Zero;

            try
            {
                zero = Marshal.AllocHGlobal(queryTemplate.Size);
                Marshal.Copy(queryTemplate.Buffer, 0, zero, queryTemplate.Size);
                destination = Marshal.AllocHGlobal(referenceTemplate.Size);
                Marshal.Copy(referenceTemplate.Buffer, 0, destination, referenceTemplate.Size);
                num = this.Verify(zero, destination, out verifyScore, context);
            }
            catch (OutOfMemoryException exception)
            {
                throw new FingerprintException(-7, exception);
            }
            catch (NullReferenceException exception2)
            {
                throw new FingerprintException(-5, exception2);
            }
            catch (ArgumentException exception3)
            {
                throw new FingerprintException(-5, exception3);
            }
            finally
            {
                Marshal.FreeHGlobal(zero);
                Marshal.FreeHGlobal(destination);
            }
            return(num);
        }
Example #5
0
        /// <summary>
        /// Extract a fingerprint template from a raw fingerprint image
        /// </summary>
        /// <param name="image">The image to extract the template from</param>
        /// <returns></returns>
        public FingerprintTemplate ExtractTemplate(FingerprintRawImage image)
        {
            var template = new FingerprintTemplate();

            griauleLibrary.ExtractEx(image, ref template, (GrTemplateFormat)DefaultTemplateFormat);
            return(template);
        }
Example #6
0
        public double Match(FingerprintTemplate candidate)
        {
            const int maxTriedRoots = 70;
            const int maxTriedTriangles = 7538;

            Candidate = candidate;

            int rootIndex = 0;
            int triangleIndex = 0;
            double bestScore = 0;
            foreach (MinutiaPair root in GetRoots())
            {
                double score = TryRoot(root);
                if (score > bestScore)
                    bestScore = score;
                ++rootIndex;
                if (rootIndex >= maxTriedRoots)
                    break;
                if (PairCount >= 3)
                {
                    ++triangleIndex;
                    if (triangleIndex >= maxTriedTriangles)
                        break;
                }
            }
            return bestScore;
        }
Example #7
0
        public void Extract()
        {
            var db = Path.Combine("FVC2000", "DB1_B");

            Console.WriteLine("Extracting database {0}", db);
            var images    = Path.Combine(TestUtils.ImagePath, db);
            var templates = Path.Combine(TestUtils.TemplatePath, db);

            Directory.CreateDirectory(templates);
            var  stopwatch = new Stopwatch();
            int  count     = 0;
            long size      = 0;

            foreach (var file in Directory.GetFiles(images))
            {
                if (TestUtils.ImageExtensions.Contains(Path.GetExtension(file)))
                {
                    var image = TestUtils.LoadImage(file);
                    stopwatch.Start();
                    var fp = new FingerprintTemplate(image);
                    stopwatch.Stop();
                    var template = Path.Combine(templates, Path.GetFileNameWithoutExtension(file) + ".xml");
                    fp.ToXml().Save(template);
                    size += new FileInfo(template).Length;
                    ++count;
                }
            }
            Console.WriteLine("{0:0}ms extraction time, {1:0.0}KB templates", stopwatch.Elapsed.TotalMilliseconds / count, size / (double)count / 1024);
        }
        void Nonmatching(FingerprintTemplate probe, FingerprintTemplate candidate)
        {
            double score = new FingerprintMatcher(probe)
                           .Match(candidate);

            Assert.Less(score, 20);
        }
Example #9
0
        public static FingerprintTemplate EncodeBase64(FingerprintTemplate referenceTemplate)
        {
            FingerprintTemplate template;
            IntPtr zero          = IntPtr.Zero;
            IntPtr encodedBuffer = IntPtr.Zero;

            try
            {
                zero = Marshal.AllocHGlobal(referenceTemplate.Size);
                Marshal.Copy(referenceTemplate.Buffer, 0, zero, referenceTemplate.Size);
                int encodedSize = 0x2710;
                encodedBuffer = Marshal.AllocHGlobal(0x2710);
                EncodeBase64(zero, referenceTemplate.Size, ref encodedBuffer, ref encodedSize);
                template = new FingerprintTemplate(encodedBuffer, encodedSize);
            }
            catch (OutOfMemoryException exception)
            {
                throw new FingerprintException(-7, exception);
            }
            finally
            {
                Marshal.FreeHGlobal(zero);
                Marshal.FreeHGlobal(encodedBuffer);
            }
            return(template);
        }
Example #10
0
        public GrEnrollState Enroll(FingerprintRawImage rawImage, ref FingerprintTemplate tpt, GrTemplateFormat tptFormat, int context)
        {
            GrEnrollState state;
            IntPtr        zero = IntPtr.Zero;

            try
            {
                int num     = 0;
                int quality = -1;
                int cb      = 0x2710 * Marshal.SizeOf(typeof(byte));
                zero = Marshal.AllocHGlobal(cb);
                IntPtr destination = Marshal.AllocCoTaskMem(rawImage.Width * rawImage.Height);
                Marshal.Copy(rawImage.RawImage, 0, destination, rawImage.Width * rawImage.Height);
                num = this.Enroll(destination, rawImage.Width, rawImage.Height, rawImage.Resolution, zero, ref cb, ref quality, (int)tptFormat, context);
                Marshal.FreeCoTaskMem(destination);
                zero  = Marshal.ReAllocHGlobal(zero, (IntPtr)cb);
                tpt   = new FingerprintTemplate(zero, cb, quality);
                state = (GrEnrollState)num;
            }
            catch (OutOfMemoryException exception)
            {
                throw new FingerprintException(-7, exception);
            }
            catch (AccessViolationException exception2)
            {
                throw new FingerprintException(-113, exception2);
            }
            finally
            {
                Marshal.FreeHGlobal(zero);
            }
            return(state);
        }
Example #11
0
        private void Extract([In] IntPtr rawimage, int width, int height, int res, ref FingerprintTemplate fingerTemplate, int context)
        {
            IntPtr zero = IntPtr.Zero;

            try
            {
                int cb = 0x2710 * Marshal.SizeOf(typeof(byte));
                zero = Marshal.AllocHGlobal(cb);
                int quality = FingerprintException.CheckError(GrFingerprintProxy.GrExtract(rawimage, width, height, res, zero, ref cb, context));
                zero           = Marshal.ReAllocHGlobal(zero, (IntPtr)cb);
                fingerTemplate = new FingerprintTemplate(zero, cb, quality);
            }
            catch (OutOfMemoryException exception)
            {
                throw new FingerprintException(-7, exception);
            }
            catch (AccessViolationException exception2)
            {
                throw new FingerprintException(-113, exception2);
            }
            finally
            {
                Marshal.FreeHGlobal(zero);
            }
        }
Example #12
0
        public EdgeShape(FingerprintTemplate template, int reference, int neighbor)
        {
            var vector = template.Minutiae[neighbor].Position - template.Minutiae[reference].Position;
            int quadrant = 0;
            int x = vector.X;
            int y = vector.Y;

            if (y < 0)
            {
                x = -x;
                y = -y;
                quadrant = 128;
            }

            if (x < 0)
            {
                int tmp = -x;
                x = y;
                y = tmp;
                quadrant += 64;
            }

            int shift = MathEx.HighestBit((uint)(x | y) >> PolarCacheBits);

            Length = PolarDistance[y >> shift, x >> shift] << shift;

            var angle = (byte)(PolarAngle[y >> shift, x >> shift] + quadrant);
            ReferenceAngle = Angle.Difference(template.Minutiae[reference].Direction, angle);
            NeighborAngle = Angle.Difference(template.Minutiae[neighbor].Direction, Angle.Opposite(angle));
        }
Example #13
0
        void refFingercore_onImage(object source, GriauleFingerprintLibrary.Events.ImageEventArgs ie)
        {
            rawImage = ie.RawImage;
            SetImage(ie.RawImage.Image);
            stepCount++;
            //ExtractTemplate();

            try
            {
                _template = new GriauleFingerprintLibrary.DataTypes.FingerprintTemplate();
                int ret = (int)refFingercore.Enroll(ie.RawImage, ref _template, GrTemplateFormat.GR_FORMAT_DEFAULT, FingerprintConstants.GR_DEFAULT_CONTEXT);
                if (ret >= FingerprintConstants.GR_ENROLL_SUFFICIENT)
                {
                    //IGRDal dl = DalFactory.GetDal(GrConnector.AccessDal);
                    //dl.SaveTemplate(template);

                    if (ret == FingerprintConstants.GR_ENROLL_SUFFICIENT)
                    {
                        SetStatusMessage("Sufficient quality value.");
                        PerformStep(QualityTemplate.SUF, Color.YellowGreen);
                    }
                    else if (ret == FingerprintConstants.GR_ENROLL_GOOD)
                    {
                        SetStatusMessage("Good quality value.");
                        PerformStep(QualityTemplate.GOOD, Color.MediumSeaGreen);
                    }
                    else if (ret == FingerprintConstants.GR_ENROLL_VERY_GOOD)
                    {
                        IGRDal dl = DalFactory.GetDal(GrConnector.AccessDal);
                        dl.SaveTemplate(_template);

                        PerformStep(QualityTemplate.VERYGOOD, Color.SeaGreen);

                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }
                    else if (ret == FingerprintConstants.GR_ENROLL_MAX_LIMIT_REACHED)
                    {
                        IGRDal dl = DalFactory.GetDal(GrConnector.AccessDal);
                        dl.SaveTemplate(_template);

                        this.DialogResult = DialogResult.OK;
                        this.Close();
                    }

                    EnableOk();
                }
                else
                {
                    // WriteLog("The Template does not reach a good quality value");
                    SetStatusMessage("Please put your finger again");
                    PerformStep(QualityTemplate.INSF, Color.LightCoral);
                }
            }
            catch { }


            System.Threading.Thread.Sleep(100);
        }
        private FingerprintTemplate ExtractTemplate(FingerprintRawImage rawImage, int contextId)
        {
            FingerprintTemplate _tmpTemplate = null;

            GriauleCore.ExtractEx(rawImage, ref _tmpTemplate, contextId, GrTemplateFormat.GR_FORMAT_ISO);

            return(_tmpTemplate);
        }
        public byte[] ExtractTemplate(byte[] rawImage, int contextId)
        {
            var raw = ConvertTemplate(rawImage);
            FingerprintTemplate _tmpTemplate = null;

            GriauleCore.ExtractEx(raw, ref _tmpTemplate, contextId, GrTemplateFormat.GR_FORMAT_ISO);

            return(_tmpTemplate.Buffer);
        }
Example #16
0
        public FingerprintMatcher(FingerprintTemplate template)
        {
            Template = template;
            BuildEdgeHash();

            PairsByProbe = new PairInfo[Template.Minutiae.Count];
            PairList = new PairInfo[Template.Minutiae.Count];
            for (int i = 0; i < PairList.Length; ++i)
                PairList[i] = new PairInfo();
        }
        public bool IdentifyPrepare(byte[] toMatch, int contextId)
        {
            var template = new FingerprintTemplate();

            template.Buffer = toMatch;
            template.Size   = toMatch.Length;
            GriauleCore.IdentifyPrepare(template, contextId);

            return(true);
        }
Example #18
0
        protected virtual void ReadTemplate(IDataReader rdr, out Fingers finger, out FingerprintTemplate template)
        {
            byte[] buff    = (byte[])rdr[TemplateFieldName];
            int    quality = Convert.ToInt16(rdr[QualityFieldName]);

            template = new FingerprintTemplate {
                Size = buff.Length, Buffer = buff, Quality = quality
            };
            Byte fingerCode = Convert.ToByte(rdr[FingerFieldName]);

            finger = MatchFingerCode(fingerCode);
        }
Example #19
0
        private static void Main(string[] args)
        {
            var image = TestUtils.LoadImage(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_an\filipe_dir_an_2.bmp");
            var fp = new FingerprintTemplate(image);

            Bitmap img = (Bitmap) Bitmap.FromFile(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_an\filipe_dir_an_2.bmp");

            HistogramEqualization equalization = new HistogramEqualization();
            equalization.ApplyInPlace(img);

            img.Save("Aforge.bmp");
        }
Example #20
0
        private void DisplayImage(FingerprintTemplate template, FingerprintRawImage rawImage)
        {
            IntPtr hdc = FingerprintCore.GetDC();

            IntPtr image = new IntPtr();

            FPCore.GetBiometricDisplay(template, rawImage, hdc, ref image, FingerprintConstants.GR_NO_CONTEXT);

            SetBMapImage(Bitmap.FromHbitmap(image));

            FingerprintCore.ReleaseDC(hdc);
        }
Example #21
0
        public void SaveTemplate(FingerprintTemplate fingerPrintTemplate)
        {
            using (fpEntities db = new fpEntities()){
                enroll nuevo = new enroll();

                nuevo.quality  = fingerPrintTemplate.Quality;
                nuevo.template = fingerPrintTemplate.Buffer;

                db.enroll.Add(nuevo);

                db.SaveChanges();
            }
        }
Example #22
0
 void FPCore_onImage(object source, GriauleFingerprintLibrary.Events.ImageEventArgs ie)
 {
     try
     {
         if (ie.RawImage != null)
         {
             SetImage(ie.RawImage.Image);
             template = new FingerprintTemplate();
             int ret = (int)FPCore.Enroll(ie.RawImage, ref template, (GrTemplateFormat)Controller.DefaultTemplateFormat, FingerprintConstants.GR_DEFAULT_CONTEXT);
             if (ret >= FingerprintConstants.GR_ENROLL_SUFFICIENT)
             {
                 DisplayImage(template, ie.RawImage);
                 EnableCaptureButton(true);
                 if (ret == FingerprintConstants.GR_ENROLL_SUFFICIENT)
                 {
                     ShowQuality(EnrollQuality.Sufficient);
                     SetFingerLabel("Place finger again to improve quality", true);
                 }
                 else if (ret == FingerprintConstants.GR_ENROLL_GOOD)
                 {
                     ShowQuality(EnrollQuality.Good);
                     SetFingerLabel("Click 'Capture' to record template", true);
                 }
                 else if (ret == FingerprintConstants.GR_ENROLL_VERY_GOOD)
                 {
                     ShowQuality(EnrollQuality.VeryGood);
                     SetFingerLabel("Click 'Capture' to record template", true);
                 }
                 else if (ret == FingerprintConstants.GR_ENROLL_MAX_LIMIT_REACHED)
                 {
                     SetFingerLabel("Enrollment limit reached", true);
                 }
             }
             else
             {
                 SetFingerLabel("Place finger again", true);
                 ShowQuality(EnrollQuality.Poor);
             }
             Thread.Sleep(100);
         }
     }
     catch (FingerprintException ex)
     {
         ShowFPError(ex);
     }
     catch (Exception e)
     {
         ShowError(e);
     }
 }
        public void SaveTemplate(FingerprintTemplate fingerprintTemplate)
        {
            using (dbConection)
            {
                dbConection.Open();

                string strCommand = "INSERT INTO ENROLL(template,quality) VALUES (?,?)";

                OleDbCommand oleCommand = new OleDbCommand(strCommand, dbConection);
                oleCommand.Parameters.Add(new OleDbParameter("@template", OleDbType.VarBinary, fingerprintTemplate.Size, ParameterDirection.Input, false, 0, 0, "ID", DataRowVersion.Current, fingerprintTemplate.Buffer));
                oleCommand.Parameters.Add(new OleDbParameter("@quality", OleDbType.Integer));
                oleCommand.Parameters["@quality"].Value = fingerprintTemplate.Quality;
                oleCommand.ExecuteNonQuery();
            }
        }
Example #24
0
 public void ExtractEx(FingerprintRawImage fingerPrintRawImage, ref FingerprintTemplate fingerTemplate, int context, GrTemplateFormat tptFormat)
 {
     try
     {
         IntPtr destination = Marshal.AllocCoTaskMem(fingerPrintRawImage.Width * fingerPrintRawImage.Height);
         Marshal.Copy(fingerPrintRawImage.RawImage, 0, destination, fingerPrintRawImage.Width * fingerPrintRawImage.Height);
         this.ExtractEx(destination, fingerPrintRawImage.Width, fingerPrintRawImage.Height, fingerPrintRawImage.Resolution, ref fingerTemplate, context, (int)tptFormat);
         Marshal.FreeCoTaskMem(destination);
     }
     catch (OutOfMemoryException exception)
     {
         FingerprintException exception2 = new FingerprintException(-7, exception);
         throw exception2;
     }
 }
Example #25
0
 public void GetBiometricDisplay(FingerprintTemplate tptQuery, FingerprintRawImage rawImage, IntPtr hdc, ref IntPtr handle, int matchContext)
 {
     try
     {
         IntPtr destination = Marshal.AllocCoTaskMem(rawImage.Width * rawImage.Height);
         Marshal.Copy(rawImage.RawImage, 0, destination, rawImage.Width * rawImage.Height);
         this.GetBiometricDisplay(tptQuery, destination, rawImage.Width, rawImage.Height, rawImage.Resolution, hdc, ref handle, matchContext);
         Marshal.FreeCoTaskMem(destination);
     }
     catch (OutOfMemoryException exception)
     {
         FingerprintException exception2 = new FingerprintException(-7, exception);
         throw exception2;
     }
 }
Example #26
0
        private static void Main(string[] args)
        {
            var image = TestUtils.LoadImage(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_an\filipe_dir_an_2.bmp");
            var fp    = new FingerprintTemplate(image);

            Bitmap img = (Bitmap)Bitmap.FromFile(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_an\filipe_dir_an_2.bmp");

            HistogramEqualization equalization = new HistogramEqualization();

            equalization.ApplyInPlace(img);



            img.Save("Aforge.bmp");
        }
Example #27
0
        private void DisplayImage(FingerprintTemplate template, bool identify)
        {
            IntPtr hdc   = FingerprintCore.GetDC();
            IntPtr image = new IntPtr();

            if (identify)
            {
                fingerPrint.GetBiometricDisplay(template, rawImage, hdc, ref image, FingerprintConstants.GR_DEFAULT_CONTEXT);
            }
            else
            {
                fingerPrint.GetBiometricDisplay(template, rawImage, hdc, ref image, FingerprintConstants.GR_NO_CONTEXT);
            }

            SetImage(Bitmap.FromHbitmap(image));
            FingerprintCore.ReleaseDC(hdc);
        }
Example #28
0
 private void ExtractTemplate()
 {
     if (rawImage != null)
     {
         try
         {
             template = null;
             fingerPrint.Extract(rawImage, ref template);
             MessageBox.Show(template.Quality.ToString(), "Quality");
             DisplayImage(template, false);
         }
         catch
         {
             MessageBox.Show("An error has occurred", "Error");
         }
     }
 }
Example #29
0
 /// <summary>
 /// Save a fingerprint template for the current individual
 /// </summary>
 /// <param name="finger">The finger to which the template belongs</param>
 /// <param name="fingerPrintTemplate">The template to be saved</param>
 public void SaveTemplate(Fingers finger, FingerprintTemplate fingerPrintTemplate)
 {
     if (Connection != null && Connection.State == ConnectionState.Open)
     {
         if (ActiveIndividual != null)
         {
             InternalSaveTemplate(FingerValueTable[finger], fingerPrintTemplate);
         }
         else
         {
             throw new FPLibraryException(FPLibraryException.LibraryDalError, "Active individual not set");
         }
     }
     else
     {
         throw new FPLibraryException(FPLibraryException.LibraryDalError, "Connection is null or closed");
     }
 }
Example #30
0
        private void ExtractTemplate()
        {
            if (rawImage != null)
            {
                try
                {
                    _template = null;
                    refFingercore.Extract(rawImage, ref _template);

                    //  SetQualityBar(_template.Quality);

                    DisplayImage(_template, false);
                }
                catch
                {
                    // SetQualityBar(-1);
                }
            }
        }
Example #31
0
        public void TestMethod1()
        {
            var image = TestUtils.LoadImage(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_pol\filipe_dir_pol_1.bmp");
            var image1 = TestUtils.LoadImage(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_pol\filipe_dir_pol_2.bmp");
            var image2 = TestUtils.LoadImage(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_pol\filipe_dir_pol_3.bmp");

            var imagedif = TestUtils.LoadImage(@"D:\ScarIntelFinal\ScarIntel\BD\nuno_dir_pol\nuno_dir_pol_1.bmp");

            var fp = new FingerprintTemplate(image);
            var fp1 = new FingerprintTemplate(image1);
            var fp2 = new FingerprintTemplate(image2);
            var fpdif = new FingerprintTemplate(imagedif);

            FingerprintMatcher fm = new FingerprintMatcher(fp);

            double aux= fm.Match(fp);
            double aux1 = fm.Match(fp1);
            double aux2 = fm.Match(fp2);
            double aux3 = fm.Match(fpdif);

            Assert.AreEqual( aux , aux );
        }
Example #32
0
        public void IdentifyPrepare(FingerprintTemplate queryTemplate, int context)
        {
            IntPtr zero = IntPtr.Zero;

            try
            {
                zero = Marshal.AllocHGlobal(queryTemplate.Size);
                Marshal.Copy(queryTemplate.Buffer, 0, zero, queryTemplate.Size);
                this.IdentifyPrepare(zero, context);
            }
            catch (OutOfMemoryException exception)
            {
                throw new FingerprintException(-7, exception);
            }
            catch (ArgumentException exception2)
            {
                throw new FingerprintException(-5, exception2);
            }
            finally
            {
                Marshal.FreeHGlobal(zero);
            }
        }
        public void RoundTripSerialization()
        {
            var mt = new MutableTemplate();

            mt.Size     = new IntPoint(800, 600);
            mt.Minutiae = new List <MutableMinutia>();
            mt.Minutiae.Add(new MutableMinutia(new IntPoint(100, 200), Math.PI, MinutiaType.Bifurcation));
            mt.Minutiae.Add(new MutableMinutia(new IntPoint(300, 400), 0.5 * Math.PI, MinutiaType.Ending));
            var pt = new PersistentTemplate(mt);
            var t  = new FingerprintTemplate(SerializationUtils.Serialize(pt));

            t = new FingerprintTemplate(t.ToByteArray());
            Assert.AreEqual(2, t.Minutiae.Length);
            var a = t.Minutiae[0];
            var b = t.Minutiae[1];

            Assert.AreEqual(new IntPoint(100, 200), a.Position);
            Assert.AreEqual(Math.PI, a.Direction, 0.0000001);
            Assert.AreEqual(MinutiaType.Bifurcation, a.Type);
            Assert.AreEqual(new IntPoint(300, 400), b.Position);
            Assert.AreEqual(0.5 * Math.PI, b.Direction, 0.0000001);
            Assert.AreEqual(MinutiaType.Ending, b.Type);
        }
Example #34
0
        public void TestMethod1()
        {
            var image  = TestUtils.LoadImage(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_pol\filipe_dir_pol_1.bmp");
            var image1 = TestUtils.LoadImage(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_pol\filipe_dir_pol_2.bmp");
            var image2 = TestUtils.LoadImage(@"D:\ScarIntelFinal\ScarIntel\BD\filipe_dir_pol\filipe_dir_pol_3.bmp");

            var imagedif = TestUtils.LoadImage(@"D:\ScarIntelFinal\ScarIntel\BD\nuno_dir_pol\nuno_dir_pol_1.bmp");

            var fp    = new FingerprintTemplate(image);
            var fp1   = new FingerprintTemplate(image1);
            var fp2   = new FingerprintTemplate(image2);
            var fpdif = new FingerprintTemplate(imagedif);



            FingerprintMatcher fm = new FingerprintMatcher(fp);

            double aux  = fm.Match(fp);
            double aux1 = fm.Match(fp1);
            double aux2 = fm.Match(fp2);
            double aux3 = fm.Match(fpdif);

            Assert.AreEqual(aux, aux);
        }
        public MatchResult Identify(byte[] matchWith, int contextId)
        {
            int score    = -1;
            var f        = matchWith;
            var template = new FingerprintTemplate();

            template.Buffer = f;
            template.Size   = f.Length;
            // Comparing current template.
            var result = GriauleCore.Identify(template, out score, contextId);

            // Checking if query template and the reference template match.
            if (result == FingerprintConstants.GR_MATCH)
            {
                return new MatchResult {
                           Found = true, Score = score
                }
            }
            ;
            return(new MatchResult {
                Found = false
            });
        }
    }
 private static CompositeTemplate CreateFingerprintTemplateFromTemplate(IDSolRequestType request)
 {
     CompositeTemplate compositeTemplate = new CompositeTemplate();
       compositeTemplate.DataType = EBiometricDataType.Processed;
       for (int index = 0; index < request.FingerPrint.Length; ++index)
       {
     FingerprintTemplate fingerprintTemplate = new FingerprintTemplate();
     fingerprintTemplate.DataType = EBiometricDataType.Processed;
     fingerprintTemplate.Finger = IMSUtil.GetFingerByNumber(request.FingerPrint[index].FingerPosition.Value);
     GenericIdentifier genericIdentifier = new GenericIdentifier();
     genericIdentifier.RawData = request.FingerPrint[index].FingerPrintImage;
     genericIdentifier.IdentType = new IdentifierType();
     genericIdentifier.IdentType.Type = EBiometricIdentifierType.FingerPrint;
     fingerprintTemplate.Identifier = (IIdentifier) genericIdentifier;
     compositeTemplate.Collection.Add((object) fingerprintTemplate);
       }
       return compositeTemplate;
 }
 private static CompositeTemplate CreateTemplateFromImages(IDSolRequestType request)
 {
     CompositeTemplate compositeTemplate = new CompositeTemplate();
       compositeTemplate.DataType = EBiometricDataType.Raw;
       for (int index = 0; index < request.FingerPrint.Length; ++index)
       {
     FingerprintTemplate fingerprintTemplate = new FingerprintTemplate();
     fingerprintTemplate.DataType = EBiometricDataType.Raw;
     fingerprintTemplate.Finger = IMSUtil.GetFingerByNumber(request.FingerPrint[index].FingerPosition.Value);
     GenericIdentifier genericIdentifier = new GenericIdentifier();
     byte[] afisReadyBmp = ImageUtil.GetAFISReadyBMP(request.FingerPrint[index].FingerPrintImage);
     genericIdentifier.RawData = afisReadyBmp;
     genericIdentifier.IdentType = new IdentifierType();
     genericIdentifier.IdentType.Type = EBiometricIdentifierType.FingerPrint;
     fingerprintTemplate.Identifier = (IIdentifier) genericIdentifier;
     compositeTemplate.Collection.Add((object) fingerprintTemplate);
       }
       if (request.FaceImage != null)
       {
     IMSUtil.log.Info("Face Image Is Not Null");
     FacialTemplate facialTemplate = new FacialTemplate();
     facialTemplate.DataType = EBiometricDataType.Raw;
     GenericIdentifier genericIdentifier = new GenericIdentifier();
     genericIdentifier.IdentType = new IdentifierType(EBiometricIdentifierType.FacialFeatures);
     genericIdentifier.RawData = request.FaceImage;
     facialTemplate.Identifier = (IIdentifier) genericIdentifier;
     compositeTemplate.Collection.Add((object) facialTemplate);
       }
       return compositeTemplate;
 }