usnistgov / NFIQ2

Optical live-scan and ink fingerprint image quality assessment tool
https://www.nist.gov/services-resources/software/development-nfiq-20
Other
129 stars 57 forks source link

InitNfiq2 returns null #293

Closed hafedh-trimeche closed 3 years ago

hafedh-trimeche commented 3 years ago

Nfiq2Api.dll successfully loaded but InitNfiq2 always returns null even if the Nfiq2Api.dll and nist_plain_tir-ink.yaml are located in the same folder as the executable file.

unit uNFIQ;
{$I ReleaseDebug.inc}
{$R NFIQ}
{$R NFIQLib}
interface
uses
  Classes;
var
  GetNfiq2Version   : procedure(out major,minor,patch:Integer;var ocv:PAnsiChar);stdcall;
  ComputeNfiq2Score : function(fpos:Integer;pixels:PByte;size,width,height,ppi:Integer):Integer;stdcall;

procedure InitNfiqLib;

implementation
uses
  uDynLib;
var
  LibLoaded : Boolean=False;
  InitNfiq2 : function(var hash:PAnsiChar):PAnsiChar;stdcall;

procedure InitNfiqLib;
var
  LibHandle : TModuleHandle;
  hash      : PAnsiChar;
  ret       : PAnsiChar;
function ProcAddress(FunctionName:string):Pointer;
begin
  Result := DllProcAddress(LibHandle,FunctionName);
end;
begin
  if LibLoaded then Exit;
  LibLoaded := True;
  DllLoad(LibHandle,'Nfiq2Api.dll');
  @GetNfiq2Version   := ProcAddress('GetNfiq2Version');
  @InitNfiq2         := ProcAddress('InitNfiq2');
  @ComputeNfiq2Score := ProcAddress('ComputeNfiq2Score');
  hash               := nil;
  ret                := InitNfiq2(hash);
  Assert(ret<>nil);
end;

end.
gfiumara commented 3 years ago

Hello, a couple notes:

  1. The C API in Nfiq2Api.dll is basic, unsupported, and will be removed in the very near future, replaced with something better and actually tested. This was hopefully evident by the required pre-processor compile-time definition. Did you set that?
  2. When InitNfiq2 returns nullptr (as opposed to crashing or returning != nullptr), it prints to stderr starting with NFIQ2 ERROR =>. Do you see anything?
  3. Is this Pascal? We have not anticipated directly supporting that language, though if Pascal can call C, then maybe so! That said, I have no idea what to expect when calling this unsupported library from an unsupported language.
gfiumara commented 3 years ago

Closing due to inactivity and unsupported language in original issue.