资源简介
Windows64位环境下:
1. 安装python3.6.5
2. pip install numpy
3. pip install matplotlib
4. pip install opencv-python
5. 安装opencv-conrib(https://download.csdn.net/download/u012442083/10809277)
代码片段和文件信息
# coding=utf-8
import os
import cv2
import shutil
# 指纹匹配
# src_file 待匹配的指纹图片
# db_file 指纹数据库中的特征指纹图片
# 指纹 1 x 1 匹配,返回该指纹的匹配得分
# 参考 http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_feature2d/py_matcher/py_matcher.html
def match1_1_sift(src_file db_file):
img1 = cv2.imread(src_file) # queryImage
#img1 = cv2.cvtColor(img1 cv2.COLOR_BGR2GRAY)
img2 = cv2.imread(db_file) # trainImage
#img2 = cv2.cvtColor(img2 cv2.COLOR_BGR2GRAY)
# Initiate SIFT detector
cv2.ocl.setUseOpenCL(False)
sift = cv2.xfeatures2d.SIFT_create()
# find the keypoints and descriptors with SIFT
kp1 des1 = sift.detectAndCompute(img1 None)
kp2 des2 = sift.detectAndCompute(img2 None)
FLANN_INDEX_KDTREE = 0
index_params = dict(algorithm=FLANN_INDEX_KDTREE trees=5)
search_params = dict(checks=50)
flann = cv2.FlannbasedMatcher(index_params search_params)
matches = flann.knnMatch(des1 des2 k=2)
good = []
for m n in matches:
if m.distance < 0.55 * n.distance:#0.65
good.append(m)
return len(good)
# 指纹批量匹配
# src_file 待匹配的指纹图片
# db_path 指纹数据库路径,该路径下包含若干特征指纹图片
# 指纹 1 x N 匹配,返回该指纹是否匹配成功
def match1_N(src_file db_path):
good_max = 0
for afile in os.listdir(db_path):
db_file = os.path.join(db_path afile)
num = match1_1_sift(src_file db_file)
if good_max < num:
good_max = num
if good_max < 7: # 指纹得分阈值为10
return False
else:
return True
# 指纹批量匹配
# src_file 待匹配的指纹图片
# db_path 指纹数据库路径,该路径下包含若干特征指纹图片
# 指纹 1 x N 匹配,返回该指纹的最高得分
def match1_N_test2(src_file db_path):
good_max = 0
for afile in os.listdir(db_path):
db_file = os.path.join(db_path afile)
num = match1_1_sift(src_file db_file)
if good_max < num:
good_max = num
return good_max
# 指纹批量测试
# src_path 待匹配的指纹文件夹,该文件夹下包含若干指纹图片
# db_path 指纹数据库路径,该路径下包含若干特征指纹图片
# f 文件标识符,该函数会把结果写入到文件
# 指纹 N x N 匹配,输出该文件夹下指纹匹配成功的比例
def matchN_N_test(src_path db_path f):
i = 0
j = 0
for afile in os.listdir(src_path):
src_file = os.path.join(src_path afile)
j = j + 1
if match1_N(src_file db_path):
i = i + 1
f.write(src_path + ‘----------‘ + db_path + ‘\n‘)
f.write(‘ratio:‘ + str(i) + ‘/‘ + str(j) + ‘\n‘)
f.write(‘--------------------‘ + ‘\n‘)
f.flush()
# 指纹批量测试
# src_path 待匹配的指纹文件夹,该文件夹下包含若干指纹图片
# db_path 指纹数据库路径,该路径下包含若干特征指纹图片
# f 文件标识符,该函数会把结果写入到文件
# 指纹 N x N 匹配,输出该指纹的最高得分
def matchN_N_test2(src_path db_path f):
for afile in os.listdir(src_path):
src_file = os.path.join(src_path afile)
# 对每个指纹图片进行 1 x N 匹配,得到一个得分
good_num = match1_N_test2(src_file db_path)
f.write(src_file + ‘----------‘ + db_path + ‘\n‘)
f.write(‘max good:‘ + str(good_num) + ‘\n‘)
f.write(‘--------------------‘ + ‘\n‘)
f.flush()
# 判断指纹质量
# file_path 指纹图片文件路径
# 该函数通过计算指纹图片中白色无效块和黑色无
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-12-03 21:09 sift\
文件 61 2018-12-03 21:11 sift\data.txt
目录 0 2018-11-26 21:22 sift\db1\
目录 0 2018-11-27 15:40 sift\db1\img\
文件 26678 2018-11-27 15:20 sift\db1\img\fp0_1.bmp
文件 26678 2018-11-27 15:20 sift\db1\img\fp0_2.bmp
文件 26678 2018-11-27 15:20 sift\db1\img\fp0_3.bmp
文件 26678 2018-11-27 15:20 sift\db1\img\fp0_4.bmp
文件 26678 2018-11-27 15:20 sift\db1\img\fp0_5.bmp
文件 26678 2018-11-27 15:20 sift\db1\img\fp0_6.bmp
文件 26678 2018-11-27 15:20 sift\db1\img\fp1_0.bmp
文件 26678 2018-11-27 15:21 sift\db1\img\fp1_1.bmp
文件 26678 2018-11-27 15:21 sift\db1\img\fp1_2.bmp
文件 26678 2018-11-27 15:21 sift\db1\img\fp1_3.bmp
文件 26678 2018-11-27 15:21 sift\db1\img\fp1_4.bmp
文件 26678 2018-11-27 15:21 sift\db1\img\fp1_5.bmp
文件 26678 2018-11-27 15:21 sift\db1\img\fp1_6.bmp
文件 26678 2018-11-27 15:21 sift\db1\img\fp2_0.bmp
文件 26678 2018-11-27 15:21 sift\db1\img\fp2_1.bmp
文件 26678 2018-11-27 15:21 sift\db1\img\fp2_2.bmp
文件 26678 2018-11-27 15:22 sift\db1\img\fp2_3.bmp
文件 26678 2018-11-27 15:22 sift\db1\img\fp2_4.bmp
文件 26678 2018-11-27 15:22 sift\db1\img\fp2_5.bmp
文件 26678 2018-11-27 15:22 sift\db1\img\fp2_6.bmp
文件 26678 2018-11-27 15:22 sift\db1\img\fp3_0.bmp
文件 26678 2018-11-27 15:22 sift\db1\img\fp3_1.bmp
文件 26678 2018-11-27 15:23 sift\db1\img\fp3_2.bmp
文件 26678 2018-11-27 15:23 sift\db1\img\fp3_3.bmp
文件 26678 2018-11-27 15:23 sift\db1\img\fp3_4.bmp
文件 26678 2018-11-27 15:23 sift\db1\img\fp3_5.bmp
文件 26678 2018-11-27 15:23 sift\db1\img\fp3_6.bmp
............此处省略54个文件信息
相关资源
- 基于Keras的attention实战
- Pyomo – Optimization Modeling in Python 无水
- Python基础教程第二版源代码.zip
- Python.2.and.3.Compatibility
- python课设--网购平台比价系统天猫、京
- 卷积神经网络的Python实现 -《卷积神经
- 基于Python专用型网络爬虫的设计及实
- Python版飞机大战源码和素材包括有声
- 飞机大战源码和素材Python版
- python实现云盘 代码及实验报告
- Packt.Modern.Python.Standard.Library.Cookbook
- mysql-connector-python-2.1.3-py2.7-winx64.msi
- 基于Python的飞机大战项目源码素材包
- OpenCV+python手势识别框架和简单
- 《Python语言程序基础第2版》课后答案
- 用笨办法学python第四版
- Python 3 Text Processing with NLTK 3 Cookbook
- hog_svm_train_python
- 基于python的车牌定位
- Python飞机大战完整素材包字体音乐图
- Python-60DaysRLChallenge中文版强化学习6
- Python-python3实现互信息和左右熵的新词
- python 机器人 开题报告
- 小甲鱼-飞机大战python
- 深入理解Python特性(Python-Tricks).pd
- 计算机网络-自顶向下方法-第6版-pyt
- 从记录到编程--Python在ABAQUS程序化参数
- Text Processing In Python (Python文本处理)
- scapy+python2.7 windows 64位安装包
- python淘宝网指定关键词爬取商品信息
评论
共有 条评论