91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 1.75MB
    文件類型: .zip
    金幣: 2
    下載: 7 次
    發布日期: 2021-04-10
  • 語言: Python
  • 標簽: python??sift??opencv??

資源簡介

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?????????????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?????????????good_max?=?num
????if?good_max?????????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?????????????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個文件信息

評論

共有 條評論