繁体   English   中英

使用 Morpho SDK 旋转指纹

[英]Rotate fingerprint using Morpho SDK

我正在使用 MOrpho sdk 来捕获指纹,但我遇到了一些设备以反向布局捕获指纹的问题(这意味着捕获图像应该是从左到右,但它是从右到左捕获),那又如何到目前为止,我所做的是将收到的字节 [] 转换为 bitmap 并旋转它。 但是它不起作用,因为从 bitmap 转换回来后 byte[] 的内容有所改变。

我只想知道使用 morpho sdk 方法轻松更改布局。

下面是我正在捕获的 function。

 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 byteArray 与从初始/源 Bitmap 中提取的原始 byteArray 进行比较。 压缩通常是有损的(如果未另行指定),因此像素会以不同的方式重新排列、移动、合并等,因此无法将解压缩的有损图像(png 或 jpg)与原始 Bitmap 进行比较如果您尝试从有损压缩 Stream 开始返回到 Bitmap,则也不会。

只有无损压缩图像可以再次解码并与原始 Bitmap 进行比较。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM