-->

Creating digital persona fingerprint template from

2020-06-27 01:10发布

问题:

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));

回答1:

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);