PostgreSQL , 指紋 , printfinger , pgafis , 特徵值 , 索引git
pgafis是一個插件,支持存儲指紋特徵值,同時將指紋特徵比對算法做爲UDF編寫到了數據庫中,安裝這個插件依賴指紋比對算法庫。github
https://www.nist.gov/services-resources/software/nist-biometric-image-software-nbis算法
https://github.com/lessandro/nbis數據庫
pgafis插件代碼地址app
https://github.com/hjort/pgafisless
pgAFIS - Automated Fingerprint Identification System support for PostgreSQLide
Table "public.fingerprints" Column | Type | Modifiers --------+--------------+----------- id | character(5) | not null pgm | bytea | wsq | bytea | mdt | bytea | xyt | text | Indexes: "fingerprints_pkey" PRIMARY KEY, btree (id)
afis=> SELECT id, length(pgm) AS raw_bytes, length(wsq) AS wsq_bytes, length(mdt) AS mdt_bytes, length(xyt) AS xyt_chars FROM fingerprints LIMIT 5; id | pgm_bytes | wsq_bytes | mdt_bytes | xyt_chars -------+-----------+-----------+-----------+----------- 101_1 | 90015 | 27895 | 162 | 274 101_2 | 90015 | 27602 | 186 | 312 101_3 | 90015 | 27856 | 146 | 237 101_4 | 90015 | 28784 | 154 | 262 101_5 | 90015 | 27653 | 194 | 324 (5 rows)
afis=> UPDATE fingerprints SET wsq = cwsq(pgm, 2.25, 300, 300, 8, null) WHERE wsq IS NULL;
afis=> UPDATE fingerprints SET mdt = mindt(wsq, true) WHERE mdt IS NULL;
afis=> SELECT (bz_match(a.mdt, b.mdt) >= 20) AS match FROM fingerprints a, fingerprints b WHERE a.id = '101_1' AND b.id = '101_6'; match ------- t (1 row)
afis=> SELECT a.id AS probe, b.id AS sample, bz_match(a.mdt, b.mdt) AS score FROM fingerprints a, fingerprints b WHERE a.id = '101_1' AND b.id != a.id AND bz_match(a.mdt, b.mdt) >= 23 LIMIT 3; probe | sample | score -------+--------+------- 101_1 | 101_2 | 23 101_1 | 101_4 | 24 101_1 | 101_5 | 27 (3 rows)
afis=> SELECT a.id AS probe, b.id AS sample, bz_match(a.xyt, b.xyt) AS score FROM fingerprints a, fingerprints b WHERE a.id = '101_1' AND b.id != a.id AND bz_match(a.mdt, b.mdt) >= 20 ORDER BY score DESC; probe | sample | score -------+--------+------- 101_1 | 101_6 | 28 101_1 | 101_5 | 27 101_1 | 101_8 | 26 101_1 | 101_2 | 23 101_1 | 101_4 | 23 (5 rows)