Search code examples
c#fingerprint

How to Serialize the fingerprint of Digital Persona in C# and saved to a database


I downloaded an Enrollment Sample Code for my digitalPersona device to use. It could already register and verify fingerprints but the problem is that it save its fingerprint .fpt file in a folder. I want to save it in the database.

i can't serialize the fingerprint of FMD objetc type,

private void OnCaptured(CaptureResult captureResult)
{

    try
    {
        //check capture quality and throw an error if bad
        if (!_sender.CheckCaptureResult(captureResult)) return;

        SendMessage(Action.SendMessage, "la huella se capturo");

        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)
        {
            indiceDr = resultConversion.Data;
            XmlSerializer xml = new XmlSerializer(resultConversion.GetType());
            StringBuilder sb = new StringBuilder();
            StringWriter writer = new StringWriter(sb);
            xml.Serialize(writer,resultConversion);
            count += 1;
            SendMessage(Action.SendMessage, "Ahora coloca tu pulgar en el lector");
            SendMessage(Action.SendMessage, "gethashcode = "+sb.ToString());
        }
        else if (count == 1)
        {
            pulgarDr = resultConversion.Data;
            count += 1;
            SendMessage(Action.SendMessage, "Ahora coloca cualquier dedo en el lector");
        }
        else if (count == 2)
        {
            AnyFinger = resultConversion.Data;
            Fmd[] fmds = new Fmd[2];
            fmds[0] = indiceDr;
            fmds[1] = pulgarDr;

            //Verificar la documentacion del SDK
            int thresholdScore = DPFJ_PROBABILITY_ONE * 1 / 10000;

            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,"Resultado de la identificación " + identifyResult.Indexes.Length.ToString());
            SendMessage(Action.SendMessage, "coloca el indice" );
            count = 0;
        }
    }
    catch (Exception ex)
    {
        SendMessage(Action.SendMessage, "Error" + ex.Message);
    }
}

Solution

  • You could serialize in XML as this:

    tempFingerPrint = Fmd.SerializeXml(resultConversion.Data);