Griaule Biometrics

Home » Forums » FINGERPRINT SDK » Delphi Specific » Delphi XE
9 replies [Last post]
TEKO
Offline
Joined: 2010-10-27
Rate this post:
0
No votes yet
Delphi XE

Bom dia,

Pesquisei no forum a possibilidade de trabalhar Delphi XE com o SDK2009 da Griaule, porem vi relatos de quem usa o Activex, onde sugerem somente mudar os tipo de campos unicode, efetuei estes procedimentos mas nao funcionou, o sistema efetua o cadastro mas nao efetua a identificacao.

 

Como posso efetuar esta correcao?

 

Obrigado.

 

davi.st1
Offline
Joined: 2010-08-26
Rate this post:
0
No votes yet

Prezado cliente,

 

Qual erro está dando? Seja mais específico quanto a "não efetua a identificação".

Poderia postar a parte do seu código que dá problema? Já debugou a aplicação e viu em qual parte exatamente ele não entra?

 

Atenciosamente,

 

Davi Stuart Zilli

Griaule Support Team

TEKO
Offline
Joined: 2010-10-27
Rate this post:
0
No votes yet

Ola Davi, primeiro gostaria de agradecer a atenção.

 

Então o mesmo codigo funciona no Delphi 7, mas no Delphi XE não, no Delphi XE ele efetua a gravação da biometria normalmente,  mas na hora da identificação usando o metodo GrIdentify ele não da erro mas retorna o Match como GR_NOT_MATCH como se não encontrasse a biometria.

 

Andei vendo que algumas pessoas tiveram o mesmo problema no Delphi 2010 usando o Activex devido as alterações de unicode do Delphi, e eu estou usando DLL

taciely
Offline
Joined: 2011-05-26
Rate this post:
0
No votes yet

Prezado cliente,

O unicode não foi alterado para DLL também?

Atenciosamente,
Thiago Aciely Rodrigues;
Griaule Support Team.

TEKO
Offline
Joined: 2010-10-27
Rate this post:
0
No votes yet

Entao alterei somente das bilbio DBClasses onde tem comunicação com o SGDB, como alterar as unicode das DLL?

taciely
Offline
Joined: 2011-05-26
Rate this post:
0
No votes yet

Prezado cliente,

 

Desculpe mas creio que não me expressei bem. O que quiz dizer com a pergunta que fiz é se você tem conhecimento se foi ou não alterado o unicode para DLLs. Desculpe o inconveniente. Procuraremos saber mais desse problema a fim o resolvermos o mais rápido possivel.

 

Atenciosamente,

Thiago Aciely Rodrigues;

Griaule Support Team.

TEKO
Offline
Joined: 2010-10-27
Rate this post:
0
No votes yet

pelo menos no SDK 2009 ainda nao tinha a mudança pelo q entendi as unica forma no momento seria utilizar o Activex, por favor se ouver alguma forma de corrigir isso. orbigado pela atenção.

taciely
Offline
Joined: 2011-05-26
Rate this post:
0
No votes yet

Prezado cliente,

 

As imagens que está utilizando são de onde? Você está lendo elas de algum leitor ou carregando as imagens de algum arquivo. Pode ser q não passe de um erro de qualidade, ou então o Match não alcance um minimo que voce tenha definido. Ja debugou o codigo? Teria como colar um trecho do codigo para podermos ver?

 

Atenciosamente,

Thiago Aciely Rodrigues;

Griaule Support Team.

TEKO
Offline
Joined: 2010-10-27
Rate this post:
0
No votes yet

Olá, já debuguei sim, porem no Delphi 7 funciona mas no Delphi XE não, colocarei abaixo o fonte inteiro no qual criei com as funções da griaule:

 

unit uGriaule;

interface

uses SysUtils, GrFinger, DBClient, Classes, DB, Forms, Windows, SqlExpr, Dialogs, OracleUniProvider, Uni;
type
  TRawImage = record
    IMG    : PChar;
    Width  : Integer;
    Height : Integer;
    Res    : Integer;
  end;

type
  TTemplate = class
    public
      TPT  : Pchar;
      Size : Integer;
      ID   : Integer;
      constructor Create;
      destructor Destroy; override;
  end;

type
  TPessoa = Record
    Codigo : String;
    Nome   : String;
  end;

const
  ERR_CANT_OPEN_BD = -999;
  ERR_INVALID_ID = -998;
  ERR_INVALID_TEMPLATE = -997;

   function IniciarFinger : Integer;
   function CriarComponentesDB : Boolean;
   function IniciarCaptura : Integer;
   function ExtrairTemplate : Integer;
   function ExtraindoTemplate : Integer;
   function ValidandoTemplate : boolean;
   function Identificar(score: Integer) : Integer;
   function ProximoTemplate : TTemplate;

   procedure MontarSQL;
   procedure GravarTemplate;
   procedure FinalizarFinger;
   procedure LerTemplate;
   procedure StatusCallback(idSensor: Pchar; event: GRCAP_STATUS_EVENTS); stdcall;
   procedure FingerCallback(idSensor: Pchar; event: GRCAP_FINGER_EVENTS); stdcall;
   Procedure ImageCallback(idSensor: PChar; imageWidth: Integer; imageHeight: Integer; rawImage: PChar; res: Integer); stdcall;
   procedure PrintBiometricDisplayFFinger(biometricDisplay: boolean; context: Integer);
   procedure PrintBiometricDisplayFFingerTerminal(biometricDisplay: boolean; context: Integer);

var
  Raw : TRawImage;
  Template: TTemplate;
  TPTBlob: TTemplate;
  Form : string;
  Q : TUniQuery;
  Pessoas : TPessoa;

implementation

uses uDM, uFun03, uMainBiometria, uFunctions;

function IniciarFinger : Integer;
var
  Err: Integer;
begin
  if not CriarComponentesDB then begin
    Result := ERR_CANT_OPEN_BD;
    Exit;
  end;
  //Criando Novo Template
  Template := TTemplate.Create();
  // Create a novo raw image
  if Raw.IMG = nil then
    Raw.IMG := AllocMem(GR_MAX_IMAGE_HEIGHT * GR_MAX_IMAGE_WIDTH);
  //Iniciando a Biblioteca
  Err := GrInitialize();
  if (Err < 0) then begin
    Result := Err;
    Exit;
  end;
  Result := IniciarCaptura;
end;

function CriarComponentesDB : Boolean;
begin
  try
    Raw.IMG :=nil;
    Raw.Width :=0;
    Raw.Height :=0;
    Raw.Res :=0;
    TPTBlob :=TTemplate.Create();
    Result  :=True;
  except
    Result  :=False;
  end;
end;

function IniciarCaptura : Integer;
begin
  Result := GrCapInitialize(@StatusCallback);
end;

procedure StatusCallback(idSensor: Pchar; event: GRCAP_STATUS_EVENTS); stdcall;
begin
  if (event = GR_PLUG) then begin
    GrCapStartCapture(idSensor, @FingerCallback, @ImageCallback)
  end
  else if (event = GR_UNPLUG) then begin
    GrCapStopCapture(idSensor);
  end;
end;

procedure FingerCallback(idSensor: Pchar; event: GRCAP_FINGER_EVENTS); stdcall;
begin
//nao faz nada
end;

Procedure ImageCallback(idSensor: PChar; imageWidth: Integer; imageHeight: Integer; rawImage: PChar; res: Integer); stdcall;
Begin
  Raw.Height :=imageHeight;
  raw.Width  :=imageWidth;
  Raw.Res    :=res;
  Move(rawImage^, Raw.IMG^, imageWidth*imageHeight);
  if (Form = 'FFun03') then begin
    PrintBiometricDisplayFFinger(false, GR_DEFAULT_CONTEXT);
    ExtrairTemplate;
    GravarTemplate;
  end;
  if (Form = 'FMainBiometria') then begin
    PrintBiometricDisplayFFingerTerminal(false, GR_DEFAULT_CONTEXT);
    ExtrairTemplate;
    LerTemplate;
  end;
end;

constructor TTemplate.Create();
begin
  TPT := AllocMem(GR_MAX_SIZE_TEMPLATE);
  Size := 0;
end;

destructor TTemplate.Destroy();
begin
  FreeMemory(TPT);
end;

function ExtrairTemplate : Integer;
var
  Ret: Integer;
begin
  //Extraindo o Template
  Ret := ExtraindoTemplate;
  if Form = 'FFun03' then begin
    PrintBiometricDisplayFFinger(true, GR_NO_CONTEXT);
    if (ret = GR_BAD_QUALITY)
      then FFun03.LQualidade.Caption :='Digital de Má Qualidade.'
    else if (ret = GR_MEDIUM_QUALITY)
      then FFun03.LQualidade.Caption :='Digital de Qualidade Média.'
    else if (ret = GR_HIGH_QUALITY)
      then FFun03.LQualidade.Caption :='Digital de Alta Qualidade.';
  end;
  if Form = 'FMainBiometria' then begin
    PrintBiometricDisplayFFingerTerminal(true, GR_NO_CONTEXT);
  end;
  Result :=Ret;
end;

function ExtraindoTemplate : Integer;
var
  Ret: Integer;
begin
  Template.Size :=GR_MAX_SIZE_TEMPLATE;
  Ret :=GrExtract(Raw.IMG, Raw.Width, Raw.Height, Raw.Res, Template.TPT, Template.Size, GR_DEFAULT_CONTEXT);
  if (ret < 0 ) then begin
    Template.Size := 0;
  end;
  Result :=Ret;
end;

procedure GravarTemplate;
var
  TPTStream: TMemoryStream;
begin
  //Checando se o Template é valido
  if (ValidandoTemplate) then begin
    if (Form = 'FFun03') then begin
      TPTStream :=TMemoryStream.Create;
      //Escrevendo o Template na Memoria
      TPTStream.Write(template.tpt^, template.size);
      // save template data from memory stream to database.
      (DM.QFun.FieldByName('BIOMETRIA') as TBlobField).LoadFromStream(TPTStream);
      TPTStream.Free;
    end;
  end;
end;

function ValidandoTemplate : Boolean;
begin
  Result :=((Template.Size > 0) and (Template.TPT <> nil));
end;

procedure FinalizarFinger;
begin
  GrFinalize;
  GrCapFinalize;
  TPTBlob.Free;
  Raw.IMG    :=nil;
  Raw.Width  :=0;
  Raw.Height :=0;
  Raw.Res    :=0;
  Template.Free;
  FreeMemory(Raw.IMG);
end;

procedure PrintBiometricDisplayFFinger(biometricDisplay: boolean; context: Integer);
var
  Handle: HBitmap;
  // screen HDC
  HDC: LongInt;
begin
  FFun03.iFinger.Picture :=nil;
  FFun03.iFinger.Picture.Bitmap.FreeImage();
  Handle := FFun03.iFinger.Picture.Bitmap.ReleaseHandle();
  DeleteObject(Handle);
  {$IFOPT R+}
    {$DEFINE CKRANGE}
  {$R-}
  {$ENDIF}
  HDC := GetDC(HWND(nil));
  if biometricDisplay then begin
    GrBiometricDisplay(Template.TPT,Raw.IMG, Raw.Width, Raw.Height,Raw.Res, hdc, handle, context);
  end
  else begin
    GrCapRawImageToHandle(raw.img, raw.width, raw.height, hdc, handle);
  end;
  if (handle <> 0) then
  begin
    FFun03.iFinger.Picture.Bitmap.Handle := handle;
    FFun03.iFinger.Width := FFun03.bevelFinger.Width;
    FFun03.iFinger.Height := FFun03.bevelFinger.Height;
    FFun03.iFinger.Repaint();
  end;
  ReleaseDC(HWND(nil), hdc);
end;

procedure PrintBiometricDisplayFFingerTerminal(biometricDisplay: boolean; context: Integer);
//var
//  Handle: HBitmap;
  // screen HDC
//  HDC: LongInt;
begin
  {FFingerTerminal.image.Picture.Bitmap.FreeImage();
  Handle := FFingerTerminal.image.Picture.Bitmap.ReleaseHandle();
  DeleteObject(Handle);                                          }
  {$IFOPT R+}
    {$DEFINE CKRANGE}
  {$R-}
  {$ENDIF}
  {HDC := GetDC(HWND(nil));
  if biometricDisplay then begin
    GrBiometricDisplay(Template.TPT,Raw.IMG, Raw.Width, Raw.Height,Raw.Res, hdc, handle, context);
  end
  else begin
    GrCapRawImageToHandle(raw.img, raw.width, raw.height, hdc, handle);
  end;
  if (handle <> 0) then
  begin
    FFingerTerminal.image.Picture.Bitmap.Handle := handle;
    FFingerTerminal.image.Width := FFingerTerminal.Bevel1.Width;
    FFingerTerminal.image.Height := FFingerTerminal.Bevel1.Height;
    FFingerTerminal.image.Repaint();
  end;
  ReleaseDC(HWND(nil), hdc);}
end;

procedure LerTemplate;
var
  ret, score: Integer;
  vSetor : String;
begin
  score :=0;
  ret :=Identificar(score);
  if ret > 0 then begin
    if (Form = 'FMainBiometria') then begin
      vSetor :=ReturnString('SELECT CODIGO_SETOR FROM ' + DM.vOwner + '.' + 'PONTO_FUNCIONARIOS WHERE CRACHA = ' + QuotedStr(FormatarCracha(5,Pessoas.Codigo)),DM.conexao);
      if ReturnString('SELECT COUNT(*) FROM ' + DM.vOwner + '.' + 'PONTO_IP_SETORES PIS INNER JOIN TI_IP IP ON IP.CODIGO = PIS.CODIGO_IP AND IP.NUMERO_IP = ' + QuotedStr(FMainBiometria.IP.LocalIP) + ' AND PIS.CODIGO_SETOR = ' + QuotedStr(vSetor),DM.conexao) <> '0' then begin
        FMainBiometria.lNome.Caption :=Pessoas.Nome;
        SetRegistro(DM.QMar,'0','I','',DM.conexao);
        DM.QMarCRACHA.AsString := Pessoas.Codigo;
        DM.QMarHORA.AsString := FormatDateTime('hh:mm:ss',FMainBiometria.vHora);
        DM.QMarDATA.AsDateTime :=FMainBiometria.vData;
        DM.QMar.ApplyUpdates;
        FMainBiometria.iBtnPequeno.Visible :=not(FMainBiometria.iBackground.Visible);
        FMainBiometria.ibtnGrande.Visible  :=not(FMainBiometria.iBackground.Visible);
        FMainBiometria.iBackground.Visible :=not(FMainBiometria.iBackground.Visible);
      end
      else begin
        Mensagem('Local não autorizado para passagem de ponto, favor contatar departamento Gestão de Pessoas.',mtInformation,0);
      end;
    end;
  end
  else begin
    FMainBiometria.lNome.Caption :='Digital não encontrada.';
  end;
  FMainBiometria.Atualiza.Enabled :=True;
end;

function Identificar(score: Integer) : Integer;
var
  Ret: Integer;
  TPTRef: TTemplate;
begin
  if not(ValidandoTemplate)then begin
    Result :=ERR_INVALID_TEMPLATE;
    Exit;
  end;
  Ret :=GrIdentifyPrepare(Template.TPT, GR_DEFAULT_CONTEXT);
  if (Ret < 0) then begin
    Result :=Ret;
    Exit;
  end;
  Q.First;
  TPTRef := ProximoTemplate;
  if (TPTRef.Size > 0) then
    repeat
      Ret :=GrIdentify(TPTRef.TPT, score, GR_DEFAULT_CONTEXT);
      if (Ret = GR_MATCH) then begin
        Result :=TPTRef.ID;
        Exit;
        Q.Free;
      end
      else if (Ret < 0) then begin
        Result :=Ret;
        Exit;
      end;
      TPTRef := ProximoTemplate;
    until TPTRef.Size <= 0;
    Result :=GR_NOT_MATCH;
end;

function ProximoTemplate : TTemplate;
Var
  tmp: String;
begin
  if Q.Eof then
  begin
    TPTBlob.Size := -1;
    Result :=TPTBlob;
  end else
  begin
    TPTBlob.ID :=Q.FieldValues['CRACHA'];
    tmp := Q.FieldValues['BIOMETRIA'];
    Pessoas.Codigo :=Q.FieldValues['CRACHA'];
    Pessoas.Nome   :=Q.FieldValues['NOME'];
    TPTBlob.Size   :=Length(tmp);
    Move(PChar(tmp)^, TPTBlob.TPT^, TPTBlob.Size);
    Q.Next;
    Result :=TPTBlob;
  end;
end;

procedure MontarSQL;
begin
  Q :=TUniQuery.Create(Application);
  Q.Connection :=DM.conexao;
  Q.Close;
  Q.SQL.Clear;
  Q.SQL.Add('SELECT CRACHA, NOME, BIOMETRIA FROM ' + DM.vOwner + '.' + 'PONTO_FUNCIONARIOS WHERE BIOMETRIA IS NOT NULL');
  Q.Open;
  Q.First;
end;

end.

taciely
Offline
Joined: 2011-05-26
Rate this post:
0
No votes yet

Caro cliente,

 

Estive pesquisando e ao que parece houve mudança de tipos do Delphi 7 para o Delphi XE, por isso seu código roda em um mas não no outro. Tente oncontrar quais as relações entre os tipos que foram substituidos e adeque seu código à essas mudanças. Seu código deve funcionar assim que os tipos forem trocados.

 

Caso alguma duvida tenha ficado sem resolução, por favor, nos contate novamente.

 

Atenciosamente,

Thiago Aciely Rodrigues;

Griaule Support Team.