Get a database management tool for your database system. Using it you can form queries to the database in an interactive way. Once you discover what queries need to be made to get the results you want then translate those queries to your application. If you're database is SQL Server based then MS has the free "Microsoft SQL Server Management Studio Express", get the version that matches your server (2005, 2008).
What database system do you use? Someone here can probably point you to a good management tool for your particular system.
http://en.wikipedia.org/wiki/Compari...database_tools
If there is no upper limit to the number of database entries, then "to read in memory the content of the database in 1 shot" is not a solution. It's possible that the current query can be reformed to work more efficient with the db. Playing what if queries in an interactive way can help with the discovery.
I don't know what your query is or the db structure. From the description it sounds like the query is doing a brute force search. If so, then maybe this simple, far from optimized, approach could be better than the current one. There are iris codes 1 - 3, lets call them x, y, z.
1) get collection results of everything matching x.
2) from previous result set, get collection result of everything matching y.
3) from previous result set, get collection result of everything matching z.
4) Should have 1 result in collection.
Here is an example that creates an Sqlite database with 100 test rows and a series of queries against it.Should work against a Mysql or other database also.Qt Code:
#include <QtCore> #include <QtSql> #include <QDebug> void createTestData() { db.setDatabaseName("test.db"); if (db.open()) { QSqlQuery query; query.exec("create table irisdata (" "userid varchar(20), " "iriscode1 blob, " "iriscode2 blob, " "iriscode3 blob, " "primary key(userid) )"); if (query.prepare( "insert into irisdata (" "userid, iriscode1, iriscode2, iriscode3) " "values (?, ?, ?, ?)" )) { for (int i=0; i<100; ++i) { query.bindValue(1, blobData1); query.bindValue(2, blobData2); query.bindValue(3, blobData3); query.exec(); } } } } { QSqlQuery query; if (query.prepare( "select userid from irisdata " "where iriscode1 = ? OR iriscode2 = ? or iriscode3 = ?") ) { query.bindValue(0, ba); query.bindValue(1, ba); query.bindValue(2, ba); if (query.exec()) { while (query.next()) qDebug() << "Found" << query.value(0).toString(); } } } int main(int argc, char *argv[]) { createTestData(); }To copy to clipboard, switch view to plain text mode
Hi Wysota.
I don't know how a neural network can help me. IN the database I don't store iris images but only the extracted encoded iris code.
Regards,
SixDegrees I was part of the development of the iris recognition kernel and now I would implement a demo showing the results of the matching.
So my 'problem' is looping through the iris codes stored in the database.
Regards
Added after 10 minutes:
Hi Chris,
your code is very interesting but the 'queryTestData' will not work because a iris code will never be the same. A matching is performed calculating the hamming distance over 2 iris codes. Something like this:
Qt Code:
if ( hamming_distance( iris_code1, iris_code2) < threshold ) qDebug() << " MATCH "; else qDebug() << " NO MATCH ";To copy to clipboard, switch view to plain text mode
So I think it's mandatory to scan every code stored in the database.
Best Regards
Last edited by franco.amato; 31st December 2010 at 06:47.
Franco Amato
Are you calculating the hamming distance between the values in two columns of the same record, or between a candidate iris code and each of three columns in each record? If it is the former then you only ever need do this once and store the result.
Have you profiled your code to make sure that it is not the hamming distance algorithm that is chewing the time? Don't waste time optimising something that is not the biggest problem.
It is possible to provide an extension to Sqlite to give it the hamming_distance function it does not currently have. This is will be more efficient than dragging the data through Qt's Sql layers but is obviously another bunch of APIs to learn.
It's between a candidate and each of the three columns in each record.
I didn't get you.If it is the former then you only ever need do this once and store the result.
The matching routine is really fast.Have you profiled your code to make sure that it is not the hamming distance algorithm that is chewing the time? Don't waste time optimising something that is not the biggest problem.
My initial doubt was if I have to copy all database entry in memory and performing the matching there instead of doing n queries against the database.
Here we're using microsoft sql express 2005.It is possible to provide an extension to Sqlite to give it the hamming_distance function it does not currently have. This is will be more efficient than dragging the data through Qt's Sql layers but is obviously another bunch of APIs to learn.
Regards
Franco Amato
I'm sure it can be extended with custom functions as well.
The first three links from Google:
http://www.sqlteam.com/article/user-defined-functions
http://www.sqlteam.com/article/intro...ctions-updated
http://www.dreamincode.net/forums/to...ions-in-mssql/
Just a side note - IF the database runs on another host than the device performing the scans there is always a subject of security as I understand this iris scanning is meant to provide security. If you do the matching on a machine different than the one that actually gives the user some "access" then you have to think whether you are not making yourself vulnerable to things such as man-in-the-middle attack, a situation when an intruder substitutes the host with the database server with his own version (e.g. by rerouting you to a different machine) or simply performs a successfull attack against the host that contains the database. Since you have no control over the other host, protection against such attacks is not a trivial task.
Based on the information you've provided I'd look into storing a spatial index in the database. Queries could then be very fast. This link might be of use (refer to the excepted answer).
http://stackoverflow.com/questions/3...mysql-database
Given the luxury of having a whole spatial index in memory, look into adapting the Kd-tree algorithm to the data set. Iris codes 1 - 3 are treated as X, Y, Z coordinates, distance calculations would use the hammering algorithm. Then nearest neighbor and nearest range queries could be performed.
Based on the features (the "iris code" as you call it) it immediately classifies an unknown feature vector into a pre-learned set of feature sets (iris scans) without the need for looping over each iris record and performing the comparison. Then you don't even have to load the scans from the database or just load one or two to confirm the results of the algorithm.
Bookmarks