我一直在修改SDK提供的代码。该代码为我提供了一个选项,用于在ItemList中选择的扫描指纹进行验证,并返回计算得分的值,并说明扫描的指纹是否与所选的相同。但我想要的是读取指纹并在数据库中找到它。我使用的是U.are.U 4500指纹识别器。所以我想做的就是这个,我想要表现的是matching one-to-many
所以,这里是修改之前执行匹配的代码:
private void btnVerify_Click(object sender, EventArgs e)
{
if (lbDatabase.SelectedIndex < 0)
{
MessageBox.Show("Please select a record from the database.");
}
else
{
try
{
RunWorkerCompletedEventArgs taskResult = BusyForm.RunLongTask("Waiting for fingerprint ...", new DoWorkEventHandler(doVerify),
false, ((CData)lbDatabase.SelectedItem).EngineUser, new EventHandler(CancelScanningHandler));
VerificationResult verificationResult = (VerificationResult)taskResult.Result;
if (verificationResult.engineStatus == NffvStatus.TemplateCreated)
{
if (verificationResult.score > 0)
{
MessageBox.Show(string.Format("{0} verified.\r\nFingerprints match. Score: {1}", ((CData)lbDatabase.SelectedItem).Name, verificationResult.score));
}
else
{
MessageBox.Show(string.Format("{0} not verified.\r\nFingerprints do not match. Score: {1}", ((CData)lbDatabase.SelectedItem).Name, verificationResult.score));
}
}
else
{
MessageBox.Show(string.Format("Verification was not finished. Reason: {0}", verificationResult.engineStatus));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
private void doVerify(object sender, DoWorkEventArgs args)
{
VerificationResult verificationResult = new VerificationResult();
verificationResult.score = _engine.Verify((NffvUser)args.Argument, 20000, out verificationResult.engineStatus);
args.Result = verificationResult;
}
以下是我在数据库中查找指纹所做的修改的代码。
private void btnVerify_Click(object sender, EventArgs e)
{
try
{
RunWorkerCompletedEventArgs taskResult = BusyForm.RunLongTask("Waiting for finger ...", new DoWorkEventHandler(doVerify),
false, lbDatabase.Items.Cast<CData>().ToArray(), new EventHandler(CancelScanningHandler));
VerificationResult verificationResult = (VerificationResult)taskResult.Result;
if (verificationResult.engineStatus == NffvStatus.TemplateCreated)
{
if (verificationResult.score > 0)
{
MessageBox.Show(string.Format("{0} verified.\r\nFingerprints match. Score: {1}", ((CData)lbDatabase.SelectedItem).Name, verificationResult.score));
}
else
{
MessageBox.Show(string.Format("{0} not verified.\r\nFingerprints do not match. Score: {1}", ((CData)lbDatabase.SelectedItem).Name, verificationResult.score));
}
}
else
{
MessageBox.Show(string.Format("Verification was not finished. Reason: {0}", verificationResult.engineStatus));
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void doVerify(object sender, DoWorkEventArgs args)
{
CData[] items = (CData[])args.Argument;
VerificationResult verificationResult = new VerificationResult();
uint timep = 5000;
for (int i = 0; i < items.Length; i++)
{
if (i != 0)
{
timep = 0;
}
verificationResult.score = _engine.Verify(items[i].EngineUser, timep, out verificationResult.engineStatus);
if (verificationResult.score > 0) break;
}
args.Result = verificationResult;
}
好吧,当我扫描人的手指并且是数据库中的第一个时,我得到了正确的结果(匹配的分数),但是当扫描的手指在另一个不是itemList中的第一个的地方时verificationResult.score
始终返回-1
。
我不知道这个实现是否正确我想要任何建议。