loba73
asked on
Convertion SDK Vc++ to Delphi - fingerprint reader
Hi,
i have a problem with a fingerprint reader. My SDK is in Vc++ and i need to write the application in Delphi.
Could you help me ?
I try with the code found in this site and it work well, but when i verify never pass.
If I build in Vc++ the code it works fine.
This is the procedure in VC++ and bottom the same in Delphi where never verify finger :
********* VC++ *************
void
CHM120SS500ASDK4DemoAPDlg: :OnDoenrol l() {
BYTE pEnrolledFeatures[PTFV_MAX _TEMPLATE_ SIZE];
int iStatus = 1;
DWORD iEnSize;
BOOL bret;
int sensor_timeout = 10000;
char pctmp[128];
int iQStatus;
bsweep = true;
while ((iStatus > 0) && (bsweep)) {
memset(m_pPicture, 0x00, SENSOR_HEIGHT * SENSOR_WIDTH);
m_status.SetWindowText("Sw eep your finger...");
m_iWidth = SENSOR_WIDTH;
m_iHeight = SENSOR_HEIGHT;
bret = bAPI4_GetImage(m_pPicture, sensor_timeout, SENSOR_RESOLUTION,
&m_iWidth, &m_iHeight, &iQStatus);
if (SENSOR_OK != bret) {
m_status.SetWindowText("Ge t finger image failed");
return ;
} else {
m_status.SetWindowText("Ge t Image OK!");
}
if (!bAPI4_PTFVEnroll(SENSOR_ RESOLUTION , SENSOR_WIDTH, SENSOR_HEIGHT,
m_pPicture, pEnrolledFeatures, &iEnSize,
&iStatus)) {
m_status.SetWindowText("En rolled error!");
bsweep = 0;
}
//m_iEnroll++;
//sprintf(pctmp, "%d", iEnSize);
//MessageBox(pctmp);
this->InvalidateRect(NULL, TRUE);
this->UpdateWindow();
}
switch (iStatus) {
case PTFV_STS_EN_SUCCESS:
memcpy(m_SAbuf + m_iEnroll * PTFV_MAX_TEMPLATE_SIZE,
pEnrolledFeatures, PTFV_MAX_TEMPLATE_SIZE);
m_iEnroll++;
sprintf(pctmp, "*** The %d-th finger enrolled ***", m_iEnroll);
if (MAX_ENROLLED_FINGER_NUM == m_iEnroll) {
m_iEnroll--;
}
m_status.SetWindowText(pct mp);
break;
case PTFV_STS_EN_TOOMANY_POORIM G:
m_status.SetWindowText("'M AX_POOR_IM AGE_TOLERA NCE' of poor image met");
break;
case PTFV_STS_EN_TOOMAY_TRIALS:
m_status.SetWindowText("To o many useless sweepings (12 times in default)");
break;
case PTFV_STS_EN_FAIL:
m_status.SetWindowText("En rolled failed");
break;
case PTFV_STS_EN_CONTINUE:
m_status.SetWindowText("Bu tton 'Stop Getting Image' pressed");
break;
}
GetDlgItem(IDC_DOENROLL)-> EnableWind ow(FALSE);
}
****** DELPHI *******
In delphi the part of code that seem wrong is :
procedure TForm1.EnrollClick(Sender: TObject);
Var
iWidth, iHeight, TimeOut, iEnSize, iStatus,iStatusImg, Num: Integer;
r_value, r_value2: Boolean;
bsweep: Boolean;
EnrlTemplate: TMyByteArray ;
m_Picture: TMyByteArray;
bmpFinger:TBitmap;
i:Integer;
begin
SetLength(EnrlTemplate,(PT FV_MAX_TEM PLATE_SIZE ) );
SetLength(m_Picture,(SENSO R_WIDTH * SENSOR_HEIGHT) );
TimeOut := 10000;
bsweep := True;
iStatus := 1;
m_iEnroll := 0;
While (iStatus > 0) And (bsweep = True) Do
Begin
m_Picture:=nil;
SetLength(m_Picture,(SENSO R_WIDTH * SENSOR_HEIGHT) );
iWidth := SENSOR_WIDTH ;
iHeight := SENSOR_HEIGHT;
Label1.Caption := 'Put your finger on sensor + ...'+ IntToStr (m_iEnroll);
Application.ProcessMessage s;
r_value := bAPI4_GetImage(@m_Picture[ 0], TimeOut, SENSOR_RESOLUTION, iWidth, iHeight,iStatusImg);
if r_value = False Then
Label1.Caption := 'Get finger image failed!'
Else
Label1.Caption := 'Get Image OK!';
r_value2 := bAPI4_PTFVEnroll(SENSOR_RE SOLUTION, iWidth, iHeight,
@m_Picture[0], @EnrlTemplate[0], iEnSize, iStatus);
bmpFinger:= TBitmap.Create;
bmpFinger.Width:= iWidth;
bmpFinger.Height:= iHeight;
bmpFinger.PixelFormat:= pf8bit;
BytesToBitmap(m_Picture, bmpFinger,
pf8bit,
bmpFinger.Width,
bmpFinger.Height);
Image1.Picture.Bitmap.Assi gn(bmpFing er);
if r_value2 = False Then
Begin
Label1.Caption := 'Enrolled error!';
bsweep := False;
End;
End;
Case iStatus Of
PTFV_STS_EN_SUCCESS:
Begin
// ********** THIS PART IS DIFFERENT FROM VC++ using MemCpy ************
Label1.Caption := 'Enrolled OK!';
For Num := 0 To PTFV_MAX_TEMPLATE_SIZE -1 Do
m_SAbuf[m_iEnroll * PTFV_MAX_TEMPLATE_SIZE + Num] := EnrlTemplate[Num];
End;
PTFV_STS_VF_FAIL: Begin
Label1.Caption := ' PTFV_STS_VF_FAIL !';
End;
PTFV_STS_EN_TOOMANY_POORIM G: Begin
Label1.Caption := ' PTFV_STS_EN_TOOMANY_POORIM G!';
End;
PTFV_STS_EN_TOOMAY_TRIALS: Begin
Label1.Caption := ' PTFV_STS_EN_TOOMAY_TRIALS! ';
End;
End;
end;
and in the verify
procedure TForm1.VerifyPBClick;
var
...
...
begin
...
r_value2 := bAPI4_PTFVVerify(SENSOR_RE SOLUTION, iWidth, iHeight,
@m_Picture[0], @m_SAbuf[0], m_iEnroll, iMatchID, iStatus);
if r_value2 Then
if (iStatus = PTFV_STS_VF_SUCCESS) Then
begin
// ************************** **********
// ***** IN DELPHI NEVER ENTER HERE *****
//************************ ********** **
label1.Caption := '*** Verify Pass! ' + IntToStr(iMatchID)
end
Else
label1.Caption := 'No Pass';
end;
Thanks in advance.
i have a problem with a fingerprint reader. My SDK is in Vc++ and i need to write the application in Delphi.
Could you help me ?
I try with the code found in this site and it work well, but when i verify never pass.
If I build in Vc++ the code it works fine.
This is the procedure in VC++ and bottom the same in Delphi where never verify finger :
********* VC++ *************
void
CHM120SS500ASDK4DemoAPDlg:
BYTE pEnrolledFeatures[PTFV_MAX
int iStatus = 1;
DWORD iEnSize;
BOOL bret;
int sensor_timeout = 10000;
char pctmp[128];
int iQStatus;
bsweep = true;
while ((iStatus > 0) && (bsweep)) {
memset(m_pPicture, 0x00, SENSOR_HEIGHT * SENSOR_WIDTH);
m_status.SetWindowText("Sw
m_iWidth = SENSOR_WIDTH;
m_iHeight = SENSOR_HEIGHT;
bret = bAPI4_GetImage(m_pPicture,
&m_iWidth, &m_iHeight, &iQStatus);
if (SENSOR_OK != bret) {
m_status.SetWindowText("Ge
return ;
} else {
m_status.SetWindowText("Ge
}
if (!bAPI4_PTFVEnroll(SENSOR_
m_pPicture, pEnrolledFeatures, &iEnSize,
&iStatus)) {
m_status.SetWindowText("En
bsweep = 0;
}
//m_iEnroll++;
//sprintf(pctmp, "%d", iEnSize);
//MessageBox(pctmp);
this->InvalidateRect(NULL,
this->UpdateWindow();
}
switch (iStatus) {
case PTFV_STS_EN_SUCCESS:
memcpy(m_SAbuf + m_iEnroll * PTFV_MAX_TEMPLATE_SIZE,
pEnrolledFeatures, PTFV_MAX_TEMPLATE_SIZE);
m_iEnroll++;
sprintf(pctmp, "*** The %d-th finger enrolled ***", m_iEnroll);
if (MAX_ENROLLED_FINGER_NUM == m_iEnroll) {
m_iEnroll--;
}
m_status.SetWindowText(pct
break;
case PTFV_STS_EN_TOOMANY_POORIM
m_status.SetWindowText("'M
break;
case PTFV_STS_EN_TOOMAY_TRIALS:
m_status.SetWindowText("To
break;
case PTFV_STS_EN_FAIL:
m_status.SetWindowText("En
break;
case PTFV_STS_EN_CONTINUE:
m_status.SetWindowText("Bu
break;
}
GetDlgItem(IDC_DOENROLL)->
}
****** DELPHI *******
In delphi the part of code that seem wrong is :
procedure TForm1.EnrollClick(Sender:
Var
iWidth, iHeight, TimeOut, iEnSize, iStatus,iStatusImg, Num: Integer;
r_value, r_value2: Boolean;
bsweep: Boolean;
EnrlTemplate: TMyByteArray ;
m_Picture: TMyByteArray;
bmpFinger:TBitmap;
i:Integer;
begin
SetLength(EnrlTemplate,(PT
SetLength(m_Picture,(SENSO
TimeOut := 10000;
bsweep := True;
iStatus := 1;
m_iEnroll := 0;
While (iStatus > 0) And (bsweep = True) Do
Begin
m_Picture:=nil;
SetLength(m_Picture,(SENSO
iWidth := SENSOR_WIDTH ;
iHeight := SENSOR_HEIGHT;
Label1.Caption := 'Put your finger on sensor + ...'+ IntToStr (m_iEnroll);
Application.ProcessMessage
r_value := bAPI4_GetImage(@m_Picture[
if r_value = False Then
Label1.Caption := 'Get finger image failed!'
Else
Label1.Caption := 'Get Image OK!';
r_value2 := bAPI4_PTFVEnroll(SENSOR_RE
@m_Picture[0], @EnrlTemplate[0], iEnSize, iStatus);
bmpFinger:= TBitmap.Create;
bmpFinger.Width:= iWidth;
bmpFinger.Height:= iHeight;
bmpFinger.PixelFormat:= pf8bit;
BytesToBitmap(m_Picture, bmpFinger,
pf8bit,
bmpFinger.Width,
bmpFinger.Height);
Image1.Picture.Bitmap.Assi
if r_value2 = False Then
Begin
Label1.Caption := 'Enrolled error!';
bsweep := False;
End;
End;
Case iStatus Of
PTFV_STS_EN_SUCCESS:
Begin
// ********** THIS PART IS DIFFERENT FROM VC++ using MemCpy ************
Label1.Caption := 'Enrolled OK!';
For Num := 0 To PTFV_MAX_TEMPLATE_SIZE -1 Do
m_SAbuf[m_iEnroll * PTFV_MAX_TEMPLATE_SIZE + Num] := EnrlTemplate[Num];
End;
PTFV_STS_VF_FAIL: Begin
Label1.Caption := ' PTFV_STS_VF_FAIL !';
End;
PTFV_STS_EN_TOOMANY_POORIM
Label1.Caption := ' PTFV_STS_EN_TOOMANY_POORIM
End;
PTFV_STS_EN_TOOMAY_TRIALS:
Label1.Caption := ' PTFV_STS_EN_TOOMAY_TRIALS!
End;
End;
end;
and in the verify
procedure TForm1.VerifyPBClick;
var
...
...
begin
...
r_value2 := bAPI4_PTFVVerify(SENSOR_RE
@m_Picture[0], @m_SAbuf[0], m_iEnroll, iMatchID, iStatus);
if r_value2 Then
if (iStatus = PTFV_STS_VF_SUCCESS) Then
begin
// **************************
// ***** IN DELPHI NEVER ENTER HERE *****
//************************
label1.Caption := '*** Verify Pass! ' + IntToStr(iMatchID)
end
Else
label1.Caption := 'No Pass';
end;
Thanks in advance.
The only thing that jumps out at me is that the boolean should most likely be word bool. I will need to look at it more when I have time.
WordBool
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.