Skip to content

Instantly share code, notes, and snippets.

@zaagan
Created July 19, 2019 05:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaagan/0696daf3cc3053ca291d92208dfd51e8 to your computer and use it in GitHub Desktop.
Save zaagan/0696daf3cc3053ca291d92208dfd51e8 to your computer and use it in GitHub Desktop.
ZkScanner Matching Users Fingerprint
// Matching fingerprint tempates
// Continuation to https://github.com/zaagan/ZKTecoFingerPrintScanner-Implementation
//
/*
Step 1 : Load the fingerprint templates to the device memory
1.1 Convert base64 encoded template to byte array
1.2 Add the template to device memory along with users unique ID
*/
int fID = 1; // Can be the users unique ID
byte[] regTemplate = zkfp.Base64String2Blob("Users fingerprint");
DataHolder.fpInstance.AddRegTemplate(fID, regTemplate);
/*
Step 2 : Fingerprint matching (After the user has provided his/her fingerprint)
This snippet should be used after line 217 in
https://github.com/zaagan/ZKTecoFingerPrintScanner-Implementation/blob/master/ZKTecoFingerPrintScanner-Implementation/Controls/FingerPrintControl.cs
*/
byte[] CapTmp = new byte[2048];
int fid = 0;
int score = 0;
int ret = DataHolder.fpInstance.Identify(CapTmp, ref fid, ref score);
if (fid > 0)
{
// Match successful.
}
else
{
// Match failed.
}
@RikusM
Copy link

RikusM commented Aug 6, 2019

Hi how will I get the reg template in memory after 3 finger prints has been registered as one? I want to display it as an image?
The image is return black and not a image?

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment