vb.net 如何将指纹转换为唯一 ID 以用于在数据库中搜索?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37231480/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-17 19:52:43  来源:igfitidea点击:

How to convert fingerprint to unique id to use it for searching in database?

mysqlvb.netfingerprintbiometrics

提问by ss.5

I have fingerprint reader secugen and I have been able to get my application to control the fingerprint device by scanning fingerprints and I have been able to save them to mysql database!

我有指纹读取器 secugen 并且我已经能够通过扫描指纹来让我的应用程序控制指纹设备,并且我已经能够将它们保存到 mysql 数据库中!

After saving the fingerprints to the db, I now want to search for the user using fingerprint, and I can't search using new fingerprint because the fingerprint saved as blob/img. so I need to convert fingerprint to unique id to use it for searching in database?

将指纹保存到数据库后,我现在想使用指纹搜索用户,我无法使用新指纹搜索,因为指纹保存为 blob/img。所以我需要将指纹转换为唯一 id 以使用它在数据库中搜索?

I have mysql database with 9,000,000 user. Now I can get any user information by using user's (username)

我有 9,000,000 个用户的 mysql 数据库。现在我可以通过使用用户的(用户名)获取任何用户信息

SELECT USERS FROM members WHERE username=username_var

But now I can't use WHEREin my query because I have fingerprint template which is instead of (username)and the fingerprint will be changed every time, so i can't use the fingerprint in my query like (username)when i use WHEREin my query.

但是现在我不能WHERE在我的查询中使用,因为我有指纹模板而不是(username)指纹并且每次都会更改指纹,所以我不能在查询中使用指纹,就像(username)WHERE在查询中使用一样。

All fingerprint SDK have functions can help me with this but they are not so fast and take 7 minutes to search and that's a very long time.

所有指纹 SDK 的功能都可以帮助我解决这个问题,但它们不是那么快,搜索需要 7 分钟,这是很长的时间。

I do not know what to do and how. I hope that you you understand my problem

我不知道该怎么做和怎么做。我希望你能理解我的问题

回答by LSerni

Summary

概括

Either your SDK provides a way of transforming a fingerprint taken from its sensor into a string suitable for relaxed/approximate pattern matching using regular expressions, or into a binary bit vector of fixed size suitable for binary matching; oryou need to find a library to do this conversion yourself. All other cases, while feasible in theory, simply aren't practical.

您的 SDK 提供了一种方法,可以将取自传感器的指纹转换为适合使用正则表达式进行宽松/近似模式匹配的字符串,或者转换为适合二进制匹配的固定大小的二进制位向量;或者您需要找到一个库来自己进行此转换。所有其他情况虽然理论上可行,但根本不实用。

You cannot do anything with just the images.

你不能只用图像做任何事情。

And in this case, the Secugen SDKonly allows access to image (for diagnostic purposes, I imagine) and it needs to run the check itself(and you want the 1:N kit for that; the 1:1 kit won't do). If you still want to pursue this, I'll include a suggestion at the bottom. Not reallysuggested, mind you.

在这种情况下,Secugen SDK只允许访问图像(出于诊断目的,我想)并且它需要自己运行检查(并且您需要 1:N 套件;1:1 套件不会这样做)。如果你还想继续这个,我会在底部包含一个建议。不是真的建议,请注意。



Boring details

无聊的细节

Fingerprints look too much alike one another to be amenable to standard image search. Even worse, the same fingerprint from the same person will never look the same in any two readings. Different pressure, speed, direction, environment temperature, sensor and skin moisture level, will lead to different images. Basically, you can do nothinguntil and unless you convert your fingerprint to a "feature vector".

指纹看起来太相似了,无法进行标准图像搜索。更糟糕的是,同一个人的同一指纹在任何两次读数中都不会看起来相同。不同的压力、速度、方向、环境温度、传感器和皮肤湿度水平,会导致不同的图像。基本上,除非您将指纹转换为“特征向量”,否则您无能为力

There are instead functions (and your SDK should have them) to convert a fingerprint image to a list of special feature points (intersections, whorls and so on, called minutiae), along with their relative positioning and other parameters. The level up to which this happens depends on the SDK and library in use: there is more than one method. Being targeted for a very specific sensor helps, but then the methods differ in what they offer (e.g. robustness, invariance to slight fingerprints rotations, and so on). See this paperfor an example as well as references to other methods.

相反,有一些函数(你的 SDK 应该有它们)将指纹图像转换为特殊特征点列表(交叉点、螺纹等,称为细节),以及它们的相对定位和其他参数。发生这种情况的级别取决于使用的 SDK 和库:方法不止一种。针对非常特定的传感器有所帮助,但是这些方法在提供的内容上有所不同(例如,鲁棒性、对轻微指纹旋转的不变性等)。有关示例以及对其他方法的引用,请参阅本文

Some kits do not allow this (do not supply the feature vector to the user) and only provide the means of comparing two fingerprint images, usually aligning them using PCA and then running a direct minutia matching. This works very well for a few images, but run time for finding an image in a database can be ruinous, so much that specialized hardware exists for the task (google 'Automatic Fingerprint Identification Systems').

有些套件不允许这样做(不向用户提供特征向量),只提供比较两个指纹图像的方法,通常使用 PCA 对齐它们,然后运行直接细节匹配。这对于一些图像非常有效,但是在数据库中查找图像的运行时间可能是毁灭性的,以至于存在专门用于该任务的硬件(谷歌“自动指纹识别系统”)。

Once you do have the feature vector, you need to convert it to a SQL storable object, which can be a string or a series of columns in a tuple. How to do this depends on how the vector is constructed. The nature of this object will dictate what kind of search you'll be able to run. This translation can be done in a number of waysand it definitely isn't something you should try on your own.

获得特征向量后,您需要将其转换为 SQL 可存储对象,该对象可以是字符串或元组中的一系列列。如何做到这一点取决于向量的构建方式。此对象的性质将决定您可以运行的搜索类型。这种翻译可以通过多种方式完成绝对不是您应该自己尝试的事情。

This also because even after vectorizing the fingerprints, you will still have no exactmatch. Not even between two fingerprints from the same person taken within the same minute. You will have instead a number of positive matches and a number of negative matches, and will need to establish a confidence threshold for both ("it's him", "it's not him", "can't say"). As well as deciding whether and to what extend tolerate false positives ("Yes, it's him!" - but it's not) and false negatives ("Nay, it's not him" - and it was). On a door lock you want no false positives, but can tolerate a false negative (you just slide your finger again). In a criminal investigation you can't allow a false negative to let the culprit slip, and you can accept a dozen false positives (you'll check their alibis later...) but not a hundred (you can't check out one hundred persons, and some of them won't have an alibi - no way you can arrest them all).

这也是因为即使在对指纹进行矢量化之后,您仍然没有准确的比赛。甚至在同一分钟内采集的同一个人的两个指纹之间也不行。相反,您将有一些肯定匹配和一些否定匹配,并且需要为两者建立一个置信度阈值(“是他”、“不是他”、“不能说”)。以及决定是否以及在多大程度上容忍误报(“是的,是他!” - 但不是)和漏报(“不,不是他” - 确实如此)。在门锁上,您不希望出现误报,但可以容忍误报(您只需再次滑动手指)。在刑事调查中,你不能让假阴性让罪魁祸首溜走,你可以接受十几个假阳性(你稍后会检查他们的不在场证明......)但不能接受一百个(你不能)

And for large databases you will alwayshave to run a first pass whereby you restrict the search to those fingerprints that do have a reasonable invariantfeature match (for instance, "absolute number of whorls between 75% and 125% of the sample). This is necessary to reduce the number of tuples you will then subject to further non-invariant analysis, which is much more expensive and definitely cannotbe done with standard MySQL functions.

对于大型数据库,您将始终必须运行第一遍,从而将搜索限制为具有合理不变特征匹配的指纹(例如,“样本的 75% 到 125% 之间的绝对螺纹数)。这有必要减少元组的数量,然后您将接受进一步的非不变分析,这要昂贵得多,而且绝对不能用标准的 MySQL 函数来完成。

A different approach is to transform a fingerprint in a coded string representation, such that search may be done using a reasonable lexicographical approach available in a mainstream database (e.g. regular expression plus Levenshtein distance). Your SDK either supports this string conversion, or it doesn't; it involves one, possibly several transforms in feature and spectral domain. The trustworthiness of the method depends on how many features can be crammed into the string (the more signatures you have, the more precise the match needs to be, the more features you need, the longer the string).

一种不同的方法是在编码字符串表示中转换指纹,这样可以使用主流数据库中可用的合理词典方法进行搜索(例如,正则表达式加上 Levenshtein 距离)。您的 SDK 要么支持此字符串转换,要么不支持;它涉及一个,可能是几个特征域和谱域的变换。该方法的可信度取决于可以将多少特征塞进字符串中(您拥有的签名越多,匹配需要越精确,您需要的特征越多,字符串越长)。

You may be able to use some external library that does the encoding and checking for you using a suitable algorithm.

您可以使用一些外部库,使用合适的算法为您进行编码和检查。

Even a simple thing such as "returning the closest match or define whether there isa match at all?" heavily depends on how the fingerprint is manipulated before storing. That's why usually SDKs will supply a high-level interface to match a fingerprint, andthey'll do the heavy lifting themselves. Sometimes this heavy lifting is not translatable to a database at all (or not without tremendous difficulties); for example if the "enrollment" is actually the training of a neural network, and not the insertion of a feature vector into a database.

即使是一个简单的事情,如“返回最接近的匹配或定义是否匹配呢?” 在很大程度上取决于在存储之前如何操作指纹。这就是为什么通常 SDK 会提供一个高级接口来匹配指纹,并且它们会自己完成繁重的工作。有时,这种繁重的工作根本无法转化为数据库(或者并非没有巨大的困难);例如,如果“注册”实际上是神经网络的训练,而不是将特征向量插入数据库。

Dirty hack

肮脏的黑客

You have nine million users (who are you, the FBI?) and permission to get nine million fingerprints. And you have this one SDK. And matching nine million images is out of the question. Butfor the reasons stated above, you can only ask the SDK the question, "is this image in your database?" and receive a list of, say, three names with "Yes at 99%, yes at 92%, yes at 90%".

你有 900 万用户(你是谁,联邦调查局?)并允许获取 900 万个指纹。你有这个 SDK。匹配 900 万张图像是不可能的。由于上述原因,您只能向 SDK 提出问题,“这张图片在您的数据库中吗?” 并收到一个包含三个名字的列表,例如“是 99%,是 92%,是 90%”。

You can perhapsdo this: run a very high level, very rough binningon the image, based on something really macroscopic. I don't know, maybe the number of ridge minutiae. You will have to do this by examinining the image; possibly OpenCV might help you. You will get a number ranging from 1 to N, and this number will be unreliable, with an error of say 2%.

也许可以这样做:基于非常宏观的东西,在图像上运行非常高级别、非常粗略的分箱。我不知道,也许是山脊细节的数量。您必须通过检查图像来做到这一点;可能 OpenCV 可能会帮助你。你会得到一个从 1 到 N 的数字,这个数字是不可靠的,有 2% 的误差。

The key here is that you must be sure that the SDK will never say that a fingerprint that should go into block X will ever match with one that you binned into block Y.

这里的关键是您必须确保 SDK 永远不会说应该进入块 X 的指纹将永远与您分入块 Y 的指纹匹配。

Then you can build fifty databases with one fiftieth of the users each, supposing (rather: hoping) that your parameter distribution is reasonably flat, and not a steep Gaussian. When analyzing a fingerprint, you can copy in the SDK database directory one of the fifty databases, the one corresponding to the X value from the fingerprint you have, and in which you will have stored only those users with the same X value. Due to uncertainty, some users will be in two databases, but this way you reduce the problem by a factor of fifty (or maybe forty-five).

然后您可以构建五十个数据库,每个数据库包含五分之一的用户,假设(而是:希望)您的参数分布相当平坦,而不是陡峭的高斯分布。在分析指纹时,您可以将 50 个数据库中的一个复制到 SDK 数据库目录中,该数据库与您拥有的指纹中的 X 值相对应,并且您将仅存储具有相同 X 值的那些用户。由于不确定性,一些用户将在两个数据库中,但通过这种方式,您可以将问题减少 50 倍(或者可能是 45 倍)。

You still need to call the SDK matching function, since you have no other way of classifying the incoming fingerprint; but you can perhaps reduce the run time to manageable proportions.

您仍然需要调用SDK匹配函数,因为您没有其他方法对传入的指纹进行分类;但是您也许可以将运行时间减少到可管理的比例。

回答by mageos

There is a common misconception that there is a way to convert a fingerprint image into a unique ID that can be compared against the same way a password or a hash of a password can be compared. In reality, all fingerprint algorithms that I know of operate on some basic principles.

有一种常见的误解,认为有一种方法可以将指纹图像转换为唯一 ID,该 ID 可以与比较密码或密码散列的相同方式进行比较。实际上,我所知道的所有指纹算法都基于一些基本原理。

Extraction
The first step in processing a fingerprint image is extraction. This typically involves a number of image processing algorithms to create a clean, binarized version of the image. This is then processed for minutia points and other data points that are useful when comparing images. These points are stored in a data struct called a template. Because no two impressions of a finger will ever be exactly the same, even these templates cannot be hashed and compared for equality. The only way to compare fingerprints is with a matching algorithm.

提取
处理指纹图像的第一步是提取。这通常涉及许多图像处理算法来创建图像的干净、二值化版本。然后对细节点和其他在比较图像时有用的数据点进行处理。这些点存储在称为模板的数据结构中。由于手指的两个印象永远不会完全相同,因此即使这些模板也无法进行散列和比较以确保相等性。比较指纹的唯一方法是使用匹配算法。

Matching
Matching takes two templates and compares them. Most of the time this involves taking the relative locations of similar minutia points in each image. Sometimes the templates need to be rotated to accommodate variations in the users placement of their finger. The algorithm then takes the results of all these comparisons and generates a score that represents how confident the algorithm is that the two templates match.

匹配
匹配需要两个模板并比较它们。大多数情况下,这涉及获取每个图像中相似细节点的相对位置。有时需要旋转模板以适应用户手指放置的变化。然后,该算法获取所有这些比较的结果,并生成一个分数,该分数表示该算法对两个模板匹配的置信度。

Once a score is generated the application can check to see if is high enough to consider as a match.

生成分数后,应用程序可以检查是否足够高以视为匹配。

No biometric algorithm is perfect. Algorithms have their accuracy measured by two metrics, the False Accept Rate (FAR) and the False Reject Rate (FRR). As you work to lower the FAR, you inevitably will increase the FRR as the threshold for matching will increase.

没有生物识别算法是完美的。算法的准确性通过两个指标来衡量,即错误接受率 (FAR) 和错误拒绝率 (FRR)。当您努力降低 FAR 时,您不可避免地会增加 FRR,因为匹配阈值会增加。

回答by Joseph

I do not know if this will be of much help to you but basing my answer on what I have done on other SDKs while converting extracted templates to either ANSI or ISO format for saving of fingerprint templates to database, in your case you could e.g. use either of the following based on if you want ANSI or ISO template formats.

我不知道这是否对您有很大帮助,但我的回答基于我在其他 SDK 上所做的工作,同时将提取的模板转换为 ANSI 或 ISO 格式以将指纹模板保存到数据库,在您的情况下,您可以使用以下任一基于您是否需要 ANSI 或 ISO 模板格式。

m_FPM.SetTemplateFormat(SGFPMTemplateFormat.ANSI378);to set your template to ANSI378 then save it to database

m_FPM.SetTemplateFormat(SGFPMTemplateFormat.ANSI378); 将您的模板设置为 ANSI378 然后将其保存到数据库

or

或者

m_FPM.SetTemplateFormat(SGFPMTemplateFormat.ISO19794);to set your template to ISO19794-2 then save it to database

m_FPM.SetTemplateFormat(SGFPMTemplateFormat.ISO19794); 将您的模板设置为 ISO19794-2 然后将其保存到数据库

then when you are matching your captured fingerprint template to those saved in the database you then capture a fingerprint image then convert it to either ANSIor ISOtemplate depending on the template format type you chose to save your templates then do the matching with either MatchAnsiTemplateor MatchIsoTemplatefunctions in your SDK according to the template format you chose for your archived fingerprint templates in your database.

然后,当您将捕获的指纹模板与保存在数据库中的指纹模板进行匹配时,您将捕获指纹图像,然后根据您选择保存模板的模板格式类型将其转换为ANSIISO模板,然后使用MatchAnsiTemplate或根据您为数据库中存档指纹模板选择的模板格式,MatchIsoTemplate在您的 SDK 中运行。

I also noted that Secugen has it own proprietor Template format SG400which you could also choose to use as well. The main concern here is that if you saved your fingerprint templates in ANSI format then for your captured fingerpint image convert it to ANSI template then loop through your fingerprint templates in database and use MatchAnsiTemplatefunction to find the correct match. If you saved your fingerprint templates in ISOformat then for your captured fingerpint image convert it to ISOtemplate then loop through your fingerprint templates in database and use MatchIsoTemplatefunction to find the correct match.

我还注意到 Secugen 拥有自己的所有者模板格式SG400,您也可以选择使用它。这里的主要问题是,如果您以 ANSI 格式保存指纹模板,那么对于您捕获的指纹图像,将其转换为 ANSI 模板,然后在数据库中循环您的指纹模板,并使用MatchAnsiTemplate函数找到正确的匹配项。如果您以ISO格式保存指纹模板,那么对于捕获的指纹图像,将其转换为ISO模板,然后在数据库中循环您的指纹模板并使用MatchIsoTemplate函数找到正确的匹配项。