Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   C++ Builder (https://www.clubdelphi.com/foros/forumdisplay.php?f=13)
-   -   Digital Persona SDK en C++ Builder (https://www.clubdelphi.com/foros/showthread.php?t=85167)

mordaz 08-02-2014 00:27:35

Digital Persona SDK en C++ Builder
 
Buenos dias,

Estoy tratando de traducir el código de ejemplo del SDK del lector biometrico Digital Persona de un ejemplo de Delphi a C++ Builder, pero no logro hacerlo funcionar correctamente.

El código original es el siguiente:

Código Delphi [-]

procedure TForm1.SaveTemplate();
 var
outFile : File of byte;
vrnt: Variant;
vtByteBuf : PByteArray;
aryLow: integer;
aryHigh : integer;
rawDataSize: integer;
loopIndex : integer;
numWritten : integer;
bt : byte;
iTemplate : DPFPShrXLib_TLB.IDPFPTemplateDisp;
begin

try
if SaveDialog.Execute then
      begin
iTemplate := DPFPEnrollment.Template as DPFPShrXLib_TLB.IDPFPTemplateDisp;
vrnt:=iTemplate.Serialize;  //raw data is now stored in this variant

        //Now that you have the variant, try to get raw byte array
        //We are assuming here that you cannot save a variant directly to database field
        //That you need a byte array before saving the data to the database.
        
        aryLow:=VarArrayLowBound(vrnt,1);
        aryHigh:=varArrayHighBound(vrnt,1);
        aryHigh:=aryHigh-aryLow;

        vtByteBuf:=VarArrayLock(vrnt);  //lock down the array
        AssignFile(outFile,saveDialog.FileName);
        Rewrite(outFile);
        for loopIndex := 0 to aryHigh  do
        begin
               //fpData[loopIndex]:=vtByteBuf[loopIndex];
               //bt:=fpData[loopIndex];
               Write(outFile,vtByteBuf[loopIndex]);  //Save directly to file here
        end;
        VarArrayUnlock(vrnt);
      end;
except
on E: Exception do showmessage('Trouble saving data');
end;
        CloseFile(outFile);


end;

Mi codigo en C++ Builder es el siguiente

Código:

void __fastcall TForm1::btnSaveClick(TObject *Sender)
{
  //Guardando la muestra
  OleVariant Ovt;
  IDispatch &pSample=static_cast<IDispatch&>(*DPFPEnrollment->Template);
  IDPFPSample &Muestra=static_cast<IDPFPSample&>(pSample);
  Muestra.Serialize(Ovt);

  //Guardando en archivo
  int aryLow;
  int aryHigh;
  Variant vrnt;
  vrnt=reinterpret_cast <Variant&> (Ovt);
  aryLow=VarArrayLowBound(vrnt,1);
  aryHigh=VarArrayHighBound(vrnt,1);
  aryHigh=aryHigh-aryLow;
  PByteArray vtByteBuf=(PByteArray)VarArrayLock(vrnt);

  ofstream myfile;
  myfile.open ("muestra.bin", ios::out | ios::app | ios::binary);
  for (int loopIndex=0;loopIndex<=aryHigh;loopIndex++){
    myfile<<vtByteBuf[loopIndex];
  }
  VarArrayUnlock(vrnt);
  myfile.close();
}

El código me genera correctamente el archivo "muestra.bin" pero al compararlo en tamaño con uno generado con Delphi existe una diferencia en tamaño considerable. Lo que me hace suponer que no estoy guardando los datos correctamente.

Gracias por su apoyo.

kbolas 25-03-2014 23:28:11

Cita:

Empezado por mordaz (Mensaje 472468)
Buenos dias,

Estoy tratando de traducir el código de ejemplo del SDK del lector biometrico Digital Persona de un ejemplo de Delphi a C++ Builder, pero no logro hacerlo funcionar correctamente.

El código original es el siguiente:

Código Delphi [-]

procedure TForm1.SaveTemplate();
 var
outFile : File of byte;
vrnt: Variant;
vtByteBuf : PByteArray;
aryLow: integer;
aryHigh : integer;
rawDataSize: integer;
loopIndex : integer;
numWritten : integer;
bt : byte;
iTemplate : DPFPShrXLib_TLB.IDPFPTemplateDisp;
begin

try
if SaveDialog.Execute then
      begin
iTemplate := DPFPEnrollment.Template as DPFPShrXLib_TLB.IDPFPTemplateDisp;
vrnt:=iTemplate.Serialize;  //raw data is now stored in this variant

        //Now that you have the variant, try to get raw byte array
        //We are assuming here that you cannot save a variant directly to database field
        //That you need a byte array before saving the data to the database.
        
        aryLow:=VarArrayLowBound(vrnt,1);
        aryHigh:=varArrayHighBound(vrnt,1);
        aryHigh:=aryHigh-aryLow;

        vtByteBuf:=VarArrayLock(vrnt);  //lock down the array
        AssignFile(outFile,saveDialog.FileName);
        Rewrite(outFile);
        for loopIndex := 0 to aryHigh  do
        begin
               //fpData[loopIndex]:=vtByteBuf[loopIndex];
               //bt:=fpData[loopIndex];
               Write(outFile,vtByteBuf[loopIndex]);  //Save directly to file here
        end;
        VarArrayUnlock(vrnt);
      end;
except
on E: Exception do showmessage('Trouble saving data');
end;
        CloseFile(outFile);


end;

Mi codigo en C++ Builder es el siguiente

Código:

void __fastcall TForm1::btnSaveClick(TObject *Sender)
{
  //Guardando la muestra
  OleVariant Ovt;
  IDispatch &pSample=static_cast<IDispatch&>(*DPFPEnrollment->Template);
  IDPFPSample &Muestra=static_cast<IDPFPSample&>(pSample);
  Muestra.Serialize(Ovt);

  //Guardando en archivo
  int aryLow;
  int aryHigh;
  Variant vrnt;
  vrnt=reinterpret_cast <Variant&> (Ovt);
  aryLow=VarArrayLowBound(vrnt,1);
  aryHigh=VarArrayHighBound(vrnt,1);
  aryHigh=aryHigh-aryLow;
  PByteArray vtByteBuf=(PByteArray)VarArrayLock(vrnt);

  ofstream myfile;
  myfile.open ("muestra.bin", ios::out | ios::app | ios::binary);
  for (int loopIndex=0;loopIndex<=aryHigh;loopIndex++){
    myfile<<vtByteBuf[loopIndex];
  }
  VarArrayUnlock(vrnt);
  myfile.close();
}

El código me genera correctamente el archivo "muestra.bin" pero al compararlo en tamaño con uno generado con Delphi existe una diferencia en tamaño considerable. Lo que me hace suponer que no estoy guardando los datos correctamente.

Gracias por su apoyo.

Hola, buenas tardes, sabes que tengo el mismo problema en c++ builder, y no logro hacerlo funcionar. solo me agrega 2 controles de OCX, pero no puedo crear ningun tipo de variable( ej. *DPFPEnrollment->) para utilizar el lector, los controles funciona, si corro la aplicacion, el programa me pide que capture la huella 4 veces, y al termino me dice que todo esta bien, pero no puedo recuperar los datos de la huella que se utilizo, supongo que es por el sdk que no se me registra bien. Estoy usando C++ Builder 4. Alguna sugerencia?

Gracias de Antemano

mordaz 06-05-2014 23:30:18

1 Archivos Adjunto(s)
Cita:

Hola, buenas tardes, sabes que tengo el mismo problema en c++ builder, y no logro hacerlo funcionar. solo me agrega 2 controles de OCX, pero no puedo crear ningun tipo de variable( ej. *DPFPEnrollment->) para utilizar el lector, los controles funciona, si corro la aplicacion, el programa me pide que capture la huella 4 veces, y al termino me dice que todo esta bien, pero no puedo recuperar los datos de la huella que se utilizo, supongo que es por el sdk que no se me registra bien. Estoy usando C++ Builder 4. Alguna sugerencia?
Que tal, acabo de retomar el tema espero que aun sea de ayuda, debes instalar los componentes ActiveX, adjunto el paquete que compile para C++ Builder 6, espero se de tu ayuda.

En cuanto al tema de guardar la huella en un archivo, lo resolví guardándolo directamente en una base de datos Interbase.

arturoio 05-01-2018 21:02:39

Hola que tal
Justo ahora estoy en esta misma situación, tengo la documentación en mano y he instalado el SDK de Digital Persona, pero no logro enternder cual es el procedimiento para trabajar con el lector.
Te agradecería mucho si me puedes orientar un poco

kagua77 28-08-2021 04:53:42

Cita:

Empezado por mordaz (Mensaje 476117)
Que tal, acabo de retomar el tema espero que aun sea de ayuda, debes instalar los componentes ActiveX, adjunto el paquete que compile para C++ Builder 6, espero se de tu ayuda.

En cuanto al tema de guardar la huella en un archivo, lo resolví guardándolo directamente en una base de datos Interbase.

que tal mordaz, quisiera saber si es posible pudieras ayudar con la implementacion del lector de huella digital(digitalpersonal) y ponernos en contacto.

de antemano, gracias


La franja horaria es GMT +2. Ahora son las 09:49:17.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi