Search code examples
c#zkteco

ZKTeco merge 3 finger print C# with ZKFingerSDK


I have been working on a small application to get fingerprints after 3 scanned. I used the ZKFingerSDK and when trying to get the register finger prints it brings the image back as black. I am using the ZK9500 device

if (RegisterCount >= REGISTER_FINGER_COUNT && !bIdentify)
{

    RegisterCount = 0;
    ret = GenerateRegisteredFingerPrint();   // <--- GENERATE FINGERPRINT TEMPLATE


    if (zkfp.ZKFP_ERR_OK == ret)
    {

        ret = AddTemplateToMemory();        //  <--- LOAD TEMPLATE TO MEMORY
        if (zkfp.ZKFP_ERR_OK == ret)         // <--- ENROLL SUCCESSFULL
        {
            string fingerPrintTemplate = string.Empty;
            zkfp.Blob2Base64String(newRegTmp, cbCapTmp, ref fingerPrintTemplate);
            newRegTmp =  zkfp.Base64String2Blob(fingerPrintTemplate);

            Bitmap bmp2;
            MemoryStream ms2 = new MemoryStream();

                BitmapFormat.GetBitmap(newRegTmp, mfpWidth, mfpHeight, ref ms2);
                bmp2 = new Bitmap(ms2);
                this.pictureBox1.Image = bmp2;


            Console.WriteLine("finger print" + fingerPrintTemplate);
            textRes.AppendText("merged " + fingerPrintTemplate + "\n");
        }
    }
}

Solution

  • I assume ret = AddTemplateToMemory(); loads the template into newRegTmp.

    zkfp.Blob2Base64String(newRegTmp, cbCapTmp, ref fingerPrintTemplate); from this line i understand that you have the rawdata of the fingerprint at newRegTmp and you are extracting the size of cbCapTmp into fingerPrintTemplate.

    In that case, you should not use newRegTmp in next line newRegTmp =zkfp.Base64String2Blob(fingerPrintTemplate); , which overwrites the actual data with the Base64 string. You can use Base64 string for displaying image on the web page with img tag. But to convert the raw data into image, you need to pass the actual data to GetBitMap.

    If the above suggestion doesnt work, please share the implementation of AddTemplateToMemory.