Biometrics U2U DigitalPersona; Register & Verification

Please discuss general Delphi programming topics here.

Biometrics U2U DigitalPersona; Register & Verification

Postby mdomeyko2 » February 7th, 2007, 10:17 pm

OK, Resolved it on my own. As it was so dificult, and since DigitalPersona support did not help much, here's my experience... :D

For users using UrU DigitalPersona on D6 & Firebird:

Registering FingerPrint

Code: Select all
Procedure TfrmRegisterFingerPrint.FPRegisterTemplate1done(Sender: TObject; var pTemplate: OleVariant);
var l_val    : OleVariant;
    l_pArray : PSafeArray;
    i        : integer;
    fpBuffer : PByteArray;
    MS       : TMemoryStream;
begin
     pTemplate.Export(l_val);
     l_pArray := PSafeArray(TVarData(l_val).VArray);
     blobSize := l_pArray.rgsabound[0].cElements * l_pArray.cbElements;
     fpBuffer := VarArrayLock(l_val);

     for i := 0 to blobSize - 1 do
         fpData[i] := fpBuffer[i];     // pvData is byte array

     VarArrayUnlock(l_val);
     mode := 0;

     MS := TMemoryStream.Create;  { creates stream }
     MS.WriteBuffer(fpData, blobsize);  { writes stream }

     try
        t_users.filtered := false;  // TIBTable
        t_users.filter   := 'userid = ' + inttostr(gUserid);  // the useer ID to assign the fingerprint
        t_users.filtered := true;
        t_usersopen;
        t_users.edit;
        TBlobField(t_users.fieldbyname('FingerPrint')).LoadFromStream(MS); // gets from stream
        t_servers.post;

       DMLogOn.IBTransac.commit;
     except
       DMLogOn.IBTransac.Rollback;
     end;
     t_users.close;
     MS.free;
end;


Verifying FingerPrint

Code: Select all
Procedure TfrmLogOn.FPGetTemplate1done(Sender: TObject; var pTemplate: OleVariant);
var i : integer; pErr  : AIErrors;
begin
     i := GetFingerID(pTemplate);  // returns UserId
     if   i <> 0 then begin 
          bbOKClick(nil);   // gets in whatever...
     end
     else if   (gUsesFingerPrint) then begin  // indicator that system can use fingerprint system
               finger_image.Picture := nil;  // cleans fingerprint image
               FPGetTemplate1.Run(1,pErr);  // runs again if fingerprint not found or until manual input...
          end;
end;

Code: Select all
Function TfrmLogOn.GetFingerID(pTemplate : OleVariant): Integer;
var m_verifyOk  : WordBool;
    m_score     : OleVariant;
    m_security  : AISecureModeMask;
    m_threshold : OleVariant;
    m_learning  : WordBool;
    m_tUnknown  : IUnknown;
    c_IVerify   : ifPVerify;
    c_regTemplate : ifPTemplate;
    ST  : TMemoryStream;
    ExistingTemplate: OleVariant;
    iCounter: Integer;
begin
    m_learning := False;
    m_verifyOk := False;
    m_tUnknown := CreateComObject(CLASS_FPVerify);
    m_tUnknown.QueryInterface(IID_ifPVerify,c_IVerify);

    qrefresh(@q_users);   // select userid, fingerprint from users.....
    ST := TMemoryStream.Create;
    Try
      While NOT q_users.EOF do begin
            ST.Clear;
            TBlobField(q_users.FieldByName('FingerPrint')).SaveToStream(ST);  // blob field from DB and store in memory stream
            ExistingTemplate := MemoryStreamToOleVariant(ST);     // convert to olevariant
            m_tUnknown       := CreateComObject(CLASS_FPTemplate);
            m_tUnknown.QueryInterface(IID_ifPTemplate,c_RegTemplate);
            c_regTemplate.Import(ExistingTemplate);

            c_IVerify.Compare(c_RegTemplate,
                              pTemplate,
                              m_verifyOk,
                              m_score,
                              m_threshold,
                              m_learning,
                              m_security);

            if  m_verifyOk Then begin
                Result := q_users.FieldByName('userid').AsInteger;     // returns user ID
                VarClear(ExistingTemplate);
                Exit;
            end;
            VarClear(ExistingTemplate);
            c_regTemplate := nil;
            q_users.Next;  // reads next user
      end;
    Finally;
       ST.Free;
       VarClear(pTemplate);
       if  c_regTemplate <> nil Then
           c_regTemplate := nil;
       c_IVerify := nil;
    end;
end;
Canguro
Miami, FL
mdomeyko2
Active Member
Active Member
 
Posts: 11
Joined: September 18th, 2006, 10:06 pm

Postby Kambiz » February 7th, 2007, 11:02 pm

I'm glad to see you could resolve the problem.
Also, thank you for sharing the solution.
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2421
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron