How to Compare fingerprints using Digital Persona

2019-07-03 23:12发布

问题:

I´m trying to compare two fingerprint in java using DigitalPersona SDK v 3.0.0, but I geeting FMD is Invalid Error or sometimes I get One or more parameters passed to the API call are invalid.

I have a png image obtained from Javascript API and I tried to create a FID then a FDM like in this post example

But I don´t know how to get the method params: inDpi, fingerPosition, cbeffId, outDpi and rotate180 to get de Fid

Fid fid = UareUGlobal.getImporter().ImportRaw(rawPixels, width, height, inDpi, fingerPosition, cbeffId, Fid.Format.ANSI_381_2004, outDpi, rotate180);

also I had tried ImportFmd using intermediate format without success

Any help will be apreciated

回答1:

This code worked for me as on digital persona 4500 model.

private boolean ProcessCaptureResult(CaptureThread.CaptureEvent evt) throws IOException{
        boolean bCanceled = false;
//        CaptureThread.CaptureEvent evt = evt;

        if(null != evt.capture_result){
                    System.out.println("This is Processing Capture");
            if(null != evt.capture_result.image && Reader.CaptureQuality.GOOD == evt.capture_result.quality){
                //extract features
                Engine engine = UareUGlobal.GetEngine();

                try{
                    Fmd fmd = engine.CreateFmd(evt.capture_result.image, 
            Fmd.Format.ISO_19794_2_2005;
  BufferedImage img=ImageIO.read(new File("C:\\Users\\User\\Documents\\NetBeansProjects\\FingerPrintApp\\MembersImages","imag6.jpg"));
                                        ByteArrayOutputStream baos = new ByteArrayOutputStream();
    ImageIO.write( img, "jpg", baos );
    baos.flush();
    byte[] imageInByte = baos.toByteArray();
    baos.close();
//                                        Fmd fmd1 = engine.CreateFmd(img, 0xa, 0xa, 0x14, Fmd.Format.ANSI_378_2004);
                                        Fmd fmd2=UareUGlobal.GetEngine().CreateFmd(
                    toBytes(img),
                    img.getWidth(),
                    img.getHeight(),
                    500, 0, 3407615, Fmd.Format.ISO_19794_2_2005
                                        );
                                       System.out.println("Resulotion: "+evt.capture_result.image.getImageResolution()); ;
                                        System.out.println("ID : "+evt.capture_result.image.getCbeffId()); ;
                                           System.out.println(evt.capture_result.image.getData());

//                  if(null == m_fmds[0])
                                            m_fmds[0] = fmd;
//                  else if(null == m_fmds[1]) 
                                            m_fmds[1] = fmd2;
                }
                catch(UareUException e){ System.out.println("Engine.CreateFmd() "+e.getMessage()); }

//              if(null != m_fmds[0] &&  null != m_fmds[1]){
                    //perform comparison
                    try{
                                            System.out.println(m_fmds[0].getFormat().name());
                        int falsematch_rate = engine.Compare(m_fmds[0], 0, m_fmds[1], 0);

                        int target_falsematch_rate = Engine.PROBABILITY_ONE / 100000; //target rate is 0.00001
                        if(falsematch_rate < target_falsematch_rate){
                            System.out.println("Fingerprints matched.\n");
                            String str = String.format("dissimilarity score: 0x%x.\n", falsematch_rate);
                            System.out.println(str);
                            str = String.format("false match rate: %e.\n\n\n", (double)(falsematch_rate / Engine.PROBABILITY_ONE));
                            System.out.println(str);
                        }
                        else{
                            System.out.println("Fingerprints did not match.\n\n\n");
                        }
                    }
                    catch(UareUException e){ System.out.println("Engine.CreateFmd()"+ e.getMessage()); }

                    //discard FMDs
                    m_fmds[0] = null;
                    m_fmds[1] = null;

                    //the new loop starts
                    System.out.println(m_strPrompt1);
//              }
//              else{
//                  //the loop continues
//                  System.out.println(m_strPrompt2);
//              }
            }
            else if(Reader.CaptureQuality.CANCELED == evt.capture_result.quality){
                //capture or streaming was canceled, just quit
                bCanceled = true;
            }
            else{
                //bad quality
                MessageBox.BadQuality(evt.capture_result.quality);
            }
        }
        else if(null != evt.exception){
            //exception during capture
            MessageBox.DpError("Capture", evt.exception);
            bCanceled = true;
        }
        else if(null != evt.reader_status){
            //reader failure
            MessageBox.BadStatus(evt.reader_status);
            bCanceled = true;
        }

        return !bCanceled;
    }
    public static byte[] toBytes(BufferedImage image) {
    WritableRaster raster = image.getRaster();
    DataBufferByte data = (DataBufferByte) raster.getDataBuffer();

    return (data.getData());
}
    -

  • Code working in digital persona 4500

    #



回答2:

Well, I currently working on that one too. UareU SDK V3.0.0,

But I have problem with Verify and Compare feature.

However, to answer your question, In case you have a fingerprint image,
You can import image into Fmd directly. I meant this (I use ISO standard):

Fmd fmd = UareUGlobal.GetEngine().CreateFmd(bInput, 500, 550, 700, 0, 0, Fmd.Format.ISO_19794_2_2005)

Then, you can do compare or verify directly with this fmd.
Note: with, height, resolution must be changed according to your image and reader.
cbeffid parameter, I have tried 0 and 1.
If any one found the right answer for this parameter, please suggest me as well.
CBEFF



error

API call are invalid

Mostly, I found the resolution, fingerprint format and finger position param is in correct. fingerprint param, I usually set to 0 (first finger or first view)

Update
If you are using javascript. I would recommend you to convert base64 string from javascript to bufferedImage first.

    public static Fmd importImageString(String image) throws UnsupportedEncodingException, IOException, UareUException {
    byte[] bytes = Base64.getDecoder().decode(image.getBytes("UTF-8"));
    if (null != bytes && bytes.length > 0) {
        ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
        BufferedImage buf = ImageIO.read(stream);
        if (null != buf) {
            return UareUGlobal.GetEngine().CreateFmd(
                    TestDPuareU.toBytes(buf),
                    buf.getWidth(),
                    buf.getHeight(),
                    500, 0, 1, Fmd.Format.ISO_19794_2_2005
            );
        }
    }
    return null;
}

public static byte[] toBytes(BufferedImage image) throws IOException {
    WritableRaster raster = image.getRaster();
    DataBufferByte data = (DataBufferByte) raster.getDataBuffer();

    return (data.getData());
}

The image I got it from javascript (var finger) sdk.onSamplesAcquired = function (s) like below

var samples = JSON.parse(s.samples);
var finger = Fingerprint.b64UrlTo64(samples[0])


回答3:

Something like this is how you obtain those values, BUT Im getting the same error PID IS INVALID,so good luck and WHETHER you have the answer I hope you share it, regards.

m_fmd = m_engine.CreateFmd(cap_result.image, Fmd.Format.ANSI_378_2004);

data = m_fmd.getData();
width = m_fmd.getWidth();
height = m_fmd.getHeight();
resolution = m_fmd.getResolution();
finger_position = m_fmd.getCaptureEquipmentCompliance();
cbeff_id = m_fmd.getCbeffId();
format = m_fmd.getFormat();