我在BackEnd中使用Java和play框架开发了一个Web应用程序,在FrontEnd中使用了AngularJS。
我与U.are.U SDK进行了指纹扫描的集成,但是在尝试比较两个相同的指纹时我遇到了错误。
这是我在Angular部分中的代码:
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"
}
}
有没有人将图像转换为可以帮助我的FMD?谢谢!
// 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();
Fid fid = UareUGlobal.getImporter().ImportRaw(rawPixels,
width, height, inDpi, fingerPosition, cbeffId,
Fid.Format.ANSI_381_2004, outDpi, rotate180);
Fmd fmd = UareUGlobal.GetEngine().CreateFmd(fid,
Fid.Format.ANSI_381_2004);
我使用这种方法获得一个成功的结果,m_fmdAuxiliar是一个存储来自DB的数据的变量,我只是保存数据然后我检索。
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);