2017-07-30 100 views
0

我開發了一個使用Java的Web應用程序,並在BackEnd中播放框架,在FrontEnd中使用AngularJS。集成指紋U.are.U SDK與Java Web應用程序的錯誤

我與U.are.U SDK進行了指紋掃描集成,但是在嘗試比較兩個相同的指紋時出現錯誤。

這是我在角部位代碼:

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); 
     }); 
    } 

我在哪裏拍攝的這個SDK的JavaScript API的指紋。

然後,他發出了Base64編碼字符串到Web服務,並按照以下步驟進行:

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" 
    } 
} 

有沒有人轉換的圖像口蹄疫,可以幫助我嗎? 謝謝!

+0

你的輸入圖像是PNG格式嗎?你如何獲得這張圖片?這張圖片是從哪裏來的? – LaurentY

+0

是的,它是一個PNG圖像,這是通過javascript和相同的Digital Persona API獲得的前端。這個圖像是在Base64中生成的,我隨後建立了一個圖像以顯示在html –

回答

0
  1. 轉換您的PNG圖像的原始字節組灰度:

     // 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. 轉換您的ByteArray的FID

     Fid fid = UareUGlobal.getImporter().ImportRaw(rawPixels, 
         width, height, inDpi, fingerPosition, cbeffId, 
         Fid.Format.ANSI_381_2004, outDpi, rotate180); 
    
  3. 轉換您的FID口蹄疫

     Fmd fmd = UareUGlobal.GetEngine().CreateFmd(fid, 
         Fid.Format.ANSI_381_2004); 
    
  4. 現在你可以用當前捕獲

+0

謝謝@LaurentY,在您的幫助下,我可以解決我在比較兩個指紋時遇到的問題! 如果這是我需要的圖像管理主題,而無需修改我的代碼,那麼添加您的幫助和FID對象就可以解決第一次嘗試。我很討厭你... –

0

我用這個方法來獲得成功的結果,是m_fmdAuxiliar其存儲從數據庫中的數據的變量,我只保存數據,那麼我找回比較這口蹄疫。

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); 
相關問題