2

I developed a web application using Java and play framework in the BackEnd, and AngularJS in the FrontEnd.

I did an integration with the U.are.U SDK for fingerprint scanning, however I'm getting an error while trying to compare two equal fingerprints.

This is my code in the Angular part:

if(currentFormat == Fingerprint.SampleFormat.PngImage){
        localStorage.setItem("imageSrc", "");
        var samples = JSON.parse(s.samples); //parse json
        var finger = Fingerprint.b64UrlTo64(samples[0]); // convertion to Base64

        localStorage.setItem("imageSrc", "data:image/png;base64," + finger);

        var vDiv = document.getElementById('imagediv');
        vDiv.innerHTML = "";
        var image = document.createElement("img");
        image.id = "image";
        image.src = localStorage.getItem("imageSrc");
        vDiv.appendChild(image);

        AuthService.fingerValidation(finger, vm.username, function(response){
          showMessage("Login biométrico", response);
        });
    }

Where I captured the fingerprint with the javascript API of this SDK.

He then sent a Base64 String to the web service and performed the following procedure:

UserFingerPrint print = fingerprintService.getFinderByUser(data.getUsername()); //Db data
if (print != null) {
    String equals = "";
    //'finger' is the base64 String from JavaScript
    //Convert finger to byte[]
    byte[] bytesImage = fingerprintService.getFMD(Base64.decodeBase64(finger), "first"); 

    //Convert byte[] to FMD format from SDK with parameters of image example
    Fmd fmd = UareUGlobal.GetEngine().CreateFmd(bytesImage, 320, 350, 500, 1, 3407615, Fmd.Format.ANSI_378_2004);

    //Image from DB
    byte[] imageDB = fingerprintService.resizeImage(print.getImage());
    Fmd fmd2 = UareUGlobal.GetEngine().CreateFmd(imageDB, 320, 350, 500, 1, 3407615, Fmd.Format.ANSI_378_2004);

    //The error is when comparing with the following method.
    //The fingerprint is always different, even if it is the same image.
    int falsematch_rate = UareUGlobal.GetEngine().Compare(fmd, 0, fmd2, 0);
    int target_falsematch_rate = Engine.PROBABILITY_ONE / 100000;
    if (falsematch_rate < target_falsematch_rate) {
        equals = "match success";
    } else {
        equals = "No match"
    }
}

Has anyone converted an image to FMD that can help me? Thanks!

  • Is your input image a PNG format ? How do you obtain this image ? where this image com from ? – LaurentY Jul 31 '17 at 10:00
  • Yes, it is a PNG image, this is obtained the front end with the help of javascript and the same Digital Persona API. This image is generated in Base64 and I subsequently built it an image to display in html – Daniel Contreras Aug 01 '17 at 12:56
  • @DanielContreras this is similar to what I am currently facing. I have a base64 string coming from javascript sent to java. My problem is how to convert this base64 string to FMD. – ilovejavaAJ Apr 24 '19 at 17:46

2 Answers2

1
  1. Convert your PNG image to raw bytearray in grayscale:

         // read an image from the disk
         BufferedImage image = ImageIO.read(new File("kittens.jpg"));
    
         setPreferredSize(new Dimension(
             image.getWidth(),image.getHeight()));
    
         // create a grayscale image the same size
         gray = new BufferedImage(image.getWidth(),image.getHeight(),
             BufferedImage.TYPE_BYTE_GRAY);
    
         // convert the original colored image to grayscale
         ColorConvertOp op = new ColorConvertOp(
             image.getColorModel().getColorSpace(),
             gray.getColorModel().getColorSpace(),null);
         op.filter(image,gray);
    
         //convert BuffuredImage to raw byte array
         WritableRaster raster = gray.getRaster();
         DataBufferByte data = (DataBufferByte) raster.getDataBuffer();    
         byte[] rawPixels = data.getData();
    
  2. convert your bytearray to FID

         Fid fid = UareUGlobal.getImporter().ImportRaw(rawPixels, 
             width, height, inDpi, fingerPosition, cbeffId, 
             Fid.Format.ANSI_381_2004, outDpi, rotate180);
    
  3. convert your FID to FMD

         Fmd fmd = UareUGlobal.GetEngine().CreateFmd(fid, 
             Fid.Format.ANSI_381_2004);
    
  4. Now you could compare this Fmd with current capture

LaurentY
  • 7,495
  • 3
  • 37
  • 55
  • Thanks @LaurentY, with your help I could solve the problem I had when comparing both fingerprints !! If it was the subject of the image management that I needed, without modifying my code a lot, adding your help and the FID object was solved the first attempt. I hate you a lot... – Daniel Contreras Aug 02 '17 at 02:51
  • 1
    where to get these parameters?? inDpi, fingerPosition, cbeffId, – Ali Sajid May 23 '18 at 06:49
  • Thanks a lot!!! I was trying to solve this for days. Read the Dev Guide several times trying to find the solution. – Renan Ceratto Jan 22 '19 at 17:28
  • @RenanCeratto, you're welcome, please dont forget to upvote response – LaurentY Jan 22 '19 at 23:25
  • @LaurentY. I am facing problem similar to Daniel. I have only a base64 javascript string sent to java. My problem is how to convert that string to Fmd. – ilovejavaAJ Apr 24 '19 at 17:48
0

I use this method to get a successful result, being m_fmdAuxiliar a variable which store the data from DB, I just save data then I retrieve.

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

Fmd m_fmdAuxiliar = UareUGlobal.GetImporter().ImportFmd(data, Fmd.Format.ANSI_378_2004, Fmd.Format.ANSI_378_2004);

Fmd m_fmd2 = m_engine.CreateFmd(cap_result.image, Fmd.Format.ANSI_378_2004);
m_score = m_engine.Compare(m_fmdAuxiliar, 0, m_fmd2, 0);
The Weirdo
  • 19
  • 1