views:

994

answers:

2

This is a very specific question which will probably earn me the tumbleweed badge, but please answer if you can

I've imported DigitalPersona sdk dll's as type libraries into Delphi and am trying to verify fingerprints which I've stored as serialized data in a database, it's working very awesomely. Enrollment seems to work fine, but I can't turn the binary data from the finger prints back into DPFPTemplate objects. I keep getting an OLEException every time I try to used the defaultinterface property of a TDPFPTemplate object.

What I'm wondering is how Digital Persona expects you to use their SDK to recreate fingerprints. This is what their instructions say:

1. *Retrieve serialized fingerprint template data from a fingerprint data storage subsystem.
2. Deserialize a DPFPTemplate object by calling the Deserialize method (VB page 40, C++
page 83).
3. Return a DPFPTemplate object.

All the ways of making a DPFPTemplate seem to only include using the fingerprint reader itself.

Here's one way that doesn't work

 Result := CreateOleObject('DPFPShrX.DPFPTemplate.1') as IDPFPTemplate;
 Result.Deserialize(string(AUserFinRecPtr.FingerBuffer));

and here's another

DPFPTemplate := TDPFPTemplate.Create(nil);
DPFPTemplate.DefaultInterface.Deserialize(String(AUserFinREcPtr.FingerBuffer));
+2  A: 

I found a pdf document where the Deserialize method is feaded a byte array. Your FingerBuffer is a PAnsiChar, which is an array of bytes. But then you cast it to a string which is automatically converted to an OleString (Delphi converts a string to an OleString when you assign it to an OleVariant). So you don't have an array of bytes anymore.

What you can try to do (I won't garantee it :) ):

var
  lByteArray: Variant;
  lArrayPointer: Pointer;
  lStr: AnsiString;
  DPFPTemplate: TDPFPTemplate;
begin
  lStr := AUserFinREcPtr.FingerBuffer;
  lByteArray := VarArrayCreate([0, Length(lStr) - 1], varByte );
  lArrayPointer:= VarArrayLock(lByteArray);
  try
    Move( lStr[1], lArrayPointer^, Length(lStr) );
  finally
    VarArrayUnlock(lByteArray);
  end;
  DPFPTemplate := TDPFPTemplate.Create(nil);
  DPFPTemplate.DefaultInterface.Deserialize(lByteArray);
The_Fox
Wow, that worked, not crashing at least. Thanks a ton!
Peter Turner
A: 

Am having the same problem. But in Java. How do i create a Template object from a serialized object (byte[]) already stored in a database? I dont understand Delphi so am A bit stomped. any help?? Her is a peice of the code

DPFPFeatureSet features = extractFeatures(sample, DPFPDataPurpose.DATA_PURPOSE_VERIFICATION); //Feature Set from the Login Capture ()

int count = db.getRowCount(); //remember to check if row count is zero (ie Database is empty)

    // Check quality of the sample and start verification if it's good
    if (features != null)
    {
                //for each row of entries in the database
                for(int i = 1; i<=count; i++)
                {
                    //Compare the feature set with our stored database template
                    byte[] print =  db.getPrint(count);

                    DPFPTemplate template = deserialize(print);
        DPFPVerificationResult result = verificator.verify(features, print); //DPFPTemplate from the DB

                    if (result.isVerified())
            System.out.println("The fingerprint was VERIFIED.");
        else
            System.out.println("The fingerprint wan NOT VERIFIED.");
                }
    }
Sensei