我正在使用MOrpho sdk来捕捉指纹,但我遇到了一个问题,一些设备以反向布局捕捉指纹(意味着捕捉图像应该从左到右,但它是从右到左捕捉的(,所以到目前为止,我所做的是将接收到的byte[]转换为位图,然后旋转它。然而,它没有起作用,因为从位图转换回byte[]后的内容发生了一些变化。
我只想知道如何使用morpho-sdk方法轻松更改布局。
下面是我正在捕捉的函数。
public FTPImage fpCapture(int timeoutInSeconds) {
Logger.d("fpCapture ():::");
if (context == null) {
Logger.e("fpCapture()::Context is null");
return null;
}
TemplateList templateList = new TemplateList();
templateList.setActivateFullImageRetrieving(true);
try {
Logger.d("Device is not null:");
MorphoImage morphoImage = new MorphoImage();
int detectModeChoice = DetectionMode.MORPHO_ENROLL_DETECT_MODE.getValue() | DetectionMode.MORPHO_FORCE_FINGER_ON_TOP_DETECT_MODE.getValue();
int detectModeChoice1= DetectionMode.MORPHO_ENROLL_DETECT_MODE.getValue() | DetectionMode.MORPHO_DEFAULT_DETECT_MODE.getValue();
int detectModeChoice2= DetectionMode.MORPHO_VERIF_DETECT_MODE.getValue() | DetectionMode.MORPHO_DEFAULT_DETECT_MODE.getValue();
int detectModeChoice3= DetectionMode.MORPHO_DEFAULT_DETECT_MODE.getValue();
int acquisitionThreshold = 0;
int compressionRate = 0;
int callbackCmd = 0;
int ret = morphoDevice.getImage(timeoutInSeconds, acquisitionThreshold, CompressionAlgorithm.MORPHO_NO_COMPRESS, compressionRate, detectModeChoice2, LatentDetection.LATENT_DETECT_ENABLE, morphoImage, callbackCmd, null);
if (ret == 0) {
Logger.d("MorphoPlugin::--------- "+"d="+detectModeChoice+"-d1"+detectModeChoice1+"d2="+detectModeChoice2+"d3"+detectModeChoice3);
/* Logger.d("MorphoPlugin::--bytearray "+new String(morphoImage.getImage().toString()));
Logger.d("MorphoPlugin::--bytearray-- "+Arrays.toString(morphoImage.getImage()).toString());
String s = new String(morphoImage.getImage(), "UTF-8");
Logger.d("MorphoPlugin::--sttinh image bytearay-- "+s.getBytes("UTF-8"));
//fpCaptureAndConvert(20);
String s1 = new String(morphoImage.getImage(), "UTF-8");
Logger.d("MorphoPlugin::--template image bytearay-- "+s1.getBytes("UTF-8"));
*/
/* Bitmap bitmap = BitmapFactory.decodeByteArray(morphoImage.getImage() , 0, morphoImage.getImage().length);
YuvImage yuvimage=new YuvImage(morphoImage.getImage(), ImageFormat.NV21, 100, 100, null);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
yuvimage.compressToJpeg(new Rect(0, 0, 100, 100), 80, baos);
byte[] jdata = baos.toByteArray();
// Convert to Bitmap
Bitmap bmp = BitmapFactory.decodeByteArray(jdata, 0, jdata.length);
System.out.println("Bitmap Name 3" + bmp);
if (bmp!=null)
{
Logger.d("MorphoPlugin::--bitmap not null"+bmp.toString());
Logger.d("MorphoPlugin::--bitmap not null-a1-"+morphoImage.getImage().toString());
byte[] b1=getByteArray(bmp);
Logger.d("MorphoPlugin::--bitmap not null-bytearr-"+b1.toString());
}else{
Logger.d("MorphoPlugin::--bitmap null");
}*/
// Logger.d("MorphoPlugin:: "+"normal bytearray"+fpCaptureAndConvert(5));
Logger.d("MorphoPlugin::--------- "+"actual bytearray[]"+Arrays.toString(morphoImage.getImage()).toString());
/* byte[] bytearray1 = getByteArray(bmp);
Logger.d("MorphoPlugin:: "+"reversed bytearray1"+Arrays.toString(bytearray1).toString());
*/
//byte[] rotatedbyte=rotateByteArray(morphoImage.getImage());
//byte[] rotatedbyte1=rotateByteArray(rotatedbyte);
int imageRowNumber = morphoImage.getMorphoImageHeader()
.getNbRow();
int imageColumnNumber = morphoImage.getMorphoImageHeader()
.getNbColumn();
// byte[] rotated=rotateYUV420Degree90(morphoImage.getImage(),imageColumnNumber,imageRowNumber);
/* //For decoding
String str=getStringImage(bitmp);
byte convertedBytearray[]= android.util.Base64.decode(str, android.util.Base64.DEFAULT);
Bitmap bmp=getBitmapFromRawImage(convertedBytearray);
// Logger.d("MorphoPlugin::--------- "+"converted bytearray[]"+new String(convertedBytearray));
// Logger.d("MorphoPlugin:: "+"converted bitmap"+bmp);
//
Bitmap rotatetedBitmp= rotateImage(180,bmp);
String rotatedstr=getStringImage(rotatetedBitmp);
byte rotatedBytearray[]= android.util.Base64.decode(rotatedstr, android.util.Base64.DEFAULT);
*/
Bitmap rotatetedBitmp=rotateImage(morphoImage.getImage());
// createExternalImage(rotatetedBitmp);
//createExternalImage(bitmp);
// Logger.d("MorphoPlugin:: "+"bitmap with rot"+rotatetedBitmp);
// createExternalImage(bitmp);
/* byte[] b1=getByteArray(bitmp);
byte[] b2=getByteArray(rotatetedBitmp);
Logger.d("MorphoPlugin:: "+"before rotation bytearray"+b1);
Logger.d("MorphoPlugin:: "+"after rotation bytearray"+b2);
*/
//Logger.d("MorphoPlugin::--bytearray "+new String(morphoImage.getImage()));
FTPImage ftpImage = new FTPImage();
ftpImage.imgData = morphoImage.getImage();
ftpImage.imgHeight = morphoImage.getMorphoImageHeader().getNbRow();
ftpImage.imgWidth = morphoImage.getMorphoImageHeader().getNbColumn();
Bitmap bitmp=getBitmapFromRawImage(morphoImage.getImage(),imageColumnNumber,imageRowNumber);
createExternalImage(bitmp);
// byte[] bytearray= getByteArray(bitmp);
byte[] bytearray = getByteArray(bitmp);
Logger.d("MorphoPlugin:: "+"---ftp- bytearray"+Arrays.toString(bytearray).toString());
/* Logger.d("MorphoPlugin:: "+"ftp-actual"+new String(ftpImage.imgData));
Bitmap ftpbitmp=getBitmapFromRawImage(morphoImage.getImage(),ftpImage.imgWidth,ftpImage.imgHeight);
byte[] bytearrayftp= getByteArray(ftpbitmp);
ftpImage.imgData = bytearrayftp;
Logger.d("MorphoPlugin:: "+"ftp-reversed"+new String(bytearrayftp));*/
return ftpImage;
}
} catch (Exception e) {
Logger.e("Exception occurred " + e.getLocalizedMessage());
}
return null;
}
无法将COMPRESSED字节数组与从初始/源位图中提取的原始字节数组进行比较。压缩通常是LOSSY(如果没有另行指定(,因此像素会以不同的方式重新排列、移动、合并等,因此,如果您试图从有损压缩流返回位图,则不可能将解压缩的有损图像(png或jpg(与原始位图进行比较。
只有无损压缩图像才能再次解码,并与原始位图进行比较。